akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;

int query(int i) {
    printf("%d\n", i);
    fflush(stdout);
    char s[10];
    scanf("%s", s);
    return s[0] == 'V' ? 0 : s[0] == 'M' ? 1 : -1;
}

int main() {
    int N;
    scanf("%d", &N);

    int low = 0, high = N - 1;
    int slow = query(low);
    if (slow == 0) return 0;
    int shigh = query(high);
    if (shigh == 0) return 0;

    for (int i = 0; i < 18; ++i) {
        int mid = (low + high) / 2;
        int smid = query(mid);
        if (smid == 0) return 0;

        if ((smid != slow) ^ ((mid - low) % 2)) {
            high = mid;
            shigh = smid;
        }
        else if ((smid != shigh) ^ ((high - mid) % 2)) {
            low = mid;
            slow = smid;
        }
        else {
            low = mid;
            slow = smid;
        }
    }
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

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

int n;
// n 頂点グラフ g
vvi g;
// g の頂点 0 から n-1 までに
// parity = 1 or 2 を交互に振り当てる
vi parity;

void dfs(int v){
  	for (auto u:g[v]) {
      	if(parity[u] == -1) {
          	parity[u] = 3 - parity[v];            	
      		dfs(u);
        }
    }
}

void Main()
{
  	cin >> n;
  	g.resize(n);

  	rep(i,n-1) {
      	int a, b;
		cin >> a >> b;
      	a--; b--;
      	g[a].emplace_back(b);
      	g[b].emplace_back(a);
    }
  	
  	/*
  	rep(v,n) {
		for(auto u:g[v]){
      		cout << v << ", " << u << endl;
        }
    }
    */
  
  	parity.resize(n,-1);
	parity[0] = 1;  
  	dfs(0);        	
  	// rep(i,n) cout << parity[i] << " ";
  	
  	// cnt = (parity = 1) の頂点がいくつあるか
  	int cnt = 0;
  	rep(i,n) if(parity[i]==1) cnt++;
  	
  	// 3*j + 1, 3*k + 2, 3*l を配置していく
  	vi ans(n);
  	int j = 0, k = 0, l = 1;  	
  
  	// もし cnt >= n/3 かつ n-cnt >= n/3 ならば 3*j+1 と 3*k+2 を配置するだけ
  	if(cnt>n/3 && n-cnt>n/3){
    	rep(i,n){
        	if(parity[i] == 1 && 3*j+1 <= n){
            	ans[i] = 3*j+1;
              	j++;
            }
          	else if(parity[i] == 2 && 3*k+2 <= n){
              	ans[i] = 3*k+2;
              	k++;
            }
          	else{
            	ans[i] = 3*l;
              	l++;
            }
        }
    }
	else{
      	int few = 2;
      	if(cnt<=n/3) few = 1;
    	rep(i,n){
        	if(parity[i] == few){
            	ans[i] = 3*l;
              	l++;
            }
         	else if(3*j+1 <= n){
            	ans[i] = 3*j+1;
              	j++;
            }
          	else if(3*k+2 <= n){
            	ans[i] = 3*k+2;
              	k++;
            }
 			else{
            	ans[i] = 3*l;
              	l++;
            }
        }
    }

  	rep(i,n) cout << ans[i] << " ";
  	cout << endl;
  	
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

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

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

    int n;
    cin >> n;
    map<int, int> pos;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        pos[a]=i;
    }
    for(int i=1;i<=n;i++){
        cout<<pos[i]+1<<" ";
    }
    cout<<endl;
}



Measured memory_bytes: 8220
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CPP #-}
module Main where

import qualified Data.Map.Strict as M
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import qualified Data.Vector.Unboxed as V
import Data.Char
import Data.Bits
dump :: (Show a) => a -> IO()
#if __GLASGOW_HASKELL__ >= 800
dump x = print x
#else
dump _ = pure ()
#endif

-- "101010" -> [1,0,1,0,1,0]
readToList :: String -> [Int]
readToList [] = []
readToList (x:xs) = read [x] : readToList xs

-- "10 10 10" -> [10, 10, 10]
getIntVec :: Int -> IO (V.Vector Int)
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

newtype UF a = UF (M.Map a a) deriving (Show) -- Map node parent

makeuf :: Int -> UF Int
makeuf n = let m = M.fromList $ zip [0..n] [0..n]
                in UF m

union :: (Eq a, Ord a) => a -> a -> UF a -> UF a
union l r uf@(UF m) = let lp = find l uf
                          rp = find r uf
                      in if lp == rp
                         then uf
                         else if size l uf < size r uf
                              then UF $ M.update (const $ Just rp) lp m
                              else UF $ M.update (const $ Just lp) rp m

find :: (Eq a, Ord a) => a -> UF a -> a
find x uf@(UF m) = let px = m M.! x
                in if px == x
                   then px
                   else find px uf -- TODO 貼り直し

size :: (Eq a, Ord a) => a -> UF a -> Int
size x (UF m) = M.size $ M.filter (\par -> par==x) m

base :: Int
base = 10 ^ 9 + 7


forn :: (Num a, Enum a, Monad m) => a -> (a -> m b) -> m [b]
forn x = forM [0..(x-1)]

count :: (V.Unbox a, Eq a) => a -> V.Vector a -> Int
count y = V.length . V.filter (== y)

