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

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

const int MIN = -2147483647;

using type = long long;

using namespace std;

type * vec;
int n;
long long ans = 0;

bool check_mon_up(type * start, type * end)
{
	if (end - start <= 1)
		return true;
	
	for (auto i = start; i < end - 1; i++)
		if (*i >= *(i + 1))
			return false;
	return true;
}

bool chec_mon_do(type * start, type * end)
{
	if (end - start <= 1)
		return true;

	for (auto i = start; i < end - 1; i++)
		if (*i <= *(i + 1))
			return false;
	return true;
}

type * m_find_max(type * start, type * end)
{
	int max = MIN;
	type * numb = nullptr;
	for (type * i = start; i < end; i++)
		if (max < *i) max = *i, numb = i;
	return numb;
}

void m_find_two_max(type * start, type * end, type *& max, type *& tax)
{
	int mm = MIN, mt = MIN;
	for (type * i = start; i < end; i++)
	{
		if (*i > mm)
		{
			mt = mm;
			mm = *i;
			tax = max;
			max = i;
		}
		else if (*i > mt)
		{
			mt = *i;
			tax = i;
		}
	}
}

void m_find_tax(type * start, type * end, type * max, type *& tax)
{
	int mm = *max, mt = MIN;
	for (type * i = start; i < end; i++)
		if (*i > mt)
			if (i != max)
			{
				tax = i;
				mt = *i;
			}
}

void fu(type * start, type * end, type * max)
{
	if (end - start == 1)
		return;
	type * tax = 0;
	m_find_tax(start, end, max, tax);
	if (tax == max)
		return;
	if (tax > max)
	{
		ans += (*tax) * (max - start + 1) * (end - tax);
		fu(start, tax, max);
	}
	else
	{
		ans += (*tax) * (tax - start + 1) * (end - max);
		fu(tax + 1, end, max);
	}
	return;
}

void func(type * start, type * end)
{
	if (end - start <= 1)
		return;
	if (end - start == 2)
	{
		ans += min(*(end - 1), *start);
		return;
	}
	if (check_mon_up(start, end))
	{
		for (int i = 0; i < end - start - 1; i++)
			ans += (*(start + i)) * (i + 1);
		return;
	}
	if (chec_mon_do(start, end))
	{
		for (int i = 1; i < end - start; i++)
			ans += (*(start + i)) * (end - start - i);
		return;
	}
	type * max = m_find_max(start, end);
	fu(start, end, max);
	func(start, max);
	func(max + 1, end);
	return;
}

