akhauriyash/Code-Regression huggingface dataset:
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数
vector<long long> fact, fact_inv, inv;

//二項係数前処理計算量O(SIZE)
void init_nCk(int SIZE) {
    fact.resize(SIZE + 5);
    fact_inv.resize(SIZE + 5);
    inv.resize(SIZE + 5);
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < SIZE + 5; i++) {
        fact[i] = fact[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
}
    
//nCk　計算量(1)
ll nCk(int n, int k) {
    assert(!(n < k));
    assert(!(n < 0 || k < 0));
    return fact[n] * (fact_inv[k] * fact_inv[n - k] % MOD) % MOD;
}


// xのn乗%modを計算
ll mod_pow(ll x, ll n, ll mod){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res*x%mod;
        x = x*x%mod;
        n >>= 1;
    }
    return res;
}

int main(){
    ll K,N;
    string S;
    cin>>K;
    cin>>S;
    N=S.size();
    ll ans=0;
    init_nCk(10000000);
    REP(i,K+1){
        ans+=((mod_pow(26,i,MOD)*mod_pow(25,K-i,MOD))%MOD*nCk(N+K-(1+i),N-1))%MOD;
        ans%=MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 238592
#include <cstdio>
#include <vector>
using namespace std;

bool binary_search(int target, int low, int high, vector<int>& S) {
	int mid=low+(high-low)/2;
	if(S.at(mid)==target) {
		return true;
	}
	if(low>=high) return false;
	if(S.at(mid)>target) {
		return binary_search(target, low, mid-1, S);
	} else {
		return binary_search(target, mid+1, high, S);
	}
}

int main() {
	int n,q,a,c=0,i,j;
	vector<int> S;
	scanf("%d",&n);
	S.resize(n);
	for(i=0; i<n; ++i) {
		scanf("%d",&S[i]);
	}

	scanf("%d",&q);
	for(j=0; j<q; ++j) {
		scanf("%d",&a);
		if(binary_search(a,0,n-1,S)) ++c;
	}
	printf("%d\n",c);
	return 0;
}

Measured memory_bytes: 2752
use std::io::Read;

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

    let n: i32 = iter.next().unwrap().parse().unwrap();
    let i: i32 = iter.next().unwrap().parse().unwrap();

    println!("{}", n - i + 1);

    ()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define node first
#define weight second
#define MOD 1000000007
typedef pair <int, int> ii;

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef LOCAL_PROJECT
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	int h, w;
	cin >> h >> w;
	char maze[h+5][w+5];
	int ways[h+5][w+5] = {0};
	memset(ways, 0, sizeof(ways));
	for(int i = 1; i <= h; i++)
		for(int j = 1; j <= w; j++)
			cin >> maze[i][j];
	ways[1][1] = 1;
	for(int i = 1; i <= h; i++)
		for(int j = 1; j <= w; j++)
		{
			if(maze[i][j] == '.' && !(i == 1 && j == 1))
				ways[i][j] = (ways[i-1][j] + ways[i][j-1])%MOD;
			else
				continue;
		}
	cout << ways[h][w];
}

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

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

	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) cout << "Possible" << endl;
	else cout << "Impossible" << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int A = sc.nextInt();
        if(H % A == 0){
            System.out.println(H / A);
        }else{
            System.out.println((H / A) + 1);
        }
    }
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
#define ll  long long int
#define mod 1000000007
#define modd 998244353
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
main()
{
    fast;
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n,greater<ll>());
    ll ans = a[0];
    ll j =1;
    ll f=0;
    for(ll i=2;i<n;i++)
    {
        if(f <2 )
        {
            ans+=a[j];
            f++;
        }
        else
        {
            j++;
            ans+=a[j];
            f=1;
        }
        // cout<<a[j]<<" ";
    }
    cout<<ans<<"\n";
}

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

int main() {
  string S;
  cin >> S;
  if(S=="ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;
}


Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,l,r) for(int i=(l);i<(r);i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef long long ll;  //ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;  
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<ll, ll> > PS;
template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b){
    if (a < b){ a = b;return 1;}
    return 0;
}
template <class T, class U> //chmin(min,a)
bool chmin(T &a, U b){
    if (a > b){ a = b; return 1;}
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

// g++ -std=c++11 prac.cpp 
int main(){
    ll x=0,y=0,z=0,n,m=0,k,ans=0,h,w,sum=0,Max=-1e9-1,cnt=0,Min=1e9+1;
    string s,t,u;
    bool ok=true;
    cin >> n;
    VI a(n),b(n),c(n);
    rep(i,n){ a[i] = i+1; }
    rep(i,n){ cin >> b[i]; }
    rep(i,n){ cin >> c[i]; }
    x = -1; y = -1; cnt = 1;
    do {
        if(x == -1){
            rep(i,n){
                if(b[i] != a[i]) break;
                else if(i == n-1) 
                    x = cnt;
            }
        }
        if(y == -1){
            rep(i,n){
                if(c[i] != a[i]) break;
                else if(i == n-1) 
                    y = cnt;
            }
        }
        cnt++;
    } while (next_permutation(ALL(a)));
    cout << abs(x-y) << endl;
    return 0;
}


 

Measured memory_bytes: 384
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const double pi = acos(-1);
const int maxn = 2e6 + 10;
const double eps = 1e-8;
const ll mod = 1e9 + 7;
const ull base = 131;
const ull mod1 = 1e9 + 9;
const ull mod2 = 1610612741;

int a[maxn];

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf("%d", a+i);
	int ans = 1 << 30;
	for (int i = -100; i <= 100; ++i)
	{
		int c = 0;
		for (int j = 1; j <= n; ++j)
			c += (a[j]-i) * (a[j]-i);
		ans = min(ans, c);
	}
	printf("%d", ans);
	return 0;
}

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