main :: IO()
main = do
  ns <- getIntVec 1
  xs <- getIntVec $ ns V.! 0
  ress <- forn 60 $ \offset -> do
            let a = shift 1 offset
            let ys = V.map (a .&.) xs
            let zeros = count 0 $ ys :: Int 
            let ones = V.length ys - zeros :: Int
            return $ zeros * ones 
  print $ foldr (\x r -> (r*2+x) `mod` base) 0 ress




Measured memory_bytes: 21372
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#define all(x) (x).begin(),(x).end()
typedef long long ll;

using namespace std;

int main()
{
    int N;  cin >> N;
    ll sum, ans;
    vector<int> v(N+2), s(N+1);
    v[0] = 0;
    v[N+1] = 0;
    sum = 0;
    for(int i=0; i<N; i++)  cin >> v[i+1];
    for(int i=0; i<N+1; i++){
        s[i] = abs(v[i+1] - v[i]);
        sum += s[i];
    }
    for(int i=0; i<N; i++){
        ans = sum - s[i] - s[i+1] + abs(v[i+2] - v[i]);
        cout << ans << '\n';
    }
}

Measured memory_bytes: 4000
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
typedef vector<vector<int>> tree;
#define MAXN 100000

int main() {
  int n;
  cin >> n;
  int a, b[MAXN-1];
  tree t(MAXN);
  for (int i = 0; i < n-1; i++) {
    cin >> a >> b[i];
    t[--a].push_back(--b[i]);
  }
  int c[MAXN] = {};
  int mcolor = 1;
  queue<int> next;
  next.push(0);
  while (!next.empty()) {
    int color = 1;
    int now = next.front();
    next.pop();
    for (int node : t[now]) {
      if (color == c[now]) color++;
      c[node] = color;
      next.push(node);
      mcolor = max(mcolor, color);
      color++;
    }
  }

  cout << mcolor << endl;
  for (int i = 0; i < n-1; i++) {
    cout << c[b[i]] << endl;
  }
}

Measured memory_bytes: 5248
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: u32 = read();
    let b: u32 = read();
    let tmp = a + b;
    if tmp % 2 == 0 {
        println!("{}", tmp / 2);
    } else {
        println!("IMPOSSIBLE");
    }
}

Measured memory_bytes: 4352
n=int(input())
countlist={'AC':0,"WA":0,"TLE":0,"RE":0}
for i in range(n):
    i=input()
    if i =='AC':
        countlist['AC']+=1
    elif i == 'WA':
        countlist["WA"]+=1
    elif i == 'TLE':
        countlist["TLE"]+=1
    else:
        countlist["RE"]+=1

def main():
    for i in countlist:
        print('{0} x {1}'.format(i,countlist[i]))

main()
        


Measured memory_bytes: 9040
#include <iostream>
#include <numeric>
#include <vector>
#include <string>

#include <algorithm>
using namespace std;


int main(void) {

    string a,b,c;
    cin >> a >> b >> c;

    if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }


    return 0;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
"""
data=[set() for i in range(N)]
for i in range(N):
    data[A]
"""

count=0
for a in A:
    if a==count+1:
        count+=1
if count:
    print(N-count)
else:
    print(-1)


Measured memory_bytes: 26268
"use strict";
function Main(input) {
    let lines = input.split("\n");
    let nw = lines.shift().split(/\s/).map((v) => v - 0);
    let N = nw[0] - 0, W = nw[1] - 0;
    let wv = new Array(N);
    for (let n = 0; n < N; n++) {
        wv[n] = lines.shift().split(/\s/).map((v) => v - 0);
    }
    let dp = new Array(N + 1).fill(0).map(() => new Array(W + 1).fill(0));
    for (let n = 0; n < N; n++) {
        for (let sum_w = 0; sum_w <= W; ++sum_w) {
            if (sum_w - wv[n][0] >= 0) {
                dp[n + 1][sum_w] = Math.max(dp[n + 1][sum_w], dp[n][sum_w - wv[n][0]] + wv[n][1]);
            }
            dp[n + 1][sum_w] = Math.max(dp[n + 1][sum_w], dp[n][sum_w]);
        }
    }
    console.log(dp[N][W]);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 197776
#include<cstring>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;

char s[105];
map<char,int>q;

int main(){
	int n;
	int ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf(" %c",&s[i]);
		if(s[i]=='G'&&q[s[i]]==0){
			ans++;
			q[s[i]]=1;
		}
		if(s[i]=='W'&&q[s[i]]==0){
			ans++;
			q[s[i]]=1;
		}
		if(s[i]=='P'&&q[s[i]]==0){
			ans++;
			q[s[i]]=1;
		}
		if(s[i]=='Y'&&q[s[i]]==0){
			ans++;
			q[s[i]]=1;
		}
	}
	if(ans==3) printf("Three\n");
	else printf("Four\n");
}

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

# define F first    
# define S second
# define mp make_pair
// everything go according to my plan      
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right  

using namespace std;

