akhauriyash/Code-Regression huggingface dataset:
/* include */
#include <bits/stdc++.h>

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

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

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) \
    sort(all(x));  \
    (x).erase(unique(all(x)), (x).end())
#define int long long
#define mp make_pair
#define r0 return 0

/* function */
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

/* const */
const int inf = 1e9 + 7;
const int dxl[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dyl[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dxs[4] = {1, 0, -1, 0};
const int dys[4] = {0, 1, 0, -1};

/* main */
signed main(void)
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c && c == a)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,lst[1000100][26],gg[1000100];
char s[1000100],t[1000100];

struct treaps
{
	int son[1201000][2],size[1201000],num[1201000],tag[1201000],rd[1200100],tt;
	void update(int s){size[s]=size[son[s][0]]+size[son[s][1]]+1;}
	int build(int n)
	{
		if (n==0) return 0;
		int s=++tt;size[s]=1;
		n--;
		son[s][0]=build(n/2);son[s][1]=build(n-n/2);
		update(s);
		return s;
	}
	inline void pushdown(int s)
	{
		if (son[s][0]) {tag[son[s][0]]+=tag[s];num[son[s][0]]+=tag[s];}
		if (son[s][1]) {tag[son[s][1]]+=tag[s];num[son[s][1]]+=tag[s];}
		tag[s]=0;
	}

	void addtag(int s) {tag[s]++;num[s]++;}
	int merge(int s,int t)
	{
		if (!s) return t;
		if (!t) return s;
		pushdown(s);pushdown(t);
		if ((rand()*32768+rand())%(size[s]+size[t])<size[s]) {son[s][1]=merge(son[s][1],t);update(s);return s;}
		else {son[t][0]=merge(s,son[t][0]);update(t);return t;}
	}
	pair<int,int> split(int s,int k)
	{
		if (!s) return pair<int,int>(0,0);
		pushdown(s);
		if (size[son[s][0]]>=k)
		{
			pair<int,int> ls=split(son[s][0],k);
			son[s][0]=ls.second;update(s);
			return pair<int,int>(ls.first,s);
		}
		pair<int,int> ls=split(son[s][1],k-size[son[s][0]]-1);
		son[s][1]=ls.first;update(s);
		return pair<int,int>(s,ls.second);
	}
	int findkth(int s,int k)
	{
		while (1)
		{
			pushdown(s);
			if (size[son[s][0]]>=k) s=son[s][0];
			else if (size[son[s][0]]+1==k) return num[s];
			else {k-=(size[son[s][0]]+1);s=son[s][1];}
		}
	}
}treap;
int main()
{
	//freopen("in.txt","r",stdin);
	scanf("%d\n%s\n%s",&n,s+1,t+1);
	bool err=false;
	for (int i=1;i<=n;i++)
	{
		for (int j=0;j<26;j++) lst[i][j]=lst[i-1][j];
		lst[i][s[i]-'a']=i;
		if (s[i]!=t[i]) err=true;
	}
	if (err==false) {printf("0\n");return 0;}
	int root=treap.build(n),ans=1,rem=n;
	for (int i=n;i>=1;i--) if (t[i]!=t[i-1])
	{//if (i%10000==0) cerr<<i<<' '<<treap.size[root]<<endl;
		//for (int j=1;j<=i;j++) cout<<treap.findkth(root,j)<<' ';cout<<endl;
		int w=treap.findkth(root,i);
		if ((w!=0)||(s[i]!=t[i])) ans=max(ans,w+2);
		int d=lst[min(i-(w!=0),rem)][t[i]-'a'];rem=d-1;
			if (d==0) {printf("-1\n");return 0;}
			pair<int,int> p=treap.split(root,d-1);
			pair<int,int> q=treap.split(p.second,1);
			treap.addtag(q.second);
			root=treap.merge(p.first,q.second);
		
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 131712
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <assert.h>

using namespace std;

typedef long long ll;

const int MAXN = 100005;
const int INF = (1 << 30) - 1;

int n;
int A[MAXN];
int B[MAXN];

ll ans,final_ans;

bool mark[MAXN];

pair<int,int> a[MAXN];
pair<int,int> b[MAXN];

int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 1;i <= n;i++)
	{
		cin >> a[i].first >> b[i].first;
		A[i] = a[i].first;
		B[i] = b[i].first;
		a[i].second = b[i].second = i;
	}
	sort(a + 1,a + n + 1);
	sort(b + 1,b + n + 1);
	int i = 1,j = 1,MINa = INF,MINb = INF;
	for (int t = 1;t <= n;t++)
	{
		if (a[i].first < b[j].first)
		{
			ans += a[i].first;
			mark[a[i].second] = true;
			if (i > 1)
				MINb = min(MINb,B[a[i - 1].second]);
			i++;
		}
		else
		{
			ans += b[j].first;
			mark[b[j].second] = true;
			if (j > 1)
				MINa = min(MINa,A[b[j - 1].second]);
			j++;
		}
	}
	if (i == 1 || j == 1)
	{
		cout << ans << endl;
		return 0;
	}
	for (int i = 1;i <= n;i++)
		if (!mark[i])
		{
			cout << ans << endl;
			return 0;
		}
	final_ans = (1ll << 60) - 1;
	final_ans = min(final_ans,ans - a[i - 1].first + MINb);
	if (i == 2)
		final_ans = min(final_ans,ans - a[i - 1].first + b[j].first);
	if (i > 2)
		final_ans = min(final_ans,ans - a[i - 2].first + B[a[i - 1].second]);
	final_ans = min(final_ans,ans - a[i - 1].first + min(MINa,A[b[j - 1].second]));
	final_ans = min(final_ans,ans - b[j - 1].first + MINa);
	if (j == 2)
		final_ans = min(final_ans,ans - b[j - 1].first + a[i].first);
	if (j > 2)
		final_ans = min(final_ans,ans - b[j - 2].first + A[b[j - 1].second]);
	final_ans = min(final_ans,ans - b[j - 1].first + min(MINb,B[a[i - 1].second]));
	cout << final_ans << endl;
	return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<stdio.h>
#include<cmath>
#include<limits>
#include<iomanip>

using namespace std;

template <class T> using V = vector<T>;

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;
}

const long long INF = 1LL << 60;

using ll = long long;
using db = long double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
using graph = V<V<int>>;
using pq = priority_queue<ll>;



#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define pb(a) push_back(a);



ll Sum(ll n) {
ll m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}



const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}


