akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void)
{
  int D;
  scanf("%d", &D);
  if (D==3){
    printf("YES");
  }
  else if (D==5){
    printf("YES");
  }
  else if (D==7){
    printf("YES");
  }
  else {
    printf("NO");
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
//#define int long long
#define all(vec) vec.begin(), vec.end()
#define dbg(x) cerr << #x << " = " << (x) << endl

int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct mystr{
	int minn = 500000;
	int cnt = 0;
};

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

	int N;
	cin>>N;
	mystr tmp[26];
	for (int i = 0; i < N; i++) {
		int cnttmp[26] = {0};
		int count[26] = {0};
		string s;
		cin>>s;
		for (int j = 0; j < s.size(); j++) {
			cnttmp[s[j] - 'a'] = 1;
			count[s[j] - 'a']++;
		}
		for (int j = 0; j < 26; j++) {
			tmp[j].minn = min(tmp[j].minn, count[j]);
			tmp[j].cnt += cnttmp[j];
		}
	}
	for (int i = 0; i < 26; i++) {
		if(tmp[i].cnt==N){
			for (int j = 0; j < tmp[i].minn; j++) {
				printf("%c", 'a' + i);
			}
		}
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

#約数列挙
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

n,m = na()
k = m/n
a = make_divisors(m)
ans = 0
for i in a:
    if i <= k:
        ans = max(ans,i)

print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>

using namespace std;

int main()
{
	int n, t;
	cin >> n >> t;
	vector<pair<int, int>> e(n);
	for(int i = 0; i < n; i++)
	{
		int c, ti;
		cin >> c >> ti;
		e[i] = {ti, c};
	}
	sort(e.begin(), e.end());
	int minc = 1001;
	for(int i = 0; i < n; i++)
	{
		if(e[i].first > t) break;
		minc = min(minc, e[i].second);
	}
	if(minc == 1001)
	{
		cout << "TLE" << endl;
	}else{
		cout << minc << endl;
	}
	return 0;
}


Measured memory_bytes: 256
n, k = gets.chomp.split.map(&:to_i)

ans = 0

1.upto(n) do |b|
  p, r = n.divmod(b)
  if b > k
    ans += p * (b - k)
    if r - k + 1 > 0
      ans += r - k + 1
    end
    ans -= 1 if k == 0
  end
end

p ans


Measured memory_bytes: 1788
#include<iostream>
using namespace std;
int main(){
  int n;
  int card[4][13]={{}};
  cin >> n;
  char k;
  int a,i;
  for(i=0;i<n;i++) {
    cin >> k >> a;
    switch(k){
    case 'S':
      card[0][a-1]=1;
      break;
    case 'H':
      card[1][a-1]=1;
      break;
    case 'C':
      card[2][a-1]=1;
      break;
    case 'D':
      card[3][a-1]=1;
      break;
    }
  }
  for(i=0;i<52;i++) {
    switch(i/13){
    case 0:
      if(card[0][i%13]==0) cout << "S " << i+1<< endl;
      break;
    case 1:
      if(card[1][i%13]==0) cout << "H " << i%13+1 << endl;
      break;
    case 2:
      if(card[2][i%13]==0) cout << "C " << i%13+1 << endl;
      break;
    case 3:
      if(card[3][i%13]==0) cout << "D " << i%13+1 << endl;
      break;
    }
  }
  
  return 0;
}



Measured memory_bytes: 3080
X = int(input())

if 400 <= X <= 599:
    print("8")
elif 600 <= X <= 799:
    print("7")
elif 800 <= X <= 999:
    print("6")
elif 1000 <= X <= 1199:
    print("5")
elif 1200 <= X <= 1399:
    print("4")
elif 1400 <= X <= 1599:
    print("3")
elif 1600 <= X <= 1799:
    print("2")
elif 1800 <= X <= 1999:
    print("1")
    
    


Measured memory_bytes: 9180
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void *wmem;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void rd(string &x){
  char *buf=(char *)wmem;
  rd(buf);
  x = buf;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  char f[20];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
char memarr[96000000];
int N;
string S[100000];
int main(){
  int i, j;
  long long res=0;
  wmem = memarr;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<(N);Lj4PdHRW++){
      rd(S[Lj4PdHRW]);
    }
  }
  for(i=0;i<(N);i++){
    sort(S[i].begin(), S[i].end());
  }
  sort(S, S+N);
  j = 0;
  for(i=(1);i<(N);i++){
    if(S[i]==S[i-1]){
      j++;
    }
    else{
      j = 0;
    }
    res += j;
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190820-1

// --- original code ---
// int N;
// string S[1d5];
// {
//   int i, j;
//   ll res = 0;
// 
//   rd(N,S(N));
//   rep(i,N) sort(S[i].begin(), S[i].end());
//   sort(S, S+N);
// 
//   j = 0;
//   rep(i,1,N){
//     if(S[i]==S[i-1]) j++;
//     else             j = 0;
//     res += j;
//   }
//   wt(res);
// }


Measured memory_bytes: 5760
# -*- coding: utf-8 -*-
import heapq

n,m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
ab = sorted(ab, key=lambda x:(x[0],-x[1]))
q = []

res = 0
idx = 0
for i in range(1,m+1):
    while idx<n and ab[idx][0]<=i:
        heapq.heappush(q,-ab[idx][1])
        idx += 1

    if len(q)>0:
        res += -q[0]
        heapq.heappop(q)

print(res)


Measured memory_bytes: 39316
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
ll f(ll n){
    return (n*n + 4) / 8;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll k = 1;
    while(k*k <= N) k++;
    print((k-1)*(k-1));


}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int a,b,c; cin >> a >> b >> c;

  if(a==b) cout << c << endl;
  else if(b==c) cout << a << endl;
  else cout << b << endl;
  
  return 0;
}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int N;

vector<i64> A;

int main(){
  cin >> N;
  A.resize(N + 2);
  rep(i,1,N)
    cin >> A[i];
  i64 sum = 0;
  rep(i,0,N)
    sum += abs(A[i] - A[i + 1]);
  rep(i,1,N){
    cout << sum - abs(A[i] - A[i - 1]) - abs(A[i + 1] - A[i]) + abs(A[i + 1] - A[i - 1]) << endl;
  }
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
#define size(a) int((a).size())
#define present(c, x) (c.find(x) != c.end()) 
#define printArray(arr) for (int i = 0; i<size(arr); i++) cout << arr[i] << '\n';cout << '\n'
#define printVerdict(verdict) cout << (verdict ? "Yes": "No") << '\n'
#define printDecimal(d) printf("%.9f\n", d)
#define inrange(val, start, end) (val >= start && val <= end)

const int inf = 0x3f3f3f3f;
const int mod = 998244353;

template <class T1, class T2, class T3> 
void printTuple(tuple<T1, T2, T3> t) {cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << '\n';}
template <class T1, class T2>
void printPair(pair<T1, T2> p) {cout << p.first << " " << p.second << '\n';}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	int a[n];
	for (int i = 0; i<n; i++) cin >> a[i];
	int curr = a[0];
	ll ret = 0;
	for (int i = 1; i<n; i++) {
		if (a[i] >= curr) curr = a[i];
		else ret += curr - a[i];
	}
	cout << ret << '\n';
}


Measured memory_bytes: 4348
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) ((int)(x).size())

typedef	long long ll;

int main(void)
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	string s; cin >> s;

	if (SZ(s) %2)
		cout << "No" << endl;
	else
	{
		for (int i(0); i < SZ(s); i += 2)
			if (s[i] != 'h' or s[i+1] != 'i')
			{
				cout << "No" << endl;
				return 0;
			}
		cout << "Yes" << endl;
	}
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

//using namespace std;

int main()
{
    uint32_t nn;

    int a_mat[3][3] = {
        {0, 0, 0},
        {0, 0, 0},
        {0, 0, 0},
    };

    int ans_mat[3][3] = {
        {0, 0, 0},
        {0, 0, 0},
        {0, 0, 0},
    };

    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            std::cin >> a_mat[i][j];
        }
    }

    std::cin >> nn;
    std::vector<int> b_vec(nn, 0);

    for(int j = 0; j < nn; j++){
        std::cin >> b_vec[j];
    }

    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < nn; k++){
                if(a_mat[i][j] == b_vec[k]){
                    ans_mat[i][j] = 1;
                }
            }
        }
    }

    if( (ans_mat[0][0] * ans_mat[0][1] * ans_mat[0][2]) ||
        (ans_mat[1][0] * ans_mat[1][1] * ans_mat[1][2]) ||
        (ans_mat[2][0] * ans_mat[2][1] * ans_mat[2][2]) ||
        
        (ans_mat[0][0] * ans_mat[1][0] * ans_mat[2][0]) ||
        (ans_mat[0][1] * ans_mat[1][1] * ans_mat[2][1]) ||
        (ans_mat[0][2] * ans_mat[1][2] * ans_mat[2][2]) ||

        (ans_mat[0][0] * ans_mat[1][1] * ans_mat[2][2]) ||
        (ans_mat[2][0] * ans_mat[1][1] * ans_mat[0][2])
    ){
        std::cout << "Yes" << std::endl;
        return 0;
    }

    std::cout << "No" << std::endl;
    return 0;
}

