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

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
#define NIL -1
const double PI  = acos(-1.0);
const int INF = 1e9 + 7;
//-------------------------------------------


int N;

LL d, add ,del;
LL a[N+1];

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N;

    REP(i, N){
        cin >> a[i+1];
    }

    a[0] = 0;
    a[N+1] = 0;


    for( int i = 1; i <= N;i++){
        d = 0;
        del = 0;
        add = 0;

        for ( int j = 1; j <= N+1; j++){
            d += abs(a[j-1] - a[j]);
        }

        del = abs(a[i-1] - a[i]) + abs( a[i] - a[i+1]);
        add = abs( a[i-1] - a[i + 1]);

        cout << d - del + add << endl;
    }



    return 0;
}


Compiler output:
a.cc:42:7: error: size of array 'a' is not an integral constant-expression
   42 | LL a[N+1];
      |      ~^~
Language: C++

#include<cstdio>
using namespace std;int main(){int n,a[100002];long t=0;scanf("%d",&n);for(int i=1;i<= n;i++)scanf("%d",&a[i]),t+=abs(a[i]-a[i-1]);t+=abs(a[n]);for(int i=1;i<=n;i++)printf("%ld\n",t-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]));}

Compiler output:
a.cc: In function 'int main()':
a.cc:2:115: error: 'abs' was not declared in this scope
    2 | using namespace std;int main(){int n,a[100002];long t=0;scanf("%d",&n);for(int i=1;i<= n;i++)scanf("%d",&a[i]),t+=abs(a[i]-a[i-1]);t+=abs(a[n]);for(int i=1;i<=n;i++)printf("%ld\n",t-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]));}
      |                                                                                                                   ^~~
a.cc:2:135: error: 'abs' was not declared in this scope
    2 | using namespace std;int main(){int n,a[100002];long t=0;scanf("%d",&n);for(int i=1;i<= n;i++)scanf("%d",&a[i]),t+=abs(a[i]-a[i-1]);t+=abs(a[n]);for(int i=1;i<=n;i++)printf("%ld\n",t-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]));}
      |                                                                                                                                       ^~~
Language: C++

#include <cstdlib>
#include <cmath>  
using namespace std;
int main()
{
    

    int N;
    cin>>N;
    int* A = new int[N+1];
    A[0] = 0;
    for(int i=1;i<N+1;i++){
        cin>>A[i];
    }

    for(int i=1;i<N+1;i++){
        int ret = 0;
        for(int j=1;j<N+1;j++){
            if(j==i)continue;
            
            if(j==i+1){ 
                ret += abs(A[j] -A[j-2]);
            }
            else{
            ret += abs(A[j] -A[j-1]);
            }
         
        }
        if(i!=N)
        {ret += abs(A[N]);
        }
        else{
            ret+= abs(A[N-1]);
        }
            
        cout<<ret<<endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:5: error: 'cin' was not declared in this scope
    9 |     cin>>N;
      |     ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include <cmath>
  +++ |+#include <iostream>
    3 | using namespace std;
a.cc:36:9: error: 'cout' was not declared in this scope
   36 |         cout<<ret<<endl;
      |         ^~~~
a.cc:36:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:36:20: error: 'endl' was not declared in this scope
   36 |         cout<<ret<<endl;
      |                    ^~~~
a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    2 | #include <cmath>
  +++ |+#include <ostream>
    3 | using namespace std;
Language: C++

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const int Maxx = 1e5;
int n;
int a[Maxx + 7];

int main() {
	while(scanf("%d", &n) != EOF) {
		int sum = 0;
		for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
		a[0] = 0;
		a[n + 1] = 0;
		for(int i = 1; i <= n + 1; i++) sum += abs(a[i] - a[i - 1]); //所有花费
		for(int i = 1; i <= n; i++) {
			int t1 = a[i + 1] - a[i]; //多加的花费，要减掉
			int t2 = a[i] - a[i - 1]; //多加的花费，要减掉
			int t3 = a[i + 1] - a[i - 1]; //少加的花费，要加上
			printf("%d\n", sum - t1 - t2 + t3);
		}
	}
}

	/

Compiler output:
a.cc:27:9: error: expected unqualified-id before '/' token
   27 |         /
      |         ^
Language: C++

#include<stdio.h>#include<math.h>int a[100005];int main(){    int i,n,sum=0,k,t,x,y;    scanf("%d",&n);    n=n+1;    a[0]=0;    a[n]=0;    for(i=1;i<n;i++)    {        scanf("%d",&a[i]);        sum=sum+fabs(a[i]-a[i-1]);    }    sum=sum+fabs(a[n]-a[n-1]);    t=sum;    for(k=1;k<n;k++)    {  sum=t;        x=fabs(a[k]-a[k-1])+fabs(a[k+1]-a[k]);        y=fabs(a[k+1]-a[k-1]);        if(x>y)        sum=sum-(x-y);        if(x<=y)        sum=sum+(x-y);        printf("%d\n",sum);    }    return 0;}


Compiler output:
a.cc:1:18: warning: extra tokens at end of #include directive
    1 | #include<stdio.h>#include<math.h>int a[100005];int main(){    int i,n,sum=0,k,t,x,y;    scanf("%d",&n);    n=n+1;    a[0]=0;    a[n]=0;    for(i=1;i<n;i++)    {        scanf("%d",&a[i]);        sum=sum+fabs(a[i]-a[i-1]);    }    sum=sum+fabs(a[n]-a[n-1]);    t=sum;    for(k=1;k<n;k++)    {  sum=t;        x=fabs(a[k]-a[k-1])+fabs(a[k+1]-a[k]);        y=fabs(a[k+1]-a[k-1]);        if(x>y)        sum=sum-(x-y);        if(x<=y)        sum=sum+(x-y);        printf("%d\n",sum);    }    return 0;}
      |                  ^
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C

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

#define N 100000
int a[N+2];

int main(void){
    int n;
    scanf("%d", &n);
    int d=0;
    for(int i=1; i<=n; i++){
        int t;
        scanf("%d", &t);
        d += abs(a[i-1]-t);
        a[i]=t;
    }
    d += abs(a[n]-a[n+1]);
    for(int i=1; i<=n; i++){
        int t = abs(a[i-1]-a[i]) + abs(a[i]-a[i+1]) - abs(a[i-1]-a[i+1]);
        printf("%d\n", d-t);
    }
    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.*;
import java.lang.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N+2];
        int[] sum = new int[N];
        A[0] = 0;
        A[N+1] = 0;

        for(int i1 = 1; i1 < N+1; i1++){
            A[i1] = sc.nextInt();
        }

        for(int i3  = 0; i3 < N; i3++){
            for(int i4 = 0; i4 < N+1; i4++){
                sum[i3] = sum[i3] + Math.abs(A[i4+1] - A[i4]);
            }
        }

        for(int i5 = 0; i5 < N; i5++){
                sum[i5] = sum[i5] - Math.abs(A[i5] - A[i5 + 1]) - Math.abs(A[i5 + 1] - A[i5 + 2]) + Math.abs(A[i5] - A[i5 + 2]);
                System.out.println(sum[i5]);
            }
        }
    }
}