int main()
{
	cin >> n;
	vec = new type[n];
	type * const start = vec;
	type * const end = vec + n;
	for (type * i = start; i < end; i++)
		scanf_s("%d", &*i);
	func(start, end);
	printf_s("%d", ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:134:17: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
  134 |                 scanf_s("%d", &*i);
      |                 ^~~~~~~
      |                 scanf
a.cc:136:9: error: 'printf_s' was not declared in this scope; did you mean 'printf'?
  136 |         printf_s("%d", ans);
      |         ^~~~~~~~
      |         printf
Language: C++

#include <bits/stdc++.h>
using namespace std;
const LL mod = 1e9 + 7;
const int maxN = 1e5 + 7;
const LL ONE = 1;
int N;
int P[maxN];    
int pos[maxN];    
int leftFirstMaxPos[maxN];    
int rightFirstMaxPos[maxN];
LL ans = 0; 

int main(){
    scanf("%d", &N);
    For(i, 1, N) {
        scanf("%d", &P[i]);
        pos[P[i]] = i; 

        leftFirstMaxPos[i] = i - 1;
        rightFirstMaxPos[i] = i + 1;
    }
    

    For(i, 1, N) {
        int Lpos1 = leftFirstMaxPos[pos[i]];    
        int Lpos2 = leftFirstMaxPos[Lpos1];    
        int Rpos1 = rightFirstMaxPos[pos[i]];   
        int Rpos2 = rightFirstMaxPos[Rpos1];    
        
        if(Lpos1 != 0) ans += ONE * i * (Lpos1 - Lpos2) * (Rpos1 - pos[i]);
        if(Rpos1 != N + 1) ans += ONE * i * (pos[i] - Lpos1) * (Rpos2 - Rpos1);
        leftFirstMaxPos[Rpos1] = Lpos1;
        rightFirstMaxPos[Lpos1] = Rpos1;
    }
    
    printf("%lld", ans);
    return 0;
}

Compiler output:
a.cc:3:7: error: 'LL' does not name a type
    3 | const LL mod = 1e9 + 7;
      |       ^~
a.cc:5:7: error: 'LL' does not name a type
    5 | const LL ONE = 1;
      |       ^~
a.cc:11:1: error: 'LL' does not name a type
   11 | LL ans = 0;
      | ^~
a.cc: In function 'int main()':
a.cc:15:9: error: 'i' was not declared in this scope
   15 |     For(i, 1, N) {
      |         ^
a.cc:15:5: error: 'For' was not declared in this scope
   15 |     For(i, 1, N) {
      |     ^~~
a.cc:36:20: error: 'ans' was not declared in this scope; did you mean 'abs'?
   36 |     printf("%lld", ans);
      |                    ^~~
      |                    abs
Language: C++

use std::io::Read;

fn main(){
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let mut p: Vec<usize> = vec![];

    for _ in 0..n{
        p.push(iter.next().unwrap().parse().unwrap());
    }

    let mut ans = 0;

    for l in 0..(n-1){
        for r in (l+1)..n{
            let range = &mut p[l..(r+1)].to_owned();
            range.sort();
            range.reverse();

            let x = range[1];
            ans += x;
        }
    }

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


Compiler output:
a.cc:11:14: error: too many decimal points in number
   11 |     for _ in 0..n{
      |              ^~~~
a.cc:17:14: error: too many decimal points in number
   17 |     for l in 0..(n-1){
      |              ^~~
a.cc:1:1: error: 'use' does not name a type
    1 | use std::io::Read;
      | ^~~
a.cc:3:1: error: 'fn' does not name a type
    3 | fn main(){
      | ^~
Language: C

#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    int N;
    cin >> N;
    
    vector<int> locs(N + 1);
    REP(n, N) {
        int p;
        cin >> p;
        locs[p] = n + 1;
    }
    
    // 番兵を入れる
    multiset<int> seen;
    seen.insert(0);
    seen.insert(0);
    seen.insert(N + 1);
    seen.insert(N + 1);
    
    // 以下のように並んでいるとき、2番めに大きい値が4となる範囲を考える
    // inf inf 1 5 2 4 3 7 6 inf inf
    //      w    x       y z
    //
    
    ll ans = 0;
    for(int n = N; n >= 1; --n) {
        auto loc = locs[n];
        auto it = seen.lower_bound(loc);
        auto y = *it;
        ++it;
        auto z = *it;
        --it;
        --it;
        auto x = *it;
        --it;
        auto w = *it;
        cout << "loc of " << n << ": " << loc << endl;
        cout << "y = " << y << endl;
        cout << "z = " << z << endl;
        cout << "x = " << x << endl;
        cout << "w = " << w << endl;
        
        ll combination = (x - w) * (y - loc);
        combination += (z - y) * (loc - x);
        ans += combination * n;
        
        cout << "added: " << (x - w) * (y - loc) << endl;
        cout << "added: " << (z - y) * (loc - x) << endl;
        
        seen.insert(loc);
    }
    
    cout << ans << endl;
    
    return 0;
}

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

#include <iostream>
#include <vector>
using namespace std;
vector<int> a,b;
int n,_in,i,l,cou;
int main(){
    cin >> n;
    while(i<n){
        cin >> _in;
        a.push_back(_in);
        i++;
    }
    for(int i=0;i<n-1;i++){
        for(int l=(i+1);l<n;l++){
        b.clear();
        for(int p=i;p<=l;p++){
            b.push_back(a[p]);
        }
        sort(b.begin(),b.end(),greater<int>());
        unique(b.begin(),b.end());
        cou+=b[1];
        }
    }
    cout << cou << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   19 |         sort(b.begin(),b.end(),greater<int>());
      |         ^~~~
      |         short
a.cc:20:9: error: 'unique' was not declared in this scope
   20 |         unique(b.begin(),b.end());
      |         ^~~~~~
Language: Java

import java.util.Scanner;

public class E {
	
	
	private final static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] arg) {
		int N = sc.nextInt();
		int[] P = new int[N];
		for (int i = 0; i < P.length; i++) {
			P[i] = sc.nextInt();
		}
		int [][] array = new int[N-1][2];
		int sum =0;
		for(int i = 0; i < N-1; i ++) {
			if(P[i] < P[i+1]) {
				array[i][0] = P[i];
				array[i][1] = P[i+1];
				sum += P[i];
			} else {
				array[i][1] = P[i];
				array[i][0] = P[i+1];
				sum += P[i+1];
			}
		}
		for (int k = N-2; k > 0; k--) {
			for(int i = 0; i < k; i++ ) {
				if(array[i][0] < array[i+1][0]) {
					sum += array[i+1][0];
					array[i][0] = array[i+1][0]; 
					array[i][1] = array[i+1][1];
				} else if(array[i][0] > array[i+1][0]) {
					sum += array[i][0];
				} else {
					if(array[i][1] < array[i+1][1]) {
						sum += array[i][1];
						array[i][0] = array[i][1];
						array[i][1] = array[i+1][1];
					} else if(array[i][1] > array[i+1][1]){
						sum += array[i+1][1];
						array[i][0] = array[i+1][1];
						array[i][1] = array[i][1];
					} else {
						sum += array[i][0];
					}
				}
			}
			
		}
		System.out.println(sum);
	}
}


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

import java.util.Scanner;

public class R {
	
	
	private final static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] arg) {
		int N = sc.nextInt();
		int[] P = new int[N];
		for (int i = 0; i < P.length; i++) {
			P[i] = sc.nextInt();
		}
		int [][] array = new int[N-1][2];
		int sum =0;
		for(int i = 0; i < N-1; i ++) {
			if(P[i] < P[i+1]) {
				array[i][0] = P[i];
				array[i][1] = P[i+1];
				sum += P[i];
			} else {
				array[i][1] = P[i];
				array[i][0] = P[i+1];
				sum += P[i+1];
			}
		}
		for (int k = N-2; k > 0; k--) {
			for(int i = 0; i < k; i++ ) {
				if(array[i][0] < array[i+1][0]) {
					sum += array[i+1][0];
					array[i][0] = array[i+1][0]; 
					array[i][1] = array[i+1][1];
				} else if(array[i][0] > array[i+1][0]) {
					sum += array[i][0];
				} else {
					if(array[i][1] < array[i+1][1]) {
						sum += array[i][1];
						array[i][0] = array[i][1];
						array[i][1] = array[i+1][1];
					} else if(array[i][1] > array[i+1][1]){
						sum += array[i+1][1];
						array[i][0] = array[i+1][1];
						array[i][1] = array[i][1];
					} else {
						sum += array[i][0];
					}
				}
			}
			for(int i = 0; i < k; i++ ) {
				System.out.println("{ " + array[i][0] + " , " + array[i][1] + " }");
			}
		}
		System.out.println(sum);
	}
}


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

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

int main()
{
    priority_queue<int> q;
    int n; cin >> n;
    vector<int> arr(n);
    for(int i=0; i<n; i++) cin >> arr[i];  
    int ans = 0;

    for(int i=0;i<n-1;i++){
        for(int j= i+1;j<n;j++){
            for(int k=i; k<=j;k++){
                q.insert(arr[k]);
            }
            q.pop();
            ans += q.top();
            while(!q.empty()) q.pop();
        }
    }

    cout << ans << endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:19: error: 'class std::priority_queue<int>' has no member named 'insert'
   15 |                 q.insert(arr[k]);
      |                   ^~~~~~
Language: C++

#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}
// https://www1181.hlsmp4.com/token=84ewH9fbxpp4czZeHrJcQA/1568133957/0.0.0.0/70/b/4d/030d7ca247fb28cf3effcf5c8e6cd4db-1080p.mp4
//もしも一番大きいやつならば
// Ci 最大値がiになる区間の個数
// sum of Ci * i

//二番目に大きいのは自分より大きいものをちょうど１個含む区間
int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    REP(i, N) {
        cin >> a[i];
        a[i]--;
    }
    vector<int> idx(n);
    REP(i, n) { idx[a[i]] = i; }
    set<int> s;
    ll ans = 0;
    for(int x = n - 1; x >= 0; x--) {
        int i = idx[x];
        ll c = 0;
        { // calc c
            s.insert(i);
            vector<int> l(2);
            vector<int> r(2);
            {                        // calc l
                auto it = s.find(i); //いまxがいる場所のiterator
                REP(j, 2) {
                    if(it == s.begin())
                        break;
                    it--;
                    l[j] = *it; // iteratorの値をとる
                }
            }
            {                        // calc r
                auto it = s.find(i); //いまxがいる場所のiterator
                REP(j, 2) {
                    if(it == s.end())
                        break;
                    it++;
                    r[j] = *it; // iteratorの値をとる
                }
            }
            vector<int> ls(2);
            ls[0] = i - l[0];
            ls[1] = l[0] - l[1];
            vector<int> rs(2);
            rs[0] = r[0] - i;
            rs[1] = r[1] - r[0];
            c = (ll)ls[0] * rs[1] + (ll)ls[1] * rs[0]
        }
        ans += c * (x + 1);
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:21: error: 'n' was not declared in this scope
   47 |     vector<int> idx(n);
      |                     ^
a.cc:82:54: error: expected ';' before '}' token
   82 |             c = (ll)ls[0] * rs[1] + (ll)ls[1] * rs[0]
      |                                                      ^
      |                                                      ;
   83 |         }
      |         ~
Language: Java

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] array = new int[n];
		int[] array_x = new int[n];
		int[] taihi=new int[n];
		int goukei = 0;
		for (int i = 0; i < n; i++) {
			array[i] = scan.nextInt();
		}
		for (int i = 0; i < n - 1; i++) {
			for (int j = 0, k = i; k < n; j++, k++) {
				array_x[j] = array[k];
				  System.arraycopy(array_x,0,taihi,0,array_x.length);//[3]
				Arrays.sort(taihi);
				goukei += taihi[n - 2];
			}
			for(int j=0;j<n;j++){
				array_x[j]=0;
			}
		}
		System.out.println(goukei);

	}
}


Compiler output:
Main.java:18: error: cannot find symbol
				Arrays.sort(taihi);
				^
  symbol:   variable Arrays
  location: class Main
1 error
Language: C++

#include<bits/stdc++.h>
using namespace std;
long long n,a[100005],pos[100005],pre[100005],nxt[100005];
int main(){
    long long s=0,ans=0;
	cin>>n;
	for (int i=1;i<=n;i++)
		cin>>a[i],pos[a[i]]=i;
	for (int i=0;i<=n+1;i++)
		pre[i]=max(0,i-1),nxt[i]=min(n+1,i+1);
	s=n*(n-1)/2;
   	for (int i=1;i<=n;i++){
   		ans+=s;
   		int x=pos[i];
   		s-=(pre[x]-pre[pre[x]])*(nxt[x]-x);
   		s-=(nxt[nxt[x]]-nxt[x])*(x-pre[x]);
   		pre[nxt[x]]=pre[x];
   		nxt[pre[x]]=nxt[x];
	}
	cout<<ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:45: error: no matching function for call to 'min(long long int, int)'
   10 |                 pre[i]=max(0,i-1),nxt[i]=min(n+1,i+1);
      |                                          ~~~^~~~~~~~~
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:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:10:45: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   10 |                 pre[i]=max(0,i-1),nxt[i]=min(n+1,i+1);
      |                                          ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281: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:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:10:45: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   10 |                 pre[i]=max(0,i-1),nxt[i]=min(n+1,i+1);
      |                                          ~~~^~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int n,a[N],q[N];
ll ans;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	int t=0; a[n+1]=n+1;
	for (int i=1;i<=n;i++){
    	for (;t&&a[q[t]]<a[i];suff[q[t--]]=i);
        pref[i]=q[t]; q[++i]=i;
    }
	for (int i=1;i<=n;i++){
      	ans+=1ll*a[i]*pref[i]*(suff[i]-i);
        ans+=1ll*a[i]*(n+1-suff[i])*(i-pref[i]);
    }
	printf("%lld\n",ans);
}

Compiler output:
a.cc:5:1: error: 'll' does not name a type
    5 | ll ans;
      | ^~
a.cc: In function 'int main()':
a.cc:11:31: error: 'suff' was not declared in this scope
   11 |         for (;t&&a[q[t]]<a[i];suff[q[t--]]=i);
      |                               ^~~~
a.cc:12:9: error: 'pref' was not declared in this scope
   12 |         pref[i]=q[t]; q[++i]=i;
      |         ^~~~
a.cc:15:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   15 |         ans+=1ll*a[i]*pref[i]*(suff[i]-i);
      |         ^~~
      |         abs
a.cc:15:23: error: 'pref' was not declared in this scope
   15 |         ans+=1ll*a[i]*pref[i]*(suff[i]-i);
      |                       ^~~~
a.cc:15:32: error: 'suff' was not declared in this scope
   15 |         ans+=1ll*a[i]*pref[i]*(suff[i]-i);
      |                                ^~~~
a.cc:18:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
   18 |         printf("%lld\n",ans);
      |                         ^~~
      |                         abs
Language: C++

N = int(input())
P = list(map(int, input().split()))

ans = 0
for i in range(N):
    L = [-1] + [j for j in range(i) if P[i] < P[j]]
    R = [j for j in range(i + 1, N) if P[i] < P[j]] + [N]

    if len(L) > 1:
        ans += P[i] * (L[-1] - L[-2]) * (R[0] - i)
    if len(R) > 1:
        ans += P[i] * (i - L[-1]) * (R[1] - R[0])

print(ans)

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin>>n;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin>>p[i];
  }
  int ans=0;
  int sec=0;
  int max=0;
  for(int i=0;i<n-1;i++){

    for(int j=i+1;j<n;j++){
      if(i+1==j){
       sec=min(p[i],p[j]);
       max=max(p[i],p[j]);
      }
      if(max>p[j] && p[j]>sec){
        sec=p[j];
      }
      if(max<p[j]){
        sec=max;
        max=p[j];
      }
      ans+=sec;
    }
  }
  cout<<ans<<endl;
}
      