#define comuse Comuse()

ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll perm(int n,int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] % MOD) % MOD;
}


ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}


vll div(ll n){
  vll ret;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ret.push_back(i);
      if(i*i!=n){
        ret.push_back(n/i);
      }
    }
  }
  SORT(ret);
  return (ret);
}

ll modpow(ll a,ll n,ll mod){
  ll ans=1;
  while(n>0){
    if(n&1){
      ans=ans*a%mod;
    }

    a=a*a%mod;
    
    n>>=1;
  }

  return ans;
}

void Solve();


const int MAX_N = 131072;
//segment tree 
int NN;
int seg[MAX_N*2-1];
void seguse(){
  for(int i=0;i<2*NN-1;i++){
    seg[i]=INT_MAX;
  }
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //cout<<setprecision(20)<<fixed;
  Solve();
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
//segtreeの葉の先頭の添え字はn-1
void Solve(){
  ll n;
    cin>>n;
  vll A(n);
  ll ans=INF;
  ll all=0;
  FOR(i,0,n){
    cin>>A[i];
    all+=A[i];
  }

  FOR(i,1,n){
    A[i]+=A[i-1];
  }

  FOR(i,0,n){
	ll a=abs(2*A[i]-all);
    chmin(ans,a);
  }
  cout<<ans<<endl;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  int mi,ma;
  int c,d;
  mi = 0;
  ma = a;
  for(int i = 0;i < b;i++){
    cin >> c >> d;
    if(mi < c){
      mi = c;
    }
    if(ma > d){
      ma = d;
    }
  }
  if(ma-mi < 0){
    cout << "0" << endl;
  }else{
    cout << ma-mi+1 << endl;
  }
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

public class Hello{
    public static void Main(){
        var n = int.Parse(Console.ReadLine());
        var a=Console.ReadLine().Trim().Split().Select(int.Parse).ToArray();
        var ans=true;
        var hashset = new HashSet<int>();
        foreach(var v in a)
        {
          if (hashset.Add(v) == false)
          {
            ans=false;
            break;
          }
        }
        System.Console.WriteLine(ans?"YES":"NO");
    }
}


Measured memory_bytes: 37456
n,m=map(int,input().split())
s=[list(map(int,input().split())) for _ in range(n)]
c=[list(map(int,input().split())) for _ in range(m)]
where=[]
for i in range(n):
    distance=10**9
    for j in range(m):
        if distance>abs(s[i][0]-c[j][0])+abs(s[i][1]-c[j][1]):
            distance=abs(s[i][0]-c[j][0])+abs(s[i][1]-c[j][1])
            w=j
    where.append(w+1)
[print(i) for i in where]

Measured memory_bytes: 9100
import Data.List

take' :: [Int] -> [String] -> [String]
take' [] xs = xs
take' (n:ns) xs = take' ns (take n xs ++ tail (xs!!n):[] ++ drop (n+1) xs)

solve :: [String] -> String
solve xs
  | elemIndex [] xs /= Nothing = []
  | 1 == (length . f) xs = f xs ++ solve (map tail xs)
  | otherwise = solve (take' (elemIndices (head $ sort $ map head xs) $ map head xs) xs)
    where f = nub . map head

main = getContents >>= putStrLn . solve . map sort . tail . lines

Measured memory_bytes: 1148
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


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

    int N, K;  cin >> N >> K;

    int ans=0;
    REP(i, N - K + 1) ans++;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
while line = gets
  xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2 = line.chomp.split.map(&:to_f)
  puts (xa2 < xb1 || xb2 < xa1 || ya2 < yb1 || yb2 < ya1) ? :NO : :YES
end

Measured memory_bytes: 8684
n,k=map(int,input().split())
a=list(map(int,input().split()))
maxans=0
sumplus=[0]
for i in range(n):
  if a[i]>0:
    maxans+=a[i]
  sumplus.append(maxans)
penalty=10**18
summinus=[0]
current=0
for i in range(n):
  if a[i]<0:
    current-=a[i]
  summinus.append(current)
for i in range(k,n+1):
  penalty=min(penalty,sumplus[i]-sumplus[i-k])
  penalty=min(penalty,summinus[i]-summinus[i-k])
print(maxans-penalty)
  


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

#define INF (1LL << 31 - 1)
#define MOD int(1e9+7)
#define repi(i,j,n) for(int i = (j); i < (n); ++i)
#define rep(i,n) repi(i,0,n)
#define fi first
#define se second

inline void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

map<int, bool> mp, used;
int n, ans;
vector<int> a;

int main() {
    init();
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (!mp[a[i]]) mp[a[i]] = true;
        else mp[a[i]] = false;
    }

    for (int i = 0; i < n; ++i) {
        if (!used[a[i]]) {
            if (mp[a[i]]) ans++;
            used[a[i]] = true;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9984
#include <cstdio>

using namespace std;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

    long N;

    scanf("%ld", &N);

    long a = N / 15;

    printf("%ld\n", N * 800 - a * 200);

    return 0;
}


Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    int table[200001] = {0}; // n以下の数で、kで割った余りがiの数の個数
    for (int i = 1; i <= n; ++i) table[i % k]++;
    long long ans = 0;
    for (int i = 0; i < k; ++i) { // a % k
        int j = (k - i + k) % k;
        int l = (k - j + k) % k;
        //cout << i << " " << j << " " << l << endl;
        if ((i + l + k) % k != 0) continue;
        ans += (long long)table[i] * table[j] * table[l];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

fn main() {
    let s: String = read();
    let v = s.as_bytes();
    if v[0] == v[1] && v[1] == v[2] {
        println!("No");
    } else {
        println!("Yes");
    }
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

bool U[105];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    REP(i, K) {
        ll d;
        cin >> d;
        REP(j, d) {
            ll a;
            cin >> a;
            U[a - 1] = true;
        }
    }
    ll ans = 0;
    REP(i, N) {
        if (!U[i])
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define N 200005

using namespace std;

const long long mod = 1e9+7;
long long n, k;
long long c[N];

long long a[N], b[N];
long long num[N];
long long ans;

long long calc(int x) {
	long long res = 0;
	for (int i = n; i > x; --i)
		if (a[i] < a[x]) ++res;
	return res;
}

int main() {
	ios::sync_with_stdio(false);

	cin >> n >> k;
	for (int i = 1; i <= n; ++i)
		cin >> a[i], b[i] = a[i];

	sort(b + 1, b + n + 1);
	for (int i = 1; i <= n; ++i)
		num[i] = lower_bound(b + 1, b + n + 1, a[i]) - b - 1;

	for (int i = n; i; --i) {
		(ans += calc(i) * k % mod) %= mod;
		(ans += k * (k - 1) / 2 % mod * num[i] % mod) %= mod;
	}

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


Measured memory_bytes: 2304
import math


def resolve():
    import sys
    input = sys.stdin.readline
    # row = [int(x) for x in input().rstrip().split(" ")]
    # n = int(input().rstrip())

    abm = [int(x) for x in input().rstrip().split(" ")]
    a_list = [int(x) for x in input().rstrip().split(" ")]
    b_list = [int(x) for x in input().rstrip().split(" ")]

    # 最小値
    ans = min(a_list) + min(b_list)

    for i in range(abm[2]):
        xyc = [int(x) for x in input().rstrip().split(" ")]
        price = a_list[xyc[0] - 1] + b_list[xyc[1] - 1] - xyc[2]
        if price < ans:
            ans = price

    print(ans)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 90232
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
typedef long long ll;



set <int> m;


int main()
{
    int N;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        int x;
        cin >> x;
        m.insert(x);
    }

    if (m.size() % 2 == N % 2) cout << m.size();
    else cout << m.size() -1;
    return 0;
}



Measured memory_bytes: 4864
def main():
    H, W = map(int, input().split())
    c = [list(map(int, input().split())) for _ in range(10)]
    a = [list(map(int, input().split())) for _ in range(H)]

    for k in range(10):
        for i in range(10):
            for j in range(10):
                c[i][j] = min(c[i][j], c[i][k] + c[k][j])

    ans = 0
    for row in a:
        for cell in row:
            if ~cell:
                ans += c[cell][1]

    print(ans)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 3316
#include <bits/stdc++.h>
    using namespace std;
    
    typedef long long ll;
    typedef pair<ll , ll> pair_t;
    
    bool comp(const pair_t &a, const pair_t &b) {
        return a.first < b.first;
    }
    
    int main(){
        ll n , m , d ;
        cin >> n >> m >> d;
        double ans = 0.0;
        ll t;
        if(d == 0 ){
            ans = (m -1) * 1.0 / n * 1.0;
        }else if(2 * d < n){
            t = 2 * d;
            ans = ((n - 2 * d) * 2 + 2 * d)* 1.0 / n * (m - 1) * 1.0 / n * 1.0; 
        }else{
            t = n - d;
            ans = 2.0 *  t * 1.0 / n * (m - 1) * 1.0 / n * 1.0;
        }
        
        
        cout << setprecision(10) << fixed << ans << endl;
        
        return 0;
        
    }

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

const ll day_lim = 3652425;

int main(){
  ll n,q;
  scanf("%lld%lld",&n,&q);
  vector<ll> w(n),t(n),x(n);
  rep(i,n)scanf("%lld%lld%lld",&w[i],&t[i],&x[i]);
  vector<ll> y(q);
  rep(i,q)scanf("%lld",&y[i]);
  
  ll pn = 0, pq = 0;
  priority_queue< pll, vector<pll>, greater<pll> > end;
  vector<ll> ansn(n,day_lim+1), ansq(q,day_lim+1);
  ll day=0, sum = 0, a=0,b=0,c=1;

  while(day<=day_lim){
    if(pq<q && y[pq] == day){
      ansq[pq] = sum;
      pq++;
    }

    while(pn<n && w[pn]<=sum){
      ansn[pn] = day;
      if(t[pn] == 0){
	c++;
      }else if(t[pn] == 1){
	b++; c-=day;
      }else if(t[pn] == 2){
	a++; b-=2*day; c+=day*day;
      }
      end.push(pll(day+x[pn],pn));
      pn++;
    }

    while(end.size() && end.top().first==day){
      ll id = end.top().second; end.pop();
      if(t[id] == 0){
	c--;
      }else if(t[id] == 1){
	b--; c+=ansn[id];
      }else if(t[id] == 2){
	a--; b+=2*ansn[id]; c-=ansn[id]*ansn[id];
      }
    }

    day++;
    sum += a*day*day + b*day + c;
    if(pn == n && pq==q)break; 
  }

  rep(i,n){
    if(ansn[i]>day_lim)puts("Many years later");
    else printf("%lld\n",ansn[i]);
  }
  rep(i,q)printf("%lld\n",ansq[i]);
}

Measured memory_bytes: 7292
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
    result=(result*base)%modulus;
    exponent=exponent>>1;
    base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
  if(N<K)return 0;
  if(K==0)return 1;
  if(N==0)return 0;

  ll den=1;
  for(ll i=1;i<=K;i++)den*=i;
  ll num=1;
  while(K--){
    num*=N;
    if(num%den==0){
      num/=den;
      den=1;
    }
    N--;
  }

  return num;
}
*/
string s,t;
ll a,b;
int main(){FAST;
cin>>s>>t;
cin>>a>>b;
string u;
cin>>u;
if(s == u)a--;
else if(t == u)b--;
cout<<a<<' '<<b;
return 0;
} 

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	string o, e; cin >> o >> e;
	for (int i = 1; i <= (int)o.size()+(int)e.size(); ++i) {
		if (i%2==0) {
			cout << e[i/2-1];
		} else {
			cout << o[i/2];
		}
	}
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);

		int a;
		int b;

		a = scan.nextInt();
		b = scan.nextInt();

		System.out.print(a * b + " ");
		System.out.println(2 * a + 2 * b);
	}
}

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

int main() {
  int n,cost;
  while(cin >> n >> cost) {
    int v[cost+1],d[cost+1],l[cost+1];
    for(int i=0; i<=cost; i++) {
      v[i]=0;
      d[i]=0;
      l[i]=0;
    }
    int ans=0;
    while(n--) {
      string s;
      for(int i=0; i<2; i++) {
	string t;
	getline(cin, t);
	if(i==1) s=t;
      }
      int z,a,b,c;
      cin >> z >> a >> b >> c;
      for(int i=0; i<=cost; i++) {
	if(i==0 || v[i]) {
	  if(i+z<=cost) v[i+z]=max(v[i+z],v[i]+a);
	  if(ans<v[i]) ans=v[i];
	}
	if(i==0 || d[i]) {
	  if(i+z<=cost) d[i+z]=max(d[i+z],d[i]+b);
	  if(ans<d[i]) ans=d[i];
	}
	if(i==0 || l[i]) {
	  if(i+z<=cost) l[i+z]=max(l[i+z],l[i]+c);
	  if(ans<l[i]) ans=l[i];
	}
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 1212
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int i = s; i < e; i++)
#define endl '\n'
int main()
{
    int n, x, t;
    cin >> n >> x >> t;
    int ans = (n +x-1)/x * t;
    cout << ans << endl;
}

Measured memory_bytes: 3588
#include <stdio.h>

int main()
{
  int i, j, n;
  unsigned int pow2[] = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144};
  char buf[128];
  buf[127] = 0;
  buf[126] = ':';
  int b[19];
  fscanf(stdin, "%d\n", &n);
  unsigned int u, v, val=1;
  fgets(buf, 120, stdin);
  b[0] = 0;  
  i=0;
  for (char *p=buf; *p!='\n'; p++) {
    if (*p == ' ') {
      i++;
      p++;
      b[i] = *p-'0';
    } else {
      b[i] = b[i] * 10 + *p - '0';
    }
  }
  unsigned int c=0;
  for (i=0; i<b[0]; i++)  c |= pow2[b[i+1]];
  
  if (b[0]==0)  fputs("0:\n", stdout);
  //  for (i=0; i<n; i++) val <<= 1;
    val = pow2[n];
  for (u=1; u<val; u++) {
    v = u;
    if ((u & c) != c)  continue;
    for (j=125; v>0; j--, v/=10)   buf[j] = '0' + (v%10);
    fputs(buf+j+1, stdout);
    v = u;
    for (i=0; i<n; i++) {
      if (v%2) {
	putc_unlocked(' ', stdout);
	if (i>=10)	putc_unlocked('0' + i/10, stdout);
	putc_unlocked('0' + i%10, stdout);
      }
      v>>=1;
    }
    putc_unlocked('\n',stdout);
  }
  return 0;
}



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

int main () {
  int N,T;
  cin >> N >> T;
  vector<int>t(N);
  for (int i = 0; i < N; i++) {
    cin >> t.at(i);
  }
  int sum = T;
  for (int i = 1; i < N; i++) {
    sum += min(t.at(i) - t.at(i-1),T);
  }
  cout << sum << endl;
}
    
  
   

Measured memory_bytes: 3912
#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>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;

int d[200005][20];

int main() {
    int n;
    cin >> n;
    rep(i,n) {
        int a;
        cin >> a;
        rep(j,20) {
            d[i][j] = a%2;
            a /= 2;
        }
    }
    int l = 0, r = 0;
    vector<int> tmp(20);
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        int nextleft = i;
        while (l < nextleft) {
            rep(j,20) tmp[j] -= d[l][j];
            l++;
        }
        while (1) {
            if (r == n) break;
            bool ok = false;
            rep(j,20) {
                if (tmp[j] == 1 && d[r][j] == 1) ok = true;
            }
            if (ok) break;
            rep(j,20) tmp[j] += d[r][j];
            r++;
        }
        ans += r-l;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 19252
l,r = map(int,input().split())
c=2019
for i in range(l,r+1):
  if i%2019==0:
    print(0)
    break
else:
  for j in range(l,r+1):
    for k in range(j+1,r+1):
      if c>(j*k%2019):
        c=(j*k%2019)
  print(c)
        

Measured memory_bytes: 9080
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
 
using namespace std;
#define ll long long
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("aa_input.txt", "r", stdin);
    int t=1;
    //cin>>t;
    while (t--)
    {
       ll n, m;
       cin>>n>>m;
       int a;
       ll ans = 0;
       for(int i=0; i<m; i++){
           
           cin>>a;
           ans += a;
       }
       if(ans>n) cout<<-1<<endl;
       else cout<<n-ans<<endl;
    }
    
    
    return 0;
}
/*
 
riaadmorshed@gmail.com
 
*/

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

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

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

  vector<int> p(n);
  for (auto &x : p) cin >> x;

  vector<int> v(n);
  for (int i = 0; i < n; ++i) {
    v[p[i] - 1] = i;
  }

  int diff = -v[0];
  vector<int> inc(n);
  for (int i = 0; i < n; ++i) {
    inc[i] = v[i] + diff;
  }

  vector<int> a(n), b(n);
  a[0] = 0;
  b[0] = 0;

  for (int i = 1; i < n; ++i) {
    if (v[i] > v[i - 1]) {
      b[i] = b[i - 1] - 1;
      a[i] = inc[i] - b[i];
    } else {
      a[i] = a[i - 1] + 1;
      b[i] = inc[i] - a[i];
    }
  }

  int inc_a = 1 - *min_element(a.begin(), a.end());
  int inc_b = 1 - *min_element(b.begin(), b.end());

  for (auto &x : a) x += inc_a;
  for (auto &x : b) x += inc_b;

  for (int i = 0; i < n; ++i) {
    if (i) cout << " ";
    cout << a[i];
  }
  cout << endl;

  for (int i = 0; i < n; ++i) {
    if (i) cout << " ";
    cout << b[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 1024
//
//  second.cpp
//  CoderTest
//
//  Created by yuya on 2019/05/23.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
    int i;
    int j;
    int  N;
    string mincity;
    int minj;
    int maxp;
    
    cin >> N;
    
    vector<pair<string,int>> rstrnt(N);
    
    for(i=0;i<N;i++){
        cin >> rstrnt[i].first >> rstrnt[i].second;
    }
    
    for(i=0;i<N;i++){
        minj = N;
        mincity = "zzzzzzzzzz";
        maxp = -1;
        for(j=0;j<N;j++){
            if(rstrnt[j].first < mincity){
                mincity = rstrnt[j].first;
                minj = j;
                maxp = rstrnt[j].second;
            } else if(mincity == rstrnt[j].first && maxp < rstrnt[j].second){
                minj = j;
                maxp = rstrnt[j].second;
            }
        }
        cout << minj+1 << endl;
        rstrnt[minj].first = "zzzzzzzzzz";
        rstrnt[minj].second = -1;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EPS 1e-10
#define setNil(x) memset((x),0,sizeof(x))
#define setINF(x) memset((x),63,sizeof(x))
#define setNegINF(x) memset((x),192,sizeof(x)) //NegINF=-INF-1
#define setNeg1(x) memset((x),255,sizeof(x))
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=100005;
int n,L,q,x[N],f[20][N];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++)cin>>x[i];
	cin>>L;
	for(int i=1,r=1;i<=n;i++){
		for(;r<=n && x[r]-x[i]<=L;r++);
		f[0][i]=r-1;
	}
	for(int k=1;k<18;k++)for(int i=1;i<=n;i++)f[k][i]=f[k-1][f[k-1][i]];
	cin>>q;
	while(q--){
		int l,r,ans=0;
		cin>>l>>r;
		if(l>r)swap(l,r);
		for(int i=17;~i;i--){
			if(f[i][l]<r){
				l=f[i][l];
				ans+=1<<i;
			}
		}
		cout<<ans+1<<endl;
	}
	return 0;
}

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

using lint = long long;

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

    vector<lint> a(n + 1), b(n);
    for(int i = 0 ; i < n + 1 ; ++i){
        cin >> a[i];
    }
    for(int i = 0 ; i < n ; ++i){
        cin >> b[i];
    }

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

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int n;
    cin >> n;
    vector<int> a(n),b(n);
    vector<P> p(n);
    REP(i,n){
        cin >> a[i] >> b[i];
        p[i].first = b[i];
        p[i].second = a[i];
    }
    sort(all(p));
    bool flag = true;
    ll sum = 0;
    REP(i,n){
        sum+=p[i].second;
        if(sum>p[i].first){
            put("No");
            return 0;
        }
    }
    put("Yes");
    return 0;
}


Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);
    private static final long MOD = 1000_000_007L;
    private static long[] count = new long[1001];

    public static void main(String[] args) {
	int N = Integer.parseInt(scan.next());
	for (int i = 1; i <= N; i++) {
	    factorization(i);
	}

	long ans = 1;
	for (int i = 2; i <= N; i++) {
	    ans = ans * (count[i]+1) % MOD;
	}

	System.out.println(ans);
	scan.close();
    }

    private static void factorization(int x) {
	for (int i = 2; i*i <= x; i++) {
	    if(x % i == 0) {
		factorization(i);
		factorization(x / i);
		return;
	    }
	}
	count[x]++;
    }
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    int n;cin>>n;
    string s;cin>>s;
    int c1=0,c2=0;
    rep(i,s.size()){
        if(s[i]=='(')c1++;
        else{
            if(c1>0)c1--;
            else c2++;
        }
    }
    while(c2>0){
        s='('+s;
        c2--;
    }
    while(c1>0){
        s+=')';
        c1--;
    }
    cout<<s<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
#define ll long long
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define in(a) a=read()
#define out(a) printf("%lld\n",a)
ll read(){
    ll f=1,x=0;char c=getchar();
    while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
    return x*f;
}
#define inf 0x7fffffff
#define maxn 200010
ll sum[maxn],a[10];
int main(){
	int n;
	in(n);
	FOR(i,1,n)in(sum[i]),sum[i]+=sum[i-1];
	int l=1,r=1;ll ans=inf;
	FOR(i,2,n-1){
		while(l<i&&abs(sum[l]-(sum[i]-sum[l]))>abs(sum[l+1]-(sum[i]-sum[l+1])))l++;
		while(r<n&&abs((sum[n]-sum[r])-(sum[r]-sum[i]))>abs((sum[n]-sum[r+1])-(sum[r+1]-sum[i])))r++;
		a[1]=sum[l];a[2]=sum[i]-sum[l];a[3]=sum[r]-sum[i];a[4]=sum[n]-sum[r];
		sort(a+1,a+5);
		ans=min(ans,a[4]-a[1]);
//		cout<<l<<' '<<i<<' '<<r<<' '<<a[4]-a[1]<<endl;
	}
	out(ans);
}


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

using namespace std;
#define rep(i, n) for(int i = 0 ; i < (int)n ; i++)

int main(void){
    int N;
    int ps[52];
    int counter;
    counter = 0;

    cin >> N;

    rep(i, N) cin >> ps[i];

    rep(i, N) if(ps[i] != i + 1) counter++ ;
    if(counter <= 2) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;

}

Measured memory_bytes: 256
from sys import exit
from collections import defaultdict
import itertools
# dic = defaultdict(int)
# N = int(input())
# a = [int(input()) for _ in range(N)]
S = str(input())
x,y = [int(n) for n in input().split()]

dx = []
dy = []
X = True
tmp = 0


S = [len(s) for s in S.split("T")]
dx = S[0::2]
dy = S[1::2]
x -= dx[0]
del dx[0]

def check(d, p):
    memo = set([0])
    for t in d:
        memo = {a+b for a,b in itertools.product(memo, [-t, t])}
    return (p in memo)


print("Yes" if check(dx,x) and check(dy,y) else "No")


Measured memory_bytes: 4056
N = int(input())
mod = 10**9 + 7

pf = {}
for i in range(2, N + 1):
    for j in range(2, int(i**0.5) + 1):
        while i % j == 0:
            pf[j] = pf.get(j, 0) + 1
            i //= j
    if i > 1:
        pf[i] = pf.get(i, 0) + 1

ans = 1
for p in pf.values():
    ans = ans * (p + 1) % mod
print(ans)

Measured memory_bytes: 3064
import scala.io.StdIn.readInt

object Main extends App {
  val n = readInt
  for(i <- 1 to n) {
    var m = readInt

    println("Case " + i + ":")
    for(j <- 1 to 10){
      m = "%08d".format(m*m).substring(2,6).toInt
      println(m)
    }
  }
}

Measured memory_bytes: 43952
using System;
// using System.Collections.Generic;
// using System.Linq;
// using System.Text;

class Program
{
    static void Main()
    {
        string[] arr = Console.ReadLine().Split();
        int A, B, C;
        A = int.Parse(arr[0]);
        B = int.Parse(arr[1]);
        C = int.Parse(arr[2]);
        Console.WriteLine(A < B + C ? B + C - A : 0);
        return;
    }
}

Measured memory_bytes: 27488
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
 
#define NMAX 200000
vector<int> cnt(NMAX);
 
int main(void){
  int n,k,ans;
  scanf("%d%d", &n, &k);
  for (int i=0; i<n; i++){
    int tmp;
    scanf("%d", &tmp);
    cnt[tmp]++;
  }
  sort(cnt.begin(),cnt.end());
  ans = 0;
//for(int i=0; i<NMAX; i++) printf("%d ", cnt[i]);
//puts("");
  for (int i=0; i<NMAX && i<k; i++){
    //printf("(%d)\n", cnt[NMAX-1-i]);
    ans += cnt[NMAX-1-i];
  }
  printf("%d\n", n-ans);
  return 0;
}

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

int main() {
  vector<string> s(3);
  for (int i = 0; i < 3; i++) {
    cin >> s[i];
  }
  string res;
  for (int i = 0; i < 3; i++) {
    res += s[i][0];
  } 
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    p = list(map(int, input().split()))
    ans = 0
    for i in range(1, n - 1):
        if p[i - 1] <= p[i] < p[i + 1] or p[i + 1] <= p[i] < p[i - 1]:
            ans += 1
    print(ans)


main()


Measured memory_bytes: 2940
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    double L;
    cin >> L;
    cout << fixed << setprecision(15) << pow(L / 3, 3) << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 384
#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>;

int main()
{
    // 入力
    // a,b,cの入力
    int n;;
    cin >> n ;

    if (n % 10 == 4 || n % 10 == 2 || n % 10 == 5 || n % 10 == 7 || n % 10 == 9 ){
        cout << "hon" << endl;
    }
    else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8){
        cout << "pon" << endl;
    }
    else{
        cout << "bon" << endl;
    }


    return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int dh[4] = {-1, 0, 0, 1};
int dw[4] = {0, -1, 1, 0};

int main() {
    int H, W; cin >> H >> W;
    vector<vector<char>> g(H, vector<char>(W));
    int sharp = 0; // 黒いマスの個数
    rep(i, H) {
        rep(j, W) {
            char c; cin >> c;
            if(c == '#') sharp++;
            g[i][j] = c;
        }
    }
    vector<vector<int>> seen(H, vector<int>(W, -1));
    seen[0][0] = 0;
    queue<pair<int, int>> q;
    q.push(make_pair(0, 0));
    while(q.size()) {
        pair<int, int> now = q.front();
        q.pop();
        rep(i, 4) {
            int nh = now.first + dh[i];
            int nw = now.second + dw[i];
            if(nh < 0 || H <= nh || nw < 0 || W <= nw) continue;
            if(g[nh][nw] == '#') continue;
            if(seen[nh][nw] != -1) continue;
            seen[nh][nw] = seen[now.first][now.second] + 1;
            q.push(make_pair(nh, nw));
        }
    }
    if(seen[H-1][W-1] == -1) cout << -1 << endl;
    else cout << H * W - seen[H-1][W-1] - 1 - sharp << endl;
}


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

int main(void){
  int S[12];
  char number[12];
  long num;
  int i,min=753,length,test;

  scanf("%s", &number);
  length=strlen(number);
  num=strtol(number,0,0);

  for(i=1;i<=length;i++){
   S[length-i]=num%10;
   num=num/10;
  }

  for(i=0;i<length-2;i++){
   test=S[i]*100+S[i+1]*10+S[i+2];
   if(test>=753) test=test-753;
    else test=753-test;
   if(test<min) min=test;
  }

  printf("%d", min);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

const int N = 200200;
const int LOG = 18;
int a[N];
int n, d;
ll b[LOG][N][2];
ll c[LOG][N][2];

ll solveL(int l, int r) {
	ll ans = 0;
	int len = 0;
	for (int k = LOG - 1; k >= 0; k--) {
		if (b[k][l][0] <= r) {
			len += 1 << k;
			ans += b[k][l][1];
			l = b[k][l][0];
		}
	}
//	eprintf("len = %d\n", len + 1);
	return ans + l;
}
ll solveR(int l, int r) {
	ll ans = 0;
	int len = 0;
	for (int k = LOG - 1; k >= 0; k--) {
		if (c[k][r][0] >= l) {
			len += 1 << k;
			ans += c[k][r][1];
			r = c[k][r][0];
		}
	}
//	eprintf("len = %d\n", len + 1);
	return ans + r + 1;
}

int main()
{
	startTime = clock();
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d%d", &n, &d);
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);

	int p = 1;
	for (int i = 1; i <= n; i++) {
		while(p <= n && a[p] - a[i] < d) p++;
		//eprintf("%d %d\n", i, p);
		b[0][i][0] = p;
		b[0][i][1] = i;
	}
	b[0][n + 1][0] = n + 1;

	for (int k = 0; k < LOG - 1; k++) {
		for (int i = 1; i <= n + 1; i++) {
			int v = b[k][i][0];
			b[k + 1][i][0] = b[k][v][0];
			b[k + 1][i][1] = b[k][i][1] + b[k][v][1];
		}
	}

	p = n;
	for (int i = n; i >= 1; i--) {
		while(p > 0 && a[i] - a[p] < d) p--;
		//eprintf("%d %d\n", i, p);
		c[0][i][0] = p;
		c[0][i][1] = i + 1;
	}
	c[0][0][0] = 0;

	for (int k = 0; k < LOG - 1; k++) {
		for (int i = 0; i <= n; i++) {
			int v = c[k][i][0];
			c[k + 1][i][0] = c[k][v][0];
			c[k + 1][i][1] = c[k][i][1] + c[k][v][1];
		}
	}

	int q;
	scanf("%d", &q);
	while(q--) {
		int l, r;
		scanf("%d%d", &l, &r);
		printf("%lld\n", solveR(l, r) - solveL(l, r));
	}

	return 0;
}


Measured memory_bytes: 116624
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <stdio.h>
#include <vector>
#include <queue>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <string.h>
#include <time.h>
#include <algorithm>
#define INF (2<<29)

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

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

    vector<int> arr(n);

    for (int i = 0; i < n; i++)
    {
        scanf("%d", &arr[i]);
    }

    int start = *min_element(arr.begin(), arr.end());
    int end = *max_element(arr.begin(), arr.end());

    int minCost = 987654321;

    for (int i = start; i <= end; i++)
    {
        int cost = 0;

        for (auto& a : arr)
            cost += (a - i) * (a - i);

        minCost = min(cost, minCost);
    }

    printf("%d", minCost);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main() {
	string s;
	ll k;
	cin >> s;
	cin >> k;
	vector<string> yojo;
	for (int i = 0; i < s.size(); i++) {
		string a = {};
		a += s[i];
		yojo.push_back(a);
		if (s.size() - i > 1) {
			a += s[i + 1];
			yojo.push_back(a);
		}
		if (s.size() - i > 2) {
			a += s[i + 2];
			yojo.push_back(a);
		}
		if (s.size() - i > 3) {
			a += s[i + 3];
			yojo.push_back(a);
		}
		if (s.size() - i > 4) {
			a += s[i + 4];
			yojo.push_back(a);
		}
	}
	sort(yojo.begin(), yojo.end());
	yojo.erase(unique(yojo.begin(), yojo.end()), yojo.end());
	cout<<yojo[k-1]<<endl;
	return 0;
}


Measured memory_bytes: 1660