akhauriyash/Code-Regression huggingface dataset:
//According to all known laws of aviation, there is no way that a bee should be able to fly.
//Its wings are too small to get its fat little body off the ground. The bee, of course, flies anyway.
//Because bees don't care what humans think is impossible.
#include <bits/stdc++.h>
#define FAST_IO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define endl "\n"
using namespace std ;
using bigint = long long int ;
using vi = vector<int> ;
using vll = vector<long long int> ;
bigint ans[10000001] ;
  
int main(){
    int N ; cin >> N ;
    for( int i = 1 ; i <= N ; i++ ){
              for( int j = i ; j <= N ; j += i )
                  ans[j]++ ;
          }
    bigint A = 0 ;
    for( int i = 1 ; i <= N ; i++ )
        A += ( i * ans[i] ) ;
    cout << A << endl ;
    
    return 0 ;
}


Measured memory_bytes: 81676
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var K = int.Parse(Console.ReadLine());
            var answer = (long)1e18;
            for (var bit = 0; bit < (1 << N); bit++)
            {
                var num = 1;
                for (var i = 0; i < N; i++)
                {
                    if (((bit >> i) & 1) == 1) num *= 2;
                    else num += K;
                }
                answer = Math.Min(answer, num);
            }
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 27408
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <tuple>
#include <sstream>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    //    ifstream in("input.txt");
    //    cin.rdbuf(in.rdbuf());
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, m;
    cin >> n >> m;
    
    vector<tuple<int, int, int>> p_yip(m); // year, id, prefecture
    
    rep(i, m)
    {
        int p, y;
        cin >> p >> y;
        --p;
        p_yip[i] = {y, i, p};
    }
    
    sort(p_yip.begin(), p_yip.end());
    
    vector<vector<int>> table(n); // [prefecture][city] -> city_id
    rep(i, m)
    {
        table[get<2>(p_yip[i])].push_back(get<1>(p_yip[i]));
    }
    
    vector<string> vec_ans(m);
    
    rep(prefecture, n)
    {
        std::ostringstream sout_p;
        sout_p << std::setfill('0') << std::setw(6) << prefecture + 1;
        std::string str_p = sout_p.str();
        
        for (int city = 0; city < table[prefecture].size(); ++city)
        {
            std::ostringstream sout_c;
            sout_c << std::setfill('0') << std::setw(6) << city + 1;
            std::string str_c = sout_c.str();
            
            vec_ans[table[prefecture][city]] = str_p + str_c;
        }
    }
    
    rep(i, m)
    {
        cout << vec_ans[i] << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define repin(a,n) vector<ll> a(n);rep(i,n){cin>>a[i];}
#define in(a) ll a;cin>>a;
#define out(a) cout<<a<<endl;

int main()
{
    in(a);
    in(b);
    in(c);
    out(max(0LL,c-(a-b)));
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

for i in range(1,n):
  if h[i] < h[i-1]:
    h[i] += 1
    
for i in range(1,n):
  if h[i] < h[i-1]:
    print("No")
    exit()

print("Yes")

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

int DIG_K (int meas,int K){
  int ans =0;
  int data=0;
  
  data =meas;
  while(data > 0){
    data /= K;
    ans++;
  }
  
  vector<int> DIG(ans);
  data = meas;
  for (int i=0;i<ans;i++){
    DIG.at(i) = data % K;
    data /= K;
  }
  
  //順番反転
  reverse(DIG.begin(),DIG.end());
  
  //for (int i=0;i<ans;i++)
    //cout<<DIG.at(i)<<" ";
  
  //cout<<endl;
  
	return ans;
}

int main(){
  int N,K;//データ
  int data;
  int ans;
  
  cin>>N>>K;
  
  ans=DIG_K(N,K);
  
  cout << ans << endl;
}

  

Measured memory_bytes: 3636
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
long long int inf = (8*1e18);
class Point{
public:
  long long int x, y;
};

long long int n, K;
vector<Point> p;

int main() {
  cin >> n >> K;
  p.resize(n);
  for(int i=0; i<n; i++) cin >> p[i].x >> p[i].y;
  long long int ans = inf;

  for(int lx=0; lx<n; lx++){
    for(int rx=lx+1; rx<n; rx++){
      for(int ly=0; ly<n; ly++){
        for(int ry=ly+1; ry<n; ry++){

          long long int llx = min(p[lx].x, p[rx].x);
          long long int rrx = max(p[lx].x, p[rx].x);
          long long int lly = min(p[ly].y, p[ry].y);
          long long int rry = max(p[ly].y, p[ry].y);

          long long int m = (rrx-llx) * (rry-lly);
          long long int cnt = 0;
          for(int k=0; k<n; k++){
            if( llx <= p[k].x && p[k].x <= rrx && lly <= p[k].y && p[k].y <= rry ) cnt++;
          }

          if( cnt >= K ){
            ans = min(ans, m);
          }

        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
  int n, m, r;
  cin >> n >> m >> r;
  vector<int> towns;
  REP(i,r){
    int town;
    cin >> town;
    towns.push_back(town);
  }
  int dist[n][n];
  REP(i,n){
    REP(j,n){
      dist[i][j] = (i==j) ? 0 : 1<<29;
    }
  }
  REP(i,m){
    int a,b,c;
    cin >> a >> b >> c;
    dist[a-1][b-1]=c;
    dist[b-1][a-1]=c;
  }
  REP(k,n){
    REP(i,n){
      REP(j,n){
        if(dist[i][j] > dist[i][k] + dist[k][j]){
          dist[i][j] = dist[i][k] + dist[k][j];
        }
      }
    }
  }
  sort(towns.begin(),towns.end());
  long min_length;
  bool min_set = false;
  do{
    long length = 0;
    REP(i,r-1){
      length += dist[towns[i]-1][towns[i+1]-1];
    }
    if(!min_set||length<min_length){
      min_length = length;
      min_set = true;
    }
  }while(next_permutation(towns.begin(),towns.end()));
  cout << min_length << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <math.h>
using namespace std;

const long long INF = 1LL << 60;  // どういう意味だろうか

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}


int main() {
	int N;
	string A, B, C;
	cin >> N >> A>>B>>C;
	int count = 0;

	for(int i =0; i < N; i++){
		if((A[i] == B[i]) && (A[i] == C[i])){
			continue;
		}
		else if((A[i] == B[i]) || (A[i] == C[i])|| (B[i] == C[i])){
			count++;
		}
		else{
			count += 2;
		}
	}

	cout << count << endl;


}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int n;
	scanf("%d",&n);
	if(1 <= n%100 && n%100 <=12){
		if(1<=n/100&&n/100<=12){
			printf("AMBIGUOUS\n");
			return 0;
		}else {
			printf("YYMM\n");
			return 0;
		}
	}else if(13<=n%100 || n%100==0){
		if(1<=n/100 &&  n/100 <= 12){
			printf("MMYY\n");
			return 0;
		}else{
			printf("NA\n");
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 128
n = int(input())

def divisor(n):
    res = 0
    for i in range(1,n+1):
        if n % i  == 0:
            res += 1
    return res

ans = 0
for i in range(1, n+1, 2):
    if divisor(i) == 8:
        ans += 1
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::unordered_set;
using std::map;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

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> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  ui D, N; cin >> D >> N;
  ui d{1};
  while(D)
  {
    d *= 100;
    --D;
  }

  auto ans = d * (N != 100 ? N : N + 1);
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
MOD = 1000000007  # type: int

def combination(n: int, r:int, mod=MOD):
    n1 = n+1
    r = min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod

def solve(X: int, Y: int):

    u = (2*Y - X)//3
    r = (X- u)//2

    if ((2*Y - X)%3!=0) or (r*u <0):
        print(0)
        return

    a = combination(u+r, u)
    print(a)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(X, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i, 0, n)
    {
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << '\n';
    cout << "WA x " << mp["WA"] << '\n';
    cout << "TLE x " << mp["TLE"] << '\n';
    cout << "RE x " << mp["RE"] << '\n';
    return 0;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
#define int long long
#define hh puts("")
#define mo 1000000007
using namespace std;
int n,A,B,ans=1;
int jc[200005],ny[200005],min_col[200005],cnt[200005];
struct node{
	int c,w;
}a[200005];
inline int read(){
	int ret=0,ff=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-') ff=-1;ch=getchar();}
	while(isdigit(ch)){ret=(ret<<3)+(ret<<1)+(ch^48);ch=getchar();}
	return ret*ff;
}
int ksm(int x,int y){
	int res=1;
	while(y){
		if(y&1) res=res*x%mo;
		y>>=1;
		x=x*x%mo;
	}
	return res;
}
inline int C(int x,int y){
	return jc[x]*ny[y]%mo*ny[x-y]%mo;
}
signed main(){
	jc[0]=1;
	for(int i=1;i<=200000;i++){
		jc[i]=(jc[i-1]*i)%mo;
		ny[i]=ksm(jc[i],mo-2);
	}
	n=read(),A=read(),B=read();
	for(int i=1;i<=n;i++){
		a[i].c=read();
		a[i].w=read();
		min_col[i]=1e17;
		cnt[a[i].c]++;
	}
	for(int i=1;i<=n;i++)
		min_col[a[i].c]=min(min_col[a[i].c],a[i].w);
	int zuixiao=1,cixiao=1e17;
	for(int i=1;i<=n;i++)
		if(min_col[i]!=1e17)
			if(min_col[i]<min_col[zuixiao])
				zuixiao=i;
	
	for(int i=1;i<=n;i++)
		if(min_col[i]!=1e17&&i!=zuixiao)		
			cixiao=min(cixiao,min_col[i]);
	for(int i=1;i<=n;i++){
		if(a[i].w!=min_col[a[i].c]&&a[i].w+min_col[a[i].c]<=A) continue;
		if(a[i].c!=zuixiao&&a[i].w+min_col[zuixiao]<=B) continue;
		if(a[i].c==zuixiao&&a[i].w+cixiao<=B) continue;
		cnt[a[i].c]--;
	}
	int sum=cnt[zuixiao];
	for(int i=1;i<=n;i++){
		if(i!=zuixiao&&min_col[i]+min_col[zuixiao]<=B){
			sum+=cnt[i];
			ans=ans*C(sum,cnt[i])%mo;
		}
	}
	printf("%lld",ans);	
	return 0;
}

Measured memory_bytes: 9600
N,C,K = map(int,input().split())
src = [int(input()) for i in range(N)]
src.sort()

ans = dept = seat = 0
for t in src:
    if dept >= t and seat > 0:
        seat -= 1
    else:
        dept = t + K
        seat = C-1
        ans += 1
print(ans)

Measured memory_bytes: 7384
using System;

namespace Atc_0008
{
    class Program
    {
        static void Main(string[] args)
        {
            var rstr = Console.ReadLine();

            int D = int.Parse(rstr.Split(' ')[0]);
            int T = int.Parse(rstr.Split(' ')[1]);
            int S = int.Parse(rstr.Split(' ')[2]);

            int len = 0;
            int min = 0;

            while (true)
            {
                min++;
                len += S;

                if (D <= len)
                {
                    break;
                }
            }

            if (min <= T)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 27388
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 is_prime(x: i64) -> bool {
    let mut is_p = true;
    //2未満は素数でない
    if x < 2 {
        is_p = false;
    //2は素数
    } else if x == 2 {
        is_p = true;
    //2の倍数は素数でない
    } else if x % 2 == 0{
        is_p = false;
    } else {
        //3から(i*i <= x) まで2ずつ増やしながらxを割り切れるか判定、割り切れる値があれば素数でない。
        //(i*i <= x)は√xの範囲と同値 O(√N)
        let mut counter = Some(3);
        while let Some(i) = counter {
            if i*i <= x {
                if x % i == 0 {
                    is_p = false;
                    counter = None;
                }else{
                    counter = Some(i+2);
                }
            } else{
                counter = None;
            }
        }
    }
    is_p
} 

//https://qiita.com/jin237/items/d544edcdfc7a08fa6998
//https://qiita.com/xryuseix/items/7e9b4c6f12d001a0c0db
fn main() {
    let mut a: i64 = read();

    loop{
        if is_prime(a) {
            println!("{}", a);
            break;
        }
        a += 1;
    }
}


Measured memory_bytes: 4352
<?php
$line=trim(fgets(STDIN));
for($i=0;$i<$line;$i++){
	list($a,$b,$c)=explode(" ",trim(fgets(STDIN)));
	$a=$a*$a;
	$b=$b*$b;
	$c=$c*$c;
	if($a+$b==$c||$a+$c==$b||$b+$c==$a){
		echo "YES"."\n";
	}else{
		echo "NO"."\n";
	}
}

Measured memory_bytes: 15332
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String ans = "";
		for( int i=0; i<19; i++ ){
			if( s.charAt(i) == ',' ){
				ans += " ";
			}else{
				ans += s.charAt(i);
			}
		}
	System.out.println(ans);
	return;
	}
}

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

using lint = long long int;

class Combination {
private:
	const int N;
	const lint MOD;
	vector< lint > fact, inv;
	
	lint powmod(lint x, lint k) {
		lint res = 1;
		while (k) {
			if (k&1) res = (res * x) % MOD;
            x = (x * x) % MOD;
			k >>= 1;
		}
		return res;
	}
	
	void precomputation() {
		fact[0] = fact[1] = 1;
		for (int i=2; i<=N; ++i) fact[i] = (fact[i-1] * i) % MOD;
		for (int i=0; i<=N; ++i) inv[i] = powmod(fact[i], MOD-2);
	}
	
public:
	Combination(int N_, lint MOD_) : N(N_), MOD(MOD_), fact(N_), inv(N_) {
        precomputation();
    }
	
	lint compute(int n, int k, bool duplicate = false) {
        if (duplicate) return compute(n+k-1, k);
		if (n < k) return 0;
		lint res = fact[n];
        res = (res * inv[n-k]) % MOD;
        res = (res * inv[k]) % MOD;
		return res;
	}
};

int main() {
    const lint MOD = (lint)1e9 + 7;

    int n, k;
    cin >> n >> k;

    Combination comb(2 * n, MOD);

    lint ans = 1;
    for (int i=1; i<=min(n, k); ++i) {
        lint add = comb.compute(n, i);
        add = (add * comb.compute(n-i, i, true)) % MOD;
        ans = (ans + add) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll arr[200009];
int main()
{
    ll n,t,m,x,i,j,k,maxi = INT_MIN,mini = INT_MAX,flag =0,sum=0;
    vector<ll>vi;
    cin>>n;
    for(i =0 ;i<n ;i++)
    {
        cin>>x;
        vi.push_back(x);
    }
    sum =vi[0];
    for(i = 1 ;i<n ;i++)
    {
        x = __gcd(sum,vi[i]);
        if(sum%x==0)
            sum/=x;
        else
            vi[i]/=x;
        sum*=vi[i];
    }
    cout<<sum<<endl;
    return 0;
}



Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
//#include "atcoder/all"
//using namespace atcoder;
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) (((n) >> (k)) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = true;
}  // namespace mydef
using namespace mydef;
#define pb push_back
//#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans


void solve() {
}

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max({a * c, a * d, b * c, b * d}) << endl;

    solve();
    return 0;
}


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

int main()
{
  int a, b;
  cin >> a >> b;
 // cout << (int)a / (int)b << " " << (int)a % (int)b << " " << endl;
  printf("%d ", a/b);
  printf("%d ", a%b);
  printf("%.8lf\n", (double)a / (double)b);
}


Measured memory_bytes: 3224
#include <algorithm>
#include <iostream>
#include <climits>
#include <cstring>

using namespace std;

const int cap = 1e5 + 1;
int N;
int V[3];
int dp[cap][3];

int main() {
    if (scanf("%d", &N)) {};
    fill(&dp[0][0], &dp[0][0] + (N + 1) * 3, 0);
    for (int i = 1; i <= N; ++i) {
        if (scanf(" %d %d %d", &V[0], &V[1], &V[2])) {};
        for (int j = 0; j < 3; ++j)
            for (int k = 0; k < 3; ++k)
                if (j != k)
                    dp[i][j] = max(dp[i][j], dp[i - 1][k] + V[j]);
    }
    printf("%d", *max_element(&dp[N][0], &dp[N][0] + 3));
}


Measured memory_bytes: 1408
//file_name:ABC79_D.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


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

    int dp[10][10];
    rep(i,10){
        rep(j,10){
            cin >> dp[i][j];
        }
    }

    // ワーシャルフロイド
    rep(k,10){
        rep(i,10){
            rep(j,10){
                dp[i][j] = min(dp[i][j],dp[i][k]+dp[k][j]);
            }
        }
    }


    int ans = 0;
    int hw[h][w];
    rep(i,h){
        rep(j,w){
            cin >> hw[i][j];
            if(hw[i][j]!=-1){
                ans += dp[hw[i][j]][1];
            }
        }
    }

    


    

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



Measured memory_bytes: 512
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner = new Scanner(System.in);
        long a = scanner.nextLong();
        long b = scanner.nextLong();
        long c = scanner.nextLong();
        long d = scanner.nextLong();

        long ans = a * c;
        ans = Math.max(ans, a * d);
        ans = Math.max(ans, b * c);
        ans = Math.max(ans, b * d);

        System.out.println(ans);
    }
}

Measured memory_bytes: 35820
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.07.13 01:31:57
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    while (true) {
        int r, n;
        cin >> r >> n;
        if (r == 0) break;
        vector< int > height(81);
        for (int i = 0; i < n; i++) {
            int x, y, h;
            cin >> x >> y >> h;
            x *= 2;
            y *= 2;
            x += 40;
            y += 40;
            for (int j = x + 1; j <= y - 1; j++) {
                height[j] = max(height[j], h);
            }
        }
        double ans = 1000000;
        for (int i = -r * 2 + 40; i <= r * 2 + 40; i += 2) {
            if (i == -r * 2 + 40) {
                ans = min(ans, height[i + 1] + r - sqrt(r * r - (i - 40) * (i - 40) / 4));
            } else if (i == r * 2 + 40) {
                ans = min(ans, height[i - 1] + r - sqrt(r * r - (i - 40) * (i - 40) / 4));
            } else {
                ans = min(ans, min((i >= 1 ? height[i - 1] : 0), (i < 80 ? height[i + 1] : 0)) + r - sqrt(r * r - (i - 40) * (i - 40) / 4));
            }
        }
        cout << ans << endl;
    }
    return 0;
}



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

using namespace std;

int dp[3007][3007], mx;

int main() {
	string s, t;
	cin >> s >> t;
	int n = s.size(), m = t.size();
	for ( int i = 0; i <= n; i++ ) {
		for ( int j = 0; j <= m; j++ ) {
			if ( !i || !j ) {
				dp[i][j] = 0;
			}
			else if ( s[i - 1] == t[j - 1] ) {
				dp[i][j] = dp[i - 1][j - 1] + 1;
			}
			else {
				dp[i][j] = max( dp[i - 1][j], dp[i][j - 1] );
			}
		}
	}
	mx = dp[n][m];
	int i = n, j = m;
	string ans;
	while ( i && j ) {
		if ( s[i - 1] == t[j - 1] ) {
			ans += s[i - 1];
			i--;
			j--;
		}
		else if ( dp[i - 1][j] >= dp[i][j - 1] ) {
			i--;
		}
		else {
			j--;
		}
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
}

Measured memory_bytes: 35584
#include <algorithm>
#include <bitset>
//#include <boost/multiprecision/cpp_int.hpp>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
//namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
// using ll = boost::multiprecision::cpp_int;
using ll = long long;
#define FORi(N) for(ll i = 0; i < N; ++i)
#define FORj(N) for(ll j = 0; j < N; ++j)
#define FORk(N) for(ll k = 0; k < N; ++k)

#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
void swap(ll &a, ll &b) {
    ll tmp = a;
    a = b;
    b = tmp;
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}

int main() {
    ll N;
    cin >> N;
    ll _max = 0;
    ll num_max = 0;
    vector<ll> A(N),b;
    FORi(N) {
        cin >> A[i];
    }
    b = A;
    sort(RALL(A));
    FORi(N) { 
        if(b[i]==A[0]){
            cout << A[1] << endl;
        }else{
            cout << A[0] << endl; 
        }
    }
    return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>

#define FOR(i, a, b) for(int i=(int)a; i < (int)b; ++i)
#define REP(i, n) FOR(i,0,n)
#define RFOR(i, a, b) for(int i=(int)b-1; i >= (int)a; --i)
#define RREP(i, n) RFOR(i,0,n)
#define IN(a,x,b) (a<=x && x < b)
template<class T> inline void chmax(T& a, const T& b){if(a<b) a = b;}
template<class T> inline void chmin(T& a, const T& b){if(a>b) a = b;}

using namespace std;
using ll = long long;
template<class T> using V = std::vector<T>;
template<class T> using VV = V<V<T>>;

constexpr int INFINT = (1 << 30) - 1;
int cost[22][20004];
int g[22][102][102];
int G[102][102];

signed main(){
  int n, m, C, s, g_;
  while(std::cin >> n >> m >> C >> s >> g_, n || m || C || s || g_) {
    --s; --g_;
    V<int> x(m), y(m), d(m), c(m);
    REP(i, m) std::cin >> x[i] >> y[i] >> d[i] >> c[i], --x[i], --y[i], --c[i];
    V<int> p(C);
    REP(i, C) std::cin >> p[i];
    VV<int> q(C), r(C);
    REP(i, C) {
      q[i].resize(p[i] - 1);
      r[i].resize(p[i]);
      REP(j, p[i] - 1) std::cin >> q[i][j];
      q[i].emplace_back(INFINT);
      REP(j, p[i]) std::cin >> r[i][j];
    }

    { // fill cost[][]
        REP(j, C) {
          cost[j][0] = 0;
          int pos = 0;
          FOR(d, 1, 20004) {
            cost[j][d] = cost[j][d-1] + r[j][pos];
            if(d == q[j][pos]) ++pos;
          }
        }
    }

    REP(k, C) {
      REP(i, n) REP(j, n) g[k][i][j] = INFINT;
      REP(i, n) g[k][i][i] = 0;
      REP(i, m) {
        if(c[i] != k) continue;
        chmin(g[k][x[i]][y[i]], d[i]);
        chmin(g[k][y[i]][x[i]], d[i]);
      }
    }

    REP(p, C) REP(k, n) REP(i, n) REP(j, n) {
      chmin(g[p][i][j], g[p][i][k] + g[p][k][j]);
    }

    REP(p, C) REP(i, n) REP(j, n) {
      if(g[p][i][j] >= INFINT) continue;
      g[p][i][j] = cost[p][g[p][i][j]];
    }

    REP(i, n) REP(j, n) G[i][j] = INFINT;
    REP(i, n) G[i][i] = 0;

    REP(p, C) REP(i, n) REP(j, n) chmin(G[i][j], g[p][i][j]);

    REP(k, n) REP(i, n) REP(j, n) chmin(G[i][j], G[i][k] + G[k][j]);

    int ans = G[s][g_];
    if(ans >= INFINT) ans = -1;
    std::cout << ans << std::endl;
  }
  return 0;
}



Measured memory_bytes: 5700
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define ABS(a,b) max(a,b) - min(a,b)


int main() {
	ll ans = 0, w = 0;
	string s;
	cin >> s;
	REP(i, s.size()) {
		if (s[i] == 'B')w++;
		else ans += w;
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdlib>
#include <list>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

int main(void)
{
    char c;

    cin >> c;

    switch(c)
    {
    case 'A':
        cout << 'T';
        break;
    case 'C':
        cout << 'G';
        break;
    case 'G':
        cout << 'C';
        break;
    case 'T':
        cout << 'A';
        break;
    }
    
    cout <<endl;
        
    return 0;
}

Measured memory_bytes: 888
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();

		for(int i = 1; i < x + 1; i++) {
			if(i % 3 == 0) {
				System.out.print(" " + i);
			}
			else {
				int temp = i;
				while(temp >= 1) {
					if(temp % 10 == 3) {
						System.out.print(" " + i);
						break;
					}
					temp /= 10;
				}
			}
		}
				System.out.println();
	}

}


Measured memory_bytes: 28592
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PI 				acos(-1)
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define sz(a)			a.size()
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define MOD1			998244353
#define fore(i, b, e)	for(int i = b; i < e; i++)
#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)
int in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
using namespace __gnu_pbds;

typedef long long 		ll;
typedef unsigned long long 		ull;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//find_by_order kth largest  order_of_key <
const int tam = 100010;
const int MOD = 1e9+7;
const double EPS = 1e-9;
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	//freopen("qwe.txt", "r", stdin);
	//freopen("asd.txt", "w", stdout);
	int a, b, c, x, y, ax;
	cin>>a>>b>>c>>x>>y;
	int res = 0;
	if(2 * c <= a + b)
	{
		ax = min(x, y) * 2;
		res += ax * c;
		x -= ax/2, y -= ax/2;
	}
	if(2 * c <= a)
	{
		res += x * 2 * c;
		x = 0;
	}
	if(2 * c <= b)
	{
		res += y * 2 * c;
		y = 0;
	}
	res += x * a + y * b;
	cout<<res<<'\n';
	return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int *min_arr;
void updateMin(int i, int w)
{
   if(w < min_arr[i])
   {
      min_arr[i] = w;
   }
}
int main()
{
   int n, k;

   cin >> n >> k;
   min_arr = new int[n];
   int weight[n];
   for(int i = 0; i < n; i++) {
      cin >> weight[i];
   } 
   
   for (int i = 0; i < n; i++) min_arr[i] = INT_MAX;

   //build 2d array
   for(int i = 0; i < n; i++)
   {
      if (i == 0)
      {
         min_arr[0] = 0;
         // mat[0][0] = 0;
      } 
      
      for(int j = 1; j <= k; j++)
      {
          if(i + j < n)
          {
              updateMin(i + j, abs(weight[i] - weight[i + j]) + min_arr[i]);
          }
      }
   }
   cout << min_arr[n-1] << endl;
}

Measured memory_bytes: 4384
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll t=1,n,i,j,k,l,a,b;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    //cin>>t;
    while (t--) {
      cin>>n>>a>>b;
      i=n-a;
      cout<<i-i/b*b<<"\n";
    }
    return 0;
}

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

struct code {
  vector<int> V;
  
  bool operator<( const code& right ) const { // 数字の大小
    if (V.size() != right.V.size()) {
      return V.size() < right.V.size();
    } else {
      for (unsigned int i=0; i<V.size(); i++) {
	if (V[i] != right.V[i]) {
	  return V[i] < right.V[i];
	}
      }
    }
    return true;
  }
};

struct panel {
  bool v; // valueかどうか
  int n; // 数字の場合は数字を入れる。
  code C; // 「そこから先」で作れるmaxの番号
};

const int dir[2][2] = { {0, 1}, {1, 0} };

int main() {
  int W, H;
  char t;
  while (scanf("%d%d", &W, &H) != EOF && W && H) {
    vector<vector<panel>> T(H, vector<panel> (W));
    for (int i=0; i<H; i++) {
      for (int j=0; j<W; j++) {
	scanf(" %c", &t);
	T[i][j].v = isdigit(t);
	if (T[i][j].v) {
	  T[i][j].n = (int)t - '0';
	}
      }
    }
    code max;
    for (int i=0; i<H; i++) {
      for (int j=0; j<W; j++) {
	int ip = H-1-i;
	int jp = W-1-j;
	if (T[ip][jp].v) {
	  code X;
	  for (int k=0; k<2; k++) {
	    if (ip+dir[k][0] < H && jp+dir[k][1] < W 
		&& T[ip+dir[k][0]][jp+dir[k][1]].v) {
	      code Ctemp = T[ip+dir[k][0]][jp+dir[k][1]].C;
	      if (X < Ctemp) X = Ctemp;
	    }
	  }
	  X.V.insert(X.V.begin(), T[ip][jp].n);
	  T[ip][jp].C = X;
	  if (T[ip][jp].n != 0 && max < X) {
	    max = X;
	  }
	}
      }
    }
    for (unsigned int i=0; i<max.V.size(); i++) {
      printf("%d", max.V[i]);
    }
    printf("\n");
  }
}

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

int main()
{
	int n, k, a[1005], b=0;
	cin >> n >> k;
	
	for (int i=1; i<=n; i++)
		cin >> a[i];
	
	sort (a, a+n+1);
	
	for (int i=1; i<=k; i++)
	{
		b += a[i];
	}
	
	cout << b << endl;
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

class UnionFind {
    // 各ノードが根である時の高さ
    // ノードが根でないときは意味をなさない
    vector<int> rank;
    // 各ノードが属する木の根
    // findSetするときのみ更新される
    vector<int> p;
    // 二つの根を結合
    void link(int rx, int ry) {
        if (rx == ry) return;
        if (rank[rx] > rank[ry]) p[ry] = rx;
        else p[rx] = ry;
        if (rank[rx] == rank[ry]) rank[ry]++;
    }
public:
    //　根を作成
    // その木の高さは0
    void makeSet(int x) {
        p[x] = x;
        rank[x] = 0;
    }
    // 初期化
    // 入力サイズ分のノードを確保
    // それらのノードをそれぞれ根とする木を作成
    // ノードの値は 0 ~ size-1
    UnionFind(int size) {
        rank.resize(size, 0);
        p.resize(size, 0);
        rep(i,size) makeSet(i);
    }
    // あるノードの属する木の根を返す
    // 根を探す過程で途中のノードの親も更新
    int findSet(int x) {
        if (x != p[x]) p[x] = findSet(p[x]);
        return p[x];
    }
    // 二つのノードが同じ木にあるか判定
    bool same(int x, int y) {return findSet(x) == findSet(y);}
    // 二つのノードの属する木を結合
    void unite(int x, int y) {link(findSet(x), findSet(y));}
};


int main() {
    fast_io
    int n, m;
    cin >> n >> m;
    vector<int> p(n);
    rep(i,n) {
        cin >> p[i];
        p[i]--;
    }
    UnionFind u(n);
    int x, y;
    rep(i,m) {
        cin >> x >> y;
        u.unite(x-1, y-1);
    }
    int ans = 0;
    rep(i,n) {
        if (u.same(i, p[i])) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i < n; ++i)
using namespace std;
const int INF = 2147483647;
using ll = long long;

int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    for (int i=0;i<n;i++){
        cin >> x.at(i);
    }
    vector<int> b = x;
    sort(b.begin(),b.end());
    int l,r;
    l = b.at(n/2-1);
    r = b.at(n/2);
    vector<int> ans(n);
    for (int i=0;i<n;i++){
        if(x.at(i)<=l) ans.at(i) = r;
        else ans.at(i) = l;
    }
    for (int i=0;i<n;i++){
        cout << ans.at(i) << '\n';
    }
    return 0;
}



Measured memory_bytes: 4480
/**
 * Sergey Kopeliovich (burunduk30@gmail.com)
 */

#include <bits/stdc++.h>

using namespace std;

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

const int N = 2e5;

typedef long long ll;

int n;
char s[N + 1];

int main() {

	scanf("%s", s);
	n = strlen(s);
	ll ans = 1 + (ll)n * (n - 1) / 2;
	vector<int> cnt(26);
	forn(i, n) cnt[s[i] - 'a']++;
	forn(i, 26) ans -= (ll)cnt[i] * (cnt[i] - 1) / 2;
	printf("%lld\n", ans);
	// ll ans = (ll)n * (n + 1) / 2;

	// vector<int> d1 (n);
	// int l=0, r=-1;
	// for (int i=0; i<n; ++i) {
	// 	int k = (i>r ? 0 : min (d1[l+r-i], r-i)) + 1;
	// 	while (i+k < n && i-k >= 0 && s[i+k] == s[i-k])  ++k;
	// 	d1[i] = k--;
	// 	if (i+k > r)
	// 		l = i-k,  r = i+k;
	// }

	// vector<int> d2 (n);
	// l=0, r=-1;
	// for (int i=0; i<n; ++i) {
	// 	int k = (i>r ? 0 : min (d2[l+r-i+1], r-i+1)) + 1;
	// 	while (i+k-1 < n && i-k >= 0 && s[i+k-1] == s[i-k])  ++k;
	// 	d2[i] = --k;
	// 	if (i+k-1 > r)
	// 		l = i-k,  r = i+k-1;
	// }

	// forn(i, n) printf("%d ", d1[i]); puts("");
	// forn(i, n) printf("%d ", d2[i]); puts("");
	// printf("%lld\n", ans + 1);
	// forn(i, n) ans -= d1[i] + d2[i];
	// printf("%lld\n", ans + 1);
	// set<string> was;
	// auto out = [&]( int l, int r ) {
	// 	reverse(s + l, s + r + 1);
	// 	puts(s);
	// 	fflush(stdout);
	// 	assert(was.insert(string(s)).second);
	// 	reverse(s + l, s + r + 1);
	// };
	// forn(i, n)
	// 	for (int len = d1[i]; 0 <= i - len && i + len < n; len++) {
	// 		printf("odd i=%d len=%d : ", i, len);
	// 		out(i - len, i + len);
	// 	}
	// forn(i, n)
	// 	for (int len = d2[i]; 0 <= i - len && i + len + 1 < n; len++) {
	// 		printf("event i=%d len=%d : ", i, len);
	// 		out(i - len, i + len + 1);
	// 	}
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int n,k;
int a[200010];
bool cmp(int x,int y){
	return x>y;
}
int main() { 
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n>>k;
	int mx=0;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		mx=max(mx,x);
		a[x-1]++;
	}
	sort(a,a+mx,cmp);
	int ans=n;
	for(int i=0;i<k;i++){
		ans-=a[i];
	}
	cout<<ans<<endl;
    return 0; 
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<ll, ll>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl

class mint {
    long long x;
public:
    mint(long long x=0) : x((x%MOD+MOD)%MOD) {}
    mint operator-() const {
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

/* -- template -- */

int main() {
    int K; cin >> K;
    string S; cin >> S;
    if(S.size() <= K) {
        cout << S << endl;
    }else {
        rep(i, K){
            cout << S[i];
        }
        cout << "..." << endl;
    }
}


Measured memory_bytes: 3600
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}
int mod = 1000000000 + 7;
int dp[101][4][4][4];
int main()
{
        //input->compute->output//

        int N, M;
        cin >> N >> M;
        vector<int> A(N), B(N);
        for (int i = 0; i < N; i++)
        {
                cin >> A[i] >> B[i];
        }

        vector<pair<int, int>> vec(N);
        for (int i = 0; i < N; i++)
        {
                vec[i] = make_pair(A[i], B[i]);
        }
        sort(vec.begin(), vec.end());

        ll ans = 0;
        int cnt;
        for (int i = 0; i < N; i++)
        {
                cnt = min(M, vec[i].second);
                ans += (ll)cnt * vec[i].first;
                M -= cnt;
        }
        cout << ans << endl;
        return 0;
}


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


int main(){
    int A,B,C,a,b,c;
    cin >> A >>B >> C;
    a=A;
    b=B;
    c=C;
    if(a==b){
        printf("%d\n",c);
    }
    else if(b==c){
        printf("%d\n",a);
    }
    else printf("%d\n",b);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main(){
  cin>>a>>b;
  if(a+b>=a-b && a+b>=a*b){
    cout<<a+b<<endl;}
  else if(a-b>=a*b){
    cout<<a-b<<endl;}
  else if(a*b>=a-b){
    cout<<a*b<<endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <functional>
#include <iomanip>
#include <queue>
#include <unordered_map>

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;

#define mem(a, b) memset(a, b, sizeof(a))
#define REP(i, a) for (int i = 0; i < a; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(a) a.begin(), a.end()

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}

inline void print_vector(vector<int> &A){
    for (auto&& x : A){
        cout << x << " ";
    }
    cout << endl;
}

inline void print_array(const int A[], int n) {
    REP(i, n) {
        cout << A[i] << " ";
    }
    cout << endl;
}

bool is_prime(int n) {
    if (n == 2) return true;
    for (int i = 2; i < sqrt(n) + 1; ++i) {
        if (n % i == 0) {
            return false;
        }
    }

    return true;
}

int bs(int x, vector<int>& A) {
    int cur = 0;
    for (auto a : A) {
        if (a % x == 0) {
            cur += a / x - 1;
        } else {
            cur += a / x;
        }
    }

    return cur;
}

inline void solve() {
    int n, k;
    cin >> n >> k;

    vector<int> A;

    int x;
    int max_x = 0;

    REP(i, n) {
        cin >> x;
        A.push_back(x);
        max_x = max(max_x, x);
    }

    int l = 1, r = max_x;

    while (l < r) {
        int m = l + (r - l) / 2;
        // cout << l << " " << r << " " << m << " " << bs(m, A) << endl;
        if (bs(m, A) <= k) {
            r = m;
        } else {
            l = m + 1;
        }
    }

    cout << l << endl;
}


int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    int t;
    t = 1;
    // cin >> t;

    for (int _ = 0; _ < t; _++) {
        solve();
    }

    return 0;
}


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

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

    int a, b, k;
    cin >> a >> b >> k;
    for (int i = a;; i--) {
        if (a % i == 0 && b % i == 0) {
            k--;
            if (k == 0) {
                cout << i << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)

int main()
{

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  int n, m, x;
  cin >> n >> m >> x;

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

  vector<int> b(m);
  for (int b_i = 0; b_i < m; b_i++) {
    cin >> b[b_i];
  }

  ll sum = 0, count = 0, temp = 0, i = 0, j = 0;

  while (i < n && sum + a[i] <= x) { //considering only first stack and calculating count
    sum += a[i];
    i++;
  }

  count = i;
  i--;


  while (j < m && i < n) {    //now adding one element of second stack at a time and subtracting the top element of first stack and calculating the count
    sum += b[j];

    while (sum > x && i >= 0) {

      sum -= a[i--];
    }
    if (sum > x && i < 0)
    { j--;
      break;
    }
    count = max(i + j + 2, count);
    j++;

  }

  cout << count << endl;

  return 0;
}


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

int main(){
  vector<int> count(2,0);
  string S;
  
  cin>>S;
  
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='0')
      count.at(0)++;
    else
      count.at(1)++;
  }
  if(count.at(0)<count.at(1))
    cout<<count.at(0)*2<<endl;
  else
    cout<<count.at(1)*2<<endl;
}

    


Measured memory_bytes: 512