Compiler output:
a.cc: In function 'int main()':
a.cc:18:15: error: 'max' cannot be used as a function
   18 |        max=max(p[i],p[j]);
      |            ~~~^~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin>>n;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin>>p[i];
  }
  int ans=0;
  inr sec=0;
  int max=0;
  for(int i=0;i<n-1;i++){

    for(int j=i+1;j<n;j++){
      if(i+1==j){
       sec=min(p[i],p[j]);
       max=max(p[i],p[j]);
      }
      if(max>p[j] && p[j]>sec){
        sec=p[j];
      }
      if(max<p[j]){
        sec=max;
        max=p[j];
      }
      ans+=sec;
    }
  }
  cout<<ans<<endl;
}
      

Compiler output:
a.cc: In function 'int main()':
a.cc:11:3: error: 'inr' was not declared in this scope; did you mean 'int'?
   11 |   inr sec=0;
      |   ^~~
      |   int
a.cc:17:8: error: 'sec' was not declared in this scope
   17 |        sec=min(p[i],p[j]);
      |        ^~~
a.cc:18:15: error: 'max' cannot be used as a function
   18 |        max=max(p[i],p[j]);
      |            ~~~^~~~~~~~~~~
a.cc:20:27: error: 'sec' was not declared in this scope
   20 |       if(max>p[j] && p[j]>sec){
      |                           ^~~
a.cc:24:9: error: 'sec' was not declared in this scope
   24 |         sec=max;
      |         ^~~
a.cc:27:12: error: 'sec' was not declared in this scope
   27 |       ans+=sec;
      |            ^~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define MOD 1000000007

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

int n;


signed main()
{
    cin >> n;
    int index[n + 1];
    rep(i, n)
    {
        cin >> p[i];
        index[p[i]] = i;
    }
    int ans = 0;
    multiset<int> temp;
    temp.insert(-1);
    temp.insert(-1);
    temp.insert(n);
    temp.insert(n);

    temp.insert(index[n]);

    int w, x, y, z;
    int c;

    for (int i = n - 1; i > 0; i--)
    {
        int j = index[i];
       
        auto itr = temp.lower_bound(j);
        y = *itr;
        itr++;
        z = *itr;

        itr = temp.lower_bound(j);
        itr--;
        x = *itr;
        itr--;
        w=*itr;
        c = (x - w) * (y - j) + (j - x) * (z - y);
        ans += i * c;
         temp.insert(j);
    }

    cout << ans << endl;
    
    return 0;
}


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

#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <algorithm>

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> llpair;
typedef std::pair<ll, ll> llpair;

#define mod 1000000007
#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i, n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using namespace std;

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

	int n;
	cin >> n;
	llpair* p;
	p = new llpair[n];
	rep(i, n) {
		ll num;
		cin >> num;
		p[i] = llpair(num, i);
	}

	sort(p, p + n);

	set<int> s;

	s.insert(n);
	s.insert(-1);
	s.insert(p[n - 1].second);


	ll ans = 0;
	rrep(i, n - 2) {
		s.insert(p[i].second);
		auto t = s.find(p[i].second);
		ll x, w, y, z;

		x = *--t;
		if (t == s.begin()) {
			w = x;
		}
		else {
			w = *--t;
			++t;
		}
		++t;

		y = *++t;
		if (t == s.find(n)) {
			z = y;
		}
		else {
			z = *++t;
		}

		ans += p[i].first * ((x - w)*(y - p[i].second) + (p[i].second - x)*(z - y));
	}

	cout << ans << "\n";
 }