Measured memory_bytes: 384
N, K = map(int, input().split())
A = list(map(int, input().split()))
AS = [A[0]]
b = [max(A[0], 0)]
for i in range(N - 1):
    AS.append(AS[i] + A[i + 1])
    b.append(b[i] + max(A[i + 1], 0))
ans = -1
if N == 1 or N == K:
    ans = max(sum(A), 0)
for i in range(N - K):
    c = max(AS[i + K] - AS[i], 0)
    ans = max(ans, b[-1] - b[i + K] + b[i] + c)
print(ans)

Measured memory_bytes: 17472
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5;

int par[MAX_N+1], ran[MAX_N+1];

void init(int n){
  for(int i = 0; i < n; i++){
    par[i] = i;
    ran[i] = 0;
  }
}

int find(int x){
  if(par[x] == x){
    return x;
  } else{
    return par[x] = find(par[x]);
  }
}

void unite(int x, int y){
  x = find(x);
  y = find(y);
  if(x == y) return;

  if(ran[x] < ran[y]){
    par[x] = y;
  } else {
    par[y] = x;
    if(ran[x] == ran[y]) ran[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

int main(){
  int N, M;
  cin >> N >> M;
  int p[N+1];
  int pos[N+1];
  for(int i = 1; i <= N; i++){
    cin >> p[i];
    pos[p[i]] = i;
  }
  init(N+1);
  for(int i = 0; i < M; i++){
    int x, y;
    cin >> x >> y;
    unite(x, y);
  }
  int c = 0;
  for(int i = 1; i <= N; i++){
    if(p[i] != i && !(same(pos[i],i))) c++;
  }
  cout << N - c << endl;
  return 0;
}


Measured memory_bytes: 1792
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

h,a = m()

b = l()

b.sort(reverse = True)

co = 0
for i in range(h):
    if a > 0:
        a -= 1
    else:
        co += b[i]

print(co)




Measured memory_bytes: 79184
#include<bits/stdc++.h>
using namespace std;

int main(){
  int n;
  cin >> n;
  int x = ceil(n/1.08);
  if ( floor(x * 1.08) == n){
    cout << x << endl;
  } else {
    cout << ":(" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000000)
N, K = list(map(int,input().split()))
ab = [list(map(int, input().split())) for _ in range(N - 1)]
MOD = 1000000007
if N == 1:
    print(K)
    exit()

tree = [[] for _ in range(N)]

for i in range(N - 1):
    tree[ab[i][0] - 1].append(ab[i][1] - 1)
    tree[ab[i][1] - 1].append(ab[i][0] - 1)


ans = K * (K - 1) % MOD

def f(x, y):
    global ans
    count = 2
    for i in range(len(tree[y])):
        if tree[y][i] != x:
            f(y, tree[y][i])
            ans = ans * (K - count) % MOD
            count += 1


first = 0
for i in range(N):
    if len(tree[i]) == 1:
        first = i
        break
f(first, tree[first][0])


print(ans)


Measured memory_bytes: 128468
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<iomanip>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{"; for(auto nth : list){ cout << nth << " ";}cout << "}" << endl;

using namespace std;

int main(){
	int n,w,h,s,t,x,y;

	while(true){
		cin>>n;
		if(n==0)break;
		cin>>w>>h;
		int f[100][100];
		for(int i=0;i<100;i++)for(int j=0;j<100;j++)f[i][j]=0;
		for(int i=0;i<n;i++){
			cin>>x>>y;
			f[x-1][y-1]=1;
		}
		cin>>s>>t;
		int max=0;
		for(int i=0;i<w-s+1;i++)for(int j=0;j<h-t+1;j++){
			int tr=0;
			for(int k=0;k<s;k++)for(int l=0;l<t;l++){
				if(f[i+k][j+l]==1)tr+=1;
			}
			if(tr>max)max=tr;
		}
		cout<<max<<endl;
	}
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
typedef long long ll;


int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i,N){
    cin >> A[i];
  }
  sort(all(A),greater<int>());
  map<int,int> m;
  int ans = 0;
  for(int a:A){
    if(m.count(a) && m[a]>0) m[a]--,ans++;
    else m[(1<<(32-__builtin_clz(a))) - a]++;
    //最上位ビットの次に立っているビットの数 - a
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 10496
h,w = map(int, input().split())
s = [input() for _ in range(h)]

nums = [[] for _ in range(h)]
for i in range(h):
  for j in range(w):
    if s[i][j] == "#": nums[i].append("#")
    else:
      t = 0
      for a in range(i-1, i+2):
        if a < 0 or h <= a: continue
        for b in range(j-1, j+2):
          if b < 0 or w <= b: continue
          if s[a][b] == "#": t += 1
      nums[i].append(t)

for i in nums: print(*i, sep="")

Measured memory_bytes: 9120
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
// template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE


typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define Mod 1000000007
#define MAX 5002

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n;cin>>n;
	ll b[n-1];For(i,0,n-1) cin>>b[i];
	ll sum = 0;
	ll c = 0;
	For(i,0,n){
		if(i==0) sum+=b[0];
		else if(i==n-1) sum+=b[n-2];
		else {
			sum+=min(b[c],b[c+1]);
			c++;
		}
	}
	cout<<sum<<endl;






























	
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

#define INC(i, a, b) for(int i = a; i < b; ++i)
#define DEC(i, a, b) for(int i = a; i > b; --i)
#define REP(i, n) INC(i, 0, n)

typedef unsigned int uint;
typedef unsigned long ul;
typedef long long  ll;
typedef unsigned long long ull;

using namespace std;

void TFprint(bool b, std::string T, std::string F){
    if(b){
        cout << T << endl;
    }else{
        cout << F << endl;
    }
}

int main(){
    int n, a, b;
    cin >> n,
    cin >> a,
    cin >> b;
    
    TFprint((b - a) % 2 == 0, "Alice", "Borys");
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;

int par[100001];
int depth[100001];

void init(int n){
    for(int i=0; i < n; i++){
        par[i]=i;
        depth[i]=0;
        }
}

int find(int x){
    if (par[x] == x){
        return x;
    }
    else{
        return par[x] = find(par[x]);
    }
}

void unite(int x, int y){
    x = find(x);
    y = find(y);
    if (x==y) return ;

    if(depth[x] < depth[y]){
        par[x] = y;
    }
    else{
        par[y] = x;
        if (depth[x] == depth[y]){
            depth[x]++;
        }
    }
}

bool same(int x, int y){
    return find(x)==find(y);
}


int main(void){
    int N , M;
    int p[100002];

    cin >> N >> M;

    init(N);

    int P;

    for(int i = 0; i < N ; i++){
        cin >> P;
        p[i] = P-1;
    }

    int x, y;
    for(int i = 0; i < M ; i++){
        cin >> x >> y;
        unite(p[x-1], p[y-1]);
    }

    int ans=0;

    for(int i = 0; i < N ;i++){
        if (same(p[i], i)){
            ans++;
        }
    }

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


Measured memory_bytes: 1408
N,M=map(int,input().split())
xy=[list(map(int,input().split())) for _ in [0]*M]
n = [1]*N
r = [0]*N
r[0] = 1
for x,y in xy:
    x-=1;y-=1
    n[x] -= 1
    n[y] += 1
    r[y] = r[y] or r[x]
    if n[x] == 0 : r[x] = 0
print(sum(r))

Measured memory_bytes: 28948
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int p[11];
int main(){
  int n; cin >> n;
  rep(i,n){
    cin >> p[i];
  }
  sort(p,p+n);
  int ans = 0;
  rep(i,n-1){
    ans+=p[i];
  }
  ans+=p[n-1]/2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}

int x[10],y[10];

double dis (int i, int j){
    int dx = abs(x[i]-x[j]);
    int dy = abs(y[i]-y[j]);

    return  sqrt(dx*dx + dy*dy);
 }
 //あとで取る
 
 
int main(){
    int N;
    cin >> N;

    repr(i,1,N+1)cin >>x[i]>>y[i];

    double sum = 0.0;
    vector<int>per(N);
    for(int i = 0; i<N; i++)per[i] = i+1;

    do{
        for(int i = 0; i<N-1; i++)sum +=dis(per[i],per[i+1]);
    } while(next_permutation(per.begin(),per.end()));
    int Factorial = 1;
    for(int i = 2; i <= N; i++) Factorial *= i;
    cout << fixed << setprecision(10) << sum / Factorial << endl;

 
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s,t;
	cin >> s;
	cin >> t;
	long long l=0;
	for(long long i=0; i<s.size(); i++){
		if(s[i] != t[i]) l++;
	}
	
	cout << l << endl;
}


Measured memory_bytes: 3916
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;

int main(void){
   ll n,u,v;cin>>n>>u>>v;u--,v--;
   vector<vector<int>> t(n);
   rep(i,n-1){
       int a,b;cin>>a>>b;a--;b--;
       t[a].push_back(b);
       t[b].push_back(a);
   }
   vector<ll> T(n,-1),A(n,-1);
   queue<int> que;
   que.push(u);
   T[u]=0;
   while(que.size()){
       int x=que.front();que.pop();
       rep(i,t[x].size()){
           int y=t[x][i];
           if(T[y]!=-1)continue;
           T[y]=T[x]+1;
           que.push(y);
       }
   }
   que.push(v);A[v]=0;
   while(que.size()){
       int x=que.front();que.pop();
       rep(i,t[x].size()){
           int y=t[x][i];
           if(A[y]!=-1)continue;
           A[y]=A[x]+1;
           que.push(y);
       }
   }
   ll res=0;
   rep(i,n){
       if(A[i]<=T[i])continue;
       chmax(res,A[i]-1);
   }
   cout<<res<<endl;
}

Measured memory_bytes: 7424
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val robos = Array<Robo?>(n){null}

    repeat(n) { idx ->
        val (x, l) = readLine()!!.split(" ").map { it.toInt() }
        robos[idx] = Robo(x, l, x-l, x+l)
    }

    robos.sortBy { it?.x }

    var cnt = 0
    var max = 0
    robos.forEachIndexed { index, robo ->
        if (index == 0) {
            max = robo!!.max
            return@forEachIndexed
        }
        if (max > robo!!.min) {
            cnt++
            max = Math.min(max, robo!!.max)
        } else {
            max = robo!!.max
        }
    }

    println(n - cnt)
}

data class Robo(val x: Int, val l: Int, val min: Int, val max: Int)

Measured memory_bytes: 77976
#include <stdio.h>
int main(void){
    int m[50], f[50], r[50];
    int i, j, count = 0;
    int sum[50] = {0};

    for(i = 0; i < 50; i++){
        scanf("%d %d %d", &m[i], &f[i], &r[i]);
        if(m[i] == -1 && f[i] == -1 && r[i] == -1) break;
        count += 1;
    }

    for(i = 0; i < count; i++){
        if(!(m[i] == -1 && f[i] == -1)){
            if(m[i] == -1 || f[i] == -1)  puts("F");           
            else if(m[i] + f[i] >= 80)  puts("A");
            else if(m[i] + f[i] >= 65 && m[i] + f[i] < 80)  puts("B");
            else if(m[i] + f[i] >= 50 && m[i] + f[i] < 65)  puts("C");
            else if(m[i] + f[i] >= 30 && m[i] + f[i] < 50){
                if(r[i] >= 50) puts("C");
                else puts("D");
            }
            if(m[i] + f[i] < 30)  puts("F");
        }
    }
    return 0;
}


Measured memory_bytes: 2068
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n, k, c;
string s;
llint l[200005], r[200005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> k >> c;
	cin >> s;
	s = "#" + s;
	
	llint p = n+1, cnt = 0, pre = n+1;
	for(int i = n; i >= 1; i--){
		if(s[i] == 'x') continue;
		if(i >= p) continue;
		llint np = i-c;
		for(int j = i+1; j <= pre; j++) r[j] = cnt;
		cnt++;
		p = np;
		pre = i;
	}
	for(int j = 1; j <= pre; j++) r[j] = cnt;
	
	p = 0, cnt = 0;
	for(int i = 1; i <= n; i++){
		if(s[i] == 'x') continue;
		if(i <= p) continue;
		if(r[i+1] + cnt < k) cout << i << endl;
		llint np = i+c;
		for(int j = p; j < np; j++) l[j] = cnt;
		cnt++;
		p = np;
	}
	for(int j = p+1; j <= n; j++) l[j] = cnt;
	
	//for(int i = 1; i <= n; i++) cout << l[i] << " "; cout << endl;
	//for(int i = 1; i <= n; i++) cout << r[i] << " "; cout << endl;
	return 0;
}

Measured memory_bytes: 4944
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    char s[19+5];
    scanf("%s",s);
    for(int i = 0 ; i < 19 ; i++){
        if(s[i]!=',')
            printf("%c",s[i]);
        else
            printf(" ");
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
template <class T> bool chmax(T &a,const T &b) {if(a<b) {a=b;return 1;} return 0;}
template <class T> bool chmin(T &a,const T &b) {if(b<a) {a=b;return 1;} return 0;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

bool dpx[4001][17000];
bool dpy[4001][17000];
signed main() {
    string s;
    cin>>s;
    int x,y;
    cin>>x>>y;

    int cnt=0;
    int step_x=0;
    int step_y=0;
    dpx[0][8500]=dpy[0][8500]=1;
    s+="T";
    FORE(c,s) {
        if(c=='T') {
            if((step_x+step_y)==0) {  // X
                if(8500+cnt<17000) dpx[1][8500+cnt]=1;
                step_x++;
            }
            else if((step_x+step_y)%2==0) {  // X
                REP(X,17000) {
                    if(dpx[step_x][X]) {
                        if(X-cnt>=0) dpx[step_x+1][X-cnt]=1;
                        if(X+cnt<17000) dpx[step_x+1][X+cnt]=1;
                    }
                }
                step_x++;
            } else {  // Y
                REP(Y,17000) {
                    if(dpy[step_y][Y]) {
                        if(Y-cnt>=0) dpy[step_y+1][Y-cnt]=1;
                        if(Y+cnt<17000) dpy[step_y+1][Y+cnt]=1;
                    }
                }
                step_y++;
            }
            cnt=0;
        } else {
            cnt++;
        }
    }
    cout<<(dpx[step_x][x+8500]&&dpy[step_y][y+8500]?"Yes":"No")<<endl;
    return 0;
}


Measured memory_bytes: 130048
#include<bits/stdc++.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int main(){

	int a;
	cin>>a;
	cout<<a+a*a+a*a*a<<endl;

	return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	cin>>a;
	if(a[0]=='Y'&&a[1]=='A'&&a[2]=='K'&&a[3]=='I')
		cout<<"Yes";
	else
		cout<<"No";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;

int main()
{
    int n,ans=0;
    cin>>n;
    vector<int> p(n);
    for(int i=0;i<n;i++)
        cin>>p[i];
    for(int i=0;i<n-2;i++)
        if((p[i]<p[i+1]&&p[i+1]<p[i+2])||(p[i]>p[i+1]&&p[i+1]>p[i+2]))
            ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  int a; cin>>a;
  int b; cin>>b;
  if(a <= 5){
    cout<<0<<endl;
  }else if(a <= 12 ){
    cout<<b/2<<endl;
  }else{
    cout<<b<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define fast_in_out  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main()
{
    fast_in_out;
    string s;
    cin >> s;
    int c = 0;
    if(s[0] == 'R')
    {
        c++;
        if(s[1] == 'R')
        {
            c++;
            if(s[2] == 'R')
            {
                c++;
            }
        }
    }
    else if(s[1] == 'R')
    {
        c++;
        if(s[2] == 'R')
        {
            c++;
        }
    }
    else if(s[2] == 'R')
    {
        c++;
    }
    cout << c;
}


Measured memory_bytes: 3596
#include <iostream>
#include "math.h"
#include "stdio.h"

using namespace std;

int main(){
    int n;
    double m,a = 0,sum = 0;
    int score[1000];
    while(1){
        cin >> n;
        if(n == 0){
            break;
        }
        a = 0;
        sum = 0;
        for(int i = 0;i < n;++i){
            cin >> score[i];
            sum += score[i];
        }
        m = sum / n;
        for(int i = 0;i < n;++i){
            a += (score[i] - m) * (score[i] - m) / n;
        }
        a = sqrt(a);
        printf("%.8lf\n",a);
    }
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int &e : A) {
    cin >> e;
  }
  
  int pos = 0;
  for (int i = 0; i < N; i++) {
    if(A[A[i]-1] == i+1) {
      pos += 1;
    }
  }
  
  cout << pos/2 << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace std;
using P=pair<int,int>;
using G=vector<vector<int>>;
using ll=long long;

string subsum(int* A,int n,int m){
  bitset<2010> E(1);

  rep(i,0,n){
    E |= (E<<A[i]);
  }

  if(E.test(m)) return "yes";
  else return "no";
}

vector<bool> seen;
vector<int> d;
vector<int> f;
#define pi 3.141592653589793


int main(int argc,char **argv){
  long double a,b,x; cin>>a>>b>>x;
  cout<<fixed<<setprecision(10);

  if((b*a*a/2)<x){
    long double rad=atan((a*a*a)/(2*(a*a*b-x)));
    cout<<90.0 - rad*180.0/pi<<endl;
  }else{
    long double rad=atan((2*x)/(a*b*b));
    cout<<90.0 - rad*180.0/pi<<endl;
  }
  }

Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ky112233
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BBreakNumber solver = new BBreakNumber();
        solver.solve(1, in, out);
        out.close();
    }

    static class BBreakNumber {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int num = 2;
            while (num <= n) num *= 2;
            out.println(num / 2);
        }

    }
}



Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;

int main(){
  char C;
  cin  >> C;
  if(C == 'a'){
    cout << 'b' << endl;
  }
  else if(C == 'b'){
    cout << 'c' << endl;
  }
  else if(C == 'c'){
    cout << 'd' << endl;
  }
  else if(C == 'd'){
    cout << 'e' << endl;
  }
  else if(C == 'e'){
    cout << 'f' << endl;
  }
  else if(C == 'f'){
    cout << 'g' << endl;
  }
  else if(C == 'g'){
    cout << 'h' << endl;
  }
  else if(C == 'h'){
    cout << 'i' << endl;
  }
  else if(C == 'i'){
    cout << 'j' << endl;
  }
  else if(C == 'j'){
    cout << 'k' << endl;
  }
  else if(C == 'k'){
    cout << 'l' << endl;
  }
  else if(C == 'l'){
    cout << 'm' << endl;
  }
  else if(C == 'm'){
    cout << 'n' << endl;
  }
  else if(C == 'n'){
    cout << 'o' << endl;
  }
  else if(C == 'o'){
    cout << 'p' << endl;
  }
  else if(C == 'p'){
    cout << 'q' << endl;
  }
  else if(C == 'q'){
    cout << 'r' << endl;
  }
  else if(C == 'r'){
    cout << 's' << endl;
  }
  else if(C == 's'){
    cout << 't' << endl;
  }
  else if(C == 't'){
    cout << 'u' << endl;
  }
  else if(C == 'u'){
    cout << 'v' << endl;
  }
  else if(C == 'v'){
    cout << 'w' << endl;
  }
  else if(C == 'w'){
    cout << 'x' << endl;
  }
  else if(C == 'x'){
    cout << 'y' << endl;
  }
  else if(C == 'y'){
    cout << 'z' << endl;
  }
}

Measured memory_bytes: 256
// @ts-check
'use strict';
/** @param {string} input */

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }

function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

function main(input) {
  var _input$split$map = input.split(/\s/).map(Number),
      _input$split$map2 = _slicedToArray(_input$split$map, 4),
      H = _input$split$map2[0],
      W = _input$split$map2[1],
      h = _input$split$map2[2],
      w = _input$split$map2[3];

  console.log((H - h) * (W - w));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim());

Measured memory_bytes: 21064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int L,R,D; cin >> L >> R >> D;
    int ans = 0;
    for (int i = L; i <= R; i++) {
        if (i%D==0) ans++;
    }
    cout << ans << ln;
}


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    
    vector<int> a(N);
    for (int i=0;i<N;i++) cin >> a.at(i);
    sort(a.begin(),a.end());
    
    for (int i=0;i<N-1;i++){
        if (a.at(i)==a.at(i+1)){
            cout << "NO" << endl;
            return 0;
        }
    }
    
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
//#define int long long
#define rep(i, n) for (int i=0; i<n; i++)
#define REP(n) rep(i, n)
using namespace std;

int n, hh, mm; 
char colon;
float tansin, tyousin, sa; 

signed main()
{
    cin >> n;

    REP(n)
    {   
        cin >> hh >> colon >> mm; 
        //printf("hh = %d, mm = %d\n", hh, mm);

        tansin = 30.0 * hh + 0.5 * mm; 
        tyousin = 6.0 * mm; 

        float saki = fmax(tansin, tyousin);
        float ato = fmin(tansin, tyousin);

        sa = fmin(saki - ato, 360.0 - saki + ato);
        //printf("sa = %f\n", sa);

        if (0.0 <= sa && sa < 30.0)
        {   
            cout << "alert" << endl;
        } else if (90.0 <= sa && sa <= 180.0) {
            cout << "safe" << endl;
        } else {
            cout << "warning" << endl;
        }   
    }   

    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
int H[MAX_N];

void solve() {
	cin >> N;
	int mv = -1;
	int res = 0;
	rep(i, 0, N) {
		cin >> H[i];
		res += (mv <= H[i]);
		MAX(mv, H[i]);
	}
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int arr[40];
int main()
{
    int n,m,cnt=0;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        int k,num;
        cin>>k;

        for(int i=1; i<=k; i++)
        {
            cin>>num;
            arr[num]++;

        }
    }
    for(int j=1; j<=m; j++)
    {

        if(arr[j]==n)
            cnt++;
    }
    cout<<cnt<<endl;
    return 0;





}


Measured memory_bytes: 256
n = gets.chomp.to_i
nodes = []
n.times do
    id, left, right = gets.chomp.split.map(&:to_i)
    nodes[id] = { id: id, left: left, right: right, parent: nil, sibling: nil, degree: nil, depth: nil, height: nil, type: nil }
end

nodes.each do |node|
    children = [node[:left], node[:right]]
    children.each do |c|
        if c != -1 then
            nodes[c][:parent] = node[:id]
        end
    end
    if children.count(-1) == 2 then
        node[:type] = "leaf"
        node[:degree] = 0
    elsif children.count(-1) == 1 then
        node[:type] = "internal node"
        node[:degree] = 1
    else
        node[:type] = "internal node"
        node[:degree] = 2
    end
end

nodes.each do |node|
    if node[:parent] == nil then
        node[:parent] = -1
        node[:sibling] = -1
        node[:type] = "root"
        break
    end
end

nodes.each do |node|
    next if node[:sibling] != nil
    node[:sibling] = -1
    nodes.each do |anotherNode|
        next if node[:id] == anotherNode[:id]
        if node[:parent] == anotherNode[:parent] then
            node[:sibling] = anotherNode[:id]
            anotherNode[:sibling] = node[:id]
        end
    end
end

nodes.each do |node|
    depth = 0
    parent = node[:parent]
    until parent == -1 do
        parent = nodes[parent][:parent]
        depth += 1
    end
    node[:depth] = depth
end

def getHeight(nodes, id, height)
    height += 1
    leftHeight = height
    rightHeight = height
    leftHeight = getHeight(nodes, nodes[id][:left], leftHeight) unless nodes[id][:left] == -1
    rightHeight = getHeight(nodes, nodes[id][:right], rightHeight) unless nodes[id][:right] == -1
    return [leftHeight, rightHeight].max
end

nodes.each do |node|
    height = -1
    height = getHeight(nodes, node[:id], height)
    node[:height] = height
end

# nodes.each { |node| p node }
nodes.each { |node| puts "node #{node[:id]}: parent = #{node[:parent]}, sibling = #{node[:sibling]}, degree = #{node[:degree]}, depth = #{node[:depth]}, height = #{node[:height]}, #{node[:type]}" }


Measured memory_bytes: 6888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

int main(int argc, char **argv)
{
	ll N, K, S; cin >> N >> K >> S;
	vector<ll> res;
	for (ll i = 0; i < K; ++i)
		res.push_back(S);
	ll t;
	if (S == 1000000000)
		t = 1000000000-1;
	else
		t = 1000000000;
	
	for (ll i = K; i < N; ++i)
		res.push_back(t);
	for (auto e : res)
		std::cout << e << " ";
}

Measured memory_bytes: 2164
#include <iostream>
#include <cstdio>
using namespace std;
int main(void)
{
    int a, b, c;
    int i, count = 0;

    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);

    for(i = 1; i <= c; i++){
        if((c % i) == 0){
            if(i >= a && i <= b)
                count += 1;
        }
    }
    printf("%d\n", count);

    return 0;
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)

static const ll mod = 1e9+7;
ll fact[200005], inv[200005], factinv[200005];

// a^n mod を計算する
long long modpow(long long a, long long n, long long m) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % m;
        a = a * a % m;
        n >>= 1;
    }
    return res;
};

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
};

void init() {
  fact[0] = 1;
  rep(i, 1, 200000) {
    fact[i] = (1ll * fact[i - 1] * i) % mod;
  }
  rep(i, 0, 200000) {
    inv[i] = modinv(i, mod);
    factinv[i] = modinv(fact[i], mod);
  }
};

// nCr
ll modcomb(ll n, ll r, ll m) {
  // n! * inv(r!) * inv((n - r)!) % mod
  return (fact[n] * factinv[r] % m) * factinv[n - r] % m;
};

int main() {
  init();
  ll N, a, b, c;
  cin >> N >> a >> b >> c;
  ll A = a * modinv(a + b, mod) % mod;
  ll B = b * modinv(a + b, mod) % mod;
  ll AN = modpow(A, N, mod);
  ll BN = modpow(B, N, mod);
  ll r = 0;
  for (ll M = N; M < 2 * N; M++) {
    ll tmp = (AN * modpow(B, M - N, mod) % mod + BN * modpow(A, M - N, mod) % mod) % mod;
    tmp = tmp * modcomb(M - 1, N - 1, mod) % mod;
    tmp = tmp * M % mod;
    tmp = tmp * 100 % mod;
    tmp = tmp * modinv(a + b, mod) % mod;
    r = (r + tmp) % mod;
  };
  cout << r << endl;
};


Measured memory_bytes: 4992
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] f = new int[n];
		int sz = 0;
		int[] a = new int[n];
		for (int i = 0; i < n; ++i) {
			a[i] = sc.nextInt();
			if (sz == 0) {
				f[sz] = a[0];
				++sz;
			} else {

				int ok = -1;
				int ng = sz;
				while (ng - ok > 1) {
					int middle = (ok + ng) / 2;
					if (f[middle] < a[i]) {
						ok = middle;
					} else {
						ng = middle;
					}
				}

				f[ok + 1] = a[i];
				if (ok + 1 == sz)
					++sz;
			}
		}
		
		System.out.println(sz);

	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 71072
#include<bits/stdc++.h>

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

using namespace std;

using ll = long long;
using P = pair<pair<string, int>, int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n; cin >> n;
  int a[n];
  P p[n];
  rep(i, n) {
    int x;
    cin >> p[i].first.first;
    cin >> x; p[i].first.second = x*-1;
    p[i].second = i+1;
  }
  sort(p, p+n);
  rep(i, n) {
    cout << p[i].second << '\n';
  }
}

  


Measured memory_bytes: 256