Language: C++

/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#define rep(i, n) for(Int (i) = 0; (i) < (n); (i)++)
#define debug(var) cout << #var << ": " << var << endl
using namespace std;
using Int = int64_t;
using Uint = uint64_t;
constexpr Uint mod = 1e9 + 7;
constexpr Int Int_max = LLONG_MAX;
constexpr Int Int_min = LLONG_MIN;
using Container = vector<Int>;
using Grid = vector<vector<char>>; // [y][x]
template<typename T, typename U>
using Umap = unordered_map<T, U>;
template<typename T>
using Uset = unordered_set<T>;
template<typename T>
using P = pair<T, T>;

//This sample is RMQ. Change a little difference by yourself.
template<typename Function>
class SegmentTree {
public:
	Int invalid_value = Int_max;
	Int depth = 1;
	Int leaf_size, tree_size, arr_size;
	Function f;
	Container data;

	//計算量はO(n)。*nは配列の長さ
	SegmentTree(Container arg, Function func) {

		f = func;
		arr_size = arg.size();
		Int n = 1;
		tree_size = 1;

		while (n < arr_size) {//完全二分木にするため2^n > lenとなる最小の2^nを求める
			n *= 2;
			tree_size += n;
			depth++;
		}
		leaf_size = n;
		data.resize(tree_size);//木の配列のサイズを初期化

		for (Int i = 0; i < n; ++i) {//葉の値を初期化
			if (i <= arr_size - 1)data[n + i - 1] = arg[i];
			else data[n + i - 1] = invalid_value;
		}
		//goes well till here.

		Int tmp_size = leaf_size;
		for (Int i = 0; i < depth - 1; ++i) {
			for (Int j = 0; j < tmp_size / 2; ++j) {//ノードは(j * 2, j * 2 + 1)
				data[(tmp_size + j * 2 - 2) / 2] = f(data[tmp_size + j * 2 - 1], data[tmp_size + j * 2]);
			}
			tmp_size /= 2;
		}

	}

	//k番目の配列の値をvalに変える。計算量はO(log n)
	void update(Int k, Int val) {
		//木のインデックスに変える
		k += leaf_size - 1;
		data[k] = val;
		//再帰的に更新する
		while (k > 0) {
			k = (k - 1) / 2;
			data[k] = f(data[k * 2 + 1], data[k * 2 + 2]);
		}
	}

	//[a, b)のクエリを返す。使うときはquery(a, b, 0, 0, n)で呼び出してね。計算量はO(log n)
	Int query(Int a, Int b, Int k = 0, Int l = 0, Int r = -1) {
		if (r < 0)r = leaf_size;
		if (r <= a || b <= l)return invalid_value;
		if (a <= l && r <= b)return data[k];
		Int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
		Int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return f(vl, vr);
	}
};


int main() {

	Int N; cin >> N;
	Container P(N);
	rep(i, N)cin >> P[i];
	auto f = [](Int a, Int b) {return a > b ? b : a; };
	SegmentTree seg(P, f);
	Int ans = 0;
	rep(i, N) {
		Int min = seg.query(0, i + 1);
		if (min == P[i])ans++;
	}
	cout << ans << endl;

}

Compiler output:
a.cc:29:14: error: 'uint64_t' does not name a type
   29 | using Uint = uint64_t;
      |              ^~~~~~~~
a.cc:25:1: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
   24 | #include <algorithm>
  +++ |+#include <cstdint>
   25 | #define rep(i, n) for(Int (i) = 0; (i) < (n); (i)++)
a.cc:30:11: error: 'Uint' does not name a type; did you mean 'uint'?
   30 | constexpr Uint mod = 1e9 + 7;
      |           ^~~~
      |           uint
a.cc: In instantiation of 'SegmentTree<Function>::SegmentTree(Container, Function) [with Function = main()::<lambda(Int, Int)>; Container = std::vector<long int>]':
a.cc:114:22:   required from here
  114 |         SegmentTree seg(P, f);
      |                             ^
a.cc:53:51: error: use of deleted function 'main()::<lambda(Int, Int)>::<lambda>()'
   53 |         SegmentTree(Container arg, Function func) {
      |                                                   ^
a.cc:113:19: note: a lambda closure type has a deleted default constructor
  113 |         auto f = [](Int a, Int b) {return a > b ? b : a; };
      |                   ^
a.cc:53:51: note: use '-fdiagnostics-all-candidates' to display considered candidates
   53 |         SegmentTree(Container arg, Function func) {
      |                                                   ^
a.cc:55:19: error: use of deleted function 'main()::<lambda(Int, Int)>& main()::<lambda(Int, Int)>::operator=(const main()::<lambda(Int, Int)>&)'
   55 |                 f = func;
      |                 ~~^~~~~~
a.cc:113:19: note: a lambda closure type has a deleted copy assignment operator
  113 |         auto f = [](Int a, Int b) {return a > b ? b : a; };
      |                   ^