akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N; cin>>N;
    vector<int> h(N+1,0);
    for(int i=1;i<=N;i++){
        cin>>h[i];
    }
    int cnt=0;
    int tmp=1;
    while (tmp!=0){
        int i=1;
        for(i=1;i<=N;i++){
            if(h[i-1]==0&&h[i]>0){
                cnt++;
            }
        }
        tmp=0;
        for(i=1;i<=N;i++){
            if(h[i]>0){
                h[i]--;
                tmp=tmp+h[i];
            }
        }
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 256
N,M,X = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]

ans = float('inf')
for i in range(1<<N):
  tmp = [0]*(M+1)
  for j in range(N):
    if i&(1<<j)==0: continue
    for k,l in enumerate(A[j]):
      tmp[k] += l
  if all(e>=X for e in tmp[1:]):
    ans = min(ans, tmp[0])
if ans==float('inf'):
  ans = -1
print(ans)

Measured memory_bytes: 9248
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#define ll long long
using namespace std;
const int maxn=500010;
int n, x, num;
int cnt[maxn], tree[maxn], pos[26][maxn];
ll ans;
char s[maxn];
bool v[maxn];
inline void add(int x, int delta){for(;x<=n;x+=x&-x) tree[x]+=delta;}
inline int query(int x){int sum=0; for(;x;x-=x&-x) sum+=tree[x]; return sum;}
int main()
{
	scanf("%s", s+1); n=strlen(s+1);
	for(int i=1;i<=n;i++) cnt[x=s[i]-'a']++, pos[x][++pos[x][0]]=i, tree[i]=i&-i;
	for(int i=0;i<26;i++) if(cnt[i]&1) num++;
	if(num>1) return puts("-1"), 0;
	for(int i=1;i<=n;i++)
	if(!v[i])
	{
		int x=s[i]-'a', nxt=pos[x][pos[x][0]--];
		if(i==nxt) ans+=(query(n)-query(i))>>1;
		else ans+=query(n)-query(nxt);
		add(i, -1); add(nxt, -1); v[i]=v[nxt]=1;
	}
	printf("%lld\n", ans);
}


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

int main(){
  set<string> moji;
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    string nyu;
    cin >> nyu;
    moji.insert(nyu);
  }
  cout << moji.size()<< endl;
}


Measured memory_bytes: 19180
#-------------------------------------------------------------------------------
# Name:        module2
# Purpose:
#
# Author:      ysakamot
#
# Created:     15/12/2018
# Copyright:   (c) ysakamot 2018
# Licence:     <your licence>
#-------------------------------------------------------------------------------

import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline



def gcd(a, b):
	while b:
		a, b = b, a % b
	return a


def lcm(a, b):
	return a * b // gcd (a, b)

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M] = [int(input_raw[0]), int(input_raw[1])]

    L = lcm(N, M)
    input_raw = read_func().strip().split()
    S = input_raw[0]
    input_raw = read_func().strip().split()
    T = input_raw[0]



    S_idx = set([L * i/N for i in range(N)])
    T_idx = set([L * i/M for i in range(M)])
    for i in S_idx:
        if i in T_idx:
            if S[i * N / L] != T[i * M / L]:
                print -1
                return

    print L





if __name__ == '__main__':
    main()


Measured memory_bytes: 49700
N=int(input())
Taro=0
Hanako=0
for i in range(N):
    str=list(input().split())
    if str[0]>str[1]:
        Taro+=3
    elif str[0]<str[1]:
        Hanako+=3
    else:
        Taro+=1
        Hanako+=1
print(f'{Taro} {Hanako}')



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