typedef pair <int, int> pii; 
typedef unsigned long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {   
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
int k;

ll a[Sz];

ll mn, mx;      

int main() 
{
  Read_rap ();
  cin >> k;
  for (int i = 1; i <= k; i++)
  	cin >> a[i];

 	if (a[k] != 2) {
 		cout << -1;
 		return 0;
 	}
   
 	mn = a[k], mx = 2*a[k] - 1;

  for (int i = k-1; i >= 1; i--) {
  	mn = ((mn + a[i] - 1) / a[i]) * a[i];
  	mx = (mx/a[i]) * a[i];
  	if (mn > mx) {
  		cout << -1;
  		return 0;
  	}
  	mx += a[i]-1;   
  }        
  cout << mn << ' ' << mx << endl;       

  return 0;
} 










// Coded by Z..


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

ll h,w;
char s[55][55];
ll di[]={-1,-1,-1,0,0,1,1,1};
ll dj[]={-1,0,1,-1,1,-1,0,1};

int main(){
	cin>>h>>w;
  rep(i,h)cin>>s[i];
  rep(i,h)rep(j,w){
    if(s[i][j]=='.'){
      ll cnt=0;
      rep(dir,8){
        ll ni=i+di[dir],nj=j+dj[dir];
        if(ni>=0&&ni<h&&nj>=0&&nj<w&&s[ni][nj]=='#')cnt++;
      }
      s[i][j]=(char)('0'+cnt);
    }
  }
  rep(i,h)cout<<s[i]<<endl;
	return 0;
}


Measured memory_bytes: 256
//agrawal117
//chahatagrawal117
#include <bits/stdc++.h>
#pragma GCC optimize "O3"
#define endl '\n'
using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,m,x,p;
    cin>>n>>m>>x>>p;
    vector<ll> v,pre;
    for(int i=0;i<n;i++){
        ll a;
        cin>>a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    ll sum=0;
    for(int i=0;i<n;i++){
        sum+=v[i];
        pre.push_back(sum);
    }
    int j=n-p;
    int idx=j;
    for(int i=j-1;i>=0;i--){
        if(v[i]==v[j]) idx=i;
        else break;
    }
    // cout<<idx<<endl;
    ll madar=0;
    for(int i=idx-1;i>=0;i--){
        ll val=p-1+i+1;
        val=x-val;
        if(val<0){
            if((v[i]+m)>=v[n-p]) madar++;
            continue;
        } 
        val=val*m;
        ll ans=pre[n-p]-pre[i];
        ll ma=v[i]+m;
        ma=ma*(n-p-i);
        ll space=ma-ans;
        // cout<<v[i]<<" "<<space<<" "<<val<<endl;
        if(space>=val && (v[i]+m)>=v[n-p]) madar++;
    }
    // cout<<madar<<endl;
    cout<<n-idx+madar<<endl;
    
}
 



Measured memory_bytes: 2548
#include <stdio.h>
#define N_MAX 500000
#define Q_MAX 500000
void add(int *a, int p, int x) {
	while(p <= *a) {
		a[p] += x;
		p += p & -p;
	}
	return;
}
int get(int *a, int p) {
	int s = 0;
	while(p) {
		s += a[p];
		p -= p & -p;
	}
	return s;
}
int main(int argc, char **argv) {
	int n, q;
	scanf("%i%i", &n, &q);
	int c[N_MAX + 1];
	for(int i = 1; i <= n; ++i) {
		scanf("%i", &c[i]);
	}
	int first[N_MAX + 1];
	for(int i = 1; i <= n; ++i) {
		first[i] = 0;
	}
	int next[Q_MAX + 1];
	int l[Q_MAX + 1];
	for(int i = 1; i <= q; ++i) {
		int r;
		scanf("%i%i", &l[i], &r);
		next[i] = first[r];
		first[r] = i;
	}
	int t[N_MAX + 1];
	t[0] = n;
	for(int i = 1; i <= n; ++i) {
		t[i] = 0;
	}
	int a[N_MAX + 1];
	for(int i = 1; i <= n; ++i) {
		a[i] = 0;
	}
	int ans[Q_MAX + 1];
	for(int r = 1; r <= n; ++r) {
		if(a[c[r]]) {
			add(t, a[c[r]], -1);
		}
		add(t, r, 1);
		for(int i = first[r]; i; i = next[i]) {
			ans[i] = get(t, r) - get(t, l[i] - 1);
		}
		a[c[r]] = r;
	}
	for(int i = 1; i <= q; ++i) {
		printf("%i\n", ans[i]);
	}
	return 0;
}

Measured memory_bytes: 17324
i = int(input())
case = [input() for c in range(i)]
ans = [0,0,0,0]
ac = case.count("AC")
wa = case.count("WA")
tle = case.count("TLE")
re= case.count("RE")
print("AC x " + str(ac))
print("WA x " + str(wa))
print("TLE x " + str(tle))
print("RE x " + str(re))

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

string x;
int y;
int rez=100000000;
int main(){
    getline(cin,x);
    y=x.size();
    for(int i=0;i<x.size();i++){
        if(x[i]!=x[i+1]){ rez=min(rez,max(i+1,y-i-1));}
    }
    cout << rez;
}

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

const int N = 1e5 + 10, M = 2e5 + 30;
int n, m;
struct edge {
    int y, nxt, id;
}e[M << 1];
int lin[M], len;
int dis[N], pos[N];
bool vis[N];
set<int> c[N];

inline int read() {
    int s = 0, f = 1;
    char ch;
    for(; ch < '0' || ch > '9'; ch = getchar()) if(ch == '-')   f = -1;
    for(; ch >= '0' && ch <= '9'; ch = getchar())   s = (s << 1) + (s << 3) + ch - '0';
    return s * f;
}

inline void add(int xx, int yy, int vv) {
    e[++len] = (edge){yy, lin[xx], vv};
    lin[xx] = len;
}

inline void Dijkstra() {
    priority_queue< pair < int, int > > q;
    memset(dis, 0x3f, sizeof(dis));
    memset(vis, 0, sizeof(vis));
    dis[1] = 0;
    q.push(make_pair(0, 1));
    while(!q.empty()) {
        int x = q.top().second; q.pop();
        if(vis[x])  continue;
        vis[x] = 1;
        for(int i = lin[x]; i; i = e[i].nxt) {
            int y = e[i].y, v = c[x].count(e[i].id) ? 0 : 1;
            if(dis[y] > dis[x] + v) {
                dis[y] = dis[x] + v;
                q.push(make_pair(-dis[y], y));
                c[y].clear();
                c[y].insert(e[i].id);
            } else if(dis[y] == dis[x] + v) c[y].insert(e[i].id);
        }
    }
}

int main() {
    n = read(), m = read(); 
    if(m == 0) { puts("-1"); return 0; }
    for(int i = 1; i <= m; ++i) {
        int xx = read(), yy = read(), vv = read();
        add(xx, yy, vv);
        add(yy, xx, vv);
    }
    Dijkstra();
    printf("%d\n", dis[n] == 0x3f3f3f3f ? -1 : dis[n]);
    return 0;
}

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


int main() {
    string S;
    cin >> S;
    bool flag = true;
    if(S[2]!=S[3]) flag = false;
    if(S[4]!=S[5]) flag = false;
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

Int L, A, B, M;

typedef struct m {
    Int m[3][3];
}Matrix;

Matrix operator * (Matrix a, Matrix b) {
    Matrix c;
    for(int i = 0;i < 3;i++) {
        for(int j = 0;j < 3;j++) {
            c.m[i][j] = 0;
            for(int k = 0;k < 3;k++) {
                c.m[i][j] = (c.m[i][j]+ (a.m[i][k]*b.m[k][j]%M))%M;
            }
        }
    }

    return c;
}

Matrix create(Int op, Int b) {
    Matrix A;
    A.m[0][0] = op % M;
    A.m[0][1] = 0;
    A.m[0][2] = 0;
    A.m[1][0] = 1;
    A.m[1][1] = 1;
    A.m[1][2] = 0;
    A.m[2][0] = 0;
    A.m[2][1] = B%M;
    A.m[2][2] = 1;

    return A;
}

Matrix pow(Matrix x, Int y) {
    Matrix ans;
    if(y == 1)
        return x;
    ans = pow(x*x,y/2);
    if(y&1) {
        ans = ans*x;
    }
    return ans;
}

int main(void) {
    cin>>L>>A>>B>>M;
    Int op = 10;
    Int ans = 0;
    Int o = 0;
    L--;
    for(int i = 1;i <= 19;i++) {
        Int l = o,r = L,p = -1;
        while(l <= r) {
            Int mid = (l+r)/2;
            if(mid*B+A < op) {
                p = mid;
                l = mid+1;
            } else {
                r = mid-1;
            }
        }
        if(p != -1) {
            Matrix a = create(op,B);
            a = pow(a,p-o+1);
            Int t = (B*o%M+A) % M;
            ans = (ans * a.m[0][0]%M + t*a.m[1][0]%M+a.m[2][0])%M;
            o = p+1;
        }
        if(o > L)
            break;
        op *= 10;
    }
    cout<<ans<<endl;

    return 0;
}


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

int main() {


    char g[100][100];

    for(int i=0; i<50; i++){
        for(int k=0; k<100; k++){
            g[i][k] = '.';
        }
    }

    for(int i=50; i<100; i++){
        for(int k=0; k<100; k++){
            g[i][k] = '#';
        }
    }

    int a,b;

    cin >> a >> b;

    int count = 1;
    bool painted = false;

    for(int i=1; i<50; i+=2){
        for(int k=1; k<100; k+=2){
            if(count == b){
                painted = true;
                break;
            }
            g[i][k] = '#';
            count++;
        }
        if(painted){
            break;
        }
    }

    count = 1;
    painted = false;

    for(int i=51; i<100; i+=2){
        for(int k=1; k<100; k+=2){
            if(count == a){
                painted = true;
                break;
            }
            g[i][k] = '.';
            count++;
        }
        if(painted){
            break;
        }
    }

    cout << "100 100" << endl;

    for(int i=0; i<100; i++){
        for(int k=0; k<100; k++){
            cout << g[i][k];
        }
        cout << endl;
    }

    cin >> a;

    return 0;
}

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

// 数字の各桁の和を返す
int sumDigits (int n) {
    int s;
    while (n > 0) {
        s += n % 10;
        n /= 10;
    }
    return s;
}

// 最大公約数を返す
int gcd (int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

int main () {
    int R, G, B, N; cin >> R >> G >> B >> N;
    
    int ans = 0;
    for (int i=0;i<=N;i++) {
        for (int j=0;j<=N;j++) {
            int b = N-R*i-G*j;
            if (b>=0 && b%B == 0) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
 
/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


//main function
fn main() {
    let n:usize = read();
    let mut l:Vec<i32> = Vec::with_capacity(2*n);
    let mut sum:i32 = 0;
    unsafe{
	l.set_len(2*n);
    }
    for i in 0..2*n{
	let f:i32 = read();
	l[i] = f;
    }
    l.sort();
    for i in 0..n{
	sum+=l[2*i];
    }
    println!("{}",sum);
}


Measured memory_bytes: 4352
using System;

namespace AtCoder.ABC094
{
    class a
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Trim();
            var S = line.ToCharArray();
            var cnt = 0;
            foreach(char c in S)
            {
                if (c == 'o') ++cnt;
            }
            Console.WriteLine(700 + cnt * 100);
        }
    }
}


Measured memory_bytes: 13140
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        List<Integer> a = new ArrayList<>();
        IntStream.range(0, n).forEach(i -> a.add(sc.nextInt()));

        Map<Integer, Integer> map = new HashMap<>();
        a.forEach(i -> map.merge(i, 1, (x, y) -> x + y));
        if (map.size() <= k) {
            System.out.println(0);
            return;
        }
        Integer sum = map.entrySet()
                .stream()
                .sorted(Entry.comparingByValue())
                .limit(map.size() - k)
                .mapToInt(Entry::getValue)
                .sum();

        System.out.println(sum);
    }

}


Measured memory_bytes: 94640
S=input()
SL=list(S)
count = 0
if SL.count('R') == 3:
    print(3)
elif SL.count('R') ==2:
    if S.count('RR')==1:
        print(2)
    else:
        print(1)
else:
    print(SL.count('R'))

Measured memory_bytes: 9104
/*      ###########################
        #  Author : Pranay Garg   #
        #  College : SGSITS       #
        ###########################
*/      
#include<bits/stdc++.h>
#define ll long long int
#define ironman ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MOD 1000000007
#define endl '\n'
using namespace std;
void fastio()
{
    ironman
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        freopen("error.txt","w",stderr);
    #endif
}
ll parent[100005];
ll find(ll a)
{
    std::vector<ll> v;
    while(parent[a]>0)
    {
        v.push_back(a);
        a = parent[a];
    }
    for(ll i=0;i<v.size();i++)
        parent[v[i]] = a;
    return a;
}
bool prime[100005];
void SieveOfEratosthenes(int n) 
{  
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
}  
void union1(ll a, ll b)
{
    a = find(a);
    b = find(b);
    if(a!=b)
    {
        parent[a] = min(parent[a],parent[b]);
        parent[b] = a;
    }
}  
ll n;
ll arr[100002];
ll dp[100002];
int solve(ll i)
{
    if(i==n-1)
        return 0;
    if(dp[i]!=-1)
        return dp[i];
    ll a = INT_MAX,b = INT_MAX;
    //cout << arr[i] << " " << arr[i+1] << " " << arr[i+2] << endl;
    if(i+1<n)
    a = abs(arr[i+1]-arr[i])+solve(i+1);
    if(i+2<n)   
    b = abs(arr[i+2]-arr[i])+solve(i+2);
//    cout << a << " " << b << " " << i << endl;
    return dp[i] = min(a,b);
}
int main()
{
    memset(dp,-1,sizeof(dp));
    //fastio();
    //ll n;
    cin >> n;
//    ll arr[n];
    for(ll i=0;i<n;i++)
        cin >> arr[i];
    cout << solve(0) << endl;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }



void func(long long a, long long b, long long h){

    cout<<(a+b)*h/2<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long h;
    scanf("%lld",&h);
    func(a, b, h);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        long n;
        long[] a = new long[5];
        long min = 1000000000000000L;
        int minV = 0;
        n = sc.nextLong();
        for(int i=0;i<5;i++){
            a[i] = sc.nextLong();
            if(a[i] < min){
              min = a[i];
              minV=i;
            }
        }
        System.out.println((n+a[minV]-1)/a[minV] + 4);   
	}
}

Measured memory_bytes: 21716
import sys
input = sys.stdin.readline
class Tree:
    def __init__(self, n):
        self.size = 2**((n-1).bit_length())
        self.a = [0]*(self.size*2)
        
    def find(self, c,l,r,i):
        if l == r:
            return self.a[c]
        mid = (l+r)//2
        if i <= mid:
            return self.a[c] + self.find(c*2,l,mid,i)
        else:
            return self.a[c] + self.find(c*2+1,mid+1,r,i)
    
    #この関数の考え方は勉強になる
    def add(self,c,l,r,s,t,x):
        if l == r or(l == s and t == r):
            self.a[c] += x
            return
        mid = (l+r)//2
        if t <= mid:
            self.add(c*2,l,mid,s,t,x)
        elif s > mid:
            self.add(c*2+1,mid+1,r,s,t,x)
        else:
            self.add(c*2,l,mid,s,mid,x)
            self.add(c*2+1,mid+1,r,mid+1,t,x)

n, q = map(int, input().split())
st = Tree(n)
for _ in range(q):
    cmt, *b = map(int, input().split())
    if cmt == 0:
        st.add(1,1,st.size,b[0],b[1],b[2])
    else:
        print(st.find(1,1,st.size,b[0]))


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

int main(){
    int n;cin>>n;
    int l,r;
    int ans=0;
    for(int i=0;i<n;i++){
        cin>>l>>r;
        ans+=r-l+1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

	public static void main(String argv[]) throws IOException {
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);
		String str;
		String triangle_side_str[] = new String[3];
		int max = 0;
		int remain[] = new int[2];
		int triangle_side_int[] = new int[3];
		int N = Integer.parseInt(br.readLine());

		for (int j = 0; j < N; j++) {
			str = br.readLine();
			remain[0] = 0;
			remain[1] = 0;
			max = 0;
			triangle_side_str = str.split(" ");

			for (int i = 0; i < 3; i++) {
				triangle_side_int[i] = Integer.parseInt(triangle_side_str[i]);
				if (max <= triangle_side_int[i]) {
					if (remain[1] == 0)
						remain[1] = max;
					else if (remain[0] == 0)
						remain[0] = max;
					max = triangle_side_int[i];
				} else {
					if (remain[1] == 0)
						remain[1] = triangle_side_int[i];
					else if (remain[0] == 0)
						remain[0] = triangle_side_int[i];
				}

			}
			// System.out.println(max);
			// System.out.println(remain[0]);
			// System.out.println(remain[1]);
			if (Math.pow(remain[0], 2) + Math.pow(remain[1], 2) == Math.pow(max, 2)) {
				System.out.println("YES");
			} else
				System.out.println("NO");

		}

	}

}

Measured memory_bytes: 25972
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
typedef pair<int,int> P;
using vi=vector<long long>;
using vvi=vector<vector<long long>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const int inf=1000000009;
void chmin(auto &a,auto b){if(b<a)a=b;}
void chmax(auto &a,auto b){if(a<b)a=b;}

int main(){
  ll n,a,b,c,d,e;cin>>n>>a>>b>>c>>d>>e;
  cout<<(n-1)/min(a,min(b,min(c,min(d,e))))+5<<endl;
}

Measured memory_bytes: 256
using System;

namespace MyProgram{
    class AtCoder{
        static void Main(string[] args){
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
            int N = input[0];
            int M = input[1];
            int[] L = new int[M];
            int[] R = new int[M];
            for(var i=0;i<M;i++){
                int[] temp = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
                L[i] = temp[0];
                R[i] = temp[1];
            }
            int max_L = 0;
            int min_R = N;
            for(var i=0;i<M;i++){
                if(L[i]>max_L){
                    max_L = L[i];
                }
                if(R[i]<min_R){
                    min_R = R[i];
                }
            }
            if(min_R<max_L){
                min_R = max_L-1;
            }
            Console.WriteLine(min_R-max_L+1);
        }
    }
}

Measured memory_bytes: 17312
#include<stdio.h>
#define N 100

int insertionSort(int *A, int n){
  int i,j,v,k;

  for(i=0;i<n;i++) {
    if(i==n-1)printf("%d",A[i]);
    else printf("%d ",A[i]);
  }
  
    printf("\n");
  
  for(i=1 ; i<n ; i++){
    v = A[i];
    j = i-1;
    while(j>=0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    
    for(k=0;k<n;k++) {
      if(k==n-1) printf("%d",A[k]);
      else printf("%d ", A[k]);
      }
    
    printf("\n");
  
  }
  return *A;
}
  

int main(){

  int i,j,n;
  int A[N];

  scanf("%d",&n);

  for(i=0 ; i<n ; i++) scanf("%d",&A[i]);
  
  

    insertionSort(A, n);

  
  return 0;
}
  

  


  



Measured memory_bytes: 2064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x3, y3, x4, y4;
    int dx = x2 - x1;
    int dy = y2 - y1;
    x3 = x2 - dy;
    y3 = y2 + dx;
    x4 = x3 - dx;
    y4 = y3 - dy;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int A,B;

int main() {

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

	if (A < 10 && B < 10) {
		printf("%d\n", A * B);
	}
	else
	printf("%d\n",-1);

	return 0;
}

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

int main()
{
  string s;
  cin >> s;
  if(s.length() < 4){
    cout << "No" << endl;
    return 0;
  }
  if(s.substr(0,4) == "YAKI"){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
using namespace std;
int N_MAX = 100;
int main()
{
  int n,m,b,i;
  int res[N_MAX];
  vector<int> v;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> b;
    v.push_back(b);
  }
  for(m=n;m>0;m--){
    for(i=m-1;i>=0;i--)
      if(v[i]==i+1){
        res[m-1]=i+1;
        v.erase(v.begin()+i);
        break;
      }
    if(i==-1){
      cout << "-1" << endl;
      return 0;
    }
  }
  for(i=0;i<n;i++)
    cout << res[i] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second

using namespace std;
using vi=vector<int>;
using pii=pair<int, int>;
using ull=unsigned long long;

typedef long long ll;

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

	string str;
	cin >> str;

	int n = str.size();
	int aux = count(str.begin(), str.end(), 'o');

	int aux2 = 15 - n;

	if((aux + aux2) >= 8){
		puts("YES");
	}else{
		puts("NO");
	}

    
    return 0;
}


Measured memory_bytes: 256
using System;

class Atcoder108
{
    public static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);

        if (b % a == 0)
            Console.WriteLine(a + b);
        else
            Console.WriteLine(b - a);
    }
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    int left, right;
    vector<pii> s_left, s_right;
    for (int i = 0; i < n; ++i) {
        cin >> s[i];

        left = 0;
        right = 0;
        for (int j = 0; j < s[i].length(); ++j) {
            if (s[i][j] == '('){
                left++;
            } else{
                left--;
                if (left < 0){
                    right++;
                    left = 0;
                }
            }
        }
        if (left >= right) s_left.push_back(pii(left, right));
        else s_right.push_back(pii(left, right));
    }

    sort(s_left.begin(), s_left.end(), [](pii a, pii b){return a.second < b.second; });
    sort(s_right.begin(), s_right.end(), [](pii a, pii b){return a.first > b.first; });

    int sum = 0; // '('の数 - ')'の数
    for (int i = 0; i < s_left.size(); ++i) {
        if (s_left[i].second > sum){
            cout << "No" << endl;
            return 0;
        }
        sum += s_left[i].first - s_left[i].second;
    }
    for (int i = 0; i < s_right.size(); ++i) {
        if (s_right[i].second > sum){
            cout << "No" << endl;
            return 0;
        }
        sum += s_right[i].first - s_right[i].second;
    }
    if (sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 42420
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
#define r 1000000007;

int main() {
    ll n; cin >> n;
    ll ans = 1;
    for (ll i = 1; i <= n; i++) {
        ans = ans * i % r;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/* ABC173 B */

#include<stdio.h>
#include<string.h>

int main(void){
    int n, ac_count=0, wa_count=0, tle_count=0, re_count=0, i;
    char judge[4];

    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%s", judge);
        if(strcmp(judge,"AC")==0) ac_count++;
        else if(strcmp(judge,"WA")==0) wa_count++;
        else if(strcmp(judge,"TLE")==0) tle_count++;
        else if(strcmp(judge,"RE")==0) re_count++;
    }
    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", ac_count, wa_count, tle_count, re_count);
    return 0;
}


Measured memory_bytes: 1712
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Stream;
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    int[] a = new int [n+1];
    for(int i = 0; i < n; i++){
        a[i+1] = sc.nextInt();
    }
    sc.close();
    int[] b = new int [n+1];
    int cnt = 0;
    List<Integer>ans = new ArrayList<Integer>();
    for(int i = n; i > 0; i--){
        int c = 0;
        int j = 2;
        while (i*j <= n) {
            c += b[i*j];
            j++;
        }
        if(a[i] != (c%2)){
            b[i] = 1;
            ans.add(i);
        }
    }
    System.out.println(ans.size());
    Collections.reverse(ans);
    ans.stream().forEach(v -> {System.out.print(v + " ");});
  }
}

Measured memory_bytes: 86204
using System;
using System.Linq;

namespace Sample
{
	class Program
	{
		static void Main(string[] args)
		{
			var array = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();

			var a = array[0];
			var b = array[1];
			var c = array[2];

			var cnt = 0;
			for (var i = a; i <= b; i++)
			{
				if(c % i == 0)
				{
					cnt++;
				}
			}

			Console.WriteLine(cnt);
		}
	}
}



Measured memory_bytes: 18432
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9 + 5;
constexpr long long INFLL = 1LL << 62;
constexpr double eps = (1e-9);

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

  int n, m;
  cin >> n >> m;
  vector<vector<int>> children(n+1);   // i 番目の親から繋がっている子 or 子孫
  vector<set<int>> parents(n+1);    // i 番目のノードの親たち
  set<int> nodes;
  for (int i = 1; i <= n; i++) nodes.insert(i);

  rep(i, n - 1 + m) {
    int a, b;
    cin >> a >> b;
    children[a].push_back(b);
    parents[b].insert(a);
    nodes.erase(b);
  }

  int root = *nodes.begin();

  vector<int> ans(n+1, -1);
  ans[root] = 0;

  queue<int> q;
  q.push(root);

  while (!q.empty()) {
    int p = q.front(); q.pop();
    for (auto& child : children[p]) {
      if (parents[child].size() == 1) {
        ans[child] = p;
        q.push(child);
      } else {
        parents[child].erase(p);  // 親が複数いる場合は，後から出てくる方に譲る
      }
    }
  }

  for (int i = 1; i <= n; i++) cout << ans[i] << endl;

  return 0;
}


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


// ------------------------

void solve() {
    int N, K; cin >> N >> K;
    vector<int> A(N); rep(i, N) cin >> A[i];
    map<int, int> mp; rep(i, N) ++mp[A[i]];

    // prioriy que
    auto greater = [](const P& x, const P& y){
        return x.second > y.second;
    };
    priority_queue< P, vector<P>, decltype(greater) > que(greater);
    for( auto m : mp ){
        que.push(m);
    }

    int ans = 0;
    rep(i, (int)(mp.size()-K)){
        ans += que.top().second;
        que.pop();
    }

     cout << ans << "\n";
}

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

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

int main() {
    int n;
    cin >> n;
    long long a[100100][3];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> a[i][j];
        }
    }

    long long dp[100100][3] = {0};
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (j == k) continue;
                dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    long long res = 0;
    for (int i = 0; i < 3; i++) res = max(res, dp[n][i]);

    cout << res << endl;
    return 0;
}

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