Compiler output:
Main.java:29: error: class, interface, enum, or record expected
}
^
1 error
Language: C++

#include<bits/stdc++.h>
using namespace std;
int a[100000];
int main()
{
    int n,i,s=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
	{
        scanf("%d",&a[i]);
        s+=abs(a[i]-a[i-1]);
    }
    sum+=abs(a[n]-a[n-1]);
    for(i=0;i<n;i++)
	{
        printf("%d\n",sum-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1]));
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:5: error: 'sum' was not declared in this scope
   13 |     sum+=abs(a[n]-a[n-1]);
      |     ^~~
Language: C++

#include<iostream>
using namespace std;

int abs(int a, int b);

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

    int price = 0;

    for(int i = 0; i < n; i++) {
        if(i > 0) {
            for(int j = i; j > 0; j--) {
                int raw = a[j - 1];
                a[j - 1] = a[j];
                a[j] = raw;
            }
        }  

        for(int k = 1; (k + 1) <= (n - 1); k++) {
            price += abs(a[k], a[k + 1])
        }

        price += abs(0, a[1]);
        price += abs(a[n-1], 0);

        cout << price << endl;
    }
    cout << endl;
}

int abs(int a,int b) {
    int num;

    if(a > b) {
        num = a - b;
    }
    else {
        num = b - a;
    }

    if(num < 0) {
        num *= -1;
    }

    return num;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:41: error: expected ';' before '}' token
   27 |             price += abs(a[k], a[k + 1])
      |                                         ^
      |                                         ;
   28 |         }
      |         ~
Language: C++

#include<iostream>
using namespace std;

int abs(int a, int b);

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

    int price = 0;

    for(int i = 0; i < n; i++) {
        if(i > 0) {
            for(int j = i; j > 0; j--) {
                int raw = a[j - 1];
                a[j - 1] = a[j];
                a[j] = raw;
            }
        }  

        for(int k = 1; (k + 1) <= (n - 1); k++) {
            price += abs(a[k], a[k + 1])
        }

        price += abs(0, a[1]);
        price += abs(a[n-1], k)

        cout << price << endl;
    }
    cout << endl;
}

int abs(int a, b) {
    int num;

    if(a > b) {
        num = a - b;
    }
    else {
        num = b - a;
    }

    if(num < 0) {
        num *= -1;
    }

    return num;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:41: error: expected ';' before '}' token
   27 |             price += abs(a[k], a[k + 1])
      |                                         ^
      |                                         ;
   28 |         }
      |         ~                                
a.cc:31:30: error: 'k' was not declared in this scope
   31 |         price += abs(a[n-1], k)
      |                              ^
a.cc: At global scope:
a.cc:38:16: error: 'b' has not been declared
   38 | int abs(int a, b) {
      |                ^
a.cc: In function 'int abs(int, int)':
a.cc:41:12: error: 'b' was not declared in this scope
   41 |     if(a > b) {
      |            ^
Language: Java

import java.util.*;
import java.lang.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N+2];
        int[] sum = new int[N];
        A[0] = 0;
        A[N+1] = 0;

        for(int i1 = 1; i1 < N+1; i1++){
            A[i1] = sc.nextInt();
        }

        for(int i3  = 0; i3 < N; i3++){
            for(int i4 = 0; i4 < N+1; i4++){
                sum[i3] = sum[i3] + Math.abs(A[i4+1] - A[i4]);
            }
        }

        for(int i5 = 0; i5 < N; i5++){
            if((A[i5 + 1] - A[i5])*(A[i5 + 1] - A[i5 + 2]) <= 0){
                System.out.println(sum[i5]);
            }else{

         sum[i5] = sum[i5] - Math.abs(Math.abs(A[i5] - A[i5+2]) - Math.abs(A[i5+2] -A[i5+1]))*2;
                System.out.println(sum[i5]);
            }
        }

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

import java.util.*;
import java.lang.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N+2];
        int[] sum = new int[N];
        A[0] = 0;
        A[N+1] = 0;

        for(int i1 = 1; i1 < N+1; i1++){
            A[i1] = sc.nextInt();
        }

        for(int i3  = 0; i3 < N; i3++){
            for(int i4 = 0; i4 < N+1; i4++){
                sum[i3] = sum[i3] + Math.abs(A[i4+1] - A[i4]);
            }
        }

        for(int i5 = 0; i5 < N; i5++){
            if((A[i5 + 1] - A[i5])*(A[i5 + 1] - A[i5 + 2]) <= 0){
                System.out.println(sum[i5]);
            }else{

                sum[i5] = sum[i5] - Math.abs(Math.abs(A[i5] - A[i5+2]) - Math.abs(A[i5+2] -A[i5+1]))*2;
                System.out.println(sum[i5]);
            }
        }

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