signed main() {
  int N;
  cin >> N;
  
  vector<vector<int>> hito(N, vector<int>(N));
  for( int i = 0; i < N; i++ ){
    for( int j = 0; j < N; j++ ){
      hito.at(i).at(j) = -1;
    }
  }
  
  int A, X, Y;
  for( int i = 0; i < N; i++ ){
    cin >> A;
    for( int j = 0; j < A; j++ ){
      cin >> X >> Y;
      hito.at(i).at(X-1) = Y;
    }
  }
  
  int ans = 0;
  for (int bit = 0; bit < (1<<N); ++bit){
    int cnt = 0;
    bool fg = true;
    for (int i = 0; i < N; ++i) {
      if (bit & (1<<i)) {
        for( int j  = 0; j < N; j++ ){
          if (bit & (1<<j)){
            if( hito.at(i).at(j) == 0 ) fg = false;
          }else{
          if( hito.at(i).at(j) == 1 ) fg = false;
          }
        }
        if(fg) cnt++;
      }
    }
    if(fg)ans = max( ans, cnt );
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;


int main() {
    int s,ss,cnt=1;
    cin >> s;
    ss = s;
    map<int,int>mp;
    mp[s]++;
    while (1) {
        cnt++;
        ss = (ss % 2 == 0) ? ss / 2 : 3 * ss + 1;
        if (!mp[ss])mp[ss]++;
        else break;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#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<int,int>;
using Graph = vector<vector<int>>;
int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin>>n;
    int p[n];
    rep(i,n){
        cin>>p[i];
    }
    int cnt=0;
    rep(i,n){
        if(p[i]!=i+1){
            cnt++;
        }
    }
    if(cnt==2||cnt==0)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VL = vector<LL>;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define FILL(a, b) memset(a, b, sizeof(a))

void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    LL x, y;
    cin >> x >> y;
    if (abs(x - y) > 1)
        cout << "Alice\n";
    else
        cout << "Brown\n";
    return 0;
}

Measured memory_bytes: 256
import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline
mii=lambda:map(int,input().split())

# n=4k+3 <=> the line graph works
# these fail: 1 2 4 8 16 32 ...

# 1 2 3 1 2 3
# 4 5 1 4 5
# 6 7 1 6 7

# so n=2k+1 (except n=1) works

def get(n):
    e=[]
    p=1
    while p*2<=n:
        p*=2
    if n!=p:
        # make line graph
        m=n
        while m%4!=3: m-=1
        for i in range(1,m):
            e.append([i,i+1])
            e.append([n+i,n+i+1])
        e.append([m,n+1])
        if n%4==1 or n%4==2:
            m=n
            if n%4==2: m-=1
            e.append([m-1,m])
            e.append([m,n+1])
            e.append([n+1,n+m-1])
            e.append([n+m-1,n+m])
        if n%4==0 or n%4==2:    # not a power of 2
            t=n-1
            e.append([n,t])
            for i in range(1,n+1):
                t^=i
                if t==n:
                    e.append([n+i,n+n])
                    break
    return e

n=int(input())
e=get(n)
if e:
    print("Yes")
    for i,j in e:
        print("%d %d"%(i,j))
else:
    print("No")

"""
def dfs(u):
    vis[u]=1
    root[u]^=(u-1)%n+1
    for v in g[u]:
        if vis[v]: continue
        root[v]=root[u]
        dfs(v)

for n in range(1,50):
    g=[[] for _ in range(2*n+1)]
    e=get(n)
    if not e: continue
    assert len(e)==n*2-1
    for i,j in e:
        g[i].append(j)
        g[j].append(i)
    for i in range(1,n+1):
        vis=[0]*(2*n+1)
        root=[0]*(2*n+1)
        dfs(i)
        assert root[n+i]==i
"""


Measured memory_bytes: 38876
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

func input() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	n, _ := strconv.Atoi(input())
	a := make([]int, n)
	b := make([]int, n)
	for i := 0; i < n; i++ {
		a[i], _ = strconv.Atoi(input())
	}

	copy(b, a)
	sort.Sort(sort.Reverse(sort.IntSlice(b)))

	firstMax := b[0]
	secondMax := b[1]

	for i := 0; i < n; i++ {
		if a[i] == firstMax {
			fmt.Println(secondMax)
		} else {
			fmt.Println(firstMax)
		}
	}
}


Measured memory_bytes: 7552
dy = (-1,0,1,0)
dx = (0,1,0,-1)

h,w = map(int,input().split())
grid = [input() for _ in range(h)]

ans = 0
dist = [[-1] * w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if dist[i][j] < 0:
            odd = 0
            even = 1
            dist[i][j] = 0
            stack = [(i,j)]
            while stack:
                a,b = stack.pop()
                if grid[a][b] == '#':
                    for k in range(4):
                        y = a + dy[k]
                        x = b + dx[k]
                        if y < 0 or y >= h:
                            continue
                        if x < 0 or x >= w:
                            continue
                        if grid[y][x] == '.' and dist[y][x] < 0:
                            if dist[a][b] == 0:
                                dist[y][x] = 1
                                odd += 1
                            else:
                                dist[y][x] = 0
                                even += 1
                            stack.append((y,x))
                else:
                    for k in range(4):
                        y = a + dy[k]
                        x = b + dx[k]
                        if y < 0 or y >= h:
                            continue
                        if x < 0 or x >= w:
                            continue
                        if grid[y][x] == '#' and dist[y][x] < 0:
                            if dist[a][b] == 0:
                                dist[y][x] = 1
                                odd += 1
                            else:
                                dist[y][x] = 0
                                even += 1
                            stack.append((y,x))    
            ans += even * odd
print(ans)

Measured memory_bytes: 12136
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
int main(){
    ll n,ma,mb;cin >> n >>ma >>mb;
    vl a(n),b(n),c(n);
    rep(i,n)cin >> a[i] >>b[i] >>c[i];
    ll ans=INF;
    ll ia=ma,ib=mb;
    while(ma<=400&&mb<=400){
        ll dp[ma+1][mb+1];
        rep(j,ma+1)rep(k,mb+1)dp[j][k]=inf;
        dp[0][0]=0;
        rep(i,n){
            per(j,ma+1){
                per(k,mb+1){
                    if(j+a[i]<=ma&&k+b[i]<=mb){
                        chmin(dp[j+a[i]][k+b[i]],dp[j][k]+c[i]);
                    }
                }
            }
        }
        if(dp[ma][mb]!=inf){
            chmin(ans,dp[ma][mb]);
        }
        ma+=ia;
        mb+=ib;
    }
    if(ans!=INF)cout <<ans <<endl;
    else cout << -1 <<endl;
}

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

int main() {
  string s;
  cin>>s;
  int ans = 1000;
  for(int i=0; i<s.size()-2; i++){
    int n = (s[i]-'0') * 100 + (s[i+1]-'0') * 10 + s[i+2]-'0';
    ans=min(ans,abs(n-753));
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int x=0,i,j,a[5],t;
	for(i=0;i<3;i++) scanf("%d", &a[i]);
	for(i=0;i<3;i++){
		for(j=i+1;j<3;j++){
			if(a[i]<a[j]){
				t=a[i];
				a[i]=a[j];
				a[j]=t;
			}
		}
	}
		x=(a[0]-a[1])+a[1]-a[2];
		printf("%d\n", x);
		return 0;
	}
		
				
				
	

Measured memory_bytes: 128
#include <queue>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

using ll = long long;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

#if __has_include("debugger.cpp")
  #include "debugger.cpp"
#else
void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) > 0) cout << " ";
  print(std::forward<Tail>(tail)...);
}
# endif

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

int main() {
  ll input(n, x, y);
  vector<vector<ll>> graph(n);
  REP(i, n - 1) {
    graph[i].push_back(i + 1);
    graph[i + 1].push_back(i);
  }
  graph[x - 1].push_back(y - 1);
  graph[y - 1].push_back(x - 1);

  struct Args {
    ll to, cost;
  };
  vector<vector<ll>> visited(n, vector<ll>(n, -1));
  // auto comp = [](Args &v1, Args &v2){
  //   return v1.cost > v2.cost;
  // };
  REP(i, n) {
    // priority_queue<Args, vector<Args>, decltype(comp)> que{comp};
    queue<Args> que;
    que.push({i, 0});
    while(!que.empty()) {
      Args args = que.front();
      // Args args = que.top();
      que.pop();
      if (visited[i][args.to] != -1) continue;

      visited[i][args.to] = args.cost;
      for(auto v: graph[args.to]) {
        que.push({v, args.cost + 1});
      }
    }
  }

  // print(visited);
  map<ll, ll> cnt;
  for(auto v: visited) {
    for(auto value: v) {
      cnt[value]++;
    }
  }

  REP(i, n - 1) {
    print(cnt[i + 1] / 2);
  }
}


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

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

	int N, ans;

	cin >> N;

	for (int i=N; i>=0; i=i-1)
	{
		int counter=0;
      	int tmp = i;
		while(tmp!=0)
		{
			tmp/=10;
			++counter;
		}
		if (counter%2==1)
		{
			++ans;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int n;
  cin>>n;
  int v[n];
  ll ans=0;
  rep(i,0,n) cin>>v[i];
  ans++;
  int mx=v[0];
  rep(i,1,n){
    if(v[i]>=mx){
      mx=v[i];
      ans++;
    }
  }
  cout<<ans<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3644
import sys
input = sys.stdin.readline
from collections import Counter

n = int(input())
A = sorted(map(int, input().split()), reverse=True)
C = Counter(A)
ans = 0
for a in A:
  if not C[a]:
    continue
  r = (1<<a.bit_length()) - a
  if r != a:
    if r in C and C[r] > 0:
      ans += 1
      C[r] -= 1
  else:
    if C[r] >= 2:
      ans += 1
      C[r] -= 1
  C[a] -= 1
print(ans)

Measured memory_bytes: 33424
#include<cstdio>
int main(){
    int n,p,a,odd=0,even=0;
    scanf("%d%d",&n,&p);
    for(int i=0;i<n;i++){
        scanf("%d",&a);
        if(a%2==0)even++;
        else odd++;
    }
    printf("%lld",(odd==0)?(p==1?0:(long long)1<<n):((long long)1<<(n-1)));
    return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int h[100005];
int dp[100005];

int main()
{
    int n;
    cin >> n;
    for(int i = 1; i <= n; ++i)
        cin >> h[i];
    dp[0] = 1e9;
    for(int i = 2; i <= n; ++i)
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    cout << dp[n];
    return 0;
}


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


#define fast_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
using lli = long long int;
using ll = long long ;
using ld=long double;
using d= double;

signed main(){
    fast_IO;
    int t=1;
    //cin>>t;
    while(t--){
        int n,k;
        cin>>n>>k;
        vector<ll> a(n);
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        sort(a.begin(),a.end());
        ll d=INT_MAX;
        for(int i=0;i<=n-k;i++){
            if(a[i+k-1]-a[i]<d){
                d=a[i+k-1]-a[i];
            }
        }
        cout<<d<<endl;
    }   
    return 0;
}


Measured memory_bytes: 3948
import math
A,B,H,M = map(int,input().split())
V1 = 30
V2 = 30/60
v = 6
d = abs( (V1*H + V2*M) - v*M)
print(math.sqrt(A**2 + B**2 -2*A*B*math.cos(math.radians(d))))

Measured memory_bytes: 9496
//Heaplax
//别让自己后悔
#include<bits/stdc++.h>
#define LL long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
struct node
{
	int len,sum;
	int s[555555];
	void in()
	{
		while(ch=getchar(),ch>'!')
		{
			++len;
			s[len]=ch-48;
		}
		reverse(s+1,s+len+1);
	}
	void calc(int x)
	{
		for(int i=1;i<=len;++i)s[i]*=x;
		for(int i=1;i<=len;++i)
		{
			s[i+1]+=s[i]/10;
			s[i]%=10;
			if(i==len&&s[i+1])++len;
		}
		sum=0;
		for(int i=1;i<=len;++i)
			sum+=s[i];
	}
	void add(int x)
	{
		for(int i=1;i<=len;++i)
		{
			sum-=s[i];
			s[i]+=x%10;
			x/=10;
			if(s[i]>=10)
				s[i]-=10,++x;
			sum+=s[i];
			if(!x)return;
			if(i==len)++len;
		}
	}
}a;
int main()
{
	a.in();
	a.calc(9);
	for(int i=1;;++i)
	{
		a.add(9);
		if(a.sum<=i*9)
		{
			printf("%d\n",i);
			return 0;
		}
	}
}
/*

*/


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

int main()
{
    int n, m;
    cin >> n >> m;

    cout << (n - 1) * n / 2 + (m - 1) * m / 2 << endl;

    return 0;
}

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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  vecll alpha(3, 0);
  string s;
  cin >> s;
  forll(i, 0, s.size())
	alpha[s[i] - 'a']++;
  sort(alpha.begin(), alpha.end());
  if(alpha[2] - alpha[0] > 1)
	cout << "NO" << endl;
  else
	cout << "YES" << endl;
}



Measured memory_bytes: 512
def resolve():
    '''
    code here
    '''
    sx, sy, tx, ty = [int(item) for item in input().split()]

    gx = tx - sx
    gy = ty - sy

    def r(num):
        return 'R'*num
    
    def l(num):
        return 'L'*num
    
    def u(num):
        return 'U'*num

    def d(num):
        return 'D'*num

    first_trail = l(1) + u(gy+1) + r(gx+1) + d(gy+1) + l(gx)
    second_trail = u(gy) + r(gx+1) + d(gy+1) + l(gx+1) + u(1)

    print(first_trail + second_trail)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9016
//2019.8.3 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f
#define eps 5.6e-8
#define RG register
#define db double
#define pc(x) __builtin_popcount(x)
typedef pair<int,LL> Pair;
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pb push_back
#define gc getchar
//inline char gc() {
//    static char buf[100000],*p1,*p2;
//    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
//inline int read() {
//    res s=0,ch=gc();
//    while(ch<'0'||ch>'9')ch=gc();
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s;
//}
inline int read() {
    res s=0,ch=gc(),w=1;
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s*w;
}
inline LL Read() {
    RG LL s=0;
    res ch=gc();
    while(ch<'0'||ch>'9')ch=gc();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s;
}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//clock_t start=clock();
//inline void ck(){
//    if(1.0*(clock()-start)/CLOCKS_PER_SEC>0.1)exit(0);
//}
const int N=1e5+10;
namespace MAIN {
    int n;
    int ans;
    inline int get(res x){
        res ret=0;
        while(x)ret++,x/=10;
        return ret;
    }
    inline void MAIN() {
        n=read();
        for(res i=1;i<=n;i++){
            ans+=get(i)&1;
        }
        printf("%d\n",ans);
    }
}
int main() {
//    srand((unsigned)time(NULL));
//    freopen("nothard.in","r",stdin);
//    freopen("nothard.out","w",stdout);
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    int n;
    cin >> n;

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

    int cnt = 1;
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(a[i] != cnt){
            ans++;
        } else {
            cnt++;
        }
    }

    if(cnt == 1){
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#define lol(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;

int main(){
	string s,t="AKIHABARA";
	cin>>s;
	bool ok=true;
	int a=0;
	for(int i=0;i<t.size();i++){
		if(t[i]==s[a]){
			a++;
		}
		else if(t[i]!='A')ok=false;
	}
	if(a<s.size())ok=false;
	cout<<(ok?"YES":"NO")<<endl;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

#import
#import math
#import numpy as np
#= int(input())
s = input()
#= map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]
#= [list(map(int, input().split())) for _ in range(N)]
#= [int(input()) for _ in range(N)]
#= {i:[] for i in range(N)}

if s[-1] == "s":
    print(s + "es")
else:
    print(s + "s")

Measured memory_bytes: 9108
bingo = [[int(x) for x in input().split()] for _ in range(3)]

N = int(input())

# replace pushed sectors to -1
for _ in range(N):
    push = int(input())
    for i in range(3):
        if push in bingo[i]:
            bingo[i][bingo[i].index(push)] = -1

is_bingo = False
# horizontal / Vertical
for i in range(3):
    if bingo[i][0] == -1 and bingo[i][1] == -1 and bingo[i][2] == -1:
        is_bingo = True
    if bingo[0][i] == -1 and bingo[1][i] == -1 and bingo[2][i] == -1:
        is_bingo = True

# Tilted

if bingo[0][0] == -1 and bingo[1][1] == -1 and bingo[2][2] == -1:
    is_bingo = True

if bingo[2][0] == -1 and bingo[1][1] == -1 and bingo[0][2] == -1:
    is_bingo = True

print("Yes" if is_bingo else "No")

Measured memory_bytes: 3064
import sys
n,y =map(int,input().split())
for a in range(n+1):
  for b in range(n+1-a):
    if 10000*a+5000*b+1000*(n-a-b) == y:
      print(a,b,n-a-b)
      sys.exit()
print(-1,-1,-1)


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

const int N = 100005;

int n, m, v, p, ans = 0, a[N];

bool check(int u) {
    if (a[u] + m < a[n - p + 1]) {
        return false;
    }
    if (u > n - p) {
        return true;
    }
    long long tmp = 0;
    for (int i = 1; i <= n - p + 1; i++) {
        if (u != i) {
            tmp += max(0, min(a[u] + m - a[i], m));
        }
    }
    return tmp >= 1LL * v * m;
}

int find_ans() {
    int l = 1, r = n;
    while (l <= r) {
        int m = (l + r) / 2;
        if (check(m)) {
            r = m - 1;
        } else {
            l = m + 1;
        }
    }
    return r;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m >> v >> p;
    v -= p;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    cout << n - find_ans();
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,t;
  cin >> n >> t;
  vector<vector<int>> r(n,vector<int>(2));
  for(int i=0;i<n;i++){
    for(int j=0;j<2;j++){
      cin >> r.at(i).at(j);
    }
  }
  sort(r.begin(),r.end());
  for(int i=0;i<n;i++){
    if( r.at(i).at(1) <= t ){
      cout << r.at(i).at(0);
      return 0;
    }
  }
  cout << "TLE" << endl;
  
  return 0;
  
}

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


ull gcd(ull a,ull b){
	if(!b) return a;
	return gcd(b,a%b);
}


int main(){
	int d,g,score_memo = 0,cnt_memo = 0,cnt = 1000000000,temp = 0;
	cin >> d >> g;
	int p[d],c[d],bit[d];
	
	rep(i,0,d){
		cin >> p[i] >> c[i];
	}
	
	rep(i,0,pow(2,d)){
		temp = i;
		cnt_memo = 0;
		score_memo = 0;
		rep(j,0,d){
			bit[j] = temp % 2;
			temp /= 2;
			
			if(bit[j]){
				cnt_memo += p[j];
				score_memo += c[j];
				score_memo += (j+1)*100*p[j];
			}
		}
		
		if(score_memo >= g && cnt > cnt_memo){
			cnt = cnt_memo;
		}
		
		rep(j,0,d){
			if(bit[j]){
				continue;
			}
			rep(k,0,p[j]+1){
				//cout << score_memo + (j+1)*100*k << " " << cnt_memo+k << endl;
				if(score_memo + (j+1)*100*k >= g && cnt > cnt_memo+k){
					cnt = cnt_memo+k;
				}
			}
		}
		
		
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{

    long long int k;
    cin>>k;
    long long int ans=0,f=0,nn=0,i;
    for(i=1;i<=7777777;i++)
    {
        //ans++;
         nn=(nn*10+7)%k;

         if(nn==0)
         {

             f=1;
             break;
         }

    }
    if(f==0)
        cout<<"-1\n";
    else
        cout<<i<<endl;
}


Measured memory_bytes: 3592
import java.util.HashMap;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        HashMap<String, String> hashmap = new HashMap<String, String>();
        hashmap.put("Sunny", "Cloudy");
        hashmap.put("Cloudy", "Rainy");
        hashmap.put("Rainy", "Sunny");
        System.out.println(hashmap.get(S));
    }
}

Measured memory_bytes: 20564
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

void dfs(vector<vector<int> >& Graph, int v, int par, int k, ll& ans) {
  int n = (par >= 0) ? k-2 : k-1;
  for(int i=0; i<Graph[v].size(); i++) {
    int w = Graph[v][i];
    if(w != par) {
      ans = (ans * n) % mod;
      n--;
      dfs(Graph, w, v, k, ans);
    }
  }
}

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N), B(N);
  vector<vector<int> > Graph(N);
  rep(i, N-1) {
    cin >> A[i] >> B[i];
    A[i]--; B[i]--;
    Graph[A[i]].push_back(B[i]);
    Graph[B[i]].push_back(A[i]);
  }
  ll ans = K;
  dfs(Graph, 0, -1, K, ans);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 12416
#include<iostream>
#include<complex>
#include<vector>
#include<math.h>
#include<stdio.h>
using namespace std;

typedef complex<double> po;
vector<po>vec;

int main(){
    int N;
    cin>>N;
    if(N%2==1){
        cout<<"NA"<<endl;
        return 0;
    }
    for(int i=0;i<N;i++){
        double x,y;
        cin>>x>>y;
        vec.push_back(po(x,y));
    }
    int fini=1;
    for(int i=0;i<N/2;i++){
        double l1=abs(vec[i]-vec[(i+1)%N]);
        double l2=abs(vec[N/2+i]-vec[(N/2+i+1)%N]);
        double d1=abs(vec[i]-vec[(i+N/2+1)%N]);
        double d2=abs(vec[i+1]-vec[(i+N/2)%N]);
        if(abs(l1-l2)>=1e-5||abs(d1-d2)>=1e-5){
            fini=0;
            break;
        }
    }
    if(fini==0)
        cout<<"NA"<<endl;
    else{
        double x=0,y=0;
        for(int i=0;i<N;i++){
            x+=vec[i].real();
            y+=vec[i].imag();
        }
        printf("%.6f %.6f\n",x/N,y/N);
    }
    return 0;
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
//ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
//ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  ll a,v,b,w,t;
  cin>>a>>v>>b>>w>>t;
  if(v<=w){
    out("NO"); return;
  }
  ll p=abs(a-b),q=abs(v-w);
  if(p>q*t) out("NO");
  else out("YES");
}

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


Measured memory_bytes: 3652
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999
//#define INF (1LL<<59(
 
 
#define GRID_Y 300
#define GRID_X 300
#define WALL '#'
int h,w;
string data[GRID_Y];
void grid_bfs(int sy,int sx,int d[GRID_Y][GRID_X]){
    bool used[GRID_Y][GRID_X];
    rep(i,GRID_Y)rep(j,GRID_X)used[i][j]=false;
    
    rep(i,GRID_Y)rep(j,GRID_X)d[i][j]=INF;
    d[sy][sx]=0;
    
    queue<pii> que;
    que.push(pii(sy,sx));
    while(que.size()){
        int y=que.front().first, x=que.front().second;
        que.pop();
        if(used[y][x])continue;
        used[y][x]=true;
        
        int dy[]={1,0,-1,0},dx[]={0,1,0,-1};
        rep(i,4){
            int ddy=y+dy[i],ddx=x+dx[i];
            if(ddx<0||ddy<0||ddx>=w||ddy>=h||used[ddy][ddx]||data[ddy][ddx]==WALL)continue;
            d[ddy][ddx]=d[y][x]+1;
            que.push(pii(ddy,ddx));
        }
    }
}
 
 
 
int main(){
    cin>>h>>w;
    rep(i,h) cin>>data[i];
    
    pii goal,pr;
    vector<pii> arm;
    rep(i,h){
        rep(j,w){
            if( data[i][j]=='@' )pr   = pii(i,j);
            if( data[i][j]=='%' )goal = pii(i,j);
            if( data[i][j]=='$' )arm.pb( pii(i,j) );
        }
    }
    int d[300][300];
    grid_bfs(goal.first,goal.second,d);
    
 
    int prt = d[pr.first][pr.second];
    int armt= INF;
    
    rep(i,arm.size()){
        armt = min(armt, d[arm[i].first][arm[i].second] );
    }
 
    if(prt<armt)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
//    cout<<prt<<" "<<armt<<endl;
    
}

Measured memory_bytes: 3844
#include <iostream>
using namespace std;
int a[100005];
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define CONST_RETURN(a) do{cout << (a) << endl; return 0; }while(0)

int main(){
  int n;
  cin >> n;
  if(n==1)CONST_RETURN(1);
  rep(i,n) cin >> a[i];
  int ans = 0;
  int mode = 0;
  if(a[0] < a[1]) mode = 1;
  else if(a[0] > a[1]) mode = -1;
  rep(i,n-1){
    if(mode==1 && a[i+1]<a[i]){ans++;mode=0;}
    else if(mode == -1 && a[i+1]>a[i]){ans++;mode=0;}
  	else if(mode == 0 && a[i+1] > a[i]) mode = 1;
    else if(mode == 0 && a[i+1] < a[i]) mode = -1;
  }
  cout << ans+1 << endl;
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

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

	int n; cin >> n;

	int a[2][n];
	int dp[2][n];

	for(int i=0;i<2;i++){
		for(int j=0;j<n;j++){
			cin >> a[i][j];
		}
	}
	dp[0][0] = a[0][0];
	for(int j=1;j<n;j++){
		dp[0][j] = dp[0][j-1] + a[0][j];
	}	
	dp[1][0] = dp[0][0] + a[1][0];
	for(int j=1;j<n;j++){
		dp[1][j] = max(dp[1][j-1],dp[0][j]) + a[1][j];
	}
	cout << dp[1][n-1] << "\n";

	return 0;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
res = 1
cnt = [0,0,0]
for i in range(n):
    res *= cnt.count(a[i])
    res %= mod
    if res == 0: break
    cnt[cnt.index(a[i])] += 1
print(res)

Measured memory_bytes: 78348
#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll D,G;
ll P[11];
ll C[11];
ll ans;
int main() {
    cin>>D>>G;
    REP(i,0,D){
        cin>>P[i]>>C[i];
        C[i]/=100;
    }
    G/=100;
    ans=inf;
    REP(mask,0,(1<<D)){
        stack<ll> st;
        st.push(-1);
        ll score=0;
        ll sum=0;
        REP(i,0,D){
            if(mask & (1<<i)) {
                st.push(i);
                score+=(i+1)*P[i]+C[i];
                sum+=P[i];
            }
        }
        RREP(i,0,D){
            if(st.top()==i){
                st.pop();
            }else{
                if(G-score>(i+1)*(P[i]-1)){
                    sum+=(P[i]-1);
                    score+=(i+1)*(P[i]-1);
                }else{
                    sum+=max((G-score+i)/(i+1),0LL);
                    score+=(i+1)*(G-score+i)/(i+1);
                    break;
                }
            }
        }
        if(G<=score)ans=min(sum,ans);

    }
    p(ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

const int mod = 100000;
int t[210][105][2];	// 第３引数　0:「次で曲がれない」 1:「次で曲がれる」 

int main()
{
//	cut here before submit 
//	freopen ("testcase.cr", "r", stdin );
	int w, h;
	while (scanf ("%d %d", &w, &h ), w, h ){
		memset (t, 0, sizeof (t ) );
		// 西端の南北の道路
		for (int i = 2; i < 2*h; i += 2 ){
			t[i][1][0] = 0; t[i][1][1] = 1;
		} // end for
		// 南端の東西の道路
		for (int j = 1; j < w; j++ ){
			t[1][j][0] = 0; t[1][j][1] = 1;
		} // end for
		// 西端の南北の道路から曲がった横の道
		for (int i = 3; i < 2*h; i += 2 ){
			t[i][1][0] = 1; t[i][1][1] = 0;
		} // end for
		// 南端の東西の道路から曲がった縦の道
		for (int j = 2; j < w+1; j++ ){
			t[2][j][0] = 1; t[2][j][1] = 0;
		} // end for

		for (int i = 3; i < 2*h; i++ ){
			if (i % 2 != 0 ){	// 横の道
				for (int j = 2; j < w; j++ ){
					// t[E][0] = t[S][1];
					t[i][j][0] = t[i-1][j][1];
					// t[E][1] = t[B][0] + t[B][1]
					t[i][j][1] = (t[i][j-1][0] + t[i][j-1][1] ) % mod;
				} // end for
			}else{				// 縦の道
				for (int j = 2; j < w+1; j++ ){
					// t[E][0] = t[S][1];
					t[i][j][0] = t[i-1][j-1][1];
					// t[E][1] = t[B][0] + t[B][1]
					t[i][j][1] = (t[i-2][j][0] + t[i-2][j][1] ) % mod;
				} // end for
			} // end if
		} // end for

		int res = 0;
		rep (k, 2 ){
			res = (res + t[2*h-1][w-1][k] ) % mod;
			res = (res + t[2*h-2][w][k] ) % mod;
		} // end rep
		printf ("%d\n", res );

	} // end loop
		
	return 0;
}

Measured memory_bytes: 1368
#include <stdio.h>
#include <math.h>
int main(void){
  long n,a,b,max,i;
  scanf("%ld",&n);
  b=trunc(sqrt(n));
  for(i=1;i<=b;i++){
    if(n%i != 0){
	  }
	if(n%i == 0){
	  a=n/i;
	  max=a;
	}
  }
  int s=0;
  while(max>0){
    max=max/10;
	s=s+1;
  }
  printf("%d",s);
  return 0;
}

Measured memory_bytes: 128
//Don't give up too easy bhai
#pragma GCC optimize("-O3")
 
#include<bits/stdc++.h>
using namespace std;

#define int long long int
#define double long double
#define inf 1e18

typedef pair<int,int> pii;
 
#define forall(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define fs first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define minv(a) *min_element(all(a))
#define maxv(a) *max_element(all(a))
#define vi vector<int>
#define vd vector<double>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007
#define br cout<<"\n"
#define whatis(x) cerr << "var "<<#x << " ==> " << x<<"\n"
#define inputv(a) forall(i,0,a.size()) cin>>a[i]
#define outputv(a) for(auto i:a) cout<<i<<" ";br;
#define T int __t;cin>>__t;while(__t--)

void solve()
{
    int n;cin>>n;
    vi a(n);inputv(a);

    int money = 1000;
    int ans = 0;
    forall(i,1,n)
    {
        if(a[i] > a[i-1])
        {
            int tem = money/a[i-1];
            int r = money%a[i-1];
            money = tem*a[i] + r;
        }
    }
    cout<<money;

}

signed main()
{
    fast;

    solve();
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

int main() {
	int s, w;
	cin >> s >> w;
	if (s <= w)
		cout << "unsafe"<<endl;
	else
		cout << "safe"<<endl;
}

Measured memory_bytes: 3532
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cmath>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define ALL(x) x.begin(), x.end()
#define INF (1001000000)
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i:c)
#define EXIST(cs,v) (find(ALL(cs),(v))!=cs.end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define UNIQ(c) (c).erase(unique((c).begin(),(c).end()), (c).end());
#define P(p) cout<<(p)<<endl;

int num_div(int num) {
    int ans = 0;
    FOR(i, 1, num+1) {
        if (num % i == 0) ans++;
    }
    return ans;
}

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

    int n;
    cin >> n;

    int ans = 0;
    for(int i = 1; i <= n; i+=2) {
        if (num_div(i) == 8) ans++;
    }
    P(ans);

    return 0;
}


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

int main() {
	ll H,W;
  	cin>>H>>W;
  	ll ans=0;
  	if(H%2==0||W%2==0) ans=H*W/2;
  	else ans=H*W/2+1;
  	
  	if(H==1||W==1) ans=1;
  	cout<<ans<<endl;
  
}	

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

bool a[100005] = {};
bool b[4][100005] = {};
int main() {
	ll n; string s; cin >> n >> s;

	rep(i, 0, s.size() + 2)	a[i] = ((s[i % n] == 'o') ? true : false);

	b[0][0] = 1; b[0][1] = 1; // SS
	b[1][0] = 1; b[1][1] = 0; // SW
	b[2][0] = 0; b[2][1] = 1; // WS
	b[3][0] = 0; b[3][1] = 0; // WW
	rep(i, 0, 4) {
		rep(j, 1, n + 2) {
			if (b[i][j]) {
				b[i][j + 1] = a[j] ? b[i][j - 1] : !b[i][j - 1];
			}
			else {
				b[i][j + 1] = a[j] ? !b[i][j - 1] : b[i][j - 1];
			}
		}

		if (b[i][n] == b[i][0] && b[i][n + 1] == b[i][1]) {
			rep(j, 0, n) cout << (b[i][j] ? 'S' : 'W');
			cout << endl;
			return 0;
		}
	}
	cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 1024