#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
#define CININIT cin.tie(0),ios::sync_with_stdio(false)
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main(){
    int N,A,B;
    cin>>N>>A>>B;
    ll ans=0;
    rep(i,N){
        int t;cin>>t;
        if(A<=t and t<B) continue;
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
 
using namespace __gnu_pbds;
using namespace std;

#define double      	long double
#define int         	long long
#define pb          	push_back
#define pii         	pair<int,int>
#define vi          	vector<int>
#define vii         	vector<pii>
#define mi          	map<int,int>
#define mii         	map<pii,int>
#define all(a)      	(a).begin(),(a).end()
#define sz(x)       	(int)x.size()
#define endl        	"\n"
#define repp(i,a,b) 	for(int i=a;i<b;i++)
#define rep(i,a,b) 		for(int i=a;i<=b;i++)
#define brep(i,a,b)     for(int i=a;i>=b;i--)
#define deb1(x)      	cout << #x << "=" << x << endl
#define deb2(x, y)  	cout << #x << "=" << x << "," << #y << "=" << y << endl
#define deb3(x, y, z)  	cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define trace(v) 		for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
#define tracearr(a,l,r) for(int iii=l;iii<=r;iii++)cout << a[iii] << " ";cout << endl;
#define PI          	3.1415926535897932384626
#define F 				first
#define S 				second
#define clr(x) 			memset(x, 0, sizeof(x))
#define IOS         	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
// *s.find_by_order(1) - gives the 2nd samllest element in set
// s.order_of_key(x)   - gives the number of elements in the set which are strictly smaller than x


const int N=1e6 + 5;
const int MOD=1e9 + 7;

int mp[N];

vector<int> find_factors(int f)
{
	int i;
	vector<int> vec;	
	for(i=1;i*i<=f;i++)
	{
		if(f%i==0)
		{
			if(i*i==f)
			{
				vec.pb(i);
			}
			else
			{
				vec.pb(i);
				vec.pb(f/i);
			}
		}
	}
	sort(all(vec));
	return vec;
}

int32_t main()
{
	IOS;
	int T=1;
	// int numOfSetBits = __builtin_popcountll(n);
	std::cout << std::fixed << std::setprecision(12);
	while(T--)
	{
		int n;
		cin >> n;
		int a[n+5];
		rep(i,1,n)
		{
			cin >> a[i];
			mp[a[i]]++;
		}
		int ans = 0;
		rep(i,1,n)
		{
			mp[a[i]]--;
			vi v = find_factors(a[i]);
			int flag = 0;
			for(int x:v)
			{
				if(mp[x]>=1)
				{
					flag = 1;
					break;
				}
			}
			if(flag==0)
				ans++;
			mp[a[i]]++;
		}
		cout << ans;
	}
}



Measured memory_bytes: 12964
#include<stdio.h>

int main(){
	int n;
	scanf("%d", &n);
	char str[10002];
	scanf("%s", str);
	for(int i = 0; str[i] != '\0'; i++){
		int temp = n;
		if(str[i] + n > 'Z'){
			temp = temp - ('Z' - str[i]);
			str[i] = 'A' + (temp - 1);
		}
		else{
			str[i] = str[i] + n;
		}
	}
	printf("%s", str);
	
	
	return 0;
}

Measured memory_bytes: 1688
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { let mut $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { let $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
use std::cmp::max;
fn rec(x: usize, a: &Vec<Vec<isize>>, memo: &mut Vec<Option<isize>>) -> isize {
    if let Some(res) = memo[x] {
        return res;
    }
    let res = if x == 0 {
        0
    } else {
        let n = a.len();
        let mut res = 0;
        for i in 0..(n - 1) {
            for j in (i + 1)..n {
                if (x >> i) & 1 == 1 && (x >> j) & 1 == 1 {
                    res += a[i][j];
                }
            }
        }
        let mut y = (x - 1) & x;
        while y > 0 {
            res = max(res, rec(y, a, memo) + rec(x ^ y, a, memo));
            y = (y - 1) & x;
        }
        res
    };
    memo[x] = Some(res);
    res
}
fn main() {
    input! { n, a: [[isize; n]; n] };
    let mut memo = vec![None; 1 << n];
    println!("{}", rec((1 << n) - 1, &a, &mut memo));
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<ctype.h>
int main(void){
char ABC;
while(1){
scanf("%c",&ABC);
if (isupper(ABC) != 0){
printf("%c",tolower(ABC));
}else if (islower(ABC) != 0){
printf("%c",toupper(ABC));
}else if (ABC == '\n'){
printf("\n");
break;
}else{
printf("%c",ABC);
}
}
return 0;
}

Measured memory_bytes: 524
import numpy as np
N, K = map(int, input().split())
# H = np.array([int(h) for h in input().split()])
H = np.array(list(map(int, input().split())))

dp = np.zeros(N, dtype=int)
k = np.array([i for i in range(1, K+1)])

for n in range(1, N):
    start = max(n-K, 0)
    #if n < K:
    #   dp[n] = np.amin(dp[start] + np.abs(H[n]-H[start]))
    #else:
    #   dp[n] = np.min(dp[n - k] + np.abs(H[n] - H[n - k]))
    dp[n] = np.min(dp[start:n] + np.abs(H[n]-H[start:n]))

print(dp[N-1])

Measured memory_bytes: 22780
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14 100兆
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  ll N;
  cin >> N;
  cout << (N-1) * N / 2 << endl;
}

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

typedef pair<string, int> P;

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

    queue<P> que;
    for (int i = 0; i < n; i++) {
        string name;
        int time;
        cin >> name >> time;
        que.push(P(name, time));
    }

    int elapsed = 0;
    while (!que.empty()) {
        P process = que.front(); que.pop();
        int t = min(process.second, q);
        process.second -= t;
        elapsed += t;
        if (process.second > 0)
            que.push(process);
        else
            cout << process.first << " " << elapsed << endl;
    }
    return 0;
}


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

static const int N = 100;

int main(){
    int M[N][N];
    int n, u, k, v;
    
    cin >> n;
    
    for ( int i = 0; i < n; i++ ) {
        for ( int j = 0; j < n; j++ ) M[i][j] = 0;
    }
    
    for ( int i = 0; i < n; i++ ) {
        cin >> u >> k;
        u--;
        for ( int j = 0; j < k; j++ ) {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }
    
    for ( int i = 0; i < n; i++ ) {
        for ( int j = 0; j < n; j++ ) {
            if (j) cout << " ";
            cout << M[i][j];
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3076
// Charan Sriramula

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

const ll lg=14;
const ll N=1e3+5;
const ll INF=1e9;
const ll mod=1e9+7;
const double PI = 3.14159265358979323846;

#define ints(n) scanf("%d",&n)
#define intp(n) printf("%d\n",n)
#define longs(n) scanf("%lld",&n)
#define longp(n) printf("%lld\n",n)

#define f first
#define s second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x,y) make_pair(x,y)
#define GCD(a,b) __gcd((a),(b))
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcount(x)
#define LCM(a,b) ((a)*(b))/GCD((a),(b))
#define ms(dp,val) memset(dp,val,sizeof(dp))
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
template<typename T> T power(T x,T y,ll m){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

ll n,m,a[N][N],dp[N][N];

ll F(ll i,ll j)
{
  ll ans=0;
  if(a[i][j]==0){return 0;}
  if(i==n&&j==m){return 1;}
  if(dp[i][j]!=-1){return dp[i][j]%mod;}
  ans=((ans%mod)+(F(i,j+1)%mod))%mod;
  ans=((ans%mod)+(F(i+1,j)%mod))%mod;
  return dp[i][j]=ans%mod;
}

int main()
{
  cin>>n>>m;
  for(ll i=1;i<=n;i++)
  {
    string s;
    cin>>s;
    for(ll j=1;j<=m;j++)
    {
      a[i][j]=1;
      if(s[j-1]=='#'){a[i][j]=0;}
    }
  }
  ms(dp,-1);
  cout<<F(1,1)%mod<<endl;
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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


int N;
ll v[100005];

void solve() {
    cin >> N;
    modint res = 1;
    memset(v, 0, sizeof(v));
    v[0] = 3;
    rep(i, N){
        modint tmp; cin >> tmp.n;
        res = res * modint(v[tmp.n]);
        v[tmp.n]--; v[tmp.n+1]++;
    }

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
 
    const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    long long mul(long long a, long long b){
        return mod(mod(a)*mod(b));
    }
 
    ll modPow(ll a, ll b){
        if(b==0)
            return 1LL;
        if(b==1)
            return a%M;
        ll res=1;
        while(b){
            if(b%2==1)
                res=mul(res,a);
            a=mul(a,a);
            b=b/2;
        }
        return res;
    }

    void solve (){
        int n;
        cin>>n;
        int k;
        cin>>k;
        vector<ll>pos;
        vector<ll>neg;
        for(int i=0;i<n;i++){
            ll x;
            cin>>x;
            if(x>=0)
                pos.push_back(x);
            else{
                neg.push_back(abs(x));
            }
        }
        reverse(neg.begin(),neg.end());
        // for(auto i : pos)
        //     cout<<i<<" ";
        // cout<<"\n";
        // for(auto i : neg)
        //     cout<<i<<" ";
        
        ll mini=1e18;
        if((int)pos.size()>=k)
            mini=min(mini,pos[k-1]);
        if((int)neg.size()>=k)
            mini=min(mini,neg[k-1]);
        for(int i=0;i<(int)pos.size()&&i<k;i++){
            ll on_left=k-i-1;
            if((int)neg.size()>=on_left && on_left>0){
                ll a=pos[i];
                ll b=neg[on_left-1];
                // cout<<"out "<<i<<" "<<on_left-1<<" "<<a<<" "<<b<<"\n";
                // cout<<"in "<<(2LL*a+b)<<" "<<(2LL*b+a)<<"\n";
                mini=min({mini,2LL*a+b,2LL*b+a});
            }
        }
        cout<<mini;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
        // cin>>t;
        for(int i=1;i<=t;i++){
//            cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }

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

int main(){
    int n,A,B;
    cin>>n;A=0;B=0;
    vector<int> vec(n),a(n),b(n);
        for(int i=0; i<n; i++){
        cin>>vec[i];
        }
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    for(int i=0; i<n; i++){
        if(i%2==0){
            a[i/2+1]=vec[i];
        }
        if(i%2==1){
            b[i/2]=vec[i];
        }
    }
    for(int i=0; i<a.size(); i++){
        A+=a[i];
    }
    for(int i=0; i<b.size(); i++){
        B+=b[i];
    }
    cout<<A-B<<endl;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
	int n, i, count = 1, maior, j, cnd = 0;
	scanf("%d", &n);
	int vet[n];
	for(i = 0; i < n; i++){
		scanf("%d", &vet[i]);
	}
	maior = vet[0];
	for(i = 1; i < n; i++){
		for(j = i - 1; j > 0; j--){
			if(vet[i] < vet[j] || vet[i] < maior) cnd = 1;
		}
		if(cnd == 0 && vet[i] >= maior) count++;
		cnd = 0;
	}
	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

const int N = 3;

int main () {
    int a[N];

    cin >> a[0] >> a[1] >> a[2];

    int count_5 = 0;
    int count_7 = 0;

    for (int i = 0; i < N; i++) {
        if (a[i] == 5) {
            count_5++;
        }
        else if (a[i] == 7) {
            count_7++;
        }
    }

    if (count_5 == 2 && count_7 == 1) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <complex>
#include <algorithm>
#include <cstring>

using namespace std;

typedef complex<double> P;
typedef pair<P, double> circle;
typedef vector< vector<int> > graph;

const double EPS = 1e-8;

void visit(graph &g, vector<int> &order, vector<bool> &mark, int pos){
	for(int i=0;i<g[pos].size();i++){
		int next = g[pos][i];
		if(mark[next]) continue;
		visit(g, order, mark, next);
	}
	mark[pos] = true;
	order.push_back(pos);
}

vector<int> topologicalSort(graph &g){
	vector<int> res;
	vector<bool> mark(g.size(), false);
	for(int i=0;i<g.size();i++){
		if(mark[i]) continue;
		visit(g, res, mark, i);
	}
	reverse(res.begin(), res.end());
	return res;
}

bool overlap(circle c1, circle c2){
	double d = abs(c1.first-c2.first);
	return c2.second - (d+c1.second) > EPS;
}

bool inCircle(circle c, P p){
	return c.second-abs(c.first-p) > EPS;
}

bool crossCircle(circle c1, circle c2){
	double r1 = c1.second;
	double r2 = c2.second;
	double d = abs(c1.first-c2.first);
	if(d<r1||d<r2) return d-abs(r1-r2)>EPS;
	return r1+r2-d > -EPS;
}

int main(){
	int n; 
	while(cin >> n, n){
		double xs, ys, xt, yt; cin >> xs >> ys >> xt >> yt;
		P rat = P(xs,ys), cat = P(xt,yt);
		vector<circle> vc;
		for(int i=0;i<n;i++){
			double x, y, r; cin >> x >> y >> r;
			circle c = make_pair(P(x,y),r);
			bool cRat = inCircle(c, rat);
			bool cCat = inCircle(c, cat);
			if(cRat^cCat) vc.push_back(c);
		}
		graph g(vc.size());
		for(int i=0;i<vc.size();i++){
			for(int j=0;j<vc.size();j++){
				if(i==j) continue;
				bool cA = inCircle(vc[i], cat);
				bool cB = inCircle(vc[j], cat);
				if(cA==true&&cB==true){
					if(overlap(vc[i], vc[j])) g[i].push_back(j);
				}
				if(cA==true&&cB==false){
					if(!crossCircle(vc[i], vc[j])) g[i].push_back(j);
				}
				if(cA==false&&cB==false){
					if(overlap(vc[j], vc[i])) g[i].push_back(j);
				}
			}
		}
		int step[1000];
		int ans = 0;
		memset(step, -1, sizeof(step));
		vector<int> order = topologicalSort(g);
		for(int i=0;i<order.size();i++){
			int cur = order[i];
			if(step[cur] == -1) step[cur] = 1;
			for(int j=0;j<g[cur].size();j++){
				int next = g[cur][j];
				step[next] = max(step[next], step[cur]+1);
			}
		}
		for(int i=0;i<vc.size();i++) ans = max(ans, step[i]);
		cout << ans << endl;
	}
}

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

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);

    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }

    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());

    int sum_A, sum_B, d;
    sum_A = 0;
    sum_B = 0;

    for (int i = 0; i < N; i+= 2) {
        sum_A += vec.at(i);

        if (i == N - 1) {
            break;
        }

        sum_B += vec.at(i + 1);

        int j = i + 1;

        if (j == N - 1) {
            break;
        }
    }

    d = sum_A - sum_B;

    cout << d << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MOD 1000000007
#define pb push_back
#define mp make_pair

void solve()
{
	int n, num;
	cin >> n;
	vector<int> v;
	for (int i = 0; i < n; ++i)
	{
		cin >> num;
		v.pb(num);
	}

	vector<int> dp(n, INT_MAX);
	dp[0] = 0;
	for (int i = 0; i < n ; i++)
	{
		for (int j = 1; j <= 2; j++)
		{
			if (i + j < n)
				dp[i + j] = min(dp[i + j], dp[i] + abs(v[i] - v[i + j]));
		}
	}
	cout << dp[n - 1] << "\n";
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	//cin >> t;
	t = 1;
	while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 4268
open Printf
open Scanf

let id x = x

let n = scanf "%d" id
let vs = Array.init n (fun i -> scanf " %s" id)

let first_char s = s.[0]
let last_char s = s.[String.length s - 1]
let add list w = list := w :: !list

let () =
  let list = ref [] in
  let isOk = ref true in
  add list vs.(0);
  for i = 1 to n - 1 do
    (if List.mem vs.(i) !list then
      isOk := false
    else if last_char (List.hd !list) <> first_char vs.(i) then
      isOk := false
    );
    add list vs.(i)
  done;
  print_endline @@ if !isOk then "Yes" else "No"


Measured memory_bytes: 2432
#pragma GCC optimize("Ofast")
  
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <cassert>
#include <numeric>
#include <math.h>
#include <random>

using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
 
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;
   
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }


signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n;
  string s;
  cin >> n >> s;

  s.erase(unique(all(s)),s.end());

  cout << s.size() << '\n';

  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

void solve(long long N)
{
    ll ans = 0;
    for (ll i = 1; i <= N; i++) {
        if (i % 3 != 0 && i % 5 != 0) {
            ans += i;
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
// clang-format off
#pragma GCC diagnostic ignored "-Wunused-result"
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3696
import java.util.Arrays;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int n = sc.nextInt();
            if (n==0) break;
            int length = n * (n - 1) / 2;
            int sum = 0;
            for (int i = 0; i < length; i++) {
               sum += sc.nextInt();
            }
            System.out.println(sum/(n-1));
        }

    }
}




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

int main(){
  int H,W;
  cin>>H>>W;
  int canvas[H+2][W+2];
  for(int i=0;i<H+2;i++){
    for(int j=0;j<W+2;j++){
      canvas[i][j]=0;
    }
  }
  char c;
  deque<int> x{},y{};
  int size=0;
  for(int i=1;i<H+1;i++){
    for(int j=1;j<W+1;j++){
      cin>>c;
      if(c == '#'){
        x.push_back(i);
        y.push_back(j);
        canvas[i][j]=1;
        size++;
      }
    }
  }
  int a,b;
  for(int i=0;i<size;i++){
    a=x.front();
    b=y.front();
    x.pop_front();
    y.pop_front();
    if(canvas[a-1][b]+canvas[a+1][b]+canvas[a][b-1]+canvas[a][b+1] == 0){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}
    
        

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func contains(target string, list []string) bool {
	for _, r := range list {
		if target == r {
			return true
		}
	}
	return false
}

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

func nextInt() int {
	sc.Scan()

	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextInt64() int64 {
	sc.Scan()

	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextF64() float64 {
	sc.Scan()

	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func isInteger(x float64) bool {
	return math.Floor(x) == x
}

func Ave(s []int) int {
	val := 0
	for _, i := range s {
		val += i
	}
	return int(val / len(s))
}
func cal(i int) (sum int) {
	for i != 0 {
		sum += i % 10
		i /= 10
	}
	return
}
func max(a []int) (idx int, val int) {
	max := a[0]
	idx = 0
	for j, i := range a {
		if max < i {
			max = i
			idx = j
		}
	}
	return idx, max
}

func draw(i int, a []int) (l []int) {
	// p = a[i]
	for j := i; j < len(a); j++ {
		if j != len(a)-1 {
			a[j] = a[j+1]
		} else if j == len(a)-1 {
			a = a[:len(a)-1]
		}
	}
	return a
}
func abs(i int64) int64 {
	if i < 0 {
		return -i
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	// sc.Buffer([]byte{}, math.MaxInt64)
	// a := make([][]int, 3)
	// for i := 0; i < 3; i++ {
	// 	a[i] = make([]int, 3)
	// }
	// for i := 0; i < 3; i++ {
	// 	for j := 0; j < 3; j++ {
	// 		a[i][j] = nextInt()
	// 	}
	// }
	n := nextInt()
	// var cnt int
	var d []int

	for i := 0; i < n; i++ {
		d = append(d, nextInt())
	}

	sort.Ints(d)

	x := d[len(d)/2-1]
	y := d[len(d)/2]

	fmt.Println(y - x)

}


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

int main()
{
  string S;
  cin >> S;
  for(auto c:S) {
    int cnt = 0;
    if(S[0] == c) {++cnt;}
    if(S[1] == c) {++cnt;}
    if(S[2] == c) {++cnt;}
    if(S[3] == c) {++cnt;}
    if(cnt != 2) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

string s, t;
int n, m, nm, nxt[500009], cnt, ans;
vector<int> vec[500009];
int ind[500009], ld[500009];

void fun()
{
	nxt[0] = -1;
	for (int i = 1, j  = 0; i < m; i++, j++) {
		while (t[i] != t[j]) {
			j--;
			if (j < 0) break;
			j = nxt[j] + 1;
		}
		nxt[i] = j;
	}
}

void gun(int cur, int v)
{
	cnt++;
	ld[cur] = max(ld[cur], v);
	ans = max(ans, ld[cur]);
	if (ind[cur] == 0) {
		for (int i = 0; i < (int)vec[cur].size(); i++) {
			ind[vec[cur][i]]--;
			gun(vec[cur][i], ld[cur] + 1);
		}
	}
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> s >> t;
	n = s.length();
	m = t.length();
	nm = n + m;
	fun();
	for (int i = 0, j = 0; i < nm; i++, j++) {
		while (s[i%n] != t[j]) {
			j--;
			if (j < 0) break;
			j = nxt[j] + 1;
		}
		if (j == m - 1) {
			vec[(i + 1 - m) % n].pb((i + 1)%n);
			ind[(i + 1)%n]++;
			j = nxt[j];
		}
	}
	for (int i = 0; i < n; i++) {
		if (ind[i] == 0)
			gun(i, 0);
	}
	if (cnt < n)
		cout << -1 << E;
	else {
		cout << ans << E;
	}
	//system("pause");
	return 0;
}


Measured memory_bytes: 56220
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <string>
#include <stack>
 
using namespace std;
 
#define f(i,a,b) for(int i=a;i<b;i++)
#define fll(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(ll int i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define vvi vector<vector<int>>
#define ss second
#define ff first
#define ll long long
#define lld long double
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pq priority_queue< int >
#define pqll priority_queue< ll >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define INF 1000000000
#define NINF -1000000000
 
ll maxll(ll a , ll b ){
    return a > b ? a : b;
}
 
ll minll(ll a , ll b){
    return a > b ? b : a;
}

// bool check(ll z){
//     ll temp = k;
//     // cout << z << endl;
//     f(i , 0 , n){
//         ll sub = (ll)z * a[i];
//         if (sub > b[i])
//         temp -= (sub -b[i]);
//         if (temp < 0){
//             return 0;
//         }
//     }
//         // cout << z << endl;
//     sol = z;
//         return 1;
// }


// To count Number of ones in a binary number
// int count_one(int x){
//     x = (x & (0x55555555)) + ((x >> 1) & (0x55555555));
//     x = (x & (0x33333333)) + ((x >> 2) & (0x33333333));
//     x = (x & (0x0f0f0f0f)) + ((x >> 4) & (0x0f0f0f0f));
//     x = (x & (0x00ff00ff)) + ((x >> 8) & (0x00ff00ff));
//     x = (x & (0x0000ffff)) + ((x >> 16) & (0x0000ffff));
//     // cout << x << endl;
//     return x;
// }


void solve(){

    int n , k;
    cin >> n >> k;
    vi a(n , 0);
    f( i , 0 , n){
        cin >> a[i];
    }
    vi ans (n , INT_MAX);
    ans[0] = 0;
    ans[1] = abs(a[1]-a[0]);
    f( i , 2 , n){
        for ( int j = i-1 , jump = 0; j  >= 0 && jump < k; j--, jump++){
            ans[i] = min(ans[i] , ans[j] + abs(a[i]-a[j]));
        }
    }
    cout << ans[n-1] << endl;
	return ;
    
}

 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);
 
 
    // int t;
    // cin >> t;
    int t = 1;
    
    while(t--){
        
        solve();
    }
}

Measured memory_bytes: 3992
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#include<complex>
#include<fstream>
#define INF 2e9
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

//
int main()
{
	long long int n;
	int k;
	cin >> n >> k;

	int ans = 0;
	while (n) {
		n /= k;
		ans++;
	}
	cout << ans;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char const *argv[]) {
  int N;
  cin >> N;
  vector<int> a(N + 1);
  vector<int> count(10e5 + 2, 0);
  for (int i = 1; i < N + 1; i++) {
    cin >> a[i];
    count[a[i]]++;
    if (a[i] != 0) {
      count[a[i] - 1]++;
    }
    count[a[i] + 1]++;
  }

  int max = 0;
  for (int i = 0; i < 10e5 + 2; i++) {
    max = max > count[i] ? max : count[i];
  }

  cout << max << "\n";
  return 0;
}


Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	ll sum=0;
	if(k>=a and k>0 and a>0)
	{
		sum+=a;
		k-=a;
		a=0;
	}
	if(k<a and k>0 and a>0)
	{
		sum+=k;
		a-=k;
		k=0;
	}
	if(k>=b and k>0 and b>0)
	{
		sum+=0;
		k-=b;
		b=0;
	}
	if(k<b and k>0 and b>0)
	{
		sum+=0;
		b-=k;
		k=0;
	}
	if(k>=c and k>0 and c>0)
	{
		sum+=(c*(-1));
		k-=c;
		c=0;
	}
	if(k<c and k>0 and c>0)
	{
		sum+=(k*(-1));
		c-=k;
		k=0;
	}
	cout<<sum;
	return 0;
}
		
			
	


Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <cstdio>
using namespace std;

int leap[10000001]={0};
void lea(){
    for(int i=0;i<=10000000;i++){
        if(i%400==0 || (i%4==0 && i%100!=0)) leap[i] = 1;
    }
}

int main(){
    lea();
    string s;
    while(cin >> s){
        if(s == "#") break;
        long long days=0,b=0,k=0,t=0,u=0,kin=0,y=0,m=0,d=0,cnt=0;
        for(int i=0;i<s.size();i++){
            if(s[i] == '.') cnt++;
        }
        if(cnt == 4){
            sscanf(s.c_str(),"%lld.%lld.%lld.%lld.%lld",&b,&k,&t,&u,&kin);
            days = b*144000 + k*7200 + t*360 + u*20 + kin;
            days += 735224;
            for(y=0,b=0;b<days;y++) b += (leap[y] == 1? 366:365);
            y--;
            days = (leap[y]==1? 366:365) + (days-b);
            for(m=1,b=0;b<days;m++){
                if(m==4 || m==6 || m==9 || m==11) b += 30;
                else if(m == 2) b+=(leap[y]==1? 29:28);
                else b += 31;
            }
            m--;
            days = ((m==4||m==6||m==9||m==11)?30:(m==2?(leap[y]==1?29:28):31)) + (days-b);
            printf("%lld.%lld.%lld\n",y,m,days);
        }
        else if(cnt == 2){
            sscanf(s.c_str(),"%lld.%lld.%lld",&y,&m,&d);
            if(y == 2012){
                cout << "0.0.0.0." << d-21 << endl;
                continue;
            }
            else {
                days+=10;
                for(int i=2013;i<y;i++) days +=(leap[i]==1)? 366:365;
                for(int i=1;i<m;i++){
                    if(i==4 || i==6 || i==9 || i==11) days += 30;
                    else if(i == 2) days+=(leap[y]==1)? 29:28;
                    else days += 31;
                }
                days += d;
                b = days/144000; days%=144000;
                k = days/7200; days%=7200;
                t = days/360; days%=360;
                u = days/20; days%=20;
                kin = days;
                if(b >= 13) b%=13;
                printf("%lld.%lld.%lld.%lld.%lld\n",b,k,t,u,kin);
            }
        }
    }
}

Measured memory_bytes: 40332
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scanf("%s", &s)

	answer(s)
}

func answer(s string) {
	if s[2]==s[3] && s[4]==s[5] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define MOD 1000000007
#define pii pair<int,int>
#define ff first
#define ss second
#define pb push_back
#define N 200005
#define endl "\n"
//vector<pair<int,vector<int> > > vec;
int arr[5][N];int t,st=0;
vector<int>vec[5][4*N];

vector<int>s1[5],s2[5];
void solve1();
void answerqueries(int q);

void formmergesorttree(int cur,int l,int r)
{
    if(l==r)
    {
        vec[st][cur].push_back(s1[st][l]);return;
    }
    int mid=l+(r-l)/2;
    formmergesorttree(2*cur+1,l,mid);
    formmergesorttree(2*cur+2,mid+1,r);
    int j=0;int k=0;
    /*for(int i=0;i<(vec[st][2*cur+1].size()+vec[st][2*cur+2].size());i++)//merging 2 sorted vectors
    {
        if(vec[st][2*cur+1][k]<vec[st][2*cur+2][j]&&(k<(vec[st][2*cur+1].size()))&&(j<(vec[st][2*cur+2].size())))
        {
            vec[st][cur].pb(vec[st][2*cur+1][k]);k++;//i++;
        }
        else if(vec[st][2*cur+1][k]>=vec[st][2*cur+2][j]&&(k<(vec[st][2*cur+1].size()))&&(j<(vec[st][2*cur+2].size())))
        {
            vec[st][cur].pb(vec[st][2*cur+2][j]);j++;//i++;
        }
        else if(j==(vec[st][2*cur+2].size()))
        {
            vec[st][cur].pb(vec[st][2*cur+1][k]);k++;
        }
        else if(k==(vec[st][2*cur+1].size()))
        {
            vec[st][cur].pb(vec[st][2*cur+2][j]);j++;
        }
    }*/
    while((k<(vec[st][2*cur+1].size()))&&(j<(vec[st][2*cur+2].size())))
    {
        if(vec[st][2*cur+1][k]<vec[st][2*cur+2][j])
        {
            vec[st][cur].pb(vec[st][2*cur+1][k]);k++;
        }
        else
        {
            vec[st][cur].pb(vec[st][2*cur+2][j]);j++;
        }
    }
    while(k<(vec[st][2*cur+1].size()))
    {
        vec[st][cur].pb(vec[st][2*cur+1][k]);k++;
    }
    while(j<(vec[st][2*cur+2].size()))
    {
        vec[st][cur].pb(vec[st][2*cur+2][j]);j++;
    }
}
int query(int cur,int l,int r,int x,int y, int k)
{
    if(r<x||l>y)
    {
        return 0;
    }
    if( x<=l && r<=y )
    {
        return lower_bound(vec[st][cur].begin(),vec[st][cur].end(),k)-vec[st][cur].begin();
    }
    int mid=l+(r-l)/2;
    return query(2*cur+1,l,mid,x,y,k)+query(2*cur+2,mid+1,r,x,y,k);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    solve1();
    return 0;
}
void solve1()
{
    int n,q;cin>>n>>q;int y;
    for(int i=0;i<n;i++)
    {
        cin>>y;
        s2[st].push_back(y);
    }
    for(int i=0;i<n;i++)
    {
        s1[st].pb(arr[st][s2[st][i]]);
        arr[st][s2[st][i]]=i+1;
    }
    formmergesorttree(0,0,(s1[st].size()-1));
    answerqueries(q);
}

void answerqueries(int q)
{
    int x,d;int ans=0;
    while(q--)
    {
        cin>>x>>d;
        ans=query(0,0,(s1[st].size()-1),x-1,d-1,x);
        cout<<ans<<endl;
    }
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int N, M;
void adds(VL& xs, int b, LL x){
  xs[b] += x;
  xs[b+1] += -x - 1;
  int u = min(b+x+1, (LL)SZ(xs)-1);
  xs[u] += 1;
}

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

  cin >> N >> M;
  VI xs(N);
  REP(i,N){
	cin >> xs[i];
	--xs[i];
  }

  VL acc2(M+10), acc1(M+10);
  REP(i,N-1){
	LL d = 0;
	if(xs[i] <= xs[i+1])
	  d = xs[i+1] - xs[i];
	else
	  d = M - xs[i] + xs[i+1];

	int l = xs[i+1]-d+1;
	if(0 <= l){
	  adds(acc2, l, d);
	  acc1[0] += d;
	  acc1[l] -= d;
	  acc1[xs[i+1]+1] += d;
	}
	else{
	  l = xs[i+1] + 1;
	  adds(acc2, 0, l);
	  adds(acc2, M-d+l, d);
	  acc1[xs[i+1]+1] += d;
	  acc1[M-d+l] -= d;
	}
	/*
  REP(i,M+10) cout << acc2[i] << " "; cout << endl;
  VL tmp(M+10);
  REP(j,M+10) tmp[j] = (j?tmp[j-1]:0ll)+acc2[j];
  REP(i,M+10) cout << acc1[i] << " "; cout << endl;
  REP(j,M+10) cout << tmp[j]+acc1[j] << " "; cout << endl;
  cout<<"==="<<endl;
	*/
  }

  VL ans(M+10);
  REP(i,M+10-1){
	acc2[i+1] += acc2[i];
	acc1[i] += acc2[i];
  }
  REP(i,M+10-1){
	acc1[i+1] += acc1[i];
	ans[i] = acc1[i];
  }

  LL a = 1e18;
  REP(i,M) mini(a, ans[i]);
  cout << a << endl;
  

  return 0;
}


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

typedef long long ll;

const int siz=200005;
ll sum1[siz],sum2[siz];
int main(){
    ll n,i,j,u,ans;
    while(scanf("%lld",&n)!=EOF){
        j=1,ans=sum1[0]=sum2[0]=0;
        for(i=1;i<=n;i++){
            scanf("%lld",&u);
            sum1[i]=sum1[i-1]^u;
            sum2[i]=sum2[i-1]+u;
            while(j<=i&&((sum1[i]^sum1[j-1])!=sum2[i]-sum2[j-1]))
            j++;
            ans+=(i-j+1);
        }
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
map<int,int>mp;
vector<int>vec;
int n,x,ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x;
		mp[x]++;
		if(mp[x]==1)
			vec.push_back(x);
		
	}
	for(int i=0;i<int(vec.size());i++)
		if(mp[vec[i]]>=vec[i])
			ans+=mp[vec[i]]-vec[i];
		else
			ans+=mp[vec[i]];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5112
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
  a, b = map(int, input().split())
  c, d = map(int, input().split())

  x = a * b
  x -= c * b
  x -= (a - c) * d

  print(x, flush=True)


if __name__ == '__main__':
  main()



Measured memory_bytes: 2940
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>

#ifndef ULLONG
typedef unsigned long long ULLONG;
#endif
#ifndef LLONG
typedef long long LLONG;
#endif

static void A_task();

int main()
{
	A_task();
	
	fflush(stdout);
	return 0;
}

static void A_task()
{
	int A, P;
	scanf(" %d %d", &A, &P);

	printf("%d\n", ((A * 3) + P) / 2);
}


Measured memory_bytes: 256
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18

W, H, N = list(map(int, sys.stdin.readline().split()))
X, Y, A = list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(N)]))

board = np.ones((W, H), dtype=bool)
for x, y, a in zip(X, Y, A):
    if a == 1:
        board[:x, :] = 0
    if a == 2:
        board[x:, :] = 0
    if a == 3:
        board[:, :y] = 0
    if a == 4:
        board[:, y:] = 0
print(board.sum())


Measured memory_bytes: 13636
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if (a+b == c || b+c == a || c+a == b){
		printf("Yes\n");
	}else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int P = 1000000007;
const int N = 100010, M = 3010;

int h, w, m, n;
int fac[N * 2], ifac[N * 2];
pair<int, int> pos[M];
int dp[M];
bool vis[M];

int binom(int n, int m) {
  return fac[n] * (ll)ifac[m] % P * ifac[n - m] % P;
}

int dfs(int u) {
  if (vis[u])
    return dp[u];
  vis[u] = true;
  dp[u] = binom(pos[u].first + pos[u].second - 2, pos[u].first - 1);
  for (int v = 1; v <= m; ++v)
    if (u != v && pos[v].first <= pos[u].first && pos[v].second <= pos[u].second)
      dp[u] = (dp[u] - dfs(v) * (ll)binom(pos[u].first + pos[u].second - pos[v].first - pos[v].second, pos[u].first - pos[v].first) % P + P) % P;
  return dp[u];
}

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif

  scanf("%d%d%d", &h, &w, &m);
  for (int i = 1; i <= m; ++i)
    scanf("%d%d", &pos[i].first, &pos[i].second);
  pos[++m] = make_pair(h, w);
  n = h + w - 2;
  fac[0] = 1;
  for (int i = 1; i <= n; ++i)
    fac[i] = fac[i - 1] * (ll)i % P;
  ifac[1] = 1;
  for (int i = 2; i <= n; ++i)
    ifac[i] = -(P / i) * (ll)ifac[P % i] % P + P;
  ifac[0] = 1;
  for (int i = 1; i <= n; ++i)
    ifac[i] = ifac[i - 1] * (ll)ifac[i] % P;
  printf("%d\n", dfs(m));

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const double PI  =3.141592653589793238463;
long long MOD = 1000000007;
int stringToInteger(string x){
    int gg=0;
    stringstream geek(x);
    geek >> gg;
    return gg;
}

ll powmod(ll a,ll b,ll m)
{
    ll ans=1;
    while(b>0){ if(b%2)
        {ans*=a; ans%=m;}
         b/=2; a=a*a; a=a%m;
        }
        return ans%m;
}
ll gcd(ll a,ll b)
{

    return __gcd(a,b);
}
ll mulmod(ll a,ll b,ll m)
{  ll ans=0;
    a %=m;
    while (b>0)
    {       if(b&1) ans = (ans + a) % m;
        a = (a * 2)%m;
        b /= 2;
    }
    return ans % m;
}


ll f[5000001];

ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a;
 while(b > 0)
 	{
 		if(b%2 == 1)
 	{
 		x=(x*y);
 		if(x>MOD) x%=MOD;
 	}
 	y = (y*y);
 	if(y>MOD) y%=MOD;
 	b /= 2;
 	}
 return x;
}

/* Modular Multiplicative Inverse
 Using Euler's Theorem
 a^(phi(m)) = 1 (mod m)
 a^(-1) = a^(m-2) (mod m) */
ll InverseEuler(ll n, ll MOD)
{
 return pow(n,MOD-2,MOD);
}

ll C(ll n, ll r, ll MOD)
{

 return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}
int main()
{
 ll n,t;
 cin>>n>>t;
 vector<int>v;
 for(int i=0;i<n;i++)
 {

     ll a,b;
     cin>>a>>b;
     if(b<=t)
        v.pb(a);
 }
if(v.size()==0) cout<<"TLE"<<endl;
else
 cout<<*min_element(v.begin(),v.end());
}


Measured memory_bytes: 256