import java.util.*;
import java.lang.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N+2];
        int[] sum = new int[N];
        A[0] = 0;
        A[N+1] = 0;

        for(int i1 = 1; i1 < N+1; i1++){
            A[i1] = sc.nextInt();
        }

        for(int i3  = 0; i3 < N; i3++){
            for(int i4 = 0; i4 < N+1; i4++){
                sum[i3] = sum[i3] + Math.abs(A[i4+1] - A[i4]);
            }
        }

        for(int i5 = 0; i5 < N; i5++){
            if((A[i5 + 1] - A[i5])*(A[i5 + 1] - A[i5 + 2]) <= 0){
                System.out.println(sum[i5]);
            }else{

                sum[i5] = sum[i5] - Math.abs(Math.abs(A[i5] - A[i5 + 2]) - Math.abs(A[i5 + 2] - A[i5 + 1]))*2;
                System.out.println(sum[i5]);
            }
        }

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

#include <iostream>
#include<cstdib>
using namespace std;
int main (){
  long N,A[100000],total,i;
  
cin>>N;
for(i=0;i<N-1;i++)cin>>A[i];

  for(i=1;i<=N-1;i++){
    total=total+abs(A[i]-A[i-1]);
  }
  
  total=total+A[0]+A[N-1];

cout>>total-A[0]-abs(A[1]-A[0])+abs(A[1])>>endl;
  for(i=1;i<N-1;i++){
    cout<<total-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1])>>endl;
  }
  cout>>total-A[N-1]-abs(A[N-2]-A[N-1])+abs(A[N-2])>>endl;
}

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

#include <iostream>
#include<cstlib>
using namespace std;
int main (){
  long N,A[100000],total,i;
  
cin>>N;
for(i=0;i<N-1;i++)cin>>A[i];

  for(i=1;i<=N-1;i++){
    total=total+abs(A[i]-A[i-1]);
  }
  
  total=total+A[0]+A[N-1];

cout>>total-A[0]-abs(A[1]-A[0])+abs(A[1])>>endl;
  for(i=1;i<N-1;i++){
    cout<<total-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1])>>endl;
  }
  cout>>total-A[N-1]-abs(A[N-2]-A[N-1])+abs(A[N-2])>>endl;
}

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

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int checksum(int ,int);
int lastsum(int);

int main(){
  int N,*box;
  int temp;
  scanf("%d",&N);
  box=(int *)malloc(N*sizeof(int));
  for(int i=0;i<N;i++)
   scanf("%d",&box[i]);

  for(int i=0;i<N;i++){
    temp=0;


//条件判断下の処理
    if(i==N-1){
      for(int j=0;j<N-2;j++)
       temp+=checksum(box[j],box[j+1])
    }

    else(i>0){

      for(int j=0;j<N-1;j++){
        if(j+1==i){
          temp+=checksum(box[j],box[j+2]);
          j++;
        }
        else temp+=checksum(box[j],box[j+1]);
      }

    }
    if(i==0){
      for(int j=1;j<N-1;j++)
      temp+=checksum(box[j],box[j+1]);
    }



    if(i==N-1)temp+=lastsum(box[N-2]);
    else temp+=lastsum(box[N-1]);

    if(i==0)temp+=lastsum(box[1]);
    else temp+=lastsum(box[0]);

    printf("%d\n",temp);
  }
 return 0;
}

int checksum(int a,int b){
  if(a<b)return b-a;
  else return a-b;
}

int lastsum(int a){
    if(a>0)return a;
    else return -a;
}


Compiler output:
main.c: In function 'main':
main.c:23:39: error: expected ';' before '}' token
   23 |        temp+=checksum(box[j],box[j+1])
      |                                       ^
      |                                       ;
   24 |     }
      |     ~                                  