void bubbleSort(int A[], int N){
    int j,flag = 1, count=0;
    while(flag){
        flag = 0;
        for(j=N-1;j>0;j--){
            if(A[j]<A[j-1]){
                swap(A[j],A[j-1]);
                flag = 1;
                count++;
            }
        }
    }
    for(int i=0;i<N;i++){
        if(i>0) cout << " ";
        cout << A[i];
    }
    
    cout << endl;
    cout << count << endl;
}

int main() {
    int N;
    int A[100];
    cin>>N;
    for(int i=0;i<N;i++) cin>>A[i];
    bubbleSort(A,N);
}


Measured memory_bytes: 3112
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<algorithm>

using namespace std;

typedef long long int Int;

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

    cin>>a>>b>>c;

    if(a+b >= c) {
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }

    return 0;
}


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

const int MAXN = 1e5 + 10;
vector<int> Mat[MAXN], d;
int n, cnt[MAXN];
bool ok = 0;

bool dfs(int v, int p) {
	int cnt = 0;
	for (int i = 0; i < Mat[v].size(); i++)
		if (Mat[v][i] != p)
			cnt += dfs(Mat[v][i], v);
	if (cnt == 0)
		return 1;
	if (cnt == 1)
		return 0;
	ok = 1;
	return 0;
}

