akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int INF = 1e10;

class WUF{
public:
  
  int n;
  vector<int> p, rank, w;
  
  WUF(){};
  WUF(int n):n(n),p(n),rank(n,0),w(n,0){ for(int i=0;i<n;i++) p[i] = i; };
  
  typedef pair<int,int> P;
  
  P find(int x){
    if( x != p[x] ){
      P r = find(p[x]);
      p[x] = r.first;
      w[x] += r.second;
      return P( p[x], w[x] );
    }
    return P( p[x], 0 );
  }
  
  void unite(int x, int y, int z){ // w[y] - w[x] = z
    P r1 = find(x);
    P r2 = find(y);
    x = r1.first;
    y = r2.first;
    int Wx = r1.second;
    int Wy = r2.second;
    if( rank[x] > rank[y] ){
      p[y] = x;
      w[y] = Wx - Wy + z;
    }
    else{
      p[x] = y;
      w[x] = Wy - Wx - z;
      if(rank[x]==rank[y]) rank[y]++;
    }

  }
  
  int diff(int x, int y){
    if( find(x).first != find(y).first ) return INF;
    return w[y] - w[x];
  }
  
};

signed main(){
  
  int n, q;
  cin>>n>>q;
  
  WUF wuf(n);
  
  while(q--){
    
    int flg;
    cin>>flg;

    if( flg == 0 ){
      
      int x, y, z;
      cin>>x>>y>>z;
      
      wuf.unite(x,y,z);
      
    }
    else{
      
      int x, y;
      cin>>x>>y;
      
      int ans = wuf.diff(x,y);

      if( ans == INF ) cout<<"?"<<endl;
      else cout<<ans<<endl;
      
    }
    
  }
  
  return 0;
}



Measured memory_bytes: 5200
#include<iostream>
using namespace std;
int main(){
    int a,b,n;
    cin>>a>>b>>n;
    int c[1000]={};
    for(int i=0;i<n;i++){
       int d,e;
       cin>>d>>e;
       for(int j=d;j<e;j++){
          c[j]=1;
       }
    }
    for(int i=a;i<b;i++){
       if(c[i]!=1){}
       else{
           cout<<1<<endl;
           goto loop;
       }
    }
    cout<<0<<endl;
    loop:;
    return 0;
}


Measured memory_bytes: 3108
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val a = sc.next()
  val b = sc.next()
  val c = sc.next()


  var ai = 0
  var bi = 0
  var ci = 0
  
  var now = 'a'
  var last = "A"
  while (ai <= a.length && bi <= b.length && ci <= c.length) {
    if (now == 'a') {
      last = "A"
      if (ai == a.length) break
      now = a[ai]
      ai++
    } else if (now == 'b') {
      last = "B"
      if (bi == b.length) break
      now = b[bi]
      bi++
    } else if (now == 'c') {
      last = "C"
      if (ci == c.length) break
      now = c[ci]
      ci++
    }
  }

  println(last)


}


Measured memory_bytes: 36244
#include <stdio.h>
int main(void){
    int card[4][13]={{0}};
    int n,j,x,y;
    char i;
    
    scanf("%d\n",&n);
    for(y=1; y<=n; y++)
    {
        scanf(" %c %d",&i,&x);
        
        if (i == 'S')
        card[0][x-1] = 1;
        else if (i == 'H')
        card[1][x-1] = 1;
        else if (i == 'C')
        card[2][x-1] = 1;
        else if (i == 'D')
        card[3][x-1] = 1;
    }
    
    for (i=0; i<4; i++)
    {
        for (j=0; j<13; j++)
        {
            if(card[i][j] == 0)
            {
                if (i == 0)
                printf("S %d\n",j+1);
                else if (i == 1)
                printf("H %d\n",j+1);
                else if (i == 2)
                printf("C %d\n",j+1);
                else if (i == 3)
                printf("D %d\n",j+1);
            }
        }
    }
    
    return 0;
}



Measured memory_bytes: 2040
#include <iostream>

using namespace std;

int P[10010];

void init(int N){
    for(int i=0;i<=N;i++)
        P[i] = i;
}

int root(int a){
    if(P[a]==a)
        return a;
    return(P[a] = root(P[a]));
}

bool is_same_set(int a, int b){
    return root(a) == root(b);
}

void unit(int a, int b){
    P[root(a)] = root(b);
}

int main(){
    int n,q; cin >> n >> q;
    int com,x,y;
    init(n);
    for(int i=0;i<q;i++){
        cin >> com >> x >> y;
        if(com == 0)
            unit(x,y);
        else{
            cout << is_same_set(x,y) << endl;
        }
    }
}

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

using namespace std;

int x,y;

int main(void){
    cin >> x >> y;
    if(y%2 == 0 && x*2 <= y && x*4 >= y){
        cout << "Yes" << endl;
    }else{
        cout << "No" <<endl;
    }
    return 0;
}

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

int main(){
  int n,sortmae[200000],sortato[200000],i;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>sortato[i];
    sortmae[i]=sortato[i];
  }
  sort(sortato,sortato+n);
  for(i=0;i<n;i++){
    cout<<(sortmae[i]<sortato[n/2]?sortato[n/2]:sortato[n/2-1])<<endl;
  }
}

Measured memory_bytes: 3712
#include <stdio.h>
#include <cmath>

using namespace std;