main.c:26:14: error: expected ';' before '{' token
   26 |     else(i>0){
      |              ^
      |              ;
main.c:45:5: error: 'else' without a previous 'if'
   45 |     else temp+=lastsum(box[N-1]);
      |     ^~~~
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:27:25: error: 'f' was not declared in this scope
   27 |         cout<<h[n]-h[2]+f abs(a[2])+fabs(a[n]-a[0])<<endl;
      |                         ^
Language: C

 
 #include<iostream>
 #include<string>
 using namespace std;
 
 long long int abs(long long int x)
 {
 	if(x>=0) return x;
 	else return -x;
 }
 
 int main()
 {
 	int n;
    int arr[10000+5];
 	int dp[10000+5];
 	int ans[10000+5];
 	while(cin>>n)
 	{
 		long long int pos=0;
 		arr[0]=0;
 		for(int i=1;i<=n;i++) cin>>arr[i];
 		for(int i=0;i<n;i++)
 		{
 			if(i==0) dp[i]=abs(arr[i+1]-pos);
 			else dp[i]=dp[i-1]+abs(arr[i+1]-pos);
 			pos=arr[i+1];
		 }
		 dp[n]=dp[n-1]+abs(0-arr[n]);
		 //for(int i=0;i<=n;i++) cout<<dp[i]<<endl;
		 for(int i=0;i<(n-1);i++)
		 {
		 	if(i==0) ans[i]=dp[n]-dp[i+1]+abs(arr[i+2]-arr[i]);
		 	else ans[i]=dp[n]-dp[i+1]+dp[i-1]+abs(arr[i+2]-arr[i]);
		 }
		 ans[n-1]=dp[n-2]+abs(arr[n-1]-0);
		 for(int i=0;i<n;i++) cout<<ans[i]<<endl;
	 }
 	return 0;
 }
 

Compiler output:
main.c:2:10: fatal error: iostream: No such file or directory
    2 |  #include<iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
#include<stdlib.h>
using namespace std;
int main()
{
int N,i,s=0,j=0;
vector <int> A(N);
for(i=0;i<N;i++)
{
cin>>A[i];
}
for(i=0;i<N;i++)
{
if(j!=i)
s=abs(s-A[i]);
cout<<s<<endl;
j++;
}
return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:1: error: 'vector' was not declared in this scope
    7 | vector <int> A(N);
      | ^~~~~~
a.cc:3:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    2 | #include<stdlib.h>
  +++ |+#include <vector>
    3 | using namespace std;
a.cc:7:9: error: expected primary-expression before 'int'
    7 | vector <int> A(N);
      |         ^~~
a.cc:10:6: error: 'A' was not declared in this scope
   10 | cin>>A[i];
      |      ^
a.cc:15:9: error: 'A' was not declared in this scope
   15 | s=abs(s-A[i]);
      |         ^
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)
#define FORR(i,n,m) for(ll i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K

int main(){
    ll n;
    cin >> n;

    static ll a[100000],melt[100000];
    
    REP(i,n){
        cin >> a[i];
    }
    ll sum = abs(a[0])+abs(a[n-1]);
    REP(i,n-1){
        sum += abs(a[i]-a[i+1]);
    }
    REP(i,n){
        if(a==0){
            cout << sum - abs(abs(a[i+1])-(abs(a[i]-a[i-1])+abs(a[i]-a[i+1]))) << endl;
        }else if(a==n-1){
            cout << sum - abs(abs(a[i-1])-(abs(a[i]-a[i-1])+abs(a[i]-a[i+1]))) << endl;
        }else{
            cout << sum - abs(abs(a[i-1]-a[i+1])-(abs(a[i]-a[i-1])+abs(a[i]-a[i+1]))) << endl;
        }
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:19: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   39 |         }else if(a==n-1){
      |                  ~^~~~~
Language: Java

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        int N= Integer.parseInt(s);

        s = sc.nextLine();
        String[] array = s.split(" ");
        int sum = 0;
        int abs=0;
        int x=0;
        for(int j = 0, i=0; i < N*N; i++,j=i/N) {
        	if(i%N==j)continue;
        	abs=(Integer.parseInt(array[i%N]) -x);
        	if(abs<0) abs*=-1;
        	sum+=abs;
        	x=Integer.parseInt(array[i%N]);
        if(i%N==N-1) {
        if(x<0) x*=-1;
        sum+=x;
        System.out.println(sum);
        sum=0;
        x=0;
        }

        }
        if(x<0) x*=-1;
        sum+=x;
        System.out.println(sum);

	}

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

#include <bits/stdc++.h>
using namespace std;
long long  ai[100005];
long long  bi[100005];
int main()
{
    int n;
    scanf("%d",&n);
    int su,j=0;
    long long sum=0;
    for(int i=0; i<n; i++)
    {
        int w;
        scanf("%lld",&ai[i]);
        if(i!=0)
            bi[i-1]=ai[i]-su;
        if(bi[i-1]<0) bi[i-1]=-bi[i-1];
        su=ai[i];
        sum+=bi[i-1];
    }
    int flag=0,flag1=0;
    for(int i=0; i<n; i++)
    {
        flag=0;flag1=0;
        if(i!=0&&i!=n-1)
        {
            int e=ai[i+1]-ai[i-1];
            if(ai[i+1]-ai[i-1]<0)  e=ai[i-1]-ai[i+1];
            if(ai[n-1]<0) {ai[n-1]=-ai[n-1];flag=1;}
            if(ai[0]<0) {ai[0]=-ai[0];flag1=1};
            printf("%lld\n",sum-bi[i-1]-bi[i]+e+ai[n-1]+ai[0]);
             if(flag==1) ai[n-1]=-ai[n-1];flag=0;
            if(flag1==1) ai[0]=-ai[0];flag1=0;
        }
        if(i==0)
        {
            if(ai[n-1]<0) {ai[n-1]=-ai[n-1],flag=1;}
            if(ai[1]<0) {ai[1]=-ai[1],flag1=1;}
            printf("%lld\n",sum-bi[0]+ai[n-1]+ai[1]);
            if(flag==1) ai[n-1]=-ai[n-1];flag=0;
            if(flag1==1) ai[1]=-ai[1];flag1=0;
        }
        if(i==n-1)
        {
            if(ai[n-2]<0) {ai[n-2]=-ai[n-2],flag=1;}
            if(ai[0]<0) {ai[0]=-ai[0],flag1=1;}
            printf("%lld\n",sum-bi[n-2]+ai[n-2]+ai[0]);
            if(flag==1) ai[n-2]=-ai[n-2];flag=0;
            if(flag1==1) ai[0]=-ai[0];flag1=0;
        }
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:46: error: expected ';' before '}' token
   30 |             if(ai[0]<0) {ai[0]=-ai[0];flag1=1};
      |                                              ^
      |                                              ;
Language: C++

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <vector>
using namespace std;

int a[100010];
int mark[100010];

bool cmp(int A, int B) {
	return a[A] < a[B];
}

int main() {
	//freopen("/Users/liyingyan/Documents/ACM/in.txt", "r", stdin);
	//std::ios::sync_with_stdio(false);
	int n;
	cin >> n;
	for(int i=0; i< n; i++) {
		cin >> a[i];
		mark[i] = i;
	}
	sort(mark, mark+n, cmp);
	int mi = a[mark[0]], ma = a[mark[n-1]];
	int ans = 0, ans1, ans2;
	if(ma<=0) {
		ans = -mi*2;
		ans1 = ans;
		ans2 = ans - (a[mark[1]]-mi)*2;
	} else if(mi>=0) {
		ans = ma*2;
		ans1 = ans - (ma-a[mark[n-2]])*2;
		ans2 = ans;
	} else {
		ans = (ma-mi)*2;
		if(a[mark[n-2]] < 0) 
			ans1 = ans - ma*2;
		else
			ans1 = ans - (ma-a[mark[n-2]])*2;
		if(a[mark[1]] > 0)
			ans2 = ans - (-mi)*2;
		else 
			ans2 = ans - (a[mark[1]]-mi)*2;
	}
	
	for(int i=0; i<n; i++) {
		if(a[i] == mi) {
			cout << ans2 << endl;
		} else if(a[i] == ma) {
			cout << ans1 << endl;
		} else cout << ans << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:9: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   28 |         sort(mark, mark+n, cmp);
      |         ^~~~
      |         sqrt
Language: C

#include<stdio.h>
#include<math.h>
 
main(){
    int n;
    int a[100002];
    int i;
    int t, x, k;
 
    // 整数の入力
    scanf("%d", &n);
 
    a[0] = 0;
    t = 0;
    for(i = 1; i <= n; i++){
        scanf("%d ", &a[i]);
        t += abs(a[i] - a[i-1]);
    }
    a[n+1] = 0;
    t += abs(a[n+1] - a[n];
 
    for(i = 1; i <= n; i++){
        x=t - abs(a[i]-a[i-1]) - abs(a[i]-a[i+1]) + abs(a[i+1]-a[i-1]);
        // 出力
        printf("%d\n", (int)x);
    } 
    
}
#include<stdio.h>
#include<math.h>
 
main(){
    int n;
    int a[100002];
    int i;
    int t, x, k;
 
    // 整数の入力
    scanf("%d", &n);
 
    a[0] = 0;
    t = 0;
    for(i = 1; i <= n; i++){
        scanf("%d ", &a[i]);
        t += abs(a[i] - a[i-1]);
    }
    a[n+1] = 0;
    t += abs(a[n+1] - a[n]);
 
    for(i = 1; i <= n; i++){
        x=t - abs(a[i]-a[i-1]) - abs(a[i]-a[i+1]) + abs(a[i+1]-a[i-1]);
        // 出力
        printf("%d\n", (int)x);
    } 
    
}


Compiler output:
main.c:4:1: error: return type defaults to 'int' [-Wimplicit-int]
    4 | main(){
      | ^~~~
main.c: In function 'main':
main.c:17:14: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
   17 |         t += abs(a[i] - a[i-1]);
      |              ^~~
main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
    2 | #include<math.h>
  +++ |+#include <stdlib.h>
    3 | 
main.c:20:27: error: expected ')' before ';' token
   20 |     t += abs(a[n+1] - a[n];
      |             ~             ^
      |                           )
main.c:26:6: error: expected ';' before '}' token
   26 |     }
      |      ^
      |      ;
   27 | 
   28 | }
      | ~     
main.c: At top level:
main.c:32:1: error: return type defaults to 'int' [-Wimplicit-int]
   32 | main(){
      | ^~~~
main.c:32:1: error: redefinition of 'main'
main.c:4:1: note: previous definition of 'main' with type 'int()'
    4 | main(){
      | ^~~~
Language: C

#include<stdio.h>
#include<math.h>
 
main(){
    int n;
    int a[100002];
    int i;
    int t, x, k;
 
    // 整数の入力
    scanf("%d", &n);
 
    a[0] = 0;
    t = 0;
    for(i = 1; i <= n; i++){
        scanf("%d ", &a[i]);
        t += abs(a[i] - a[i-1]);
    }
    a[n+1] = 0;
    t += abs(a[n+1] - a[n];
 
    for(i = 1; i <= n; i++){
        x=t - abs(a[i]-a[i-1]) - abs(a[i]-a[i+1]) + abs(a[i+1]-a[i-1]);
        // 出力
        printf("%d\n", (int)x);
    } 
    
}

Compiler output:
main.c:4:1: error: return type defaults to 'int' [-Wimplicit-int]
    4 | main(){
      | ^~~~
main.c: In function 'main':
main.c:17:14: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
   17 |         t += abs(a[i] - a[i-1]);
      |              ^~~
main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
    2 | #include<math.h>
  +++ |+#include <stdlib.h>
    3 | 
main.c:20:27: error: expected ')' before ';' token
   20 |     t += abs(a[n+1] - a[n];
      |             ~             ^
      |                           )
main.c:26:6: error: expected ';' before '}' token
   26 |     }
      |      ^
      |      ;
   27 | 
   28 | }
      | ~
Language: C

#include<stdio.h>
#include<math.h>
 
main(){
    int n;
    int a[100002];
    int i;
    int t, x, k;
 
    // 整数の入力
    scanf("%d", &n);
 
    a[0] = 0;
    t = 0;
    for(i = 1; i <= n; i++){
        scanf("%d ", &a[i]);
        t += abs(a[i] - a[i-1]);
    }
    a[n+1] = 0;
    t += abs(a[n+1] - a[n]);
 
    for(i = 1; i <= n; i++){
        x=t - abs(a[i]-a[i-1]) - abs(a[i]-a[i+1]) + abs(a[i+1]-a[i-1]);
        // 出力
        printf("%d\n", (int)x);
    } 
    
}
#include<stdio.h>
#include<math.h>
 
main(){
    int n;
    int a[100002];
    int i;
    int t, x, k;
 
    // 整数の入力
    scanf("%d", &n);
 
    a[0] = 0;
    t = 0;
    for(i = 1; i <= n; i++){
        scanf("%d ", &a[i]);
        t += abs(a[i] - a[i-1]);
    }
    a[n+1] = 0;
 
    for(i = 1; i <= n; i++){
        x=t - abs(a[i]-a[i-1]) - abs(a[i]-a[i+1]) + abs(a[i+1]-a[i-1]);
        // 出力
        printf("%d\n", (int)x);
    } 
    
}

Compiler output:
main.c:4:1: error: return type defaults to 'int' [-Wimplicit-int]
    4 | main(){
      | ^~~~
main.c: In function 'main':
main.c:17:14: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
   17 |         t += abs(a[i] - a[i-1]);
      |              ^~~
main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
    2 | #include<math.h>
  +++ |+#include <stdlib.h>
    3 | 
main.c: At top level:
main.c:32:1: error: return type defaults to 'int' [-Wimplicit-int]
   32 | main(){
      | ^~~~
main.c:32:1: error: redefinition of 'main'
main.c:4:1: note: previous definition of 'main' with type 'int()'
    4 | main(){
      | ^~~~
Language: C++

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

int main()
{
    // 整数の入力
    int n;
    cin >> n;
    
    // input of a_i
    int a[n+2];
    for(int i=1;i<=n;i++){
        cin >> a[i];
    }
    a[0] = 0;
    a[n + 1] = 0;

    // yen total
    int yen;
    for (int i=1;i<=n+1;i++){
        yen = yen + fabs(a[j] - a[j - 2]);
    }

    // output
    for(int i=1;i<=n;i++){
        cout << yen + fabs(a[i+1]-a[i-1]) - fabs(a[i]-a[i-1]) - fabs(a[i+1]-a[i]) << endl;
    }
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:28: error: 'j' was not declared in this scope
   23 |         yen = yen + fabs(a[j] - a[j - 2]);
      |                            ^
Language: C

#include<stdio.h>
#include<math.h>
 
main(){
    int n;
    int a[100002];
    int i;
    int t, x, k;
 
    // 整数の入力
    scanf("%d", &n);
 
    a[0] = 0;
    t = 0;
    for(i = 1; i <= n; i++){
        scanf("%d ", &a[i]);
        t += abs(a[i] - a[i-1]);
    }
    a[n+1] = 0;
 
    for(i = 1; i <= n; i++){
        x=t - abs(a[i]-a[i-1]) - abs(a[i]-a[i+1]) + abs(a[i+1]-a[i-1]);
        // 出力
        printf("%d\n", x);
    } 
    
}
#include<stdio.h>
#include<math.h>
 
main(){
    int n;
    int a[100002];
    int i;
    int t, x, k;
 
    // 整数の入力
    scanf("%d", &n);
 
    a[0] = 0;
    t = 0;
    for(i = 1; i <= n; i++){
        scanf("%d ", &a[i]);
        t += abs(a[i] - a[i-1]);
    }
    a[n+1] = 0;
 
    for(i = 1; i <= n; i++){
        x=t - abs(a[i]-a[i-1]) - abs(a[i]-a[i+1]) + abs(a[i+1]-a[i-1]);
        // 出力
        printf("%d\n", (int)x);
    } 
    
}


Compiler output:
main.c:4:1: error: return type defaults to 'int' [-Wimplicit-int]
    4 | main(){
      | ^~~~
main.c: In function 'main':
main.c:17:14: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
   17 |         t += abs(a[i] - a[i-1]);
      |              ^~~
main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
    2 | #include<math.h>
  +++ |+#include <stdlib.h>
    3 | 
main.c: At top level:
main.c:31:1: error: return type defaults to 'int' [-Wimplicit-int]
   31 | main(){
      | ^~~~
main.c:31:1: error: redefinition of 'main'
main.c:4:1: note: previous definition of 'main' with type 'int()'
    4 | main(){
      | ^~~~
Language: C

#include<stdio.h>
#include<math.h>
 
main(){
    int n;
    int a[100002];
    int i, j;
    int t, x, k;
 
    // 整数の入力
    scanf("%d", &n);
 
    a[0] = 0;
    t = 0;
    for(i = 1; i <= n; i++){
        scanf("%d", &a[i]);
        t += abs(a[i] - a[i-1]);
    }
    a[n+1] = 0;
 
    for(i = 1; i <= n; i++){
        x=t - abs(a[i]-[a[i-1]) - abs(a[i]-[a[i+1]) + abs(a[i+1]-[a[i-1]);
        // 出力
        printf("%d\n", x);
    } 
    
}

Compiler output:
main.c:4:1: error: return type defaults to 'int' [-Wimplicit-int]
    4 | main(){
      | ^~~~
main.c: In function 'main':
main.c:17:14: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
   17 |         t += abs(a[i] - a[i-1]);
      |              ^~~
main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
    2 | #include<math.h>
  +++ |+#include <stdlib.h>
    3 | 
main.c:22:24: error: expected expression before '[' token
   22 |         x=t - abs(a[i]-[a[i-1]) - abs(a[i]-[a[i+1]) + abs(a[i+1]-[a[i-1]);
      |                        ^
main.c:22:31: error: expected ']' before ')' token
   22 |         x=t - abs(a[i]-[a[i-1]) - abs(a[i]-[a[i+1]) + abs(a[i+1]-[a[i-1]);
      |                               ^
      |                               ]
main.c:22:44: error: expected expression before '[' token
   22 |         x=t - abs(a[i]-[a[i-1]) - abs(a[i]-[a[i+1]) + abs(a[i+1]-[a[i-1]);
      |                                            ^
main.c:22:51: error: expected ']' before ')' token
   22 |         x=t - abs(a[i]-[a[i-1]) - abs(a[i]-[a[i+1]) + abs(a[i+1]-[a[i-1]);
      |                                                   ^
      |                                                   ]
main.c:22:66: error: expected expression before '[' token
   22 |         x=t - abs(a[i]-[a[i-1]) - abs(a[i]-[a[i+1]) + abs(a[i+1]-[a[i-1]);
      |                                                                  ^
main.c:22:73: error: expected ']' before ')' token
   22 |         x=t - abs(a[i]-[a[i-1]) - abs(a[i]-[a[i+1]) + abs(a[i+1]-[a[i-1]);
      |                                                                         ^
      |                                                                         ]
Language: C++

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

int main(){
    int d[100002]={0};
    int N=0;
    cin >> N;
    for(int i=1;i<=N;i++){
        cin >> d[i];
    }
    
    
    d[N+1]=0;
    
    for(int i=1;i<=N;i++){       //i番目の町を省略する
        int sum=0;
        for(int k=1;k<=N;k++){
            if(i==k){
                sum+=abs(d[k+1]-d[k-1]);
                k = k+1;
            }else{
                sum += abs(d[k]-d[k-1]);
            }
            if(k==N+1){break;}
            if(k==N){sum+=abs(d[k]);}
        }
        cout << sum<<endl;
    }
 

Compiler output:
a.cc: In function 'int main()':
a.cc:30:6: error: expected '}' at end of input
   30 |     }
      |      ^
a.cc:6:11: note: to match this '{'
    6 | int main(){
      |           ^
Language: C++

#include <iostream>
#include<string>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  int arr[N + 2];
  int skip_dist[N];
  int normal_dist[N];
  int num;
  for (int i = 0; i < N; i++){
      cin >> num;
      arr[i + 1] = num;
  }
  arr[i] = 0
  arr[N + 1] = 0

  for (int i = 0; i < N; i++){
      int base_point = i + 1
      skip_distance = abs(arr[base_point - 1] - arr[base_point + 1])
      skip_dist[i] = skip_distance;

      normal_distance = abs(arr[base_point - 1] - arr[base_point])
      if (i == 0){
          normal_dist[i] = normal_distance;
      }
      else{
          normal_dist[i] = normal_distance + normal_dist[i - 1];
      }
  }

  for (int i = 0; i < N; i++){
      cout << normal_dist[N] - normal_dist[i + 1] + skip_dist[i] << endl;
  }

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:7: error: 'i' was not declared in this scope
   16 |   arr[i] = 0
      |       ^
Language: C

#include<stdio.h>
#include<math.h>
int main()
{
    int n;
    scanf("%d", &n);
    int a[100000];
    int i;
    for (i = 0; i < n; i++)
        scanf("%d", &a[i]);
    int x;
    int ans;
    int y;
    for (i = 0; i < n; i++)
    {
        if (i != 0)
            ans = abs(a[0]);
        else
            ans = abs(a[1]);
        for (x = 0; x < n - 2; x++)
        {
            if (x + 1 != i)
                ans += abs(a[x + 1] - a[x]);
            else
            {
                ans += abs(a[x + 2] - a[x];
                x++;
            }
        }
        ans += abs(b[n - 2]);
        printf("%d\n", ans);
    }
    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:17:19: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
   17 |             ans = abs(a[0]);
      |                   ^~~
main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
    2 | #include<math.h>
  +++ |+#include <stdlib.h>
    3 | int main()
main.c:26:43: error: expected ')' before ';' token
   26 |                 ans += abs(a[x + 2] - a[x];
      |                           ~               ^
      |                                           )
main.c:27:21: error: expected ';' before '}' token
   27 |                 x++;
      |                     ^
      |                     ;
   28 |             }
      |             ~        
main.c:30:20: error: 'b' undeclared (first use in this function)
   30 |         ans += abs(b[n - 2]);
      |                    ^
main.c:30:20: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

 
 #include<iostream>
 #include<string>
 using namespace std;
 
 long long int abs(int x)
 {
 	if(x>=0) return x;
 	else return -x;
 }
 
 int main()
 {
 	long long int n;
 	long long int arr[100000+5];
 	long long int dp[100000+5];
 	long long int ans[100000+5];
 	while(cin>>n)
 	{
 		long long int tot=0;
 		int pos=0;
 		for(int i=0;i<n;i++) cin>>arr[i];
 		for(int i=0;i<n;i++)
 		{
 			cin>>arr[i];
 			if(i==0) dp[i]=abs(arr[i]-pos);
 			else dp[i]=dp[i-1]+abs(arr[i]-pos);
 			pos=arr[i];
		 }
		 dp[n]=abs(0-arr[n-1]);
		 for(int i=0;i<(n-1);i++)
		 {
		 	ans[i]=dp[n]-dp[i+2]+abs(arr[i+2]-arr[i]);
		 }
		 arr[n-1]=dp[n-2]+abs(arr[n-2]-0);
		 for(int i=0;i<n;i++) cout<<arr[i]<<endl;
	 }
 	return 0;
 }
 
 
 
 

Compiler output:
a.cc:6:16: error: ambiguating new declaration of 'long long int abs(int)'
    6 |  long long int abs(int x)
      |                ^~~
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/c++/14/ext/string_conversions.h:43,
                 from /usr/include/c++/14/bits/basic_string.h:4154,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:2:
/usr/include/stdlib.h:980:12: note: old declaration 'int abs(int)'
  980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
Language: C++

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

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

	int d[N+1];
	int sum=0;
	for (int i = 0; i < N+1; ++i)
	{
		d[i] = abs(A[i+1]-A[i]);
		sum += d[i];
	}

	for (int i = 0; i < N; ++i)
	{
		cout << sum - d[i] - d[i+1] + abs(A[i+2]-A[i]) << endl;
	}


	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:17:24: error: 'abs' was not declared in this scope
   17 |                 d[i] = abs(A[i+1]-A[i]);
      |                        ^~~
a.cc:23:17: error: 'cout' was not declared in this scope
   23 |                 cout << sum - d[i] - d[i+1] + abs(A[i+2]-A[i]) << endl;
      |                 ^~~~
a.cc:23:47: error: 'abs' was not declared in this scope
   23 |                 cout << sum - d[i] - d[i+1] + abs(A[i+2]-A[i]) << endl;
      |                                               ^~~
a.cc:23:67: error: 'endl' was not declared in this scope
   23 |                 cout << sum - d[i] - d[i+1] + abs(A[i+2]-A[i]) << endl;
      |                                                                   ^~~~
Language: C++

#include <cstdio>
using namespace std;

int dist(int a, int b){
    int d;
    if(a>=b){
        d=a-b;
    }else{
        d=b-a;
    }
    return d;
}

int main(){
    int N,ini;

    scanf("%d",&N);
    int* A = new int[N+2];
    int* C = new int[N];

    A[0]=0;   
    for(int i=1;i<=N;i++){
        scanf("%d",&A[i]);
    }
    A[N+1]=0;

    ini=0;
    for(int i=0;i<=N;i++){
        ini=ini+dist(A[i]+A[i+1]);
    }

    for(int i=0;i<=N-1;i++){
        C[i]=ini-dist(A[i-1],A[i])-dist(A[i],A[i+1])+dist(A[i-1],A[i+1]);
    }


    for(int i=0;i<=N-1;i++){
       printf("%d\n", C[i]);
    }


    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:21: error: too few arguments to function 'int dist(int, int)'
   29 |         ini=ini+dist(A[i]+A[i+1]);
      |                 ~~~~^~~~~~~~~~~~~
a.cc:4:5: note: declared here
    4 | int dist(int a, int b){
      |     ^~~~
Language: C++

#include <cstdio>
using namespace std;

int dist(int a, int b){
    int d;
    if(a>=b){
        d=a-b;
    }else{
        d=b-a;
    }
    return d;
}

int main(){
    int N,ini;

    scanf("%d",&N);
    int* A = new int[N+2];
    int* C = new int[N];

    A[0]=0;   
    for(int i=1;i<=N;i++){
        scanf("%d",&A[i]);
    }
    A[N+1]=0;

    ini=0;
    for(int i=0;i<=N;i++){
        ini=ini+dist(A[i]+A[i+1])
    }

    for(int i=0;i<=N-1;i++){
        C[i]=ini-dist(A[i-1],A[i])-dist(A[i],A[i+1])+dist(A[i-1],A[i+1]);
    }


    for(int i=0;i<=N-1;i++){
       printf("%d\n", C[i]);
    }


    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:21: error: too few arguments to function 'int dist(int, int)'
   29 |         ini=ini+dist(A[i]+A[i+1])
      |                 ~~~~^~~~~~~~~~~~~
a.cc:4:5: note: declared here
    4 | int dist(int a, int b){
      |     ^~~~
Language: C++

#include <cstdio>
using namespace std;

int dist(int a, int b){
    int d;
    if(a>=b){
        d=a-b;
    }else{
        d=b-a;
    }
    return d;
}

int main(){
    int N,ini;

    scanf("%d",&N);
    int* A = new int[N+2];
    int* C = new int[N];

    A[0]=0;   
    for(int i=1;i<=N;i++){
        scanf("%d",&A[i]);
    }
    A[N+1]=0;

    ini=0;
    for(int i=0;i<=N;i++){
        ini=ini+dist(A[i]+A[i+1])
    }

    for(int i=0;i<=N-1;i++){
        C[i]=ini-dist(A[i-1],A[i])-dist(A[i],A[i+1])+dist(A[i-1],A[i+1])
    }


    for(int i=0;i<=N-1;i++){
       printf("%d\n", C[i]);
    }


    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:21: error: too few arguments to function 'int dist(int, int)'
   29 |         ini=ini+dist(A[i]+A[i+1])
      |                 ~~~~^~~~~~~~~~~~~
a.cc:4:5: note: declared here
    4 | int dist(int a, int b){
      |     ^~~~
a.cc:33:73: error: expected ';' before '}' token
   33 |         C[i]=ini-dist(A[i-1],A[i])-dist(A[i],A[i+1])+dist(A[i-1],A[i+1])
      |                                                                         ^
      |                                                                         ;
   34 |     }
      |     ~
Language: C++

//#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
#define WAIT system ("pause")
#define rt0 return 0
using namespace std;
int main()
{
	int N, A[100002];
	int ans=0;
	A[0]=0;
	A[100001]=0;
	
	cin>>N;
	for(int i=1;i<=N;i++) {
		cin>>A[i];
		ans+=abs(A[i]-A[i-1]);
	}
	ans+=abs(A[N]);
		
	for(int i=1;i<=N;i++)	{
		int temp= ans-abs(A[i]-A[i-1]);
		temp-=abs(A[i+1]-A[i]);
		temp+=abs(A[i+1]-A[i-1]);
		cout<<temp<<endl;

	} 
    rt0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:9: error: 'cin' was not declared in this scope
   15 |         cin>>N;
      |         ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | //#include <vector>
a.cc:18:22: error: 'abs' was not declared in this scope; did you mean 'ans'?
   18 |                 ans+=abs(A[i]-A[i-1]);
      |                      ^~~
      |                      ans
a.cc:20:14: error: 'abs' was not declared in this scope; did you mean 'ans'?
   20 |         ans+=abs(A[N]);
      |              ^~~
      |              ans
a.cc:26:17: error: 'cout' was not declared in this scope
   26 |                 cout<<temp<<endl;
      |                 ^~~~
a.cc:26:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:26:29: error: 'endl' was not declared in this scope
   26 |                 cout<<temp<<endl;
      |                             ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | //#include <vector>
Language: Java

import java.util.Scanner;

public class Main_C {

    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int n = cin.nextInt();
        int [] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = cin.nextInt();
        }
        int memo_x = 0;
        int memo_expence = 0;
        for (int i = 0; i < n; i++) {
            int x = memo_x;
            int expence = memo_expence;
            memo_expence = Math.abs(memo_x - a[i]);
            memo_x += a[i];
            for (int j = i + 1; j < n; j++) {
                expence += Math.abs(x- a[j]);
                x = a[j];
            }
            System.out.println(expence + Math.abs(x));
        }
    }
}


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

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String args[]) {
        FastReader sc = new FastReader();
        int n = sc.nextInt();
        int[] as = new int[n];
        for (int i = 0; i < n; i++) {
            as[i] = sc.nextInt();
        }
        int sum = Math.abs(as[0]);
        for (int i = 1; i < n; i++) {
            sum += Math.abs(as[i] - as[i-1]);
        }
        sum += Math.abs(as[n-1]);
        System.out.println(sum + Math.abs(as[1]) - Math.abs(as[0]) -
                Math.abs(as[0] - as[1]));
        for (int i = 1; i < n-1; i++) {
            int ans = sum + Math.abs(as[i-1] - as[i+1]) -
                    Math.abs(as[i-1] - as[i]) - Math.abs(as[i] - as[i+1]);
            System.out.println(ans);
        }
        System.out.println(sum + Math.abs(as[n-2]) - Math.abs(as[n-1]) -
                Math.abs(as[n-2] - as[n-1]));
    }

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

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