int main() {
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		Mat[a].push_back(b);
		Mat[b].push_back(a);
	}
	int s = 0;
	for (int i = 1; i <= n; i++)
		if (Mat[i].size() > 1)
			s = i;
	if (s == 0)
		return cout << "Second", 0;
	if (dfs(s, s) || ok)
		cout << "First";
	else
		cout << "Second";
}

Measured memory_bytes: 5888
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
constexpr lnt INF = 2e18;
/*-*/

struct UnionFind
{
  int n;
  std::vector<int> par,size;
  UnionFind(int sz) : n(sz), par(sz,0), size(sz,1) {
    std::iota(par.begin(),par.end(),0);
  }
  int find(int x) {
    if(par[x]==x) return x;
    return par[x] = find(par[x]);
  }
  void unite(int x, int y) {
    x=find(x);y=find(y);
    if(x==y) return;
    if(size[x]<size[y]) std::swap(x,y);
    size[x]+=size[y];
    par[y]=x;
  }
};


template <typename T = lnt>
struct CoordinateCompression
{
	// add with .r.emplace_back(), T->int with [], int-> T with .r[]
	std::vector<T> r;
	CoordinateCompression() {}
	void build(bool sorted=false) {
		if(!sorted) std::sort(r.begin(),r.end());
		r.erase(std::unique(r.begin(),r.end()),r.end());
	}
	int operator[](const T& k) const {
		return (int)(std::lower_bound(r.begin(),r.end(),k)-r.begin());
	}
};

