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

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

int memo[100002][100002];
int h[100002];
int N;

int f(int x,int i) {
	int best;
	if(i == N-1) best = x;
	else if (memo[x][i] != -1) {
		best = memo[x][i];
	}
	else {
		best = f(x+abs(h[i]-h[i+1]),i+1);
		if(i+2 <= N-1) {
			best = min(f(x+abs(h[i]-h[i+2]),i+2),best);
		}
		memo[x][i] = best;
	}
	return best;
}

int main() {
	cin >> N;
	memset(memo,-1,sizeof memo);
	for (int i = 0; i < N; i++) {
		int tmp; cin >> tmp; 
		h[i] = tmp;
	}

	int ans = f(0,0);
	cout << ans << endl;

	return 0;
}

Compiler output:
/tmp/cceysilq.o: in function `f(int, int)':
a.cc:(.text+0x10): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cceysilq.o
a.cc:(.text+0x98): relocation truncated to fit: R_X86_64_PC32 against symbol `h' defined in .bss section in /tmp/cceysilq.o
a.cc:(.text+0xb3): relocation truncated to fit: R_X86_64_PC32 against symbol `h' defined in .bss section in /tmp/cceysilq.o
a.cc:(.text+0xdc): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cceysilq.o
a.cc:(.text+0xfd): relocation truncated to fit: R_X86_64_PC32 against symbol `h' defined in .bss section in /tmp/cceysilq.o
a.cc:(.text+0x118): relocation truncated to fit: R_X86_64_PC32 against symbol `h' defined in .bss section in /tmp/cceysilq.o
/tmp/cceysilq.o: in function `main':
a.cc:(.text+0x18c): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cceysilq.o
a.cc:(.text+0x1f6): relocation truncated to fit: R_X86_64_PC32 against symbol `h' defined in .bss section in /tmp/cceysilq.o
a.cc:(.text+0x203): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/cceysilq.o
collect2: error: ld returned 1 exit status
Language: C++

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

int main() {
    int  n;
    cin >> n; 
    vector<int>arr(n);

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

Compiler output:
a.cc: In function 'int main()':
a.cc:20:17: error: 'INT_MAX' was not declared in this scope
   20 |         dp[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 <vector>
  +++ |+#include <climits>
    3 | using namespace std;
Language: Java

import java.util.Scanner;

public class FrogA {

    static int solve(int[] inputs){
        int[] dp = new int[inputs.length];
        dp[0] = 0;
        dp[1] = Math.abs(inputs[0] - inputs[1]);

        for(int i = 2; i < dp.length; i++)
            dp[i] = Math.min(dp[i-1] + Math.abs(inputs[i] - inputs[i-1]), dp[i-2] + Math.abs(inputs[i] - inputs[i-2]));

        return dp[dp.length - 1];
    }
    
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt(); scanner.nextLine();
        int[] inputs = new int[n];
        for(int i = 0; i < n; i++)
            inputs[i] = scanner.nextInt();

        System.out.println(FrogA.solve(inputs));
        scanner.close();
    }
}

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

import java.util.*;
public class DP1
{
    public static void main(String [] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int [] a = new int [n]; for (int i = 0; i < n; i++) a[i] = sc.nextInt();
        int [] dp = new int[n];
        dp[0] = 0; dp[1] = Math.abs(a[1] - a[0]);
        for (int i = 2; 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]));
        }
        System.out.println(dp[n-1]);
    }


}

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

import java.util.Scanner;

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

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

//Algorithm Visualizer
#include<bits/stdc++.h>
#define f(i,a,b) for(int i=a; i<b; i++)
#define F first;
#define S second;
using namespace std;
typedef long long ll;

solve()
{
    int n;
    cin>>n;
    int a[n],dp[n];
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2; i<n; i++){
        dp[i]=min(abs(a[i-1]-a[i])+dp[i-1],abs(a[i-2]-a[i])+dp[i-2]);
    }
    cout<<dp[n-1];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    while(t--){
        solve();
        cout<<endl;
    }
}




Compiler output:
a.cc:9:1: error: ISO C++ forbids declaration of 'solve' with no type [-fpermissive]
    9 | solve()
      | ^~~~~
a.cc: In function 'int solve()':
a.cc:23:1: warning: no return statement in function returning non-void [-Wreturn-type]
   23 | }
      | ^
Language: C++

#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <cstring>
#include <set>
#include <map>
#include <algorithm>  
#include <cmath>
#include <iomanip>
#define ll long long
using namespace std;
ll n;
ll mod=pow(10,9)+7;
ll arr[100005];
ll dp[100005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    for(ll i=0;i<n;++i)
    {
        cin>>arr[i];
    }
    dp[0]=0;
    for(ll i=1;i<n;++i)
    {
        ll ans=INT_MAX;
        ll add=abs(arr[i-1]-arr[i])+dp[i-1];
        if(i-2>=0)
        {
            add=min(add,abs(arr[i-2]-arr[i])+dp[i-2]);
        }
        dp[i]=add;
    }
    cout<<dp[n-1]<<endl;
}






































Compiler output:
a.cc: In function 'int main()':
a.cc:31:16: error: 'INT_MAX' was not declared in this scope
   31 |         ll ans=INT_MAX;
      |                ^~~~~~~
a.cc:12:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   11 | #include <iomanip>
  +++ |+#include <climits>
   12 | #define ll long long
Language: C

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
vector<ll>data;
map<ll, ll >res;
ll rest(ll a,ll b){
    if(b>=data.size()){
        return 1e8;
    }
    return abs(data[a]-data[b]);
}
ll m(ll i){
    if(res.count(i))return res[i];
    if(i>=data.size()-1){
        return 0;
    }
    res[i]=min(rest(i,i+1)+m(i+1),rest(i,i+2)+m(i+2));
    return res[i];
}
int main(){
    ll a,aux;
    cin>>a;
    for(ll i=0;i<a;i++){
        cin>>aux;
        data.push_back(aux);
    }
    cout<<m(0)<<endl;
    return 0;
}


Compiler output:
main.c: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;

#define endl "\n"
#define lli long long int
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define ct1(x) cout<<x<<endl;
#define ct2(x,y) cout<<x<<" "<<y<<endl;
#define ct3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define ct4(w,x,y,z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<endl;
#define ct5(v,w,x,y,z) cout<<v<<" "<<w<<" "<<x<<" "<<y<<" "<<z<<endl;
#define ct6(u,v,w,x,y,z) cout<<u<<" "<<v<<" "<<w<<" "<<x<<" "<<y<<" "<<z<<endl;
#define sq(x) ((x)*(x))
#define all(x) x.begin(),x.end()
#define ff first
#define ss second

const int MOD = (int)1e9 + 7;

void solve(){
	lli n, i,x;
    cin>>n;
    vector<lli>v(n,0);
    vector<lli>dp(n,0);
    for(i=0; i<n; i++){
    	cin>>x;
    	v.pb(x);
    }
    if(n==0)
    	return 0;
    if(n==1)
    	return abs(v[1]-v[0]);
    dp[1]=abs(v[1]-v[0]);
    for(i=2; i<n; i++){
    	dp[i]=min((dp[i-2]+abs(v[i-2]-v[i])),(dp[i-1]+abs(v[i-1]-v[i])));
    }
    return dp[n-1];
}

int main() {
    FASTER
	// lli testCases;
	// cin>>testCases;
	// for(lli caseLevel=1; caseLevel<=testCases; caseLevel++)
	// {
	    // cout<<"Case #"<<caseLevel<<": ";
        solve();
        // cout<<endl;
	// } /
	return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:32:16: error: return-statement with a value, in function returning 'void' [-fpermissive]
   32 |         return 0;
      |                ^
a.cc:34:19: error: return-statement with a value, in function returning 'void' [-fpermissive]
   34 |         return abs(v[1]-v[0]);
      |                ~~~^~~~~~~~~~~
a.cc:39:18: error: return-statement with a value, in function returning 'void' [-fpermissive]
   39 |     return dp[n-1];
      |                  ^
Language: C++

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

#define endl "\n"
#define lli long long int
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define ct1(x) cout<<x<<endl;
#define ct2(x,y) cout<<x<<" "<<y<<endl;
#define ct3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl;
#define ct4(w,x,y,z) cout<<w<<" "<<x<<" "<<y<<" "<<z<<endl;
#define ct5(v,w,x,y,z) cout<<v<<" "<<w<<" "<<x<<" "<<y<<" "<<z<<endl;
#define ct6(u,v,w,x,y,z) cout<<u<<" "<<v<<" "<<w<<" "<<x<<" "<<y<<" "<<z<<endl;
#define sq(x) ((x)*(x))
#define all(x) x.begin(),x.end()
#define ff first
#define ss second

const int MOD = (int)1e9 + 7;

void solve(){
	lli n, i;
    cin>>n;
    vector<lli>v(n,0);
    vector<lli>dp(n,0);
    for(i=0; i<n; i++){
    	cin>>x;
    	v.pb(x);
    }
    if(n==0)
    	return 0;
    if(n==1)
    	return abs(v[1]-v[0]);
    dp[1]=abs(v[1]-v[0]);
    for(i=2; i<n; i++){
    	dp[i]=min((dp[i-2]+abs(v[i-2]-v[i])),(dp[i-1]+abs(v[i-1]-v[i])));
    }
    return dp[n-1];
}

int main() {
    FASTER
	// lli testCases;
	// cin>>testCases;
	// for(lli caseLevel=1; caseLevel<=testCases; caseLevel++)
	// {
	    // cout<<"Case #"<<caseLevel<<": ";
        solve();
        // cout<<endl;
	// } /
	return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:28:14: error: 'x' was not declared in this scope
   28 |         cin>>x;
      |              ^
a.cc:32:16: error: return-statement with a value, in function returning 'void' [-fpermissive]
   32 |         return 0;
      |                ^
a.cc:34:19: error: return-statement with a value, in function returning 'void' [-fpermissive]
   34 |         return abs(v[1]-v[0]);
      |                ~~~^~~~~~~~~~~
a.cc:39:18: error: return-statement with a value, in function returning 'void' [-fpermissive]
   39 |     return dp[n-1];
      |                  ^
Language: C++

#include <bits/stdc++.h>
#define ll long long int
using namespace std;
const int M=1e9+7;
const int MAX=1<<21;
vector<vector<int>> dp(21,vector<int>(MAX));
int n;
int mat[21][21];
int calc(int i,int left){
    if(i==n){
        return 1;
    }
    if(dp[i][left]!=-1){
        return dp[i][left];
    }
    int ans=0;
    for(int j=0;j<n;j++){
        if(mat[i][j]==1){
            int res=1<<j;
            if(left&res){
                ans+=calc(i+1,left^res)%M;  
                ans%=M;
            }
        }
    }
    return dp[i][left]=ans;
}
void solve(){
    cin>>n;
  	dp.assign(n,vector<int>(MAX,-1)),
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>mat[i][j];
        }
    }
    int sol=calc(0,MAX-1);
    cout<<sol<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:31:5: error: expected primary-expression before 'for'
   31 |     for(int i=0;i<n;i++){
      |     ^~~
a.cc:31:17: error: 'i' was not declared in this scope
   31 |     for(int i=0;i<n;i++){
      |                 ^
Language: C++

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

int main() {
  int n;
  cin >> n;
  vector<long long> h(n);
  for (int& hi : h) {
    cin >> hi;
  }
  vector<long long> dp(n, INT_MAX);
  dp[0] = 0;
  for (int i = 1; i < n; ++i) {
    for (int j : {i - 1, i - 2}) {
      dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
    }
  }
  cout << dp[n - 1] << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:18: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'long long int'
    8 |   for (int& hi : h) {
      |                  ^
Language: C++

#define io_ ios_base::sync_with_stdio(0); cin.tie(0);
//da time limit por que el arbol repite indices
int *indices;
int solve(vector<int> &stones, int &i){
if (i==stones.size()-1){return 0;}
int aux=i, salto1=1e7,salto2=1e7;
aux++;
if (indices[i]==-1){
if ((i+1)<=stones.size()-1){
salto1=abs(stones[i]-stones[aux])+solve(stones,aux);
}
aux++;
if ((i+2)<=stones.size()-1){
salto2=abs(stones[i]-stones[aux])+solve(stones,aux);
}
indices[i]=min(salto1,salto2);
}
return indices[i];        
}
int main (){
io_;
int n;
cin>>n;
vector<int> v(n);
for (int i=0,val;i<n;i++){
cin>>v[i];

}
indices= new int[n];
memset(indices,-1,n*4);
int i=0 ;
int suma=0;
suma=solve(v,i);
cout<<suma<<endl;
}


Compiler output:
a.cc:4:11: error: 'vector' was not declared in this scope
    4 | int solve(vector<int> &stones, int &i){
      |           ^~~~~~
a.cc:4:18: error: expected primary-expression before 'int'
    4 | int solve(vector<int> &stones, int &i){
      |                  ^~~
a.cc:4:32: error: expected primary-expression before 'int'
    4 | int solve(vector<int> &stones, int &i){
      |                                ^~~
a.cc:4:38: error: expression list treated as compound expression in initializer [-fpermissive]
    4 | int solve(vector<int> &stones, int &i){
      |                                      ^
a.cc: In function 'int main()':
a.cc:1:13: error: 'ios_base' has not been declared
    1 | #define io_ ios_base::sync_with_stdio(0); cin.tie(0);
      |             ^~~~~~~~
a.cc:21:1: note: in expansion of macro 'io_'
   21 | io_;
      | ^~~
a.cc:1:43: error: 'cin' was not declared in this scope
    1 | #define io_ ios_base::sync_with_stdio(0); cin.tie(0);
      |                                           ^~~
a.cc:21:1: note: in expansion of macro 'io_'
   21 | io_;
      | ^~~
a.cc:24:1: error: 'vector' was not declared in this scope
   24 | vector<int> v(n);
      | ^~~~~~
a.cc:24:8: error: expected primary-expression before 'int'
   24 | vector<int> v(n);
      |        ^~~
a.cc:26:6: error: 'v' was not declared in this scope
   26 | cin>>v[i];
      |      ^
a.cc:30:1: error: 'memset' was not declared in this scope
   30 | memset(indices,-1,n*4);
      | ^~~~~~
a.cc:1:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
  +++ |+#include <cstring>
    1 | #define io_ ios_base::sync_with_stdio(0); cin.tie(0);
a.cc:33:12: error: 'v' was not declared in this scope
   33 | suma=solve(v,i);
      |            ^
a.cc:33:11: error: 'solve' cannot be used as a function
   33 | suma=solve(v,i);
      |      ~~~~~^~~~~
a.cc:34:1: error: 'cout' was not declared in this scope
   34 | cout<<suma<<endl;
      | ^~~~
a.cc:34:13: error: 'endl' was not declared in this scope
   34 | cout<<suma<<endl;
      |             ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int solve(vector<int> &stones, int &i){
if (i==stones.size()-1){return 0;}
int mi=1e7;
int aux=i, salto1=1e7,salto2=1e7;
aux++;
if ((i+1)<=stones.size()-1){
salto1=abs(stones[i]-stones[aux])+solve(stones,aux);
}
aux++;
if ((i+2)<=stones.size()-1){
salto2=abs(stones[i]-stones[aux])+solve(stones,aux);
}
return min(salto1,salto2);
}
int main (){
int n;
cin>>n;
vector<int> v(0);
for (int i=0,val;i<n;i++){
cin>>val;
v.push_back(val);
}
int i=0 ;
int suma=0;
suma=solve(v,i);
cout<<suma<<endl;
}
~                                                                                                                                                     
~                

Compiler output:
a.cc:31:1: error: expected class-name before '~' token
   31 | ~
      | ^
Language: C++

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

void recursion(int arr[], int idx, int sum, int size) {
	if (idx == size - 1)
	{
		if (sum < ans) {
			ans = sum;
		}
		cout << sum << "fun ";
		return;
	}
	if (idx + 1 < size) {
		sum += arr[idx] - arr[idx + 1];
		if (sum < 0)
			sum = sum * -1;
		recursion(arr, idx + 1, sum , size);
	}

	if (idx + 2 < size) {
		sum += arr[idx] - arr[idx + 2];
		if (sum < 0)
			sum = sum * -1;
		recursion(arr, idx + 2, sum , size);
	}

}
int main(int argc, char const *argv[])
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	//int t; cin >> t;
	int n;
	cin >> n;
	int arr[n];
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	// recursion(arr, 0, 0, n);
	// cout << ans;
	int ans = 0;
	for (int i = n - 1; i > 0;) {
		int cur = 0, c = 0;
		if (i - 1 >= 0 ) {
			cur = arr[i] - arr[i - 1];
			if (cur < 0)
				cur = cur * -1;
		}
		if (i - 2 >= 0) {
			c = arr[i] - arr[i - 2];
			if (c < 0)
				c = c * -1;
			cur = min(cur, c);
		}

		if (cur == c)
			i = i - 2;
		else
			i--;
		ans += cur;

	}
	cout << ans;
}






Compiler output:
a.cc: In function 'void recursion(int*, int, int, int)':
a.cc:7:27: error: 'ans' was not declared in this scope; did you mean 'abs'?
    7 |                 if (sum < ans) {
      |                           ^~~
      |                           abs
Language: C++

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

int frogjump(int &height,int n)
{
    int dp_2=0;int dp_1=abs(height[1]-height[2]);
    int anstillnow=INT_MAX;
    for (int i = 3; i =< n; i++)
    {
        anstillnow = min(dp_2 + abs(height[i - 2] - height[i]),dp_1 + abs(height[i - 1] - height[i]));
        dp_2=dp_1;
        dp_1=anstillnow;
    }
    return anstillnow;
    
}

int main()
{
    //freopen("inp.txt","r",stdin);
    int n;
    cin>>n;
    int height[n+1];
    for (int i = 1; i =< n; i++)
    {
        cin>>height[i];
    }
    cout<<frogjump(height,n);
    return 0;
}

Compiler output:
a.cc: In function 'int frogjump(int&, int)':
a.cc:6:35: error: invalid types 'int[int]' for array subscript
    6 |     int dp_2=0;int dp_1=abs(height[1]-height[2]);
      |                                   ^
a.cc:6:45: error: invalid types 'int[int]' for array subscript
    6 |     int dp_2=0;int dp_1=abs(height[1]-height[2]);
      |                                             ^
a.cc:8:24: error: expected primary-expression before '<' token
    8 |     for (int i = 3; i =< n; i++)
      |                        ^
a.cc:10:43: error: invalid types 'int[int]' for array subscript
   10 |         anstillnow = min(dp_2 + abs(height[i - 2] - height[i]),dp_1 + abs(height[i - 1] - height[i]));
      |                                           ^
a.cc:10:59: error: invalid types 'int[int]' for array subscript
   10 |         anstillnow = min(dp_2 + abs(height[i - 2] - height[i]),dp_1 + abs(height[i - 1] - height[i]));
      |                                                           ^
a.cc:10:81: error: invalid types 'int[int]' for array subscript
   10 |         anstillnow = min(dp_2 + abs(height[i - 2] - height[i]),dp_1 + abs(height[i - 1] - height[i]));
      |                                                                                 ^
a.cc:10:97: error: invalid types 'int[int]' for array subscript
   10 |         anstillnow = min(dp_2 + abs(height[i - 2] - height[i]),dp_1 + abs(height[i - 1] - height[i]));
      |                                                                                                 ^
a.cc: In function 'int main()':
a.cc:24:24: error: expected primary-expression before '<' token
   24 |     for (int i = 1; i =< n; i++)
      |                        ^
a.cc:28:20: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   28 |     cout<<frogjump(height,n);
      |                    ^~~~~~
      |                    |
      |                    int*
a.cc:4:19: note:   initializing argument 1 of 'int frogjump(int&, int)'
    4 | int frogjump(int &height,int n)
      |              ~~~~~^~~~~~
a.cc:28:20: error: cannot bind rvalue '(int)((int*)(& height))' to 'int&'
   28 |     cout<<frogjump(height,n);
      |                    ^~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std; 
int solve(vector<int> &stones, int &i){
//salto, salta a la piedra que le de menos costo
if (i==stones.size()-1)return 0;
int costo=abs (stones[i]-stones[i+1]);
if ((is+2)<(stones.size()-1) && abs(stones[i]-stones[i+2])<=costo){
costo=abs(stones[i]-stones[i+2]);
i++;
}
i++;
return costo+solve(stones,i); 
}
int main (){
int n;
cin>>n;
vector<int> v(0);
for (int i=0,val;i<n;i++){
cin>>val;
v.push_back(val);
}
int i=0 ;
cout<<solve(v,i);
}


Compiler output:
a.cc: In function 'int solve(std::vector<int>&, int&)':
a.cc:7:6: error: 'is' was not declared in this scope; did you mean 'i'?
    7 | if ((is+2)<(stones.size()-1) && abs(stones[i]-stones[i+2])<=costo){
      |      ^~
      |      i
Language: Java

import java.util.*;
public class  solution{
  static Integer [][]cache;
  public static void main(String []args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    cache=new Integer[n][100000];
    int []height=new int[n];
    for(int i=0;i<n;i++){
      height[i]=sc.nextInt();
    }
    System.out.println(ans(height,0,0));
  }
    public static int ans(int[] h,int index,int val){
        if(cache[index][val]!=null) return cache[index][val];
        if(index==h.length-1) return val;
        int one=Integer.MAX_VALUE;
        int two=Integer.MAX_VALUE;
        if(index+1<h.length){
            one=ans(h,index+1,val+Math.abs(h[index]-h[index+1]));
        }
        if(index+2<h.length){
            two=ans(h,index+2,val+Math.abs(h[index]-h[index+2]));
        }
        if (cache[index][val]==null) cache[index][val]=Math.min(one,two);
        return cache[index][val];
    }
}

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

import java.util.*;
public class  solution{
  static Integer [][]cache;
  public static void main(String []args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    cache=new int[n][100000];
    int []height=new int[n];
    for(int i=0;i<n;i++){
      height[i]=sc.nextnt();
    }
    System.out.println(ans(height,0,0));
  }
    public static int ans(int[] h,int index,int val){
        if(cache[index][val]!=null) return cache[index][val];
        if(index==h.length-1) return val;
        int one=Integer.MAX_VALUE;
        int two=Integer.MAX_VALUE;
        if(index+1<h.length){
            one=ans(h,index+1,val+Math.abs(h[index]-h[index+1]));
        }
        if(index+2<h.length){
            two=ans(h,index+2,val+Math.abs(h[index]-h[index+2]));
        }
        if (cache[index][val]==null) cache[index][val]=Math.min(one,two);
        return cache[index][val];
    }
}

Compiler output:
Main.java:2: error: class solution is public, should be declared in a file named solution.java
public class  solution{
       ^
Main.java:7: error: incompatible types: int[][] cannot be converted to Integer[][]
    cache=new int[n][100000];
          ^
Main.java:10: error: cannot find symbol
      height[i]=sc.nextnt();
                  ^
  symbol:   method nextnt()
  location: variable sc of type Scanner
3 errors
Language: Java

import java.util.*;

public class Frog1{
    static Scanner in  = new Scanner(System.in);
    static int N;
    static int[] h;

    static long[] dp;

    public static void main(String[] args) {
        N = in.nextInt();
        h = new int[N];
        dp = new long[N];
        for(int i = 0;i < N;i++)
            h[i] = in.nextInt();

        System.out.println(getAns(N-1));    
    }

    static long getAns(int n)
    {
        // System.out.println("n = "+n);
        if(n == 0)
            return 0;
        if(n == 1)
            return Math.abs(h[1] - h[0]);
        
        long ans1;    
        if(dp[n-1] != 0)
            ans1 = dp[n-1];
        else
            ans1 =  getAns(n-1);        
        ans1 += Math.abs(h[n] - h[n-1]);
        
        long ans2;
        if(dp[n-2] != 0)
            ans2 = dp[n-2];
        else
            ans2 =+ getAns(n-2);    
        ans2 +=  Math.abs(h[n] - h[n-2]);
        // System.out.println("n = "+n+" ans1 = "+ans1+" ans2 = "+ans2);

        return Math.min(ans1,ans2);    
    }
}

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.Scanner; // 文字列を標準入力からscanする

public class Sample { 

  static int return_smaller(int a, int b){
    if(a > b){
      return b;
    }
      return a;
  }
    
  public static void main(final String[] args) {
    Scanner scan = new Scanner(System.in);
		String str = "";
		str = scan.nextLine();
    int N = Integer.parseInt(str);

    int[] hi = new int[N];
    int[] dp = new int[N];

    str = scan.nextLine();
    String[] strs2 = str.split(" ");
    for(int i=0; i<strs2.length; i++) {
      hi[i] = Integer.parseInt(strs2[i]);
    }
    scan.close();

    dp[0] = 0;
    for (int i = 1; i < N; ++i) {
      if(i > 1){
        dp[i] = return_smaller(dp[i - 1] + Math.abs(hi[i] - hi[i - 1]), 
                                  dp[i - 2] + Math.abs(hi[i] - hi[i - 2]));
      }
      else{
        dp[1] = dp[0] + Math.abs(hi[1] - hi[0]);
      }
    }

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

  }
}

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

/*package whatever //do not write package name here */

import java.io.*;
import java.lang.Math; 
import java.util.Scanner;

public class VirtualMachineError {
	public static void main (String[] args) {
	    Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		int[] arr = new int[n];
		
		for(int i = 0; i < n; i++){
		    arr[i] = scan.nextInt();
		}
		
		int[] dp = new int[n];
		dp[1] = Math.abs(arr[0]-arr[1]);
		
		for(int i = 2; i < n; i++ ){
		    dp[i] = Integer.MAX_VALUE;
		    for(int j = k; j>0 && i-j > 0; j--){
		        dp[i] = Math.min(dp[i],dp[i-k]+Math.abs(arr[i-k]-arr[i]));
		    }
		}
		System.out.println(dp[n-1]);
		
	}
}

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

#include<bits/stdc++.h>

using namespace std;

void dfs(vector<vector<int>> &dp,vector<vector<int>> &adj,int i,int parent){
  dp[i][0] = 1;
  dp[i][1]=1;
  for(auto e: adj[i]){
    if(e == parent) continue;
    dfs(dp,adj,e,i);
    dp[i][1] = dp[i][1] * (dp[e][0]);
    dp[i][0] = dp[i][0]*(dp[e][0]*dp[e][1]);
  }
  return;
}

int main(){
  int n,a,b;
  cin >> n;
  vector<vector<int>> adj(n+1);
  for(int i=0;i<n;i++){
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  
  vector<vector<int>> dp(n+1,vector<int>(2,0));
  vector<int> parent(n+1,-1);
  dfs(dp,adj,1,parent);
  cout << dp[1][0] + dp[1][1] << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:16: error: cannot convert 'std::vector<int>' to 'int'
   29 |   dfs(dp,adj,1,parent);
      |                ^~~~~~
      |                |
      |                std::vector<int>
a.cc:5:69: note:   initializing argument 4 of 'void dfs(std::vector<std::vector<int> >&, std::vector<std::vector<int> >&, int, int)'
    5 | void dfs(vector<vector<int>> &dp,vector<vector<int>> &adj,int i,int parent){
      |                                                                 ~~~~^~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{

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

}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:12: error: expected ';' before 'dp'
   10 |   dp[0] = 0
      |            ^
      |            ;
   11 |   dp[1] = abs(h[0]-h[1]);
      |   ~~
Language: C++

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

}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:14: error: 'n' was not declared in this scope; did you mean 'yn'?
    5 | long long dp[n+1];
      |              ^
      |              yn
a.cc:9:10: error: 'h' was not declared in this scope
    9 |     cin>>h[i];
      |          ^
a.cc:10:3: error: 'dp' was not declared in this scope; did you mean 'dup'?
   10 |   dp[0] = 0
      |   ^~
      |   dup
a.cc:14:29: error: 'h' was not declared in this scope
   14 |     dp[i] = min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2] + abs(h[i]-h[i-2]));
      |                             ^
Language: C



#include<bits/stdc++.h>
using namespace std;
#define inf 1e9

struct activity{
  int A,B,C;
};


int vacation(vector<activity>v,int n){

     int dp[n+1][3];
     dp[1][0]=v[1].A;
     dp[1][1]=v[1].B;
     dp[1][2]=v[1].C;

    for(int i=2;i<=n;i++){
      dp[i][0]=v[i].A + max(dp[i-1][1],dp[i-1][2]);
      dp[i][1]=v[i].B + max(dp[i-1][0],dp[i-1][2]);
      dp[i][2]=v[i].C + max(dp[i-1][0],dp[i-1][1]);
    }

    int ans = max(dp[n][0],max(dp[n][1],dp[n][2]));
    return ans;
}



int main(){

     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     int n,k;
     cin>>n;
     vector<activity>v(n+1);
     for(int i=1;i<=n;i++){
       cin>>v[i].A;
       cin>>v[i].B;
       cin>>v[i].C;
     }

     cout<<vacation(v,n)<<endl;

     return 0;
}


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

#include<bits/stdc++.h>
using namespace std;
#define vb __int128
#define ll long long
#define ld long double
#define full(a) a.begin(),a.end()
#define stoink stack<ll>
#define vec vector <ll>
#define vg vector<vector<ll> >
#define vgw vector<vector<pair<ll,ll> >
#define pa pair<ll,ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pre 0.00000000000000000001
#define inf 1000000000000
#define mod 998244353
vec costdp;
vec height;
ll n;
ll func(ll ind) {
	if(ind > n - 1)
		return inf;
	if(costdp[ind] != -1)
		return costdp[ind];
	if(ind == n - 1)
		return 0;
	res = min(func(ind+1) + abs(height[ind+1]-height[ind]),func(ind+2) + abs(height[ind+2]-height[ind]));
	return costdp[ind] = res;
}
int main()
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> n;
	height.resize(n);
	ll i;
	costdp.resize(n,-1);
	for(i = 0; i < n ; i++) cin >> height[i];
	cout << func(0);
	return 0;
}

Compiler output:
a.cc: In function 'long long int func(long long int)':
a.cc:29:9: error: 'res' was not declared in this scope
   29 |         res = min(func(ind+1) + abs(height[ind+1]-height[ind]),func(ind+2) + abs(height[ind+2]-height[ind]));
      |         ^~~
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:9:12: error: 'x' was not declared in this scope
    9 |     cin >> x;
      |            ^
Language: C++

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

ll mincost(ll n, ll h[]){
	ll i;
  	if(n == 2) return abs(h[2]-h[1]);
    if(n == 3) return abs(h[3]-h[1]);
  	if(abs(h[n] - h[n-1]))>abs(h[n] - h[n-2])) { i = abs(h[n] - h[n-2]) + mincost(n-2, h);}
	else { i = abs(h[n] - h[n-1]) + mincost(n-1, h); }
    return i;
}

int main(){
	ll n;
	cin>>n;
  	ll i, h[n+1];
	for(i=1; i<=n; i++){ cin>>h[i]; }
  	ll ans = mincost(n,h);
  	cout<<ans;
	return 0;
}


Compiler output:
a.cc: In function 'll mincost(ll, ll*)':
a.cc:9:31: error: expected primary-expression before '>' token
    9 |         if(abs(h[n] - h[n-1]))>abs(h[n] - h[n-2])) { i = abs(h[n] - h[n-2]) + mincost(n-2, h);}
      |                               ^
Language: C++

#include<stdio.h>
int n;
int min(int a,int b)
{
    if (a>b){return b;}
    return a;
}
int knapsack(int a[],int i)
{
    int p=10000;
    if(i>n-1){return 10000;}
    if(i==n-1){return 0;}
    else if (i+2<n)
    {
        p=abs(a[i+2]-a[i])+knapsack(a,i+2);
    }
    return min(p,(abs(a[i+1]-a[i])+knapsack(a,i+1)));
}
int main()
{
    int i,a[100000];
    scanf("%d",&n);
    for(i=0;i<n;i++){scanf("%d",&a[i]);}
    printf("%d",knapsack(a,0));
    return 0;
}

Compiler output:
a.cc: In function 'int knapsack(int*, int)':
a.cc:15:11: error: 'abs' was not declared in this scope
   15 |         p=abs(a[i+2]-a[i])+knapsack(a,i+2);
      |           ^~~
a.cc:17:19: error: 'abs' was not declared in this scope
   17 |     return min(p,(abs(a[i+1]-a[i])+knapsack(a,i+1)));
      |                   ^~~
Language: C++

#include <iostream>
#include <unordered_map>
#include <vector>
#include <stack>
#include <algorithm>
#include <list>
#include <set>
#include <cmath>
#define lli long long int
using namespace std ;

int eval(vector<int> &height, vector<int> &dp, int i)
{
	if(i == 0) return 0 ;
	if(dp[i] != -1) return dp[i] ;

	dp[i] = INT_MAX ;

	dp[i] = min(dp[i],eval(height,dp,i-1) + abs(height[i] - height[i-1])) ;
	if(i-2 >= 0) 
		dp[i] = min(dp[i], eval(height,dp,i-2) + abs(height[i] - height[i-2])) ;

	return dp[i] ;
}

int main(int argc, char const *argv[])
{
	int n ;
	cin>>n ;

	vector<int> height(n) ;
	vector<int> dp(n,-1) ;
	for(int i = 0 ; i < n ; i++) cin>>height[i] ;

	cout<<eval(height,dp,n-1)<<endl ;
	return 0;
}


Compiler output:
a.cc: In function 'int eval(std::vector<int>&, std::vector<int>&, int)':
a.cc:17:17: error: 'INT_MAX' was not declared in this scope
   17 |         dp[i] = INT_MAX ;
      |                 ^~~~~~~
a.cc:9:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    8 | #include <cmath>
  +++ |+#include <climits>
    9 | #define lli long long int
Language: C++

#include<bits/stdc++.h>
using namespace std;
int n;
int arr[100010];
int t[100010];
int dp(int n)
{
	if(n==2) return abs(arr[2]-arr[1]);
	if(n==3) return min(abs(arr[3]-arr[1]) , abs(arr[3]-arr[2]) + abs(arr[2]-arr[1]));
	
	if(t[n]!=-1)
	{
		return t[n];
	}
	t[n]=min(abs(arr[n]-arr[n-1]) + dp(n-1) , abs(arr[n]-arr[n-2]) + dp(n-2));
	
	return t[n];
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>arr[i];
	}
	memset(dp , -1 , sizeof(dp));
	int ans=dp(n);
	cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:33: error: ISO C++ forbids applying 'sizeof' to an expression of function type [-fpermissive]
   26 |         memset(dp , -1 , sizeof(dp));
      |                                ~^~~
a.cc:26:16: error: invalid conversion from 'int (*)(int)' to 'void*' [-fpermissive]
   26 |         memset(dp , -1 , sizeof(dp));
      |                ^~
      |                |
      |                int (*)(int)
In file included from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/string.h:61:28: note:   initializing argument 1 of 'void* memset(void*, int, size_t)'
   61 | extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
      |                      ~~~~~~^~~
Language: C++

# include <bits/stdc++.h>

using namespace std;

int MinCostBottomUpDP(int source, int destination, int * height);


int main() {
  int n;
  cin >> n;
  int height[n];
  for (int i = 0; i < n; i++) {
    cin >> height[i];
  }
  cout <<  << MinCostBottomUpDP(0, n - 1, height) << endl;
  return 0;
}


int MinCostBottomUpDP(int source, int destination, int * height) {
  vector<int> Cache(destination + 1);
  Cache[destination] = 0;
  Cache[destination - 1] = abs(height[destination - 1] - height[destination]);
  for (int i = destination - 2; i >= source; i--) {
    int route1_min_value = Cache[i + 1] + abs(height[i] - height[i + 1]);
    int route2_min_value = Cache[i + 2] + abs(height[i] - height[i + 2]);
    Cache[i] = min(route1_min_value, route2_min_value);
  }
  return Cache[source];
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:12: error: expected primary-expression before '<<' token
   15 |   cout <<  << MinCostBottomUpDP(0, n - 1, height) << endl;
      |            ^~
Language: C++

# include <bits/stdc++.h>

using namespace std;

int MinCostTopDownDP(int source, int destination, int * height, vector<int> Memo);

int main() {
  int n;
  cin >> n;
  int height[n];
  for (int i = 0; i < n; i++) {
    cin >> height[i];
  }
  vector<int> Memo(n, -1);
  cout << << MinCostTopDownDP(0, n - 1, height, Memo) << endl;
  return 0;
}

int MinCostTopDownDP(int source, int destination, int * height, vector<int> Memo) { // Memoized
  if (source < destination) {

    if (Memo[source] == -1) {
      int route1_min_value = MinCostTopDownDP(source + 1, destination, height, Memo) + abs(height[source] - height[source + 1]);

      int route2_min_value = MinCostTopDownDP(source + 2, destination, height, Memo) + abs(height[source] - height[source + 2]);

      Memo[source] = min(route1_min_value, route2_min_value);
    }
    return Memo[source];    
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:11: error: expected primary-expression before '<<' token
   15 |   cout << << MinCostTopDownDP(0, n - 1, height, Memo) << endl;
      |           ^~
Language: C++

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

int Recursion(int arr[],int n)
{
	if(n==0)
		return 0;
	if(n==1)
		return abs(arr[n]-arr[n-1]);
	int k=n-1;
	if(abs(arr[n]-arr[n-1]) > abs(arr[n]-arr[n-2]))
	{
		k=n-2;
	}
	cout<<k<<" "<<abs(arr[n]-arr[k])<<endl;
	return abs(arr[n]-arr[k])+Recursion(arr,k);
}

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output1.txt","w",stdout);
	#endif
	int n;
	cin>>n;
	int arr[n];
	int i=0;
	for(i=0;i<n;i++)
	{
		cin>>arr[i];
	}	
	// int z = my_sizeof(arr)/my_sizeof(arr[0]); 
	
	cout<<Recursion(arr,n-1)<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int Recursion(int*, int)':
a.cc:15:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   15 |         cout<<k<<" "<<abs(arr[n]-arr[k])<<endl;
      |         ^~~~
      |         std::cout
In file included from a.cc:1:
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:15:43: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   15 |         cout<<k<<" "<<abs(arr[n]-arr[k])<<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)
      |     ^~~~
a.cc: In function 'int main()':
a.cc:26:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   26 |         cin>>n;
      |         ^~~
      |         std::cin
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:35:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   35 |         cout<<Recursion(arr,n-1)<<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:35:35: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   35 |         cout<<Recursion(arr,n-1)<<endl;
      |                                   ^~~~
      |                                   std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

#include<iostream>
#include<bits/stdc++.h>
#include<conio>

int Recursion(int arr[],int n)
{
	if(n==0)
		return 0;
	if(n==1)
		return abs(arr[n]-arr[n-1]);
	int k=n-1;
	if(abs(arr[n]-arr[n-1]) > abs(arr[n]-arr[n-2]))
	{
		k=n-2;
	}
	cout<<k<<" "<<abs(arr[n]-arr[k])<<endl;
	return abs(arr[n]-arr[k])+Recursion(arr,k);
}

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output1.txt","w",stdout);
	#endif
	int n;
	cin>>n;
	int arr[n];
	int i=0;
	for(i=0;i<n;i++)
	{
		cin>>arr[i];
	}	
	// int z = my_sizeof(arr)/my_sizeof(arr[0]); 
	
	cout<<Recursion(arr,n-1)<<endl;
	return 0;
}


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

#include<iostream>
#include<stdio>

int Recursion(int arr[],int n)
{
	if(n==0)
		return 0;
	if(n==1)
		return abs(arr[n]-arr[n-1]);
	int k=n-1;
	if(abs(arr[n]-arr[n-1]) > abs(arr[n]-arr[n-2]))
	{
		k=n-2;
	}
	cout<<k<<" "<<abs(arr[n]-arr[k])<<endl;
	return abs(arr[n]-arr[k])+Recursion(arr,k);
}

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output1.txt","w",stdout);
	#endif
	int n;
	cin>>n;
	int arr[n];
	int i=0;
	for(i=0;i<n;i++)
	{
		cin>>arr[i];
	}	
	// int z = my_sizeof(arr)/my_sizeof(arr[0]); 
	
	cout<<Recursion(arr,n-1)<<endl;
	return 0;
}


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

#include<bits/stdc++.h>
#include<stdio.h>

int Recursion(int arr[],int n)
{
	if(n==0)
		return 0;
	if(n==1)
		return abs(arr[n]-arr[n-1]);
	int k=n-1;
	if(abs(arr[n]-arr[n-1]) > abs(arr[n]-arr[n-2]))
	{
		k=n-2;
	}
	cout<<k<<" "<<abs(arr[n]-arr[k])<<endl;
	return abs(arr[n]-arr[k])+Recursion(arr,k);
}

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output1.txt","w",stdout);
	#endif
	int n;
	cin>>n;
	int arr[n];
	int i=0;
	for(i=0;i<n;i++)
	{
		cin>>arr[i];
	}	
	// int z = my_sizeof(arr)/my_sizeof(arr[0]); 
	
	cout<<Recursion(arr,n-1)<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int Recursion(int*, int)':
a.cc:15:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   15 |         cout<<k<<" "<<abs(arr[n]-arr[k])<<endl;
      |         ^~~~
      |         std::cout
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:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:15:43: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   15 |         cout<<k<<" "<<abs(arr[n]-arr[k])<<endl;
      |                                           ^~~~
      |                                           std::endl
In file included from /usr/include/c++/14/istream:41,
                 from /usr/include/c++/14/sstream:40,
                 from /usr/include/c++/14/complex:45,
                 from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
a.cc: In function 'int main()':
a.cc:26:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   26 |         cin>>n;
      |         ^~~
      |         std::cin
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:35:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   35 |         cout<<Recursion(arr,n-1)<<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:35:35: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   35 |         cout<<Recursion(arr,n-1)<<endl;
      |                                   ^~~~
      |                                   std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

#include<iostream>
int Recursion(int arr[],int n)
{
	if(n==0)
		return 0;
	if(n==1)
		return abs(arr[n]-arr[n-1]);
	int k=n-1;
	if(abs(arr[n]-arr[n-1]) > abs(arr[n]-arr[n-2]))
	{
		k=n-2;
	}
	cout<<k<<" "<<abs(arr[n]-arr[k])<<endl;
	return abs(arr[n]-arr[k])+Recursion(arr,k);
}

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output1.txt","w",stdout);
	#endif
	int n;
	cin>>n;
	int arr[n];
	int i=0;
	for(i=0;i<n;i++)
	{
		cin>>arr[i];
	}	
	// int z = my_sizeof(arr)/my_sizeof(arr[0]); 
	
	cout<<Recursion(arr,n-1)<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int Recursion(int*, int)':
a.cc:13:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   13 |         cout<<k<<" "<<abs(arr[n]-arr[k])<<endl;
      |         ^~~~
      |         std::cout
In file included from a.cc:1:
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:13:43: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   13 |         cout<<k<<" "<<abs(arr[n]-arr[k])<<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)
      |     ^~~~
a.cc: In function 'int main()':
a.cc:24:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   24 |         cin>>n;
      |         ^~~
      |         std::cin
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:33:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   33 |         cout<<Recursion(arr,n-1)<<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:33:35: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   33 |         cout<<Recursion(arr,n-1)<<endl;
      |                                   ^~~~
      |                                   std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~