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

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

int main(void){
  const int N;

  scanf("%d",&N);

  int i,j,temp=0,min=INT_MAX,n,a[N],input;

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

  for(i=N-1;i>=0;i--){
    for(j=i-1;j>=0;j--){
      temp=a[i]-a[j];
      if(temp<min){
	min=temp;
      }
    }
  }
}




/*
??????????????????????????????????????????????°??????????????±???????
*/

Compiler output:
a.cc: In function 'int main()':
a.cc:6:13: error: uninitialized 'const N' [-fpermissive]
    6 |   const int N;
      |             ^
Language: C++

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

static const int MAX=200000;
 
int main()
{
    int N[MAX],n;
     
    cin >> n;

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

    int maxv = -2000000000;
    int minv = R[0];
     
    for(int i=1;i<n;i++)
    {
        maxv = max(maxv,N[i] - minv);
         
        minv = min(minv,N[i]);

    }
     
    cout << maxv << endl;
     
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:16: error: 'R' was not declared in this scope
   15 |         cin >> R[i];
      |                ^
a.cc:19:16: error: 'R' was not declared in this scope
   19 |     int minv = R[0];
      |                ^
Language: C++

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

static const int MAX=200000;
 
int main()
{
    int N[MAX],n;
     
    cin >> n;

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

    int maxv = -2000000000;
    int minv = R[0];
     
    for(int i=1;i<n;i++)
    {
        maxv = max(maxv,N[i] - minv);
         
        minv = min(minv,N[i]);

    }
     
    cout << maxv << endl;
     
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:16: error: 'R' was not declared in this scope
   19 |     int minv = R[0];
      |                ^
Language: C++

#include <iostream>
??
int main() {
????????int num, tmp, min, ans =?? -1;
????????std::cin >> num >> min;
????????for(int i=1; i < num; i++){
????????????????std::cin >> tmp;
????????????????if(tmp - min >  ans){
????????????????????????????????ans = tmp - min;
????????????????}
        if( tmp < min){
            min = tmp;
        }
????????}
????????std::cout << ans << std::endl;
????????return 0;
}

Compiler output:
a.cc:2:1: error: expected unqualified-id before '?' token
    2 | ??
      | ^
Language: C++

#include <iostream>

int main() {
    int num, tmp, min, and;
    std::cin >> num >> min;
    for(int i=1; i < num; i++){
        std::cin >> tmp;
        if(tmp - min >  ans || i  == 1){
                ans = tmp - min;
        }
        if( tmp < min ){
            min = tmp;
        }
    }
    std::cout << ans << std::endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:27: error: expected unqualified-id before ';' token
    4 |     int num, tmp, min, and;
      |                           ^
a.cc:8:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
    8 |         if(tmp - min >  ans || i  == 1){
      |                         ^~~
      |                         abs
a.cc:15:18: error: 'ans' was not declared in this scope; did you mean 'abs'?
   15 |     std::cout << ans << std::endl;
      |                  ^~~
      |                  abs
Language: C++

import sys
n=int(input())
r=list(map(int,sys.stdin.read())
print(max([max(r[i+1:])-r[i]for i in range(n-1)]))

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import sys
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

#include <iostream>

using namespace std;

static const int MAX = 200000

int main(){
  int R[MAX], n;
  int temp;
  cin >> n;
  for(int i = 0; i < n; i++)  cin >> R[i];

  int min = r[0];
  int max = -2000000;
  for(int i = 0; i < n; i++){
    if(r[i] > max){
      max = r[i];
    } else if (r[i] < min){
      min = r[i];
    }
  }

  cout << max - min;

  return 0;
}

Compiler output:
a.cc:7:1: error: expected ',' or ';' before 'int'
    7 | int main(){
      | ^~~
Language: C++

#include <iostream>

using namespace std;

static const int MAX = 200000;

int main(){
  int R[MAX], n;
  int temp;
  cin >> n;
  for(int i = 0; i < n; i++)  cin >> R[i];

  int min = r[0];
  int max = -2000000;
  for(int i = 0; i < n; i++){
    if(r[i] > max){
      max = r[i];
    } else if (r[i] < min){
      min = r[i];
    }
  }

  cout << max - min;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:13: error: 'r' was not declared in this scope
   13 |   int min = r[0];
      |             ^
Language: C++

#include <iostream>

using namespace std;

static const int MAX = 200000;

int main(){
  int R[MAX], n;
  int temp;
  cin >> n;
  for(int i = 0; i < n; i++)  cin >> R[i];

  int min = r[0];
  int max = -2000000;
  for(int i = 0; i < n; i++){
    if(r[i] > max){
      max = R[i];
    } else if (R[i] < min){
      min = R[i];
    }
  }

  cout << max - min;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:13: error: 'r' was not declared in this scope
   13 |   int min = r[0];
      |             ^
Language: C++

#include <iostream>

using namespace std;

static const int MAX = 200000;

int main(){
  int R[MAX], n;
  int temp;
  cin >> n;
  for(int i = 0; i < n; i++)  cin >> R[i];

  int min = R[0];
  int max = -2000000;
  for(int i = 0; i < n; i++){
    if(r[i] > max){
      max = R[i];
    } else if (R[i] < min){
      min = R[i];
    }
  }

  cout << max - min;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:8: error: 'r' was not declared in this scope
   16 |     if(r[i] > max){
      |        ^
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main()
{
	int R[MAX], n;
	
	cin >> n;
	for (int i = 0; i < n; ++i) cin >> R[i]

	int maxv = -2000000000; // ???????°??????????????????????????¨????
	int minv = R[0];

	for (int i = 1; i < n; ++i)
	{
		maxv = max(maxv, R[i] - minv); // ?????§????????´??°
		minv = min(minv, R[i]);        // ???????????§???????°?????????????????????????
	}

	cout << maxv << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:48: error: expected ';' before 'int'
   11 |         for (int i = 0; i < n; ++i) cin >> R[i]
      |                                                ^
      |                                                ;
   12 | 
   13 |         int maxv = -2000000000; // ???????°??????????????????????????¨????
      |         ~~~                                     
a.cc:18:17: error: 'maxv' was not declared in this scope
   18 |                 maxv = max(maxv, R[i] - minv); // ?????§????????´??°
      |                 ^~~~
a.cc:22:17: error: 'maxv' was not declared in this scope
   22 |         cout << maxv << endl;
      |                 ^~~~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false);
	
	int n, tmp;
	ll max_profit = -1000000000;
	vector<ll> R;

	cin >> n;

	R.resize(n);

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

	for(int i = 0;i < n;++i) {
		for(int j = n - 1;i < j;--j) {
			tmp = R[j] - R[i];
			max_profit = max(max_profit, tmp);
		}
	}

	cout << max_profit << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:41: error: no matching function for call to 'max(ll&, int&)'
   27 |                         max_profit = max(max_profit, tmp);
      |                                      ~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:27:41: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   27 |                         max_profit = max(max_profit, tmp);
      |                                      ~~~^~~~~~~~~~~~~~~~~
/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,
                 from a.cc:3:
/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:27:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   27 |                         max_profit = max(max_profit, tmp);
      |                                      ~~~^~~~~~~~~~~~~~~~~
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
  int R[MAX], n;

  cin >> n;
  for ( int i = 0; i < n; i++) cin >> R[i];

  int maxv = -2000000000;
  int minv = R[0];

  for ( int i = 1; i < n; i++ ) {
    maxv = max(maxv, R[i] - minv);
    manv = min(minv, R[i]);
  }

  cout << maxv << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:5: error: 'manv' was not declared in this scope; did you mean 'minv'?
   17 |     manv = min(minv, R[i]);
      |     ^~~~
      |     minv
Language: C++

#include <iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
  int R[Max], n;
  cin >> n;
  for(int i; i<n;i++) cin>>R[i];

  int maxv = -2000000000;
  int minv = R[0];
  for(int i=1;i<n;i++){
    maxv = max(maxv,R[i]-minv);
    minv = min(minv,R[i]);
  }

  cout << maxv << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:7:9: error: 'Max' was not declared in this scope; did you mean 'MAX'?
    7 |   int R[Max], n;
      |         ^~~
      |         MAX
a.cc:9:28: error: 'R' was not declared in this scope
    9 |   for(int i; i<n;i++) cin>>R[i];
      |                            ^
a.cc:12:14: error: 'R' was not declared in this scope
   12 |   int minv = R[0];
      |              ^
Language: C++

if __name__ == '__main__':
	n = int(input())
	lists = list()

	for i in range(n):
		a = int(input())
		lists.append(a)

	S = None
	while lists:
		mini = min(lists)
		mini_ind = lists.index(mini)
		maxi = max(lists[mini_ind : len(lists)])

		T = maxi - mini
		if S is None or S < T:
			S = T
			lists = lists[0 : mini_ind]
			continue
		else:
			break

	print(S)


Compiler output:
a.cc:1:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
    1 | if __name__ == '__main__':
      |                ^~~~~~~~~~
a.cc:1:1: error: expected unqualified-id before 'if'
    1 | if __name__ == '__main__':
      | ^~
Language: C++

#include <iostream>
#include <climits>
#include <algorithm>

using std::cin;
using std::cout;
using std::max;
using std::min;

int main()
{
   int n, curr;
   int maxv = INT_MAX, minv = INT_MAX;
   cin >> n;
   for (int i = 0; i < n; ++i)
   {
       cin >> curr;
       minv = min(minv, curr);
       maxv = max(maxv, curr - minv);
   }
   
   cout << maxv << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:22:20: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   22 |    cout << maxv << endl;
      |                    ^~~~
      |                    std::endl
In file included from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

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

int main()
{
    int n;
    cin>>n;
    int a[n];
    int i=0;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    
    int maxv=-2000000000;
    int minv=a[0];
    
    for(i=0;i<n;i++)
        {
            maxv=max(maxv,a[i]-minv);
            minv=min(minv,r[i]);
        }
        
        cout<<maxv<<endl;
        
        return 0;;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:27: error: 'r' was not declared in this scope
   22 |             minv=min(minv,r[i]);
      |                           ^
Language: C++

#include<iostream>
#include<algorithm>
using namespace std:
static const int MAX = 200000;

int main()
{
int R[MAX],n;
cin>>n;

for(int i=0;i<n;i++)
  cin>>R[i];

int maxv = -2000000000;
int minv = R[0];

for (int i =1 ;i < n;i++)
{
maxv = max(maxv,R[i]-minv);
minv = min(minv,R[i]);

}

cout<<maxv<<endl;

return 0;
}


Compiler output:
a.cc:3:20: error: expected ';' before ':' token
    3 | using namespace std:
      |                    ^
      |                    ;
a.cc:3:20: error: expected unqualified-id before ':' token
a.cc: In function 'int main()':
a.cc:8:7: error: 'MAX' was not declared in this scope
    8 | int R[MAX],n;
      |       ^~~
a.cc:12:8: error: 'R' was not declared in this scope
   12 |   cin>>R[i];
      |        ^
a.cc:15:12: error: 'R' was not declared in this scope
   15 | int minv = R[0];
      |            ^
Language: C++

#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
	int n;
	int R[200000];
	int max=-1000000000;
	cin>>n;
	for(int i=0;i<n;i++) cin>>R[i];
	
	for(int i=0;i<n;i++){
	for(int j=0;j<i;j++){

	if (R[i]-R[j]>max) max=R[i]-R[[j];
	}
	}
   cout<<max<<endl;	

return 0;
}
	


Compiler output:
a.cc: In function 'int main()':
a.cc:19:38: error: two consecutive '[' shall only introduce an attribute before '[' token
   19 |         if (R[i]-R[j]>max) max=R[i]-R[[j];
      |                                      ^
Language: C++

#include <iostream>
using namespace std;
int main() {
    int n, p;
    cin >> n;
    int list[n] = {};
    int maxim[n] = {};
    for (int i = 0; i < n; i++) {
        cin >> p;
        list[i] = p;
    }

    int lowest =INT_MAX;
    for (int i = 0; i < n - 1; i++) {
        int max = INT_MIN;
        int maxnum = 0;
        if(list[i] < lowest){
            lowest = list[i];
            for (int j = i + 1; j < n; j++) {
                if(list[j] > maxnum) {
                    max = list[j] - list[i];
                    maxnum = list[j];
                }
            }
        }
        maxim[i] = max;
    }
    int max = -1000000000;
    for(int i = 0; i < n - 1; i++) {
        if(maxim[i] > max) {
            max = maxim[i];
        }
    }
    cout << max << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:17: error: 'INT_MAX' was not declared in this scope
   13 |     int lowest =INT_MAX;
      |                 ^~~~~~~
a.cc:2:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    1 | #include <iostream>
  +++ |+#include <climits>
    2 | using namespace std;
a.cc:15:19: error: 'INT_MIN' was not declared in this scope
   15 |         int max = INT_MIN;
      |                   ^~~~~~~
a.cc:15:19: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
Language: C++

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

int main()
{
    int n,Rt,min,max=-200000000000;
    cin>>n;
    cin>>Rt;
    min=Rt
        for(int i=1<i<n; i++)
    {
        cin>>Rt;
        if(Rt-min>max)
            max=Rt-min;
        if(Rt<min)
            min=Rt;
    }
    cout<<max;
    system("pause");
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:22: warning: overflow in conversion from 'long int' to 'int' changes value from '-200000000000' to '1863462912' [-Woverflow]
    7 |     int n,Rt,min,max=-200000000000;
      |                      ^~~~~~~~~~~~~
a.cc:10:11: error: expected ';' before 'for'
   10 |     min=Rt
      |           ^
      |           ;
   11 |         for(int i=1<i<n; i++)
      |         ~~~
a.cc:11:26: error: 'i' was not declared in this scope
   11 |         for(int i=1<i<n; i++)
      |                          ^
Language: C++

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

int main()
{
    int n,Rt,min,max=-200000000000;
    cin>>n;
    cin>>Rt;
    min=Rt;
    for(int i=1<i<n; i++)
    {
        cin>>Rt;
        if(Rt-min>max)
            max=Rt-min;
        if(Rt<min)
            min=Rt;
    }
    cout<<max;
    system("pause");
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:22: warning: overflow in conversion from 'long int' to 'int' changes value from '-200000000000' to '1863462912' [-Woverflow]
    7 |     int n,Rt,min,max=-200000000000;
      |                      ^~~~~~~~~~~~~
a.cc:11:25: error: expected ';' before ')' token
   11 |     for(int i=1<i<n; i++)
      |                         ^
      |                         ;
Language: C++

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

int main() {
  int a, n[200000];
  cin >> a;
  for(int i = 0; i < n; ++i) {
    cin >> n[i];
  }
  int maxv = -1000000000;
  int minv = n[0];
  for(int j - 1; j < n; ++j) {
    maxv = max(maxv, n[j] - minv);
    minv = min(minv, n[j]);
  }
  cout << maxv << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:20: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
    8 |   for(int i = 0; i < n; ++i) {
      |                  ~~^~~
a.cc:13:12: error: expected ';' before '-' token
   13 |   for(int j - 1; j < n; ++j) {
      |            ^~
      |            ;
a.cc:13:20: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   13 |   for(int j - 1; j < n; ++j) {
      |                  ~~^~~
a.cc:13:23: error: expected ')' before ';' token
   13 |   for(int j - 1; j < n; ++j) {
      |      ~                ^
      |                       )
a.cc:13:27: error: 'j' was not declared in this scope
   13 |   for(int j - 1; j < n; ++j) {
      |                           ^
Language: C++

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

int main() {
  int a, n[200000];
  cin >> a;
  for(int i = 0; i < a; ++i) {
    cin >> n[i];
  }
  int maxv = -1000000000;
  int minv = n[0];
  for(int j - 1; j < a; ++j) {
    maxv = max(maxv, n[j] - minv);
    minv = min(minv, n[j]);
  }
  cout << maxv << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:12: error: expected ';' before '-' token
   13 |   for(int j - 1; j < a; ++j) {
      |            ^~
      |            ;
a.cc:13:23: error: expected ')' before ';' token
   13 |   for(int j - 1; j < a; ++j) {
      |      ~                ^
      |                       )
a.cc:13:27: error: 'j' was not declared in this scope
   13 |   for(int j - 1; j < a; ++j) {
      |                           ^
Language: C++

// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

static const int MAX = 200000;

signed main() {
	int R[MAX], n;

	cin >> n;

	for(int i = 0; i < n; i++) cin >> R[i];

	int maxv = -2000000000;
	int minv = R[0];



Compiler output:
a.cc: In function 'int main()':
a.cc:56:25: error: expected '}' at end of input
   56 |         int minv = R[0];
      |                         ^
a.cc:48:15: note: to match this '{'
   48 | signed main() {
      |               ^
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
  int R[MAX], m;

  cin >> n;
  for ( int i = 0; i < n; i++ ) cin >> R[i];

  int maxv = -2000000000;  // 十分小さい値を初期値に設定
  int minv = R[0];

  for ( int i = 1; i < n; i++ ) {  // ここで毎回 R[i] を読み込めば、配列は不要
    maxv = max(maxv, R[i] - imnv);  // 最大値を更新
    minv = min(minv, R[i])  // ここまでの最小値を保持しておく
  }

  cout << maxv << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:10: error: 'n' was not declared in this scope
    9 |   cin >> n;
      |          ^
a.cc:16:29: error: 'imnv' was not declared in this scope; did you mean 'minv'?
   16 |     maxv = max(maxv, R[i] - imnv);  // 最大値を更新
      |                             ^~~~
      |                             minv
a.cc:17:27: error: expected ';' before '}' token
   17 |     minv = min(minv, R[i])  // ここまでの最小値を保持しておく
      |                           ^
      |                           ;
   18 |   }
      |   ~
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
  int R[MAX], m;

  cin >> n;
  for ( int i = 0; i < n; i++ ) cin >> R[i];

  int maxv = -2000000000;  // 十分小さい値を初期値に設定
  int minv = R[0];

  for ( int i = 1; i < n; i++ ) {  // ここで毎回 R[i] を読み込めば、配列は不要
    maxv = max(maxv, R[i] - minv);  // 最大値を更新
    minv = min(minv, R[i])  // ここまでの最小値を保持しておく
  }

  cout << maxv << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:10: error: 'n' was not declared in this scope
    9 |   cin >> n;
      |          ^
a.cc:17:27: error: expected ';' before '}' token
   17 |     minv = min(minv, R[i])  // ここまでの最小値を保持しておく
      |                           ^
      |                           ;
   18 |   }
      |   ~
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX=200000;
int main()
{
int R[MAX],n;
cin>>n;
for(int i=0;i<n;i++)cin>>R[i];
int maxv=-20000000;
int minv=R[0];
for(int i=1;i<n;i++)
{
maxv=max(maxv,R[i]-minv);
minv=min(R[i].minv);
}
cout<<maxv<<endl;
return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:15: error: request for member 'minv' in 'R[i]', which is of non-class type 'int'
   15 | minv=min(R[i].minv);
      |               ^~~~
Language: C++

n = int(input())
r = [int(input()) for i in range(n)]

r_temp_min = r[0]
ans = r[1]-r[0]

for r_i in r[1:]:
    if ans < (r_i - r_temp_min):
        ans = r_i - r_temp_min

for i,r_i in enumerate(r):
    if r_temp_min <= r_i:
        continue
    ans += t_temp_min - r_i
    r_temp_min = r_i


print(ans)



Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n = int(input())
      | ^
Language: C++

n = int(input())
r = [int(input()) for i in range(n)]

r_temp_min = r[0]
ans = r[1]-r[0]

for r_i in r[1:]:
    if ans < (r_i - r_temp_min):
        ans = r_i - r_temp_min

for i,r_i in enumerate(r):
    if r_temp_min <= r_i:
        continue
    ans += r_temp_min - r_i
    r_temp_min = r_i


print(ans)



Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n = int(input())
      | ^
Language: C++

n = int(input())
r = [int(input()) for i in range(n)]

r_temp_min = r[0]
ans = r[1]-r[0]

for r_i in r[1:]:
    if ans < (r_i - r_temp_min):
        ans = r_i - r_temp_min

for i,r_i in enumerate(r):
    if r_temp_min <= r_i:
        continue
    ans -= r_i - r_temp_min
    r_temp_min = r_i

print(ans)



Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n = int(input())
      | ^
Language: C++

n = int(input())
r = [int(input()) for i in range(n)]

r_temp_min = r[0]
ans = r[1]-r[0]

for r_i in r[1:]:
    if ans < (r_i - r_temp_min):
        ans = r_i - r_temp_min

for r_i in r:
    if r_temp_min <= r_i:
        continue
    ans = ans - r_i + r_temp_min
    r_temp_min = r_i

print(ans)



Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n = int(input())
      | ^
Language: C++

#include <iostream>

int main() {
    int n, result=0, f_result=0;
    
    cin >> n;
    
    int num[n];
    
    for(int i=0; i<n; i++) {
        cin >> num[i];
    }
    for(i=0; i<n-1; i++) {
        for(int j=i+1; j<n; j++) {
            result = num[j] - num[i];
            if(i==0 && j==1) {
                f_result = result;
            }
            else if(result>f_result) {
                f_result = result;
            }
        }
    }
    
    
    cout << f_result;
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:6:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    6 |     cin >> n;
      |     ^~~
      |     std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:13:9: error: 'i' was not declared in this scope
   13 |     for(i=0; i<n-1; i++) {
      |         ^
a.cc:26:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   26 |     cout << f_result;
      |     ^~~~
      |     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: C++

#include <iostream>
using namespace std;

int main() {
    int n, result=0, f_result=0;
    
    cin >> n;
    
    int num[n];
    
    for(int i=0; i<n; i++) {
        cin >> num[i];
    }
    for(i=0; i<n-1; i++) {
        for(int j=i+1; j<n; j++) {
            result = num[j] - num[i];
            if(i==0 && j==1) {
                f_result = result;
            }
            else if(result>f_result) {
                f_result = result;
            }
        }
    }
    
    
    cout << f_result;
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:9: error: 'i' was not declared in this scope
   14 |     for(i=0; i<n-1; i++) {
      |         ^
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
#define MAX 1000000000

int main() {
    int n, result=MAX*2, minnum=0;
    
    cin >> n;
    
    int num[n];
    
    for(int i=0; i<n; i++) {
        cin >> num[i];
    }
    minnum = num[0];
    
    for(int i=0; i<n; i++) {
        min = min(minnum, num[i]);
        result = max(max, num[i]-min);
    }
    
    
    cout << result << "\n";
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:33: error: overloaded function with no contextual type information
   19 |         min = min(minnum, num[i]);
      |                                 ^
a.cc:20:33: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator-'
   20 |         result = max(max, num[i]-min);
      |                           ~~~~~~^~~~
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
#define MAX 1000000000

int main() {
    int n, result=MAX*2, m=0;
    
    cin >> n;
    
    int num[n];
    
    for(int i=0; i<n; i++) {
        cin >> num[i];
    }
    m = num[0];
    
    for(int i=0; i<n; i++) {
        m = min(m, num[i]);
        result = max(max, num[i]-m);
    }
    
    
    cout << result << "\n";
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:21: error: no matching function for call to 'max(<unresolved overloaded function type>, int)'
   20 |         result = max(max, num[i]-m);
      |                  ~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'constexpr const _Tp& std::max(const _Tp&, const _Tp&) [with _Tp = int]'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:20: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const int&'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |         ~~~~~~~~~~~^~~
/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,
                 from a.cc:2:
/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:20:21: note:   couldn't deduce template parameter '_Tp'
   20 |         result = max(max, num[i]-m);
      |                  ~~~^~~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <limits>

int main()
{
	unsigned int n = 0;
	int min = std::numeric_limits<int>::max();
	int max_gap = std::numeric_limits<int>::min();

	std::cin >> n;

	unsinged int R = 0;
	for (unsigned int i = 0; i < n; i++)
	{
		std::cin >> R;
		if (R - min > max_gap){ max_gap = R - min; }
		if (R < min){ min = R; }
	}

	std::cout << max_gap << std::endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:9: error: 'unsinged' was not declared in this scope; did you mean 'unsigned'?
   12 |         unsinged int R = 0;
      |         ^~~~~~~~
      |         unsigned
a.cc:15:29: error: 'R' was not declared in this scope
   15 |                 std::cin >> R;
      |                             ^
Language: C++

#include<algorithm>
#include<iostream>
using namespace std;
static const int MAX = 200000;

int main{
  int R[MAX], n;

  cin >> n;
  for (int i = 0; i < n; i++) cin >> R[i];

  // Initial value of maximum profit and minimum value
  int maxp = -1000000000;
  int minv = 0;

  for (int i = 0; i < n; i++){
    maxp = max(maxp, R[i]-minv);
    minv = min(minv, R[i]);
  }

  cout << maxp << endl;
  return 0;
}



Compiler output:
a.cc:6:5: error: cannot declare '::main' to be a global variable
    6 | int main{
      |     ^~~~
a.cc:7:3: error: expected primary-expression before 'int'
    7 |   int R[MAX], n;
      |   ^~~
a.cc:7:3: error: expected '}' before 'int'
a.cc:6:9: note: to match this '{'
    6 | int main{
      |         ^
a.cc:9:3: error: 'cin' does not name a type
    9 |   cin >> n;
      |   ^~~
a.cc:10:3: error: expected unqualified-id before 'for'
   10 |   for (int i = 0; i < n; i++) cin >> R[i];
      |   ^~~
a.cc:10:19: error: 'i' does not name a type
   10 |   for (int i = 0; i < n; i++) cin >> R[i];
      |                   ^
a.cc:10:26: error: 'i' does not name a type
   10 |   for (int i = 0; i < n; i++) cin >> R[i];
      |                          ^
a.cc:16:3: error: expected unqualified-id before 'for'
   16 |   for (int i = 0; i < n; i++){
      |   ^~~
a.cc:16:19: error: 'i' does not name a type
   16 |   for (int i = 0; i < n; i++){
      |                   ^
a.cc:16:26: error: 'i' does not name a type
   16 |   for (int i = 0; i < n; i++){
      |                          ^
a.cc:21:3: error: 'cout' does not name a type
   21 |   cout << maxp << endl;
      |   ^~~~
a.cc:22:3: error: expected unqualified-id before 'return'
   22 |   return 0;
      |   ^~~~~~
a.cc:23:1: error: expected declaration before '}' token
   23 | }
      | ^
Language: C++

int c_2_5() {
	//string s;
	int n;
	cin >> n;
	// int price[n];
	vector<int> price(n);
	REPEAT(i, n) {
		cin >> price[i];
	}
	int maxPrice[n];
	int currentMaxPrice;
	currentMaxPrice = 0;	// or -infinite
	for (int i = n - 1; i >= 0; i--) {
		if (price[i] > currentMaxPrice) {
			currentMaxPrice = price[i];
		}
		maxPrice[i] = currentMaxPrice;
	}
	int maxUp = maxPrice[1] - price[0];
	for (int i = 1; i < n - 1; i++) {
		const int diff = maxPrice[i + 1] - price[i];
		if (diff > maxUp) {
			maxUp = diff;
		}
	}
	cout << maxUp << "\n";
	return 0;
}

int main() {
	ios::sync_with_stdio(false);
	return c_2_5();
}



Compiler output:
a.cc: In function 'int c_2_5()':
a.cc:4:9: error: 'cin' was not declared in this scope
    4 |         cin >> n;
      |         ^~~
a.cc:6:9: error: 'vector' was not declared in this scope
    6 |         vector<int> price(n);
      |         ^~~~~~
a.cc:6:16: error: expected primary-expression before 'int'
    6 |         vector<int> price(n);
      |                ^~~
a.cc:7:16: error: 'i' was not declared in this scope
    7 |         REPEAT(i, n) {
      |                ^
a.cc:7:9: error: 'REPEAT' was not declared in this scope
    7 |         REPEAT(i, n) {
      |         ^~~~~~
a.cc:14:21: error: 'price' was not declared in this scope
   14 |                 if (price[i] > currentMaxPrice) {
      |                     ^~~~~
a.cc:19:35: error: 'price' was not declared in this scope
   19 |         int maxUp = maxPrice[1] - price[0];
      |                                   ^~~~~
a.cc:26:9: error: 'cout' was not declared in this scope
   26 |         cout << maxUp << "\n";
      |         ^~~~
a.cc: In function 'int main()':
a.cc:31:9: error: 'ios' has not been declared
   31 |         ios::sync_with_stdio(false);
      |         ^~~
Language: C++

#include<iostream>
using namespace std:
static const int MAX = 200000


int main(){
int n, R[MAX];
int min, max;
int max_diff=0;
bool min_flag = false;
int diff;
 cin >> n ;
for(int t=0; t<n; t++){
  cin >> R[t];

if(t==0){
min = R[t];
max = R[t];
}

else if (t==1){
max_diff = R[t] - R[t-1];
}

else{

if(R[t] < min){ 
min = R[t]; 
min_flag = true;
}

else if(R[t] > max){
  max_diff = R[t] - min;
  min_flag = false;
}

if(min_flag == true){
if( (R[t] - min) > max_diff){
max_diff = R[t] -min ;
}
}














Compiler output:
a.cc:2:20: error: expected ';' before ':' token
    2 | using namespace std:
      |                    ^
      |                    ;
a.cc:2:20: error: expected unqualified-id before ':' token
Language: C++

#include<iostream>
using namespace std:
static const int MAX = 200000

int main(){
int n, R[MAX];
int min, max;
int max_diff=0;
bool min_flag = false;
int diff;
 cin >> n ;
for(int t=0; t<n; t++){
  cin >> R[t];

 if(t==0){
  min = R[t];
  max = R[t];
 }

  else if (t==1){
  max_diff = R[t] - R[t-1];
  }

  else{

if(R[t] < min){ 
min = R[t]; 
min_flag = true;
}

else if(R[t] > max){
  max_diff = R[t] - min;
  min_flag = false;
}

if(min_flag == true){
if( (R[t] - min) > max_diff){
max_diff = R[t] -min ;
}
}

}
}
}











Compiler output:
a.cc:2:20: error: expected ';' before ':' token
    2 | using namespace std:
      |                    ^
      |                    ;
a.cc:2:20: error: expected unqualified-id before ':' token
Language: C++

#include<iostream>
using namespace std;
static const int MAX = 200000;

int main(){
int n, R[MAX];
int min, max;
int max_diff=0;
bool min_flag = false;
int diff;
 cin >> n ;
for(int t=0; t<n; t++){
  cin >> R[t];

 if(t==0){
  min = R[t];
  max = R[t];
 }

  else if (t==1){
  max_diff = R[t] - R[t-1];
if (R[t] < R[t-1]){
min_flag = true;
}

if(R[t] < min){ 
min = R[t]; 
min_flag = true;
}

else if(R[t] > max){
  max_diff = R[t] - min;
  min_flag = false;
}

if(min_flag == true){
if( (R[t] - min) > max_diff){
max_diff = R[t] -min ;
}
}


}
}











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

#include<iostream>
using namespace std;
static const int MAX = 200000;

int main(){

int n, R[MAX];
int min, max;
int max_diff=0;
bool min_flag = false;
int diff;
 cin >> n ;
for(int t=0; t<n; t++){
  cin >> R[t];

 if(t==0){
  min = R[t];
  max = R[t];
 }

 else if (t==1){
  max_diff = R[t] - R[t-1];
   if (R[t] < R[t-1]){
   min_flag = true;
   }
   else ( 
   min_flag = false;
 }

 if(R[t] < min){ 
  min = R[t]; 
  min_flag = true;
  }

 else if(R[t] > max){
  max_diff = R[t] - min;
  min_flag = false;
 }

if(min_flag == true){
if( (R[t] - min) > max_diff){
max_diff = R[t] -min ;
 }
 }


}
}











Compiler output:
a.cc: In function 'int main()':
a.cc:27:20: error: expected ')' before ';' token
   27 |    min_flag = false;
      |                    ^
      |                    )
a.cc:26:9: note: to match this '('
   26 |    else (
      |         ^
Language: C++

#include<iostream>
using namespace std;
static const int MAX = 200000;

int main(){

int n, R[MAX];
int min, max;
int max_diff=0;
bool min_flag = false;
int diff;
 cin >> n ;
for(int t=0; t<n; t++){
  cin >> R[t];

 if(t==0){
  min = R[t];
  max = R[t];
 }

 else if (t==1){
  max_diff = R[t] - R[t-1];
   if (R[t] < R[t-1]){
   min_flag = true;
   }
   else ( 
   min_flag = false;
    }
 }

 if(R[t] < min){ 
  min = R[t]; 
  min_flag = true;
  }

 else if(R[t] > max){
  max_diff = R[t] - min;
  min_flag = false;
 }

if(min_flag == true){
if( (R[t] - min) > max_diff){
max_diff = R[t] -min ;
 }
 }


}
}











Compiler output:
a.cc: In function 'int main()':
a.cc:27:20: error: expected ')' before ';' token
   27 |    min_flag = false;
      |                    ^
      |                    )
a.cc:26:9: note: to match this '('
   26 |    else (
      |         ^
a.cc:31:7: error: 't' was not declared in this scope
   31 |  if(R[t] < min){
      |       ^
a.cc:42:8: error: 't' was not declared in this scope
   42 | if( (R[t] - min) > max_diff){
      |        ^
a.cc: At global scope:
a.cc:49:1: error: expected declaration before '}' token
   49 | }
      | ^
Language: C++

#include<iostream>
using namespace std;
static const int MAX = 200000;

int main(){

int n, R[MAX];
int min, max;
int max_diff=0;
bool min_flag = false;
int diff;
 cin >> n ;
for(int t=0; t<n; t++){
  cin >> R[t];

 if(t==0){
  min = R[t];
  max = R[t];
 }

 else if (t==1){
  max_diff = R[t] - R[t-1];
   if (R[t] < R[t-1]){
   min_flag = true;
   }
   else {
   min_flag = false;
   }
 }

  if(R[t] < min){ 
  min = R[t]; 
  min_flag = true;
  }

 else if(R[t] > max){
  max_diff = R[t] - min;
  min_flag = false;
 }

if(min_flag == true){
if( (R[t] - min) > max_diff){
max_diff = R[t] -min ;
 }
 }

}
cout << max_diff << endl
}











Compiler output:
a.cc: In function 'int main()':
a.cc:48:25: error: expected ';' before '}' token
   48 | cout << max_diff << endl
      |                         ^
      |                         ;
   49 | }
      | ~
Language: C++

#include<iostream>
using namespace std;
static const int MAX = 200000;

int main(){

int n, R[MAX];
int min, max;
int max_diff=0;
bool min_flag = false;
int diff;
 cin >> n ;
for(int t=0; t<n; t++){
  cin >> R[t];

 if(t==0){
  min = R[t];
  max = R[t];
 }

 else if (t==1){
  max_diff = R[t] - R[t-1];
   if (R[t] < R[t-1]){
   min_flag = true;
   }
   else {
   min_flag = false;
   }
 }

  if(R[t] < min){ 
  min = R[t]; 
  min_flag = true;
  }

 else if(R[t] > max){
  max_diff = R[t] - min;
  min_flag = false;
 }

if(min_flag == true){
if( (R[t] - min) > max_diff){
max_diff = R[t] -min ;
 }
 }

}
cout << max_diff << endl;

return 0
}











Compiler output:
a.cc: In function 'int main()':
a.cc:50:9: error: expected ';' before '}' token
   50 | return 0
      |         ^
      |         ;
   51 | }
      | ~
Language: C++

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

int main()
{
	long int max = -1000000000;
	long int Ri;
	long int Rj;
	int loop;

	cin >> loop;
	cin >> Ri;
	cout << "loop : " << loop << endl;

	for (int i = 0; i < loop - 1; i++) {
		cin >> Rj;
		if (max < Rj - Ri) {
			max = Rj - Ri;
		}

		if (Ri > Rj) {
			Ri = Rj;
		}
		//cout << "price : " << Ri << endl;
		//cout << "currentPrice : " << Rj << endl;
	}
	cout << max << endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:9: error: 'cin' was not declared in this scope
   13 |         cin >> loop;
      |         ^~~
a.cc:4:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    3 | #include <random>
  +++ |+#include <iostream>
    4 | using namespace std;
a.cc:15:9: error: 'cout' was not declared in this scope
   15 |         cout << "loop : " << loop << endl;
      |         ^~~~
a.cc:15:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:15:38: error: 'endl' was not declared in this scope
   15 |         cout << "loop : " << loop << endl;
      |                                      ^~~~
a.cc:4:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    3 | #include <random>
  +++ |+#include <ostream>
    4 | using namespace std;
Language: C++

#include<iostream>
#include<string>
using namespace std;
void main() {
	int *arr;
	int n;
	cin >> n;
	arr = (int *)malloc(sizeof(int)*n);
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	int maxv = arr[1] - arr[0];
	for (int i = 2; i < n; i++) {
		for (int j = 0; j < i; j++) {
			if (arr[i] - arr[j] > maxv)
				maxv = arr[i] - arr[j];
		}
	}
	cout << maxv << endl;
}


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

#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;
void main() {
	int R[MAX], n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> R[i];
	}
	int maxv = -2000000000;
	int minv = R[0];
	for (int i = 1; i < n; i++) {
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}
	cout << maxv;
}


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

#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;
void main() {
	int R[MAX], n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> R[i];
	}
	int maxv = -2000000000;
	int minv = R[0];
	for (int i = 1; i < n; i++) {
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}
	cout << maxv<<endl;
}


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

#include <stdio.h>
#include <iostream>
using namespace std;
int main (void)
{
int n;

long long a=1000000000,b=0;
int c;
int count=0,ans=0;
cin>>n;
int r[n];
for(int i=0;i<n;i++)
cin>>r[i];
for(int i=0;i<n;i++){
    if(a>=r[i]){
    a=r[i];
    count=i;
    }
}
if(count != n-1){
for(int j=count;j<n-1;j++){
    if(b<=r[j+1])
     b=r[j+1];
ans=b-a;
}
}
else if(count==n-1){
c=r[n-2];
for(int j=n-1;j>3;j--){
if(c>=r[j-3])
c=r[j-3];
}
ans=a-c;
}
cout<<ans<<endl;
}

    javascript:void(0)
        



Compiler output:
a.cc:39:5: error: 'javascript' does not name a type
   39 |     javascript:void(0)
      |     ^~~~~~~~~~
Language: C++

#include <vector>

int main(int argc, char* argv[])
{
 int idx = 0;
 int min = argv[2];
 int price = 0;
 int maxProfit = 0;

 for (idx = 0; idx < argv[1]; idx++) {
  price = argv[2+idx];
  if (min > price) {
   min = price;
  }
  maxProfit = price - min;
 }
 
 return maxProfit;
}


Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:6:18: error: invalid conversion from 'char*' to 'int' [-fpermissive]
    6 |  int min = argv[2];
      |            ~~~~~~^
      |                  |
      |                  char*
a.cc:10:20: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   10 |  for (idx = 0; idx < argv[1]; idx++) {
      |                ~~~~^~~~~~~~~
a.cc:11:21: error: invalid conversion from 'char*' to 'int' [-fpermissive]
   11 |   price = argv[2+idx];
      |           ~~~~~~~~~~^
      |                     |
      |                     char*
Language: C++

#include <vector>

int main(int argc, char* argv[])
{
 int idx = 0;
 int min = std::stoi(argv[2]);
 int price = 0;
 int maxProfit = 0;

 for (idx = 0; idx < argv[1]; idx++) {
  price = std::stoi(argv[2+idx]);
  if (min > price) {
   min = price;
  }
  maxProfit = price - min;
 }
 
 return maxProfit;
}


Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:6:17: error: 'stoi' is not a member of 'std'
    6 |  int min = std::stoi(argv[2]);
      |                 ^~~~
a.cc:2:1: note: 'std::stoi' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
    1 | #include <vector>
  +++ |+#include <string>
    2 | 
a.cc:10:20: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   10 |  for (idx = 0; idx < argv[1]; idx++) {
      |                ~~~~^~~~~~~~~
a.cc:11:16: error: 'stoi' is not a member of 'std'
   11 |   price = std::stoi(argv[2+idx]);
      |                ^~~~
a.cc:11:16: note: 'std::stoi' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
Language: C++

#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
    int temp = 0;
    int n = 0;
    cin >> n;
    int minv = 0;
    int maxv = -1.01 * RMAX;
    for(int i = 0 ; i < n ; i++)
    {
	cin >> temp;
	if(i == 0)
	{
	    minv = temp;
	}
	else
	{
	    maxv = max(maxv, temp - minv);
	    minv = min(minv, temp);
        }
    }
    cout << maxv << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:24: error: 'RMAX' was not declared in this scope
   12 |     int maxv = -1.01 * RMAX;
      |                        ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int R[200000];
  for(int i=0;i<n;i++)
    cin >> R[i];
  int min=R[0],maxv=R[0];
  for(int i=1;i<n;i++){
    maxv=max(maxv,maxv-R[i]);
    minv=min(minv,R[i]);
  }
  cout << maxv << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:5: error: 'minv' was not declared in this scope; did you mean 'min'?
   12 |     minv=min(minv,R[i]);
      |     ^~~~
      |     min
a.cc:12:13: error: 'min' cannot be used as a function
   12 |     minv=min(minv,R[i]);
      |          ~~~^~~~~~~~~~~
Language: C++

#include <iostream>

static const int MAX = 200000;

int main()
{
    int n, R[MAX];
    std::cin >> n;
    for (int i = 0; i < n; ++i) {
        std::cin >> R[i];
    }
    int maxv = -2147483648;
    int minv = R[i];
    for (int i = 1; i < n; ++i) {
        if (R[i] - minv > maxv)
            maxv = R[i] - minv;
        if (R[i] < minv)
            minv = R[i];
    }
    std::cout << maxv << std::endl;
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:18: error: 'i' was not declared in this scope
   13 |     int minv = R[i];
      |                  ^