struct P
{
	lnt a,b,c;
	P(lnt a, lnt b, lnt c) : a(a),b(b),c(c) {}
};

int main() {
	lnt n,m;
	std::cin >> n >> m;
	std::vector<std::vector<P> > edges(2);
	std::vector<CoordinateCompression<lnt>> C(2);
	rep(i,n) {
		lnt a,b,c;
		std::cin >> a >> b >> c;
		edges[0].emplace_back(a,b,c);
		C[0].r.emplace_back(a);
		C[0].r.emplace_back(b);
		C[1].r.emplace_back(c);
	}
	rep(i,m) {
		lnt a,b,c;
		std::cin >> c >> a >> b;
		edges[1].emplace_back(a,b,c);
		C[1].r.emplace_back(a);
		C[1].r.emplace_back(b);
		C[0].r.emplace_back(c);
	}
	C[0].r.emplace_back(0);
	C[1].r.emplace_back(0);
	rep(i,2) C[i].build();
	lnt N=C[0].r.size()+1;
	lnt M=C[1].r.size()+1;
	std::vector<std::vector<lnt> > bN(N,std::vector<lnt>(M,0));
	std::vector<std::vector<lnt> > bM(M,std::vector<lnt>(N,0));
	for(auto e:edges[0]) {
		bM[C[1][e.c]][C[0][e.a]]++;
		bM[C[1][e.c]][C[0][e.b]]--;
	}
	for(auto e:edges[1]) {
		bN[C[0][e.c]][C[1][e.a]]++;
		bN[C[0][e.c]][C[1][e.b]]--;
	}
	rep(i,N-1) {
		rep(j,M-1) {
			bN[i][j+1]+=bN[i][j];
			bM[j][i+1]+=bM[j][i];
		}
	}
	auto enc = [&](int i, int j) -> lnt {
		return i*M+j;
	};
	UnionFind uf(N*M);
	rep(i,N) {
		rep(j,M) {
			if(j!=M-1&&(i==0||i==N-1||bM[j][i-1]==0)) {
				uf.unite(enc(i,j),enc(i,j+1));
			}
			if(i!=N-1&&(j==0||j==M-1||bN[i][j-1]==0)) {
				uf.unite(enc(i,j),enc(i+1,j));
			}
		}
	}
	lnt sx=C[0][0]+1;
	lnt sy=C[1][0]+1;
	lnt root = uf.find(enc(sx,sy));
	lnt sum=0;
	rep(i,N) {
		rep(j,M) {
			if(uf.find(enc(i,j))==root) {
				if(i==0||j==0||i==N-1||j==M-1) {
					print("INF");
					return 0;
				}
				sum+=(C[0].r[i]-C[0].r[i-1])*(C[1].r[j]-C[1].r[j-1]);
			}
		}
	}
	print(sum);
}


Measured memory_bytes: 214984
#include <bits/stdc++.h>
using namespace std;
const int N = 200;

int a[N], b[N];
int n;

int main() {
    scanf("%d", &n);
    b[0] = 10000000;
    for (int i = 1; i <= n-1; i++) scanf("%d", &b[i]);
    for (int i = 1; i <= n-1; i++) {
        a[i] = min(b[i-1], b[i]);
        if (i == n - 1 || b[i] < b[i+1]) a[i+1] = b[i];
        else a[i+1] = b[i+1];
    }
//    for (int i = 1; i <= n; i++) printf("%d ", a[i]);
    int ans = 0;
    for (int i = 1; i <= n; i++) ans = ans + a[i];
    cout << ans << endl;
    return 0;
}

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


int main(){
   int n,m; cin>>n>>m;
   vector<int> a(n),b(n);
   rep(i,n) cin>>a[i]>>b[i];
   vector<pair<int,int>> pa(n);
   rep(i,n) pa[i]=make_pair(a[i],b[i]);
   sort(pa.begin(),pa.end());

   ll ans=0;
   rep(i,n){
      int buy=min(m,pa[i].second);
      ans+=(ll)buy*pa[i].first;
      m-=buy;
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 1792