int main(){
    int A, B, C, D;

    scanf("%d %d %d %d", &A, &B, &C, &D);

    if(ceil((float)C/(float)B) <= ceil((float)A/(float)D)){
        printf("Yes");
    }else{
        printf("No");
    }

    return(0);
}

Measured memory_bytes: 1732
#include <iostream>
using namespace std;
int main()
{
	int a, b;
	cin >> a;
	cin >> b;
	int max=0;
	int min = a;

	int i;
	for (i = 0; i < b; i++) {
		int max_,min_;
		cin >> max_;
		cin >> min_;
		if (max_ > max)
			max = max_;
		if (min_ < min)
			min = min_;
	}
	if (min - max + 1 >= 0)
		cout << min - max + 1;
	else
		cout << 0;

	return 0;
}


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vl v(n);
	ll maxv = 0, maxp = 0;
	REP(i, n) {
		cin >> v[i];
		if (maxv < abs(v[i])) {
			maxv = abs(v[i]);
			maxp = i;
		}
		
	}
	int cnt = 0;

	
	vector<pii> op;
	if (v[maxp]>0) {
	
		FOR(i, 1, n) {
			while (v[i] < v[i - 1]) {
				cnt++;
				v[i] += maxv;
				op.push_back(pii{ maxp + 1,i + 1 });
				if (v[i] > maxv) {
					maxv = v[i];
					maxp = i;
				}
			}
		

		}
	}
	else {
		maxv *= -1;
		RREP(i, n - 1) {
			while (v[i+1] < v[i]) {
				cnt++;
				v[i] += maxv;
				op.push_back(pii{ maxp + 1,i + 1 });
				if (v[i] < maxv) {
					maxv = v[i];
					maxp = i;
				}
			}
			
		}
	}
	assert(cnt <= 2 * n);
	cout << cnt << endl;
	REP(i, cnt) {
		cout << op[i].first << " " << op[i].second << endl;
	}
	

}


Measured memory_bytes: 256
N = int(raw_input())
A = raw_input().split(" ")

count = 0
for i in range(0, N):
    minj = i
    for j in range(i, N):
        if int(A[j]) < int(A[minj]):
            minj = j

    if i != minj:
        temp = A[i]
        A[i] = A[minj]
        A[minj] = temp
        count += 1

print " ".join(A)
print count

Measured memory_bytes: 6344
#include <stdio.h>
#include <math.h>

int main(void)
{
	int a, b;
	char op;

	for (;scanf("%d %s %d",&a,&op,&b),op-'?';){
		printf("%d\n",op=='+'?a+b:op=='-'?a-b:op=='*'?a*b:a/b);
	}
	return (0);
}

Measured memory_bytes: 600
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class UnionFind():
    def __init__(self):
        self.__table = {}
        self.__size = defaultdict(lambda: 1)

    def __root(self, x):
        if x not in self.__table:
            self.__table[x] = x
        elif x != self.__table[x]:
            self.__table[x] = self.__root(self.__table[x])
        return self.__table[x]

    def root(self, x):
        return self.__table[x]

    def same(self, x, y):
        return self.__root(x) == self.__root(y)

    def union(self, x, y):
        x = self.__root(x)
        y = self.__root(y)
        if x != y:
            self.__size[y] += self.__size[x]
            self.__table[x] = y

    def size(self, x):
        return self.__size[self.__root(x)]

    def num_of_group(self):
        g = 0
        for k, v in self.__table.items():
            if k == v:
                g += 1
        return g

@mt
def slv(N, M, K, AB, CD):
    f = UnionFind()
    for a, b in AB:
        f.union(a, b)


    direct = defaultdict(int)
    for a, b in AB:
        direct[a] += 1
        direct[b] += 1
    block = defaultdict(set)
    for c, d in CD:
        block[c].add(d)
        block[d].add(c)


    ans = []
    for i in range(1, N+1):
        cand = f.size(i)
        for u in block[i]:
            if f.same(i, u):
                cand -= 1
        cand -= direct[i]
        cand -= 1
        ans.append(cand)
    return ans



def main():
    N, M, K = read_int_n()
    AB = [read_int_n() for _ in range(M)]
    CD = [read_int_n() for _ in range(K)]
    print(*slv(N, M, K, AB, CD))

if __name__ == '__main__':
    main()


Measured memory_bytes: 125212
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

long long MAX = 1e18;

int main() {
    int64_t a;
    double b;
    cin >> a >> b;
    int64_t ans;
    ans = b * 100 + 0.5;
    ans = a * ans / 100;
    cout << ans << endl;

return 0;
}