Compiler output:
a.cc:16:27: error: conflicting declaration 'typedef struct std::pair<long long int, long long int> llpair'
   16 | typedef std::pair<ll, ll> llpair;
      |                           ^~~~~~
a.cc:15:29: note: previous declaration as 'typedef struct std::pair<int, int> llpair'
   15 | typedef std::pair<int, int> llpair;
      |                             ^~~~~~
Language: C++

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

ll n, ans, a[200005];
multiset<ll> st = {-1, -1};
int main() {
	ll i, t;
	multiset<ll>::iterator x, y, w, v;
	cin >> n;
	for(i=0; i<n; i++) scanf("%lld", &t), a[t] = i;
	st.insert(n);
	st.insert(n);
	for(i=n; i; i--) {
		x = st.lower_bound(a[i]);
		y = next(x);
		w = prev(x);
		v = prev(w);
		ans += i * ((*y-*x) * (a[i]-*w) + (*w-*v) * (*x-a[i]));
		st.insert(a[i]);
	}
	cout < <ans;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:16: error: expected primary-expression before '<' token
   24 |         cout < <ans;
      |                ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;


int main()
{
  ll n;
  cin >> n;
  vector<ll> pos(n+1);
  for (ll i = 1; i <= n; ++i) {
    ll p;
    cin >> p;
    pos[p] = i;
  }

  ll ans = 0;
  set<ll> s;
  s.insert(0);
  s.insert(n+1);
  s.insert(pos[n]);
  for (int i = n - 1; i > 0; ++i) {
    p = pos[i];
    auto it = s.lower_bound(p);
    ll b0 = (*it == 0) ? 0 : *it - *(it - 1) - 1;
    ll b1 = p - *it;
    ++it;
    ll b2 = *it - p;
    ll b3 = (*it == n + 1) ? 0 : *(it + 1) - *it - 1;
    ans += i * ((b0 * b2) + (b1 * b3));
    s.insert(p);
  }
  cout << ans;
  
  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:24:5: error: 'p' was not declared in this scope
   24 |     p = pos[i];
      |     ^
Language: C++

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

int main(){
  ll int n;
  ll int f,s;
  ll int sum =0;
  cin >> n;
  ll int p[n];
  for(int i = 0; i < n; i++){
    cin >> p[i];
  }
  
  for(int i = 0; i < n-1; i++){
    f=max(p[i],p[i+1]);
    s=min(p[i],p[i+1]);
    for(int j = i+1; j < n; j++){
      if(f<p[j]){
        s=f;
        f=p[j];
      }
      else if(f>p[j]&&s<p[j]){
        s=p[j];
      }
      sum+=s;
      //cout << f << s << endl;
    }
  }
  cout << sum << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:6:3: error: two or more data types in declaration of 'n'
    6 |   ll int n;
      |   ^~
a.cc:7:3: error: two or more data types in declaration of 'f'
    7 |   ll int f,s;
      |   ^~
a.cc:7:3: error: two or more data types in declaration of 's'
a.cc:8:3: error: two or more data types in declaration of 'sum'
    8 |   ll int sum =0;
      |   ^~
a.cc:9:10: error: 'n' was not declared in this scope; did you mean 'yn'?
    9 |   cin >> n;
      |          ^
      |          yn
a.cc:10:3: error: two or more data types in declaration of 'p'
   10 |   ll int p[n];
      |   ^~
a.cc:12:12: error: 'p' was not declared in this scope
   12 |     cin >> p[i];
      |            ^
a.cc:16:5: error: 'f' was not declared in this scope
   16 |     f=max(p[i],p[i+1]);
      |     ^
a.cc:16:11: error: 'p' was not declared in this scope
   16 |     f=max(p[i],p[i+1]);
      |           ^
a.cc:17:5: error: 's' was not declared in this scope
   17 |     s=min(p[i],p[i+1]);
      |     ^
a.cc:26:7: error: 'sum' was not declared in this scope
   26 |       sum+=s;
      |       ^~~
a.cc:30:11: error: 'sum' was not declared in this scope
   30 |   cout << sum << endl;
      |           ^~~
Language: C++

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

int main(){
    int n;
    cin >> n;
    vector<int> b(n);
    for (int i = 0;i < n;i++){
        cin >> b[i];
    }
    sort(b.begin(),b.end());
    int sum = 0;
    int j = 0;
    for (int i = n -1 0;i >= 0;i--){
        sum += b[j]*i;
        j++;
    }    
    cout << sum  << endl;
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:22: error: expected ';' before numeric constant
   14 |     for (int i = n -1 0;i >= 0;i--){
      |                      ^~
      |                      ;
a.cc:14:31: error: expected ')' before ';' token
   14 |     for (int i = n -1 0;i >= 0;i--){
      |         ~                     ^
      |                               )
a.cc:14:32: error: 'i' was not declared in this scope
   14 |     for (int i = n -1 0;i >= 0;i--){
      |                                ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,i,big,big2,j=0,k,ans=0;
  
  cin >> N;
  for(i=0;i<N;i++){
     cin >> P[i];
  }
  
  for(i=0;i<N-1;i++){
    big = P[i];
    for(j=i+1;i<N;i++){
      for(k=i;i<j+1;k++){
    	if(P[i]>=big){
          big2=big;
          big = P[i];
        }else if(P[i]>=big2){
          big2=P[i];
        }
  	  }
      ans+=big2;
  	}
  }
 
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:13: error: 'P' was not declared in this scope
    9 |      cin >> P[i];
      |             ^
a.cc:13:11: error: 'P' was not declared in this scope
   13 |     big = P[i];
      |           ^
Language: C++

#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int digit_sum(int n){
  if(n==0){
    return 0;
  }else{
    int res = 0;
    res = n%10;
    res += digit_sum(n/10);
    return res;
  }
}

int main(){
  
  int n;
  cin>>n;
  long long p[n];//pの要素は相異なる
  long long place[n+1];
  for(long long i=0;i<n;i++){
    cin>>p[i];
    place[p[i]] = i;
  }
  long long left[n+1];
  long long right[n+1];
  
  set<long long> s;
  s.insert(-1);
  s.insert(n);
  long long ans = 0;
  long long l,r;
  long long ll,rr;
  for(long long i=n;i>=1;i--){//二番目に大きな値としてiをとる区間の数を調べる
    auto itr_r = s.lower_bound(place[i]);
    r = *itr_r;
    auto itr_l = --itr_r;
    l = *itr_l;
    left[i] = l;
    right[i] = r;
    if(r!=n && l!=-1){
      rr = right[r];
      ans += i*(place[i]-l)*(rr-r);
      ll = lefr[l];
      ans += i*(ll-l)*(r-place[i]);
    }else if(r != n){
      rr = right[r];
      ans += i*(place[i]-l)*(rr-r);
    }else if(l != -1){
      ll = lefr[l];
      ans += i*(ll-l)*(r-place[i]);
    }else{
      ;
    }
    s.insert(place[i]);
  }
  cout<<ans<<endl;
  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:86:12: error: 'lefr' was not declared in this scope; did you mean 'left'?
   86 |       ll = lefr[l];
      |            ^~~~
      |            left
a.cc:92:12: error: 'lefr' was not declared in this scope; did you mean 'left'?
   92 |       ll = lefr[l];
      |            ^~~~
      |            left
Language: C++

#include <bits/stdc++.h>

using namespace std ;

const int MAX = 1e5 + 10 ;

vector<int>tree[4 * MAX] ;
int arr[MAX] ;

void build(int node , int l , int r)
{
	if(l == r)
	{
		tree[node].push_back(arr[l]) ;
		return ;
	}
	int mid = (l + r) >> 1 ;
	build(node << 1 , l , mid) ;
	build(node << 1 | 1 , mid + 1 , r) ;
	merge(tree[node << 1].begin(), tree[node << 1].end(), tree[node << 1 | 1].begin(), tree[node << 1 | 1].end(), inserter(tree[node], tree[node].begin()));
}

int query(int node , int l , int r , int from , int to , int x)
{
	if(from > r || to < l)
		return 0 ;
	if(l >= from && r <= to)
	{
		int idx = upper_bound(tree[node].begin() , tree[node].end() , x) - tree[node].begin() ;
		return (tree[node].size() - idx) ;
	}
	int mid = (l + r) >> 1 ;
	int a = query(node << 1 , l , mid , from  , to , x) ;
	int b = query(node << 1 | 1 , mid + 1 , r , from , to , x) ;
	return (a + b) ;
}

int readInt () {
	bool minus = false;
	int result = 0;
	char ch;
	ch = getchar();
	while (true) {
		if (ch == '-') break;
		if (ch >= '0' && ch <= '9') break;
		ch = getchar();
	}
	if (ch == '-') minus = true; else result = ch-'0';
	while (true) {
		ch = getchar();
		if (ch < '0' || ch > '9') break;
		result = result*10 + (ch - '0');
	}
	if (minus)
		return -result;
	else
		return result;
}

int main()
{
	int n ;
	n = readInt() ;
	for(int i = 1 ; i <= n ; ++i)
		arr[i] = readint() ;
	build(1 , 1 , n) ;
	long long ans = 0ll ;
	for(int i = 1 ; i <= n ; ++i)
	{
		int l = i , r = n ;
		int a = i , c = i;
		while(l <= r)
		{
			int mid = (l + r) >> 1 ;
			int x = query(1 , 1 , n , i , mid , arr[i]) ;
			if(x <= 1)
			{
				l = mid+1 ;
				if(x == 1)
					a = mid ;
			}
			else
				r = mid - 1;
		}
		l = i , r = n ;
		while(l <= r)
		{
			int mid = (l + r) >> 1 ;
			int x = query(1 , 1 , n , i , mid , arr[i]) ;
			if(x == 0)
			{
				l = mid+1 ;
				c = mid ;
			}
			else
				r = mid - 1;
		}
		l = 1 , r = i ;
		int b = i , d = i;
		while(l <= r)
		{
			int mid = (l + r) >> 1 ;
			int x = query(1 , 1 , n , mid , i , arr[i]) ;
			if(x <= 1)
			{
				r = mid-1 ;
				if(x == 1)
					b = mid ;
			}
			else
				l = mid + 1;
		}
		l = 1 , r = i ;
		while(l <= r)
		{
			int mid = (l + r) >> 1 ;
			int x = query(1 , 1 , n , mid , i , arr[i]) ;
			if(x == 0)
			{
				r = mid-1 ;
				d = mid ;
			}
			else
				l = mid + 1;
		}
		long long x1 = (i - d + 1ll) * 1ll ;
		long long x2 = (a - c) * 1ll ;
		x1 = max(x1 , 0ll) ;
		x2 = max(x2 , 0ll) ;
		ans += (x1 * x2) * arr[i] * 1ll ;
		x1 = (d - b) * 1ll ;
		x2 = (c - i + 1ll) * 1ll ;
		x1 = max(x1 , 0ll) ;
		x2 = max(x2 , 0ll) ;
		ans += (x1 * x2) * arr[i] * 1ll ;
	}
	return printf("%lld\n" , ans) , 0 ;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:65:26: error: 'readint' was not declared in this scope; did you mean 'readInt'?
   65 |                 arr[i] = readint() ;
      |                          ^~~~~~~
      |                          readInt
Language: C++

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

int main(){
  int N;
  cin >> N;
  vector<int> P(N+1);
  for(int i = 0; i < N; ++i){
    int tmp;
    cin >> tmp;
    P[tmp] = i+1;
  }
  set<int> r;
  ll ans = 0;
  ans += (N-max(P[N],P[N-1]) + 1) * min(P[N],P[N-1]) * (N-1);
  r.insert(P[N]);
  r.insert(P[N-1]);
  int a = max(P[N], P[N-1]);
  int b = min(P[N], P[N-1]);
  if(b < P[N-2]){
    ans += P[N-2] * (b-a) * (N-2);
  }else if(a < P[N-2]){
    ans += (N-P[N-2]+1) * (b-a) * (N-2);
  }else{
    ans += (b-P[N-2]) * (P[N-2]-a) * (N-2);
  }
  for(int i = N-3; i > 0; --i){
    auto itr = r.upper_bound(P[i]);
    auto itr2 = itr;
    int r1 = *itr;
    int r2 = *(itr++);
    int l1 = *(itr--);
    int l2 = *(itr--);
    int pt = P[i];
    ans += (r1 - pt) * (l1 - l2) + (pt - l1) * (r2 - r1) * i;
    r.insert(pt);
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:3: error: 'set' was not declared in this scope
   19 |   set<int> r;
      |   ^~~
a.cc:7:1: note: 'std::set' is defined in header '<set>'; this is probably fixable by adding '#include <set>'
    6 | #include <cmath>
  +++ |+#include <set>
    7 | typedef long long ll;
a.cc:19:7: error: expected primary-expression before 'int'
   19 |   set<int> r;
      |       ^~~
a.cc:22:3: error: 'r' was not declared in this scope
   22 |   r.insert(P[N]);
      |   ^
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include <iomanip>
#define REP(i, n) for(int i = 0; (i) < (n); (i)++)
#define MOD 1000000007
using namespace std;
 
int main(){
  int N, max, max2, index;
  long long sum = 0;
  cin >> N;
  int P[i], Q[i];
  REP(i,N){
    cin >> P[i];
    Q[i] = P[i];
  }
  for (int L = 0; L < N-1; L++){
    for (int R = L+1; R < N; R++){
      max = max_element(Q.L, Q.R);
      for (int i = L; i <= R; i++){
        if (Q[i] == max){
          index = i;
          Q[i] = 0;
        }
      }
      sum += max_element(Q.L, Q.R);
      Q[index] = P[index];
    }
  }
  cout << sum << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:9: error: 'i' was not declared in this scope
   17 |   int P[i], Q[i];
      |         ^
a.cc:19:12: error: 'P' was not declared in this scope
   19 |     cin >> P[i];
      |            ^
a.cc:20:5: error: 'Q' was not declared in this scope
   20 |     Q[i] = P[i];
      |     ^
a.cc:24:25: error: 'Q' was not declared in this scope
   24 |       max = max_element(Q.L, Q.R);
      |                         ^
a.cc:32:18: error: 'P' was not declared in this scope
   32 |       Q[index] = P[index];
      |                  ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define max(a,b) ((a>b)?a:b);
#define min(a,b) ((b>a)?a:b);
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert                                                                      //copy NUL check.cpp
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)                                 //g++ template.cpp -o template.exe
#define zeroes(x) memset(x,0,sizeof(x))                                        //all elements to 0
#define all(x) (x).begin(), (x).end()
typedef long long int ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn=100000;







bool sortbysec(const pair<int,int> &a,                         //sorting of elements wrt second
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 




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

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

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    int p;
    vector<P> vec;
    REP(i,n){
        cin >> p;
        vec.push_back(P(p,i));
    }
    ll ans = 0;
    sort(ALL(vec));
    reverse(ALL(vec));
    int limit_left = 0, limit_right = INF;
    REP(i,n - 1){
        int left = min(vec[i].second, vec[i + 1].second), right = max(vec[i].second, vec[i + 1].second);
        ans += max((left + 1 - max({limit_right, limit_left, 0)) * (min({limit_left, limit_right ,n - 1}) - right + 1) * vec[i].first, 0);
        if(left > limit_left){
            limit_left = left;
        }
        if(limit_right > right){
            limit_right = right;
        }
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:63: error: expected '}' before ')' token
   25 |         ans += max((left + 1 - max({limit_right, limit_left, 0)) * (min({limit_left, limit_right ,n - 1}) - right + 1) * vec[i].first, 0);
      |                                    ~                          ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define max(a,b) ((a>b)?a:b);
#define min(a,b) ((b>a)?a:b);
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert                                                                      //copy NUL check.cpp
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)                                 //g++ template.cpp -o template.exe
#define zeroes(x) memset(x,0,sizeof(x))                                        //all elements to 0
#define all(x) (x).begin(), (x).end()
typedef long long int ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn=100000;







bool sortbysec(const pair<int,int> &a,                         //sorting of elements wrt second
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 




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

Compiler output:
a.cc: In function 'int main()':
a.cc:48:14: error: 'n' was not declared in this scope; did you mean 'yn'?
   48 |         ll a[n],b[n];
      |              ^
      |              yn
a.cc:53:7: error: 'i' was not declared in this scope; did you mean 'vi'?
   53 |   for(i=0;i<n;i++)
      |       ^
      |       vi
a.cc:54:10: error: 'a' was not declared in this scope
   54 |     cin>>a[i];
      |          ^
a.cc:55:3: error: 'b' was not declared in this scope; did you mean 'pb'?
   55 |   b[0]=a[0];
      |   ^
      |   pb
a.cc:55:8: error: 'a' was not declared in this scope
   55 |   b[0]=a[0];
      |        ^
a.cc:57:7: error: 'i' was not declared in this scope; did you mean 'vi'?
   57 |   for(i=1;i<n;i++)
      |       ^
      |       vi
Language: C++

#include<bits/stdc++.h>

using namespace std;

using ll = long long;

#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define repn(i,n)  rep(i,0,n)

const double EPS = 1e-5;
const int MOD = 1e9+7;

const int N = 100000;

int pos[N+1];
int x[N+1][N+1];
int n;

int main(){
  cin >> n;

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

  for(int l = 1; l < n; l++){
    int grater_flag = 0;

    x[l][l+1] = min(pos[l], pos[l+1]);

    if(pos[l] <= pos[l + 1]) grater_flag = 1;

    for(int r = l + 2; r < n + 1; r++){
      if(x[l][r-1] >= pos[r]){
        x[l][r] = x[l][r-1];
        grater_flag = 0;
      }else if(grater_flag == 1 && pos[r-1] < pos[r]){
        x[l][r] = pos[r-1];
      }else{
        x[l][r] = pos[r];
        grater_flag = 0;
      }
    }
  }

  ll res = 0;
  for(int l = 1; l < n; l++){
    for(int r = l + 1; r < n + 1; r++){
      res += x[l][r];
      //cout << "(" << l << "," << r << ")" << x[l][r] << endl;
    }
  }

  cout << res << endl;

  return 0;

}


Compiler output:
/tmp/ccOpepxv.o: in function `main':
a.cc:(.text+0xb): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccOpepxv.o
a.cc:(.text+0x59): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccOpepxv.o
a.cc:(.text+0x296): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccOpepxv.o
a.cc:(.text+0x2a9): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccOpepxv.o
a.cc:(.text+0x305): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccOpepxv.o
a.cc:(.text+0x314): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccOpepxv.o
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>

using namespace std;

using ll = long long;

#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define repn(i,n)  rep(i,0,n)

const double EPS = 1e-5;
const int MOD = 1e9+7;

const int N = 100000;

int pos[N+1];
int x[N+1][N+1];
int n;

int main(){
  cin >> n;

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

  for(int l = 1; l < n; l++){
    int grater_flag = 0;

    x[l][l+1] = min(pos[l], pos[l+1]);

    if(pos[l] <= pos[l + 1]) grater_flag = 1;

    for(int r = l + 2; r < n + 1; r++){
      if(x[l][r-1] >= pos[r]){
        x[l][r] = x[l][r-1];
        grater_flag = 0;
      }else if(grater_flag == 1 && pos[r-1] < pos[r]){
        x[l][r] = pos[r-1];
      }else{
        x[l][r] = pos[r];
        grater_flag = 0;
      }
    }
  }

  ll res = 0;
  for(int l = 1; l < n; l++){
    for(int r = l + 1; r < n + 1; r++){
      res += x[l][r];
      //cout << "(" << l << "," << r << ")" << x[l][r] << endl;
    }
  }

  cout << res << endl;

  return 0;

}


Compiler output:
/tmp/ccnJ9Z9n.o: in function `main':
a.cc:(.text+0xb): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccnJ9Z9n.o
a.cc:(.text+0x59): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccnJ9Z9n.o
a.cc:(.text+0x296): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccnJ9Z9n.o
a.cc:(.text+0x2a9): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccnJ9Z9n.o
a.cc:(.text+0x305): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccnJ9Z9n.o
a.cc:(.text+0x314): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccnJ9Z9n.o
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>

using namespace std;

using ll = long long;

#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define repn(i,n)  rep(i,0,n)

const double EPS = 1e-5;
const int MOD = 1e9+7;

const int N = 100000;

int pos[N+1];
int x[N+1][N+1];
int n;

int main(){
  cin >> n;

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

  for(int l = 1; l < n; l++){
    int grater_flag = 0;

    x[l][l+1] = min(pos[l], pos[l+1]);

    if(pos[l] <= pos[l + 1]) grater_flag = 1;

    for(int r = l + 2; r < n + 1; r++){
      if(x[l][r-1] >= pos[r]){
        x[l][r] = x[l][r-1];
        grater_flag = 0;
      }else if(grater_flag == 1 && pos[r-1] < pos[r]){
        x[l][r] = pos[r-1];
      }else{
        x[l][r] = pos[r];
        grater_flag = 0;
      }
    }
  }

  ll res = 0;
  for(int l = 1; l < n; l++){
    for(int r = l + 1; r < n + 1; r++){
      res += x[l][r];
      //cout << "(" << l << "," << r << ")" << x[l][r] << endl;
    }
  }

  cout << res << endl;

  return 0;

}


Compiler output:
/tmp/ccxldqkf.o: in function `main':
a.cc:(.text+0xb): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccxldqkf.o
a.cc:(.text+0x59): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccxldqkf.o
a.cc:(.text+0x296): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccxldqkf.o
a.cc:(.text+0x2a9): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccxldqkf.o
a.cc:(.text+0x305): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccxldqkf.o
a.cc:(.text+0x314): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccxldqkf.o
collect2: error: ld returned 1 exit status