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

#include <iostream>

using namespace std;

int main () {
  int n;
  cin >> n;
  
  vector<int> a(n);
  for (auto i = 0; i < n; i++) cin >> a[i];
  
  int acc = 0;
  int min = 0;
  
  for (const auto num : a) {
    if (min > num) {
      acc += min - num
    } else {
      min = num
    }
  }
  
  cout << acc << endl;
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:3: error: 'vector' was not declared in this scope
    9 |   vector<int> a(n);
      |   ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | 
a.cc:9:10: error: expected primary-expression before 'int'
    9 |   vector<int> a(n);
      |          ^~~
a.cc:10:39: error: 'a' was not declared in this scope
   10 |   for (auto i = 0; i < n; i++) cin >> a[i];
      |                                       ^
a.cc:15:25: error: 'a' was not declared in this scope
   15 |   for (const auto num : a) {
      |                         ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	rep(i, N) {
		cin >> A.at(i);
	}
	ll ans = 0;
	int MAXnum = 0;
	rep(i, N) {
		MAXnum = max(MAXnum, A[i]);
		int tmp = MAXnum;
		ans += tmp - A[i];
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:9: error: 'll' was not declared in this scope
   12 |         ll ans = 0;
      |         ^~
a.cc:17:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   17 |                 ans += tmp - A[i];
      |                 ^~~
      |                 abs
a.cc:19:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   19 |         cout << ans << endl;
      |                 ^~~
      |                 abs
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll
int main()
{
	int n,i;
	cin>>n;
	ll x,s1=0,s2=0,m=0;
	for(i=1; i<=n; i++){
		cin>>x;
		s1+=x;
		if(x<m)
			s2+=m;
		m=max(m,x);
	}	
	cout<<s2-s1;
	return 0;
}


Compiler output:
a.cc:4:1: error: expected initializer before 'int'
    4 | int main()
      | ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll
int main()
{
	int n,i;
	cin>>n;
	ll x,s1=0,s2=0,m=0;
	for(i=1; i<=n; i++){
		cin>>x;
		s1+=x;
		if(x<m);
			s2+=m;
		m=max(m,x);
	}	
	cout<<s2-s1;
	return 0;
}


Compiler output:
a.cc:4:1: error: expected initializer before 'int'
    4 | int main()
      | ^~~
Language: C++

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

int main() 
{
    lli n,x;
    cin >> n;
    lli mx = -1;
    lli ans = 0;
    
    for(int i=0;i<n;i++){
        cin >> x;
        ans += max(mx-x,0);
        mx = max(mx,x);
    }
    
    cout<<ans<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:19: error: no matching function for call to 'max(long long int, int)'
   14 |         ans += max(mx-x,0);
      |                ~~~^~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:14:19: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   14 |         ans += max(mx-x,0);
      |                ~~~^~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:14:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   14 |         ans += max(mx-x,0);
      |                ~~~^~~~~~~~
Language: C

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

int main ()
{
    long long int t,a,sum,i;
    cin>>t;
    vector<long long int> arr(t);
    for (i=0;i<t;i++)
    {
        cin>>arr[i];
    }
    sum=0;
    for(i=0;i<t;i++)
    {
        if (arr[i]>arr[i+1])
            {
                sum+=arr[i]-arr[i+1];
                arr[i+1]=arr[i];
            }
    }
                  cout<<sum<<'\n';
    return 0;
}


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

#include <algorithm>
#include <numeric>
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<long long> A(N), height(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    height[0]=0;
    for (int i = 1; i < N; i++) {
        long long prev = A[i-1] + height[i-1];
        height[i] = max(0, A[i] - prev);
    }
    cout << accumulate(height.begin(), height.end(), 0) << endl;
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:24: error: no matching function for call to 'max(int, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)'
   21 |         height[i] = max(0, A[i] - prev);
      |                     ~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:21:24: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   21 |         height[i] = max(0, A[i] - prev);
      |                     ~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:21:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   21 |         height[i] = max(0, A[i] - prev);
      |                     ~~~^~~~~~~~~~~~~~~~
Language: C

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

#define REP(i, n) for(ll i=0;i<ll(n); i++)

int main(){
    ll N;
    ll i;
    vector<long long int> A;
    cin >> N;
    for(i=0;i<N;i++){
        ll ai;
        cin >> ai;
        A.push_back(ai);
    }

    ll count = 0;
    ll gap;
    ll ni, nii;
    nii = A[0];
    for(i=1;i<N;i++){
        ni = A[i];
        gap = nii - ni;
        if(gap > 0){
            count += gap;
            nii = ni + gap;
        }
        else{nii = ni;}
    }
    cout << count << endl;
    return 0;
}


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

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using st = string;
using P = pair<int, int>;
#define mrep(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) mrep(i, 0, n)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a.at(i);
    int ans = 0;
    int max = 0;
    rep(i, n){
        chmax(max, a.at(i));
        ans += max - a.at(i);
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:28: error: 'max' cannot be used as a function
    8 | #define chmax(x, y) x = max(x, y)
      |                         ~~~^~~~~~
a.cc:19:9: note: in expansion of macro 'chmax'
   19 |         chmax(max, a.at(i));
      |         ^~~~~
Language: C

#include <stdio.h>
int main(void){
  int N,i,A,max=0;
  long int sum;
  setbuf(stdout,NULL);
  scanf("%d",&N);
  for(i=1;i<=N;i++){
    scanf("%d",&A);
    if(A<max)s+=max-A;
    else max=A;
  }
  printf("%ld",s);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:9:14: error: 's' undeclared (first use in this function)
    9 |     if(A<max)s+=max-A;
      |              ^
main.c:9:14: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <stdio.h>
int main(void){
  int N,i,s=0,max=0;
  int A[200001]
  setbuf(stdout,NULL);
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
    if(A[i]<max)s+=max-A[i];
    else max=A[i];
  }
  printf("%d",s);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:5:3: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'setbuf'
    5 |   setbuf(stdout,NULL);
      |   ^~~~~~
main.c:8:17: error: 'A' undeclared (first use in this function)
    8 |     scanf("%d",&A[i]);
      |                 ^
main.c:8:17: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include <iostream>
using namespace std;

int N,P,A;
main() {
    cin>>N;
    for (int i=0;i<N;++i) {
        cin>>A;
        if (P<=A) P=A;
        else ans+=P-A;
    }
    cout<<ans<<endl;
}

Compiler output:
a.cc:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main() {
      | ^~~~
a.cc: In function 'int main()':
a.cc:10:14: error: 'ans' was not declared in this scope; did you mean 'abs'?
   10 |         else ans+=P-A;
      |              ^~~
      |              abs
a.cc:12:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   12 |     cout<<ans<<endl;
      |           ^~~
      |           abs
Language: Java

import java.util.Scanner;
public class s
{
    public static void main(String[] args)
    {
        int sl=0;
        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();
        }
        for(int j=0;j<n-1;j++)
        {
            if(a[j]>=a[j+1])
            {
                sl=sl+(a[j]-a[j+1]);
                a[j+1]=a[j+1]+(a[j]-a[j+1]);
            }
            
        }
      long ans= (long)sl;
        System.out.println(sl);
    }
}

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

#include<bits/stdc++.h>

using namespace std;

long long ans;
int a[200010];
int n;
//int d[200010];
int main()
{
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	for(int i = 2; i <= n; i++)
	{
		if(a[i] < a[i-1])
		{
			ans += (a[i-1] - a[i])
			a[i] = a[i-1];
		}
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:47: error: expected ';' before 'a'
   20 |                         ans += (a[i-1] - a[i])
      |                                               ^
      |                                               ;
   21 |                         a[i] = a[i-1];
      |                         ~
Language: C++

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

int CountHeight(vector<int>& heights) {
  int sum = 0;
  for (int i = 1; i < heights.size(); ++i) {
    if (heights[i] <= heights[i-1]) {
      sum += (heights[i-1] - heights[i]) + 1;
    }
  }
  return sum;
}

int main() {
  int N;
  cin >> N;
  vector<int> arr;
  for (int i = 0; i < N; ++i) {
    int x;
    cin >> x;
    arr.push_back(x);
  }
  

Compiler output:
a.cc: In function 'int main()':
a.cc:22:4: error: expected '}' at end of input
   22 |   }
      |    ^
a.cc:14:12: note: to match this '{'
   14 | int main() {
      |            ^
Language: Java

import java.util.*;

public class C
{
  public static void main(String[] args)
  {  	
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    // int[] arr = new int[n];

    long total = 0;

    int p = sc.nextInt();
    for (int i = 1; i<n; i++)
    {
        int c = sc.nextInt();
        if (p - c > 0)
        {
            total += p - c;
            c = p;
        }
        p = c;
    }

    System.out.println(total);
  }
}

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

#include <bits/stdc++.h>
using namespace std;
long long N,a,b,ans=0,i;
dz(int i,int ns,int ne)
{
	for(i=ns;i<ne;i++)
	{
		cin>>b;
		if(a>b) 
		ans+=a-b;
		else 
    	a=b;
	}
}
int main() 
{	
	cin>>N>>a;
	dz(i,1,N);
	cout<<ans<<endl;
	return 0;
}

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

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        ci>>arr[i];
    }
    int c=0;
    int l=arr[0];
    for(int i=1;i<n;i++)
    {
        if(arr[i]>l)
        l=arr[i];
        else
        {
            c+=l-arr[i];
            
        }
    }
    cout<<c<<endl;
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:9: error: 'ci' was not declared in this scope; did you mean 'i'?
   10 |         ci>>arr[i];
      |         ^~
      |         i
Language: C++

#include<iostream>
using namespace std;
int main(){
  int n;cin>>n;
  long long arr[n];for(int i=0;i<n;i++)cin>>arr[i];
  long long ans=0;for(int i=1;i<n;i++){
    if(arr[i-1]<arr[i]){ans+=arr[i-1]-arr[i];arr[i]=arr[i-1];}
  cout<<ans;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:2: error: expected '}' at end of input
   10 | }
      |  ^
a.cc:3:11: note: to match this '{'
    3 | int main(){
      |           ^
Language: Java

package Time_and_Space;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.StringTokenizer;

public class takoyaki {

	public static void main(String[] args)throws Exception {
//
//		Scanner sc = new Scanner(System.in);
//		BigInteger n = sc.nextBigInteger();
//	      boolean flag=solve(n);
//	      if(flag==true)
//	        System.out.println("Yes");
//	      else
//	    	  System.out.println("No");
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
        StringTokenizer st = new StringTokenizer(br.readLine());
        int max=-1;
        int sum=0;
        for(int i=0; i<n; i++){
        	int k = Integer.parseInt(st.nextToken());
        	if(i==0) {
        		max=k;
        	}
        	else {
        		sum+=k>=max?0:max-k;
        		k+=k>=max?0:max-k;
        		max=Math.max(max, k);
        	}
        }
        System.out.println(sum);
        
	        
	}

	

}


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



import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args)throws Exception {
//
//		Scanner sc = new Scanner(System.in);
//		BigInteger n = sc.nextBigInteger();
//	      boolean flag=solve(n);
//	      if(flag==true)
//	        System.out.println("Yes");
//	      else
//	    	  System.out.println("No");
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
        StringTokenizer st = new StringTokenizer(br.readLine());
        int max=-1;
        int sum=0;
        for(int i=0; i<n; i++){
        	int k = Integer.parseInt(st.nextToken());
        	if(i==0) {
        		max=k;
        	}
        	else {
        		sum+=k>=max?0:max-k;
        		k+=k>=max?0:max-k;
        		max=Math.max(max, k);
        	}
        }
        System.out.println(sum);
        
	        
	}

	private static boolean solve(BigInteger n) {
		
		long sum=0;
		
		while(n>BigInteger.valueOf(0)) {
			sum+=n%10;
			n=n/10;
		}
		return sum%9==0;
	}

}


Compiler output:
Main.java:48: error: bad operand types for binary operator '>'
		while(n>BigInteger.valueOf(0)) {
		       ^
  first type:  BigInteger
  second type: BigInteger
Main.java:49: error: bad operand types for binary operator '%'
			sum+=n%10;
			      ^
  first type:  BigInteger
  second type: int
Main.java:50: error: bad operand types for binary operator '/'
			n=n/10;
			   ^
  first type:  BigInteger
  second type: int
3 errors
Language: C++

using namespace std;

int main() {
	int n, sum = 0;
	cin >> n;

	int *A = new int[n];

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

	for (int i = 0; i < n - 1; i++) {
		if (A[i] - A[i + 1] > 0) {
			sum += A[i] - A[i + 1];
			A[i + 1] += A[i] - A[i + 1];
		}
	}

	cout << sum;

}

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

#include<stdio.h>
int main()
{
  int N;
  int A[200010]={};
  int max=0;
  int sum=0;
  scanf("%d",&N);
  for(int i=0;i<N;i++) scanf("%d",&A[i]);
  max=A[0];
  if(i>1)
  {
  for(int j=1;j<N;j++)
  {
    if(A[j]>max)
    {
      max=A[j];
    }
    else 
    {
      sum=sum+max-A[j];
    }
  }
  }
  printf("%d",sum);
  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:11:6: error: 'i' undeclared (first use in this function)
   11 |   if(i>1)
      |      ^
main.c:11:6: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

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

int main() {
  long N;
  cin >> N;
  vector<long> A(N);
  for (long i = 0; i < N; i++) cin >> A.at(i);
  long mx = A.at(0);
  long ans = 0;
  for (long i = 1; i < N; i++) {
    ans += max(0, mx - A.at(i));
    mx = max(mx, A.at(i));
  }
  cout << ans << "\n";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:15: error: no matching function for call to 'max(int, long int)'
   12 |     ans += max(0, mx - A.at(i));
      |            ~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:12:15: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long int')
   12 |     ans += max(0, mx - A.at(i));
      |            ~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:12:15: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   12 |     ans += max(0, mx - A.at(i));
      |            ~~~^~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++) cin>>v[i];
  long long mx=v[0];
  long long ans=0;
  for(int i=1;i<n;i++)
  {
    if(v[i]<mx) ans+=mx-v[i];
    mx=max(mx,v[i]);
  }
  cout<<ans;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:11: error: no matching function for call to 'max(long long int&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   14 |     mx=max(mx,v[i]);
      |        ~~~^~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:14:11: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   14 |     mx=max(mx,v[i]);
      |        ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:14:11: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   14 |     mx=max(mx,v[i]);
      |        ~~~^~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++) cin>>v[i];
  ll mx=v[0];
  long long ans=0;
  for(int i=1;i<n;i++)
  {
    if(v[i]<mx) ans+=mx-v[i];
    mx=max(mx,v[i]);
  }
  cout<<ans;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:3: error: 'll' was not declared in this scope
    9 |   ll mx=v[0];
      |   ^~
a.cc:13:13: error: 'mx' was not declared in this scope
   13 |     if(v[i]<mx) ans+=mx-v[i];
      |             ^~
a.cc:14:5: error: 'mx' was not declared in this scope
   14 |     mx=max(mx,v[i]);
      |     ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,m=0,ans=0;
  cin>>n;
  for(long long int  i=0;i<n;++i){
    cin>>x;
    int m=max(m,x);
    ans+=m-x;
  }
  cout << ans ;
}

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

use std::io;
use std::cmp::max;
//use std::vec;
// fn sum_of_string(s: &String) -> u32 {
//     s.chars().fold(0, |acc, c| c.to_digit(10).unwrap_or(0) + acc)
//   }

fn main(){

    let mut n:String = String::new();

    io::stdin().read_line(&mut n).expect("Required Input");

    let _n: i128 = n.trim().parse().unwrap();

    let mut stol_height: i128 = 0;
    let mut input: String = String::new();
    let mut prev_height: i128 = 0;

    io::stdin().read_line(&mut input).expect("Input required");

    let values: Vec<i128> = input
            .split_whitespace()
            .map(|x| x.parse::<i128>())
            .collect::<Result<Vec<i128>, _>>()
            .unwrap();

    for i in values.iter(){

        if prev_height <= *i{
            prev_height = max(prev_height, *i);
            continue;
        }

        stol_height += prev_height-*i;

    }
    
    println!("{}", stol_height);

}

Compiler output:
a.cc:1:1: error: 'use' does not name a type
    1 | use std::io;
      | ^~~
a.cc:2:1: error: 'use' does not name a type
    2 | use std::cmp::max;
      | ^~~
a.cc:8:1: error: 'fn' does not name a type
    8 | fn main(){
      | ^~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define int long long
struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
}IoSetup;

using Int = __int128_t;
using ll = long long;
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int SMOD = 1000000007;
constexpr int NMOD = 998244353;
constexpr int dx[]={1,0,-1,0,1,1,-1,-1};
constexpr int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T&b){if(a<b)return(a=b,1);return 0;}
template<class T>bool chmin(T &a, const T&b){if(b<a)return(a=b,1);return 0;}


signed main() {

    int n;
    cin >> n;
    vector<int> a(n);
    for(auto&&i:a) cin >> i;
    int sum = 0;
    int mv = a[0];

    for(auto&&i:a) {
        sum += max(0, mv - i);
        chmax(mv, i);
    }

    cout << sum << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:19: error: no matching function for call to 'max(int, long long int)'
   42 |         sum += max(0, mv - i);
      |                ~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:42:19: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   42 |         sum += max(0, mv - i);
      |                ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:42:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   42 |         sum += max(0, mv - i);
      |                ~~~^~~~~~~~~~~
Language: C

#include<stdio.h>
int main()
{
  int num
  int t[200010]
  scanf("%d",&num)
  scanf("%d",t[]);
  

Compiler output:
main.c: In function 'main':
main.c:4:10: error: expected ';' before 'int'
    4 |   int num
      |          ^
      |          ;
    5 |   int t[200010]
      |   ~~~     
main.c:6:3: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'scanf'
    6 |   scanf("%d",&num)
      |   ^~~~~
main.c:6:15: error: 'num' undeclared (first use in this function)
    6 |   scanf("%d",&num)
      |               ^~~
main.c:6:15: note: each undeclared identifier is reported only once for each function it appears in
main.c:6:19: error: expected ';' before 'scanf'
    6 |   scanf("%d",&num)
      |                   ^
      |                   ;
    7 |   scanf("%d",t[]);
      |   ~~~~~            
main.c:7:3: error: expected declaration or statement at end of input
    7 |   scanf("%d",t[]);
      |   ^~~~~
Language: C++

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

int main(){
    long long int n,x;
    cin>>n;
    int ans=0,dai=0;
    for(int i=0;i<n;i++){
        cin>>x;
        dai=max(x,dai);
        if(x<=dai)ans+=dai-x;
        }
    cout<<ans<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:16: error: no matching function for call to 'max(long long int&, int&)'
   10 |         dai=max(x,dai);
      |             ~~~^~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:10:16: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   10 |         dai=max(x,dai);
      |             ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:10:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   10 |         dai=max(x,dai);
      |             ~~~^~~~~~~
Language: C++

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

int main()
{
    ll n,ans=0,mx=0,x;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> x;
        if(x < mx)
            ans += (mx - x);

        mx = max(mx, x);
    }
    cout << ans << '\n';

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:5: error: 'll' was not declared in this scope
    6 |     ll n,ans=0,mx=0,x;
      |     ^~
a.cc:7:12: error: 'n' was not declared in this scope; did you mean 'yn'?
    7 |     cin >> n;
      |            ^
      |            yn
a.cc:10:16: error: 'x' was not declared in this scope
   10 |         cin >> x;
      |                ^
a.cc:11:16: error: 'mx' was not declared in this scope
   11 |         if(x < mx)
      |                ^~
a.cc:12:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   12 |             ans += (mx - x);
      |             ^~~
      |             abs
a.cc:14:9: error: 'mx' was not declared in this scope
   14 |         mx = max(mx, x);
      |         ^~
a.cc:16:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   16 |     cout << ans << '\n';
      |             ^~~
      |             abs
Language: C

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
//if(strcmp(s[i],"AC")==0)
//if(s[l]=='#')
/*小文字判定
if((moji>= 'a') && (moji<='z')){
    printf("a\n");
    return 0;
  }
  */
//文字列中の一文字⇒数字の時は s[i]-'0'
int W_Length(char *str){
	int length = 0;
	while(*str++ != '\0')
		length++;
	return length;
}

void swap(long long int *a, long long int *b){
  int temp;
  temp=*a;
  *a=*b;
  *b=temp;
}
//swap(&a, &b)

double deg(double theta){//deg to theta
return theta*(2*3.14159265359)/360;
}

long long int cmp( const void *p, const void *q ) {
    return *(long long int*)p - *(long long int*)q;
}//ちいさい順
//qsort(a,n,sizeof(long long int),cmp);


int cmp_s(const void * left, const void * right)
{
	char *left_char = (char *)left;
  char *right_char = (char *)right;
  return strcmp(left_char, right_char);
}
//qsort(s,n,sizeof(s[0]),cmp_s);
//char s[n][11]

long long int GCD(long long int a, long long int b){
  long long int L=a,S=b;
  while(1){
    if(S>L){
      L=S+L;
      S=L-S;
      L=L-S;
    }
    if(L%S==0){
      return S;
    }
    L=L%S;
  }
  
}

long long int LCM(long long int a, long long int b){
  return a*b/(GCD(a,b));
}

int main (void)
{
	long long int n,i,min,k,a[210000],max,j=1,count=0,max=0;
scanf("%lld",&n);
  scanf("%lld",&a[0]);
  max=a[0];
for(i=0;i<n;i++){
  scanf("%lld",&a[i]);
  if(a[i]>max){
    max=a[i];
    continue;
  }
  count+=max-a[i];
}  

  
  printf("%lld",count);
return 0;
}


Compiler output:
main.c: In function 'main':
main.c:70:59: error: redeclaration of 'max' with no linkage
   70 |         long long int n,i,min,k,a[210000],max,j=1,count=0,max=0;
      |                                                           ^~~
main.c:70:43: note: previous declaration of 'max' with type 'long long int'
   70 |         long long int n,i,min,k,a[210000],max,j=1,count=0,max=0;
      |                                           ^~~
Language: C

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
//if(strcmp(s[i],"AC")==0)
//if(s[l]=='#')
/*小文字判定
if((moji>= 'a') && (moji<='z')){
    printf("a\n");
    return 0;
  }
  */
//文字列中の一文字⇒数字の時は s[i]-'0'
int W_Length(char *str){
	int length = 0;
	while(*str++ != '\0')
		length++;
	return length;
}

void swap(long long int *a, long long int *b){
  int temp;
  temp=*a;
  *a=*b;
  *b=temp;
}
//swap(&a, &b)

double deg(double theta){//deg to theta
return theta*(2*3.14159265359)/360;
}

long long int cmp( const void *p, const void *q ) {
    return *(long long int*)p - *(long long int*)q;
}//ちいさい順
//qsort(a,n,sizeof(long long int),cmp);


int cmp_s(const void * left, const void * right)
{
	char *left_char = (char *)left;
  char *right_char = (char *)right;
  return strcmp(left_char, right_char);
}
//qsort(s,n,sizeof(s[0]),cmp_s);
//char s[n][11]

long long int GCD(long long int a, long long int b){
  long long int L=a,S=b;
  while(1){
    if(S>L){
      L=S+L;
      S=L-S;
      L=L-S;
    }
    if(L%S==0){
      return S;
    }
    L=L%S;
  }
  
}

long long int LCM(long long int a, long long int b){
  return a*b/(GCD(a,b));
}

int main (void)
{
	long long int n,i,min,k,a[210000],max,j=1,,count=0,max=0;
scanf("%lld",&n);
  scanf("%lld",&a[0]);
  max=a[0];
for(i=0;i<n;i++){
  scanf("%lld",&a[i]);
  if(a[i]>max){
    max=a[i];
    continue;
  }
  count+=max-a[i];
}  

  
  printf("%lld",count);
return 0;
}


Compiler output:
main.c: In function 'main':
main.c:70:51: error: expected identifier or '(' before ',' token
   70 |         long long int n,i,min,k,a[210000],max,j=1,,count=0,max=0;
      |                                                   ^
main.c:80:3: error: 'count' undeclared (first use in this function)
   80 |   count+=max-a[i];
      |   ^~~~~
main.c:80:3: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include <iostream>
using namespace std;
int main()
{
 	int n;
  	cin >> n;
  	int x;
  	int max = 0
  	long long int answer = 0;
  	for (int i = 0; i < n; i++)
    {
     	cin >> x;
      	if (x > max)
          max = x;
      	else answer += (max - x);
    }
  	cout << answer;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: expected ',' or ';' before 'long'
    9 |         long long int answer = 0;
      |         ^~~~
a.cc:15:14: error: 'answer' was not declared in this scope
   15 |         else answer += (max - x);
      |              ^~~~~~
a.cc:17:17: error: 'answer' was not declared in this scope
   17 |         cout << answer;
      |                 ^~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
void solve(){
    ll n;
    cin >> n;
    ll ar[n];
    for(ll  i = 0; i < n; i++)
    {
        cin>>ar[i];

    }
    ll cnt=0;
    for(lli=1; i< n ; i++){
        if(ar[i-1] >= ar[i]){
            cnt+=  abs(ar[i-1]- ar[i]);
             ar[i]=ar[i-1];
        }
    }
    cout<<cnt;
}

int main(){
    int t=1; 
    // cin>>t;
    while(t--){
   
    solve();
    }

}


Compiler output:
a.cc: In function 'void solve()':
a.cc:14:9: error: 'lli' was not declared in this scope; did you mean 'll'?
   14 |     for(lli=1; i< n ; i++){
      |         ^~~
      |         ll
a.cc:14:16: error: 'i' was not declared in this scope
   14 |     for(lli=1; i< n ; i++){
      |                ^
Language: C++

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i+){
    cin >> A.at(i);
  }
  long long ans=0;
  for(int i=0;i<N-1;i++){
    if(A.at(i)>A.at(i+1)){
      A.at(i+1)=A.at(i);
      ans+=A.at(i)-A.at(i+1);
    }
  }
  cout << ans << endl;
}
    

Compiler output:
a.cc: In function 'int main()':
a.cc:8:21: error: expected primary-expression before ')' token
    8 |   for(int i=0;i<N;i+){
      |                     ^
Language: C++

#include<iostream>
using namespace std;

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

Compiler output:
a.cc: In function 'int main()':
a.cc:14:5: error: 'sum' was not declared in this scope
   14 |     sum += (running_max - a[i]);
      |     ^~~
a.cc:16:11: error: 'sum' was not declared in this scope
   16 |   cout << sum << endl;
      |           ^~~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
 
    long long ans = 0;
    int MaxNum = 0;
    for (int i = 0; i < N; i++)
    {
        //MaxNumを使い回すことで計算を抑える
        MaxNum = max(MaxNum, A[i]);
        int Bi = MaxNum;
        ans += Bi - A[i];
    }
 
    cout << ans << endl;
}
投稿日時: 約 6 日前
最終更新: 約 6 日前

Compiler output:
a.cc:27:9: error: found ':' in nested-name-specifier, expected '::'
   27 | 投稿日時: 約 6 日前
      |         ^
      |         ::
a.cc:27:1: error: '\U00006295\U00007a3f\U000065e5\U00006642' does not name a type
   27 | 投稿日時: 約 6 日前
      | ^~~~~~~~
Language: C++

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  int64_t sum = 0;
  for (int i = 1; i < N; i++){
    if (vec.at(i - 1) > vec.at(i)){
      sum += (vec.at(i - 1) - vec.at(i));
      vec.at(i) = vec.at(i - 1);
    }
  }
  cout << sum << endl;

Compiler output:
a.cc: In function 'int main()':
a.cc:18:23: error: expected '}' at end of input
   18 |   cout << sum << endl;
      |                       ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C++

#include<iostream>
 
using namespace std;
 
int main()
{
  int N;
  vector<long int> A(N);
  
  cin>>N;
  for(int loop=0;loop<N;loop++)
  {
    cin>>A[loop];
  }
  
  long int max=A[0];
  long int sum=0;
  for(int loop=1;loop<N;loop++)
  {
    if(A[loop]<max)
    {
      sum+=max-A[loop];
    }
    else if(A[loop]>max)
    {
      max=A[loop];
    }
  }
  
  cout<<sum<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:3: error: 'vector' was not declared in this scope
    8 |   vector<long int> A(N);
      |   ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include<iostream>
  +++ |+#include <vector>
    2 | 
a.cc:8:10: error: expected primary-expression before 'long'
    8 |   vector<long int> A(N);
      |          ^~~~
a.cc:13:10: error: 'A' was not declared in this scope
   13 |     cin>>A[loop];
      |          ^
a.cc:16:16: error: 'A' was not declared in this scope
   16 |   long int max=A[0];
      |                ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main() {
	long long n;
	cin >> n;
	vector<long long> arr(n);
	
	for(int i = 0; i < n; i++)
		cin >> arr[i];
		
	long lon curr = arr[0];
	long lon tot = 0;
		
	for (int i = 1; i < n; i++) {
		if (arr[i] < curr) {
			tot += (curr - arr[i]);
		}
		else
			curr = arr[i];
	}
	
	cout << tot << endl;
	
		
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:18: error: expected initializer before 'curr'
   13 |         long lon curr = arr[0];
      |                  ^~~~
a.cc:14:18: error: expected initializer before 'tot'
   14 |         long lon tot = 0;
      |                  ^~~
a.cc:17:30: error: 'curr' was not declared in this scope
   17 |                 if (arr[i] < curr) {
      |                              ^~~~
a.cc:18:25: error: 'tot' was not declared in this scope
   18 |                         tot += (curr - arr[i]);
      |                         ^~~
a.cc:24:17: error: 'tot' was not declared in this scope
   24 |         cout << tot << endl;
      |                 ^~~
Language: C++

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

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;

#define pb push_back

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	int mx = 0, ans = 0;
	while (n--) {
		ll x;
		cin >> x;
		if (x < mx) ans += mx - x;
		mx = max(mx, x);
	}
	cout << ans;
   return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:25: error: no matching function for call to 'max(int&, ll&)'
   22 |                 mx = max(mx, x);
      |                      ~~~^~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:22:25: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   22 |                 mx = max(mx, x);
      |                      ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:22:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   22 |                 mx = max(mx, x);
      |                      ~~~^~~~~~~