Measured memory_bytes: 3732
//fold
#ifndef KHALIL
#include <bits/stdc++.h>
#else
#include "header.h"
#endif
#define endl '\n'
#define mp make_pair
#define tostr(x) static_cast<ostringstream&>((ostringstream()<<dec<<x)).str()
#define rep(i,begin,end) for(auto i = begin;i < end;i++)
#define repr(i,begin,end) for(auto i = begin-1;i >= end;i--)
#define pb push_back
#define sz(a) ((int)(a).size())
#define fi first
#define se second
#define abs(a) ((a) < (0) ? (-1)*(a) : (a))
#define SQ(a) ((a)*(a))
#define eqd(a,b) (abs(a-b)<1e-9)
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename t> t in(t q){cin >> q;return q;}
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v){os << "[";for (int i = 0; i < sz(v); ++i) { os << v[i]; if (i != sz(v) - 1) os << ",";}os << "]";return os;}
template <typename T, typename S>ostream& operator<<(ostream& os, const map<T, S>& v){for (auto it : v)os << "(" << it.first << ":" << it.second << ")";return os;}
template <typename T, typename S>ostream& operator<<(ostream& os, const pair<T, S>& v){os << "(" << v.first << "," << v.second << ")";return os;}
const long double PI = acosl(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
inline int rand(int l,int r){return uniform_int_distribution<int>(l, r)(rng);}
inline ll rand(ll l,ll r){return uniform_int_distribution<ll>(l, r)(rng64);}
//endfold
#define  N  (200'005)
#define MOD (1'000'000'007ll)
#define OO (1'050'000'000)
#define OOL (1'100'000'000'000'000'000ll)

//global
int cur[N];
int p[N];
int a[N];
int b[N];

int main(){
	//fold
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << setprecision(10);
	//endfold
	int n;
	cin >> n;
	rep(i,0,n){
		cin >> cur[i];
		p[cur[i]] = i;
		a[i] = i+(30000)*i+1;
		b[i] = 900'000'000-(a[i]);
	}
	rep(i,0,n){
		b[cur[i]-1] -= (n-i);
	}
	rep(i,0,n){
		cout << a[i] << " ";
	}cout << endl;
	rep(i,0,n){
		cout << b[i] << " ";
	}cout << endl;
	return 0;
}

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

int main(){
    unsigned long n;
    cin >> n;
    if(n % 2 != 0){
        cout << 0 << endl;
        return 0;
    }
    unsigned long five=0;
    unsigned long div = 10;
    while(n / div > 0){
        five += n / div;
        div *= 5;
    }
    cout << five << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define pb push_back
#define pf push_front

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

ll gcd(ll x, ll y) {
	ll r;
	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y) {
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x*y);
}

int main()
{
	int n, m, cnt = 0;
	cin >> n >> m;
	int ab[m * 2];
	rep(i, m * 2) {
		cin >> ab[i];
	}
	rep(i, n) {
		rep(j, m * 2) {
			if ((i + 1) == ab[j]) cnt++;
		}
		cout << cnt << endl;
		cnt = 0;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(b/a<c){
    cout << b/a << endl;
  }else{
    cout << c << endl;
  }
  return 0;
}

Measured memory_bytes: 256
// AOJ 0272: The Lonely Girl's Lie
// 2017.10.14 bal4u@uu
// 2018.1.2

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

int a[40003], b[40003];

int cmp(int *a, int *b) { return *b - *a; }

//#define getchar_unlocked()  getchar()
int in()
{
	int n, c;

	while ((c = getchar_unlocked()) < '0');
	n = 0;
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int main()
{
	int n, i, k, ans;

	while (n = in()) {
		for (i = 0; i < n; i++) a[i] = in();
		for (i = 0; i < n; i++) b[i] = in();
		qsort(a, n, sizeof(int), cmp);
		qsort(b, n, sizeof(int), cmp);

		ans = n;
		k = 0;
		for (i = 0; k < n; i++) {
			if (a[k] > b[i]) { ans = k + 1; break; }
			k += 2;
		}
		if (ans == n) puts("NA");
		else printf("%d\n", ans);
	}
	return 0;
}



Measured memory_bytes: 2280
import java.io.*;
import java.io.IOException;
import java.util.*;

class Main {
    final static int INF = 1 << 28;
    final static long LNF = 1L << 60;
    final static double EPS = 1e-9;
    final static double GOLDEN_RATIO = (1.0 + Math.sqrt(5)) / 2.0;

    static final long MOD = 1000000007;

    public static void main(String[] args) throws Exception {
        final MyScanner sc = new MyScanner();
        long N;
        N = sc.nextLong();
        long[] A = new long[(int)(N)];
        for(int i = 0 ; i < N ; i++){
                A[i] = sc.nextLong();
        }
        solve(N, A);
    }

    static void solve(long N, long[] A){
        long[] tbl = new long[3];
        long ans = 1;
        for (long a : A) {
            int hit = 0;
            Boolean inclemented  = false;
            for (int i = 0; i < tbl.length; i++) {
                if(tbl[i] == a) {
                    hit++;
                    if(!inclemented) {
                        tbl[i]++;
                        inclemented = true;
                    }
                }
            }
            ans = (ans * hit) % MOD;
        }
        System.out.println(ans);
    }


    static class MyScanner {
 
        BufferedReader br;
        StringTokenizer st;
 
        MyScanner(FileReader fileReader) {
            br = new BufferedReader(fileReader);
        }
 
        MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String nn() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        String next() {
            String ans = "";
            try {
                ans = br.readLine();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            return ans;
        }
 
        char nextChar() {
            return nn().charAt(0);
        }
 
        int nextInt() {
            return Integer.parseInt(nn());
        }
 
        long nextLong() {
            return Long.parseLong(nn());
        }
 
        double nextDouble() {
            return Double.parseDouble(nn());
        }
 
        Integer[] niArr0(int n) {
            Integer[] ar = new Integer[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nextInt();
            }
            return ar;
        }
 
        Integer[] niArr1(int n) {
            Integer[] ar = new Integer[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nextInt();
            }
            return ar;
        }
 
        Long[] nlArr0(int n) {
            Long[] ar = new Long[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nextLong();
            }
            return ar;
        }
 
        Long[] nlArr1(int n) {
            Long[] ar = new Long[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nextLong();
            }
            return ar;
        }
    }

}


Measured memory_bytes: 34480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(j, m) for (int j = 0; j < (int)(m); j++)
#define rep2(i, l, n) for (int i = l; i < (int)(n); i++)


int main() {
    string A,B;
    cin >> A >> B;
    if (A.size() > B.size()) {
        cout << "GREATER" << endl;
    }
    else if (A.size() < B.size()) {
        cout << "LESS" << endl;
    }
    else {
        int flag = 0;
        rep(i,A.size()) {
            if (A[i] > B[i]) {
                cout << "GREATER" << endl;
                flag++;
                break;
            }
            else if (A[i] < B[i]) {
                cout << "LESS" << endl;
                flag++;
                break;
            }
        }
        if (flag == 0) {
            cout << "EQUAL" << endl;
        }
    }
}



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

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

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
 int a,b,c,d;
  cin >> a >> b >> c >> d;
  if (a + b > c + d){
    cout << "Left" << endl;
  }
  if (a + b == c + d){
    cout << "Balanced" << endl;
  }
  if (a + b < c + d){
    cout << "Right" << endl;
  }
}

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

// 最大公約数
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int f(int min_diff, vector<int> hp) {
  if (min_diff == 1) return min_diff;
  if (hp.size() < 2) return min_diff;
  if (hp.size() == 2) return gcd(hp[0], hp[1]);
  vector<int> diff;
  diff.push_back(hp[0]);
  rep(i, hp.size() - 1) {
    int d = hp[i + 1] - hp[i];
    if (d > 0) {
      diff.push_back(d);
      min_diff = min(min_diff, d);
    }
  }

  sort(diff.begin(), diff.end());
  return f(min_diff, diff);
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  sort(a.begin(), a.end());
  int min_diff = f(a[0], a);

  int ans = min_diff;

  rep(i, n) {
    int d = a[i] % min_diff;
    if (d > 0) ans = min(ans, d);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1912
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
int main()
{
   int n,k;
   cin>>n>>k;
   vector<int> v;
   for(int i = 0 ; i< n; i++){
      int z;
      cin>>z;
      v.push_back(z);
   }
   sort(v.begin(),v.end());
   int answer=0;
   for(int i = 0 ; i < k ; i++){
      answer+=v[i];
   }
   cout<<answer<<endl;
   return 0;
}


Measured memory_bytes: 3572
# https://atcoder.jp/contests/abc047/tasks/arc063_a
# 連長圧縮すれば簡単
# 圧縮後の文字列長-1となる


# def run_length_encoding(s):
#     '''連長圧縮を行う
#     s ... iterable object e.g. list, str
#     return
#     ----------
#     s_composed,s_num,s_idx
#     それぞれ、圧縮後の文字列、その文字数、その文字が始まるidx'''
#     s_composed, s_sum = [], []
#     s_idx = [0]
#     pre = s[0]
#     cnt = 1
#     for i, ss in enumerate(s[1:], start=1):
#         if pre == ss:
#             cnt += 1
#         else:
#             s_sum.append(cnt)
#             s_composed.append(pre)
#             s_idx.append(i)
#             cnt = 1
#             pre = ss
#     s_sum.append(cnt)
#     s_composed.append(pre)
#     # assert len(s_sum) == len(s_composed)
#     return s_composed, s_sum, s_idx


def run_length_encoding(s):
    '''連長圧縮を行う
    s ... iterable object e.g. list, str
    return
    ----------
    s_composed,s_num,s_idx
    それぞれ、圧縮後の文字列、その文字数、その文字が始まるidx'''
    from itertools import groupby
    s_composed, s_sum = [], []
    s_idx = [0]
    for k, v in groupby(s):
        s_composed.append(k)
        n = len(list(v))
        s_sum.append(n)
        s_idx.append(s_idx[-1] + n)

    # assert len(s_sum) == len(s_composed)
    return s_composed, s_sum, s_idx


S_composed, _, _ = run_length_encoding(input())
print(len(S_composed) - 1)


Measured memory_bytes: 84368
#include <bits/stdc++.h>
#define endl '\n'
#define F first
#define S second
#define all(c) c.begin(), c.end()
#define int long long
#define forn(i,a,b) for (int i=a; i<b; i++)
#define MOD 1000000000+7;

using namespace std;

void solve (){
	int k,x;
	cin>>k>>x;
	cout<<(k*500>=x ? "Yes" : "No")<<endl;
}

signed main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    int t=1;
    //cin>>t;
    while (t--) solve();
    return 0;
}

Measured memory_bytes: 256
N = int(input())
hN = list(map(int,input().split()))
dp = [0]*N
dp[1] = abs(hN[1]-hN[0])
for n in range(2,N):
  dp[n] = min(dp[n-2]+abs(hN[n-2]-hN[n]), dp[n-1]+abs(hN[n-1]-hN[n]))
print(dp[-1])

Measured memory_bytes: 13980
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <iomanip>
#include <queue>
#include <deque>
#include <sstream>
#include <stdio.h>
#include <string>
#include <cmath>
#include <map>
#include <utility>
using namespace std;

#define s(n) scanf("%d",&n)
#define sc(n) scanf("%c",&n)
#define ss(n) scanf("%s",&n)
#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795

int main() {
	ll k;
	cin >> k;
	cout << "50\n";
	if(k%50 != 0) {
		vector<ll> nums (50,k/50+50);
		for(int i = 0; i < 50-k%50; i++) {
			int maxat = 0;
			for(int j = 0; j < 50; j++) {
				if(nums[j] > nums[maxat]) {
					maxat = j;
				}
			}
			for(int j = 0; j < 50; j++) {
				if(j == maxat) {
					nums[j]-= 50;
				} else {
					nums[j]++;
				}
			}
		}
		for(int j = 0; j < 50; j++) {
			cout << nums[j] << " ";
		}
	} else {
		vector<ll> nums (50,k/50+49);
		for(int j = 0; j < 50; j++) {
			cout << nums[j] << " ";
		}
	}
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define ABS(a) ((a)>(0)?(a):-(a))


void __merge_sort(int *a,int *temp, int left, int right){
    if (left >= right) return;
    int mid = (left + right) / 2;
    __merge_sort(a,temp,left,mid); __merge_sort(a,temp,mid+1,right);
    for (int i = left; i <= mid; i++) temp[i] = a[i];
    for (int i = mid + 1; i <= right; i++) temp[i] = a[right-(i-mid-1)];
    int j = right; int i = left;
    for (int k = left; k <= right; k++) {
        if (temp[i] <= temp[j]) a[k] = temp[i++];
        else a[k] = temp[j--];
    }
}

void merge_sort(int *a,int len){
    int *temp = (int *)malloc(len * sizeof(int));
    __merge_sort(a,temp,0,len-1);
    free(temp);
}

int main(void){
    
    int N; scanf("%d", &N);
    int *a = (int *)malloc(N * sizeof(int));
    for (int i = 0; i < N; i++) 
        scanf("%d", &a[i]);
    merge_sort(a,N);
    int ans = abs(a[N/2-1] - a[N/2]);
    free(a);
    printf("%d\n",ans);
}


Measured memory_bytes: 896
from sys import stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()]
X = [int(_) for _ in stdin.readline().rstrip().split()]
result = []
for l, r in zip(X,X[K-1:]):
    result.append(r - l + min(abs(l), abs(r)))
print(min(result))

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ul unsigned long long int
#define vi vector<int>
#define vl vector<int64_t>
#define all(x) x.begin(),x.end()
#define pb push_back
#define fo(x,a,b) for(int x=a; x<b; x++)
#define rfo(x,a,b) for(int x=a; x>=b; x--)
#define fi first
#define sec second
#define mp make_pair
int sgn(int x) { return x>0 ? 1 : ( x<0 ? -1 : 0); }
typedef pair<int,int> pairs;
double pi = 3.14159265358979323846;
ll mod = 1000000007;
ll n,m,k=0;
vi adj[200001];
bool vis[200001]={false};

void dfs(int x)
{
    vis[x]=true;
    k++;
    for(auto ip=adj[x].begin();ip!=adj[x].end();ip++)
    {
        if(!vis[*ip])
        {
            dfs(*ip);
        }
    }
}
void solve()
{
    cin>>n>>m;
    ll ans=0;
    fo(i,0,m)
    {
        int x,y;
        cin>>x>>y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    fo(i,0,n+1)
    {
        if(!vis[i])
        {
            int temp=0;
            k=0;
            dfs(i);
        }
        ans=max(ans,k);
    }
    cout<<ans;
    cout<<"\n";
    return;
}
int main()
{
#ifdef _DEBUG
    freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll t;
    //cin>>t;
    //while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 20888
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

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; }
template<class T>
inline T GCD(T a, T b) { return b ? GCD(b, a % b) : a; }
template<class T>
inline T LCM(T a, T b) { return (a + (b - 1)) / b; }
template<class T>
inline T round_int(T a, T b) {return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int main() {
	int n;
	cin >> n;
	vi a(n);
	rep(i, n) cin >> a[i];

	ll res = 0;
	int right = 0, sum = 0;
	rep(left, n) {
		while (right < n && (sum ^ a[right]) == (sum + a[right])) {
			sum += a[right];
			++right;
		}
		res += right - left;

		if (left == right) ++right;
		else sum -= a[left];
	}
	cout << res << endl;
}

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

int n,a,b,maxv,minv;
int maxx(int a,int b)
{
	if (a>b)  return a;
	else return b;
}

signed main()
{
	cin>>n>>a>>b;
	maxv=(n-1)*b+a;
	minv=(n-1)*a+b;
	
	cout<<maxx(0,maxv-minv+1)<<endl;
	
	return 0;
}

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

int main() {
	long a,b;
	long N;
	cin >> N;
	a = sqrt(N);
	for(int i=a+1;i>=0;i--){
		if(N%i==0){
			b = i + (N/i);
			break;
		}
	}
	cout << b - 2 << endl;
	return 0;
}

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


int main(){

  int m,n,t;

  cin >> t;

  while(t){

    int ans = 0;
    cin >> m >> n;

    for(int i = 1000 ; i > -1000 ; i--){
      for(int j = 1000  ; j > -1000 ; j--){
	if( i*i +j*j != 0 ) 
	if( (i*m + j*n) % (i*i +j*j) == 0 &&  (i*n - j*m) % (i*i +j*j) == 0){
	  ans++;
	  //	  cout << i <<  " "<< j << endl; 
	}
      }
    }

    //    cout << ans << endl;;
    if(ans == 8) cout << "P" << endl;
    else cout << "C" << endl;
    t--;
  }

  return 0;

}

Measured memory_bytes: 1156
from collections import deque
from sys import stdin
nii=lambda:map(int,stdin.readline().split())

n=int(input())

tree=[[] for i in range(n)]
for i in range(n-1):
  u,v,w=nii()
  u-=1
  v-=1
  tree[u].append([v,w])
  tree[v].append([u,w])

ans=[-1 for i in range(n)]
ans[0]=0

que=deque()
que.append(0)

while que:
  x=que.popleft()
  for i in tree[x]:
    nx=i[0]
    nw=i[1]
    if ans[nx]==-1:
      que.append(nx)
      if nw%2==0:
        ans[nx]=ans[x]
      else:
        ans[nx]=(ans[x]+1)%2

for i in ans:
  print(i)

Measured memory_bytes: 45352
#include<stdio.h>
#include<stdlib.h>
int main(void){
	float x;
	char a[5];
	int n = 0;
	float ans;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%f %s",&x,a);
		if(a[0] == 'J'){
			ans += x;
		}else{
			ans += x*380000;
		}
	}
	printf("%f\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>

int main() {
	int  m,h, i,j,k;
	char card[201] = { 0 }, c1[201] = {0};

	scanf("%s", card);

	while (1) {
		if (card[0] == '-'){
			break;
			}

		scanf("%d", &m);

		i = 0;
		while(i<m) {
			scanf("%d", &h);
			for (j = h,k=0; j<strlen(card); j++,k++) {
				c1[k] = card[j];
			}
			for (j = 0, k; k < strlen(card); j++, k++) {
				c1[k] = card[j];
			}
			strcpy(card, c1);
			i++;
		}
		printf("%s\n", c1);
		for (i = 0; i < 201; i++) {
			card[i] = '\0';
			c1[i] = '\0';
		}
		scanf("%s", card);
		
	}

	return 0;
}


Measured memory_bytes: 2040
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
double pie=3.14159265358979;
long long mod=998244353;
//
int main(){
	int x;
	cin>>x;
	int n=360;
	while(1){
		if(n%x==0){
			cout<<n/x<<endl;
			return 0;
		}else{
			n+=360;
		}
	}
	return 0;
}

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

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

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut a: Vec<usize> = Vec::new();
    let mut b: Vec<usize> = Vec::new();
    for _ in 0..n {
        let ai = iterator.next().unwrap().parse().unwrap();
        let bi = iterator.next().unwrap().parse().unwrap();
        a.push(ai);
        b.push(bi);
    }

    a.sort();
    b.sort();

    if n % 2 == 1 {
        let med_a = a[n / 2];
        let med_b = b[n / 2];
        return format!("{}", med_b - med_a + 1);
    }

    let med_a = a[n / 2 - 1] + a[n / 2];
    let med_b = b[n / 2 - 1] + b[n / 2];
    return format!("{}", med_b - med_a + 1);
}


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


int main() {

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

long ans=1e18;
for(int i=-100;i<=100;i++){
  long tmp=0;
  for(int j=0;j<N;j++){
    tmp+=(i-a[j])*(i-a[j]);
  }
  ans=min(tmp,ans);
}
cout<<ans<<endl;
}


Measured memory_bytes: 3640
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T& v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

/*
0 1 2 3
0 0 1 3 6
2つ選ぶ時
1, 2, 3, 4, 5
3つ選ぶ時
3, 4, 5, 6
4つ選ぶ時
6
連続したものは必ず作れる.
最小値と最大値が分かればmax-min+1
これは累積和でO(1)だな.
*/
const ll MOD = 1000000007;
int main() {
  int n,k;in(n),in(k);
  vector<ll> acc(n+2, 0);
  loop(i,0,n+1) acc[i+1] = acc[i] + i;
  ll ans = 0;
  loop(i,k,n+2) {
    // print(vector{ acc[n+1]-acc[n-i+1], acc[i]});
    ans += acc[n+1]-acc[n-i+1] - acc[i] + 1;
    ans %= MOD;
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 4788
s=input()
if s=="SUN":
    print(7)
elif s=="MON":
    print(6)
elif s=="TUE":
    print(5)
elif s=="WED":
    print(4)
elif s=="THU":
    print(3)
elif s=="FRI":
    print(2)
else:
    print(1)


Measured memory_bytes: 38256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

string S;
ll N,K;
ll H[100001];
ll ans;
vector<ll> E[100001];
bool found;
ll V[1000001];
 


int main(){
    cin >> N >> K;
    for(int i=0;i<N;i++){
        cin >> H[i];
    }
    for(int i=0;i<K;i++){
        int a,b;
        cin >> a >> b;
        E[a-1].push_back(b-1);
        E[b-1].push_back(a-1);
    }
    for(int i=0;i<N;i++){
        found = true;
        for(int j=0;j<E[i].size();j++){
            if(H[i]<=H[E[i][j]]){
                found = false;
            }
        }
        if(found){
            ans++;
        }
    }
        
    cout << ans << endl;
    
}


Measured memory_bytes: 10272
//ProblemC.cpp

#include <iostream>

static std::istream & ip = std::cin;
static std::ostream & op = std::cout;

#if OJ_MYPC
#include <ojio.h>
#endif

#ifndef OPENOJIO
#define OPENOJIO
#endif

#if 1 || DEFINE
/***************************************************************/
typedef unsigned long long u64;
typedef long long s64;

typedef unsigned uint;

#define ABS(x) ((x) > 0 ? (x) : -(x))

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))

#define MIN3(x, y, z) MIN(x, MIN(y, z))
#define MAX3(x, y, z) MAX(x, MAX(y, z))

#define FillZero(arr) memset(arr, 0, sizeof(arr));

/***************************************************************/
#endif //1 || DEFINE

#include <string>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <stack>
#include <utility>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>

//001
//op << setfill('0') << setw(3) << setiosflags(ios::right) << 1;

//op << fixed << setprecision(20);

using namespace std;

//ProblemC.cpp

#define MAXQ 100010
#define MAXN 100010

int main(int argc, char* argv[])
{
	OPENOJIO;

	int n_in, q_in;
	ip >> n_in >> q_in;

	stack<s64> s;
	s.push(0);
	s.push(n_in);

	for (int i = 0; i < q_in; ++i) {
		s64 t;
		ip >> t;

		while (s.top() >= t) s.pop();
		s.push(t);
	}
	
	map<s64, s64> parts;
	parts[0] = 0;
	parts[s.top()] = 1; s.pop();

	for (;;) {
		s64 t = s.top(); s.pop();
		if (t == 0) break;

		for(;;)
		{
			auto it = parts.end(); --it;
			if (it->first <= t) break;

			s64 len = it->first;
			s64 cnt = it->second;
			parts.erase(it);

			parts[t] += len / t * cnt;
			parts[len % t] += cnt;
		}
	}

	static s64 rst[MAXN + 2];
	for (int i = 1; i <= n_in + 1; ++i) rst[i] = 0;

	s64 index = n_in;
	s64 pre = 0;
	for (auto it = parts.rbegin(); it != parts.rend(); ++it) {
		while (index > it->first)
		{
			rst[index] = pre;
			--index;
		}
		pre += it->second;
	}

	for (int i = 1; i <= n_in; ++i)
		op << rst[i] << endl;

	return 0;
}
/***************************************************************/


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

using namespace std;

int H, W, A, B;
int ans[1010][1010];

int main() {
  cin >> H >> W >> A >> B;

  for (int y = 0; y < H; y++) {
    for (int x = 0; x < W; x++) {
      if (x < A && y < B) {
        ans[y][x] = 1;
      }
      if (A <= x && B <= y) {
        ans[y][x] = 1;
      }
    }
  }

  for (int y = 0; y < H; y++) {
    for (int x = 0; x < W; x++) {
      cout << ans[y][x];
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>
using namespace std;

int main()
{
    int a,b;
    cin >> a >> b;
    int max;
    
    max = a+b;
    if (max< 2*a -1){max = 2 * a -1;}
    if (max< 2*b -1){max = 2 * b -1;}
    cout << max << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb               push_back
#define sz(c)            (int)c.size()
#define len(c)           (int)c.length()
#define vec              vector
#define int              long long int
#define mp(x,y) 	     make_pair(x,y)
#define all(c)           c.begin(), c.end()
#define rall(c)          c.rbegin(), c.rend()
#define trav(a,i)        for(auto& i: a)
#define loop(n,i,a)      for(int i=a;i<n;i++)
#define invect(v,n)       for(int i=0;i<n;i++ ){int arb;cin>>arb;v.pb(arb);}
#define inset(s,n)        loop(n,i,0){int aset;cin>>aset;s.insert(aset);}
#define display(c)        trav(c,i) cout<<i;
#define F                 first
#define S                 second
#define pii               pair<int,int>
#define pp               pop_back
#define endl              "\n"
#define copy(a,b)         copy(all(a),back_inserter(b));
#define intersect(a,b,w)    set_intersection(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define union(a,b,w)      set_union(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define diff(a,b,w)       set_difference(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define symdiff(a,b,w)    set_symmetric_difference(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
//int m=10000009;
//int arr[100000];
#define M 					1000000007 
int isprime(int n)
{
        if(n<=1) return 0;
        if(n<=3) return 1;
        if(n%2==0 ||n%3==0)
        return 0;
    for(int i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)
        return 0;
    }
    return 1;
}
#define PI 3.1415926535
signed main(){
				fast
				//	freopen("input.txt","r",stdin);
				//	freopen("output.txt","w",stdout);
				int n;
				cin>>n;
				int a;
				long double d = 0;
				for(int i=0;i<n;i++)
				{
					cin>>a;
					d += 1.0/a;
				}
				cout<<setprecision(12) << 1.0/d;
			}
			
				
		
		 
		 


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

int main()
{
  int h, w;
  cin >> h >> w;
  bool grid[h][w];
  uint path_count[h][w];
  const uint mod = 1'000'000'007;

  for (auto row = 0; row < h; row++) {
    for (auto col = 0; col < w; col++) {
      char c;
      cin >> c;
      grid[row][col] = c == '.';
      path_count[row][col] = 0;
    }
  }
  path_count[0][0] = 1;
  for (auto row = 0; row < h; row++) {
    for (auto col = 0; col < w; col++) {
      if (row != 0 && grid[row - 1][col]) {
        path_count[row][col] += path_count[row - 1][col];
        path_count[row][col] %= mod;
      }
      if (col != 0 && grid[row][col - 1]) {
        path_count[row][col] += path_count[row][col - 1];
        path_count[row][col] %= mod;
      }
    }
  }
  cout << path_count[h - 1][w - 1] << endl;
}


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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vec h = ivec(n);
    int cnt = 1;
    int ma = h[0];
    For(i, 1, n - 1) {
        if (ma <= h[i]) cnt++;
        chmax(ma, h[i]);
    }
    print(cnt);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  bool f = false;
  rep2(i, 1, 10){
    rep2(j, 1, 10){
      if(n == i*j) f = true;
    }
  }
  if(f == true) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int r=0;
  for(int i=0; i<n; i++) {
    if(s.at(i)=='R') {
    r++;
    }
  }
  if(r==0) {
    cout << 0 << endl;
    return 0;
  }
  //cout << r << n-r << endl;
  int cntr=0, cntw=0;
  for(int i=0; i<r; i++) {
    if(s.at(i)=='W') {
      cntw++;
    }
    if(i==r-1) {
      cout << cntw << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3756
#include <stdio.h>

int main(){
	
	char S[50];
	int N,K;
	
	scanf("%d %d",&N,&K);
	getchar();
	scanf("%s",&S);
	
	S[K-1]=S[K-1]+32;
	
	printf("%s",&S);
	
	return 0;
}

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

int main(){
  int n;
  string s;
  cin >> n >> s;
  
  string a="Yes";
  
  if(n%2==1)
    a="No";
  else{
  for(int i=0;i<n/2;i++){
    if(s.at(i)!=s.at(i+n/2)){
      a="No";
    }
  }
  }
  cout << a << endl;
}

Measured memory_bytes: 256
a = int(input())

b = [0,0,0,0]
for i in range(a):
    c = input()
    if c == "AC":
        b[0] += 1
    elif c == "WA":
        b[1] += 1
    elif c == "TLE":
        b[2] += 1
    elif c == "RE":
        b[3] += 1

print("AC x " + str(b[0]))
print("WA x " + str(b[1]))
print("TLE x " + str(b[2]))
print("RE x " + str(b[3]))

Measured memory_bytes: 9224
alpha = Array.new(27,0)
class << alpha
  def [](char)
    if (char.downcase.ord - "a".ord).between?(0,25)
      super(char.downcase.ord - "a".ord)
    else
      super(26)
    end
  end
  
  def []=(pos, other)
    if (pos.downcase.ord - "a".ord).between?(0,25)
      super(pos.downcase.ord - "a".ord, other)
    else
      super(26,other)
    end
  end
  
  def to_s
    char = "a"
    result = []
    26.times do
      result << "#{char} : #{self[char]}"
      char.next!
    end
    return result
  end
end
while str = gets
  str.split(//).each{|char|alpha[char] += 1}
end
puts alpha.to_s

Measured memory_bytes: 6108
/* AOJ 0038
 *
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0038
 *
 */

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

int diff1_Aas14_count(int *hand){
    int i, j, n;
    n = 0;
    for(i =0; i<5; i++){
        for(j=i+1;j<5;j++){
            if(hand[i]== 1 || hand[j] == 1){
                if(hand[i]== 1){
                    if((14 - hand[j]) == 1)
                        n++;
                }else{ /*hand[j] == 1*/
                    if((14 - hand[i]) == 1)
                        n++;
                }
            }else{
                if(abs(hand[i] -  hand[j]) == 1){
                    n++;
                }
            }
        }
    }
    return n;
}


int diff1_Aas1_count(int *hand){
    int i, j, n;
    n = 0;
    for(i =0; i<5; i++){
        for(j=i+1;j<5;j++){
            if(abs(hand[i] -  hand[j]) == 1){
                n++;
            }
        }
    }
    return n;
}

int eq_count(int *hand){
    int i, j, n;
    n = 0;
    for(i =0; i<5; i++){
        for(j=i+1;j<5;j++){
            if(hand[i] == hand[j]){
                n++;
            }
        }
    }
    return n;
}

int test_fourcard(int* hand){
    return eq_count(hand) == 6;
}

int test_fullhouse(int* hand){
    return eq_count(hand) == 4;
}

int test_straight(int* hand){
    return diff1_Aas14_count(hand) == 4 || diff1_Aas1_count(hand) == 4;
}

int test_threecard(int* hand){
    return eq_count(hand) == 3;
}

int test_twopair(int* hand){
    return eq_count(hand) == 2;
}

int test_onepair(int* hand){
    return eq_count(hand) == 1;
}



char* test(int* hand){
    if(test_fourcard(hand)){
        return "four card";
    }

    if(test_fullhouse(hand)){
        return "full house";
    }

    if(test_threecard(hand)){
        return "three card";
    }

    if(test_twopair(hand)){
        return "two pair";
    }

    if(test_onepair(hand)){
        return "one pair";
    }

    if(test_straight(hand)){
        return "straight";
    }
    return "null";
}


int main(){
    int hand[5];
    char* r;

    while(scanf("%d,%d,%d,%d,%d", hand, hand+1, hand+2, hand+3, hand+4) == 5){
        r = test(hand);
        printf("%s\n", r);
    }

    return 0;
}

Measured memory_bytes: 0