akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1000000007;
#define Sort(a) sort(a.begin(), a.end())

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  string s, t;
  cin >> s >> t;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != t[i]) {
      cout << "No" << '\n';
      return 0;
    }
  }
  cout << "Yes" << '\n';
}

Measured memory_bytes: 3636
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main () {
    input!{
    s: String
  }
    let s:String =
        if s.ends_with("s") {
            s + "es"
        }else {
            s + "s"
        };
    println!("{:}", s)
}

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

const int DX[] = {-1, 1, 0, 0};
const int DY[] = {0, 0, -1, 1};
const int N = 800;
bool visited[N][N];
string s[N];

int main() {
	ios::sync_with_stdio(false);
	int m, n, k; cin >> m >> n >> k;
	for (int i = 0; i < m; ++i) cin >> s[i];
	int sx = -1, sy = -1;
	for (int i = 0; i < m; ++i) {
		for (int j = 0; j < n; ++j) {
			if (s[i][j] == 'S') {
				sx = i;
				sy = j;
			}
		}
	}
	queue<pair<int, int> > q;
	q.emplace(sx, sy);
	visited[sx][sy] = true;
	for (int step = 0; step < k; ++step) {
		for (int zzz = q.size(); zzz > 0; --zzz) {
			int x = q.front().first, y = q.front().second;
			q.pop();
			for (int i = 0; i < 4; ++i) {
				int nx = x + DX[i], ny = y + DY[i];
				if (nx >= 0 && nx < m && ny >= 0 && ny < n && !visited[nx][ny] && s[nx][ny] != '#') {
					visited[nx][ny] = true;
					q.emplace(nx, ny);
				}
			}
		}
	}
	int res = 1e9;
	for (int i = 0; i < m; ++i) {
		for (int j = 0; j < n; ++j) if (visited[i][j]) {
			res = min(res, min(min(i, j), min(m - i - 1, n - j - 1)));
		}
	}
	cout << (res + k - 1) / k + 1 << '\n';
	return 0;
}


Measured memory_bytes: 1536
# nCk 前処理メモ化
MOD = 10 ** 9 + 7
N = 100_000
@fac = [1, 1]
@inv = [1, 1]
@finv = [1, 1]

(2..N).each do |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
end

def nCk(n, k)
  return 0 if n < k || n < 0 || k < 0
  @fac[n] * (@finv[k] * @finv[n - k] % MOD) % MOD
end

n, k = gets.split.map(&:to_i)
nums = gets.split.map(&:to_i).sort
max_times = []
n.times do |i|
  max_times << nCk(i, k - 1)
end
min_times = max_times.reverse
ans = 0
nums.each_with_index do |num, i|
  ans += num * max_times[i]
  ans -= num * min_times[i]
end
puts ans % MOD


Measured memory_bytes: 15772
<?php
  $aa = fgets(STDIN);
$a = explode(' ', $aa);

foreach ($a as &$value) {
    $value = (int) $value;
}
unset($value);

foreach($a as $key => $i) {
  if($i === 0) {
    echo $key + 1;
    exit(0);
  }
}

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

using namespace std ;
#define int long long
int n , m ;
const int N = 1 << 13 ;
int dp[N] ;

signed main() {
  ios :: sync_with_stdio(false) ;
  cin.tie(0) ;
  cout.tie(0) ;
  memset(dp , 0x3f , sizeof(dp)) ;
  cin >> n >> m ;
  for(register int i = 1 ; i <= m ; i ++) {
    int val , tot ;
    cin >> val >> tot ;
    int bit = 0 ;
    for(register int j = 1 ; j <= tot ; j ++) {
      int x ;
      cin >> x ;
      bit += (1 << (x - 1)) ;
    }
    dp[bit] = min(dp[bit] , val) ;
  }
  int s = (1 << n) - 1 ;
  for(register int i = 1 ; i <= s ; i ++)
    for(register int j = 1 ; j <= s ; j ++)
      dp[i | j] = min(dp[i | j] , dp[i] + dp[j]) ;
  if(dp[s] == 0x3f3f3f3f3f3f3f3f) cout << -1 << endl ;
  else cout << dp[s] << endl ;
  return 0 ;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	cout << fixed << setprecision(10);
	int r;
	cin >> r;

	cout << 2 * PI * r << endl;
	return 0;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 1e18;
double Pi = 3.1415926535897932384626;
 
//vector<ll> G[500005];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
ll mod = 998244353;
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
//ll fact[800005],rfact[800005];
/*
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[800000] = rui(fact[800000],mod - 2);
    for(ll i=800000; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,ans,a,b,c,e,g,h,w,i,j,k,q;
ll t,d;
ll x[500005],y[500005],z[500005];
P table[500005];
string s;

int main(){
    cin >> n;
    for(int i=1;i<=n;i++){
    	cin >> a;
    	table[i - 1] = P(a, i);
    }
    sort(table,table + n);
    for(int i=0;i<n;i++){
    	pe(table[i].second);
    }
    el;
    
    return 0;
}


Measured memory_bytes: 2432
n,m = map(int,input().split())
inf = 1000000000
a = []
b = []
c = []
for i in range(m):
    aa,ba = map(int,input().split())
    ca = list(map(int,input().split()))
    k = 0
    for i in range(ba):
        k = k | (1 << ca[i]-1)
    a.append(aa)
    b.append(ba)
    c.append(k)

p = 2**n

dp = [[inf for i in range(p)] for i in range(m)]

for i in range(m):  
    dp[i][c[i]] = a[i]



for i in range(1,m):
    for j in range(p):
        ind = j | c[i]
        dp[i][ind] = min ( min(dp [i-1][j] + a[i], dp[i][ind]), dp[i-1][ind])
        dp[i][j] = min(dp[i][j], dp[i-1][j])

ans = dp[m-1][p-1]

if ans == inf:
    print(-1)
else:
    print(ans)


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

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

const int INF = 1000000007;

int main(void){
	int n, k; cin>>n>>k;
	int a[n] = {0};
	for(int i=0;i<n;i++) cin>>a[i];

	int ans = 0;
	if((n - 1) % (k - 1) == 0) ans = (n - 1) / (k - 1);
	else ans = (n - 1) / (k - 1) + 1;

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

Measured memory_bytes: 640
tasks = gets.split(' ').map!{|x| x.to_i}


result = nil
3.times do |i|
  3.times do |j|
    3.times do |k|
      if i!=j && i!=k && j!=k
        sum = (tasks[k]-tasks[i]).abs + (tasks[j]-tasks[i]).abs
        if result.nil? || result > sum
          result = sum
        end
      end
    end
  end
end

puts result


Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N, ans;

	cin >> N;

	for (int i = 1; i * i <= N; i++) ans = i * i;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
ll a[100010];
int main()
{
	ll n,m,k;
	scanf("%lld %lld %lld", &n,&m,&k);
	for (int i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	ll xx = m - k;
	ll left = 0;
	ll dap = 1234567890;
	ll right = 1234567890;
	while (left <= right)
	{
		ll mid = (left + right) / 2;
		ll ch = mid;
		for (int i = 0; i < n; i++)
		{
			ll oo = a[i] - mid*k;
			ll mm = 0;
			if (oo > 0)
			{
				mm = (oo / xx);
				if (oo % xx)
					mm++;
			}
			ch -= mm;
		}
		if (ch >= 0)
		{
			right = mid - 1;
			dap = min(dap, mid);
		}
		else
			left = mid + 1;
	}
	printf("%lld\n", dap);
}

Measured memory_bytes: 896
#include<stdio.h>

int main(void){
    int i,j,k,n,x;
    int count;
    while ( 1 ) {
        count = 0;
        scanf("%d %d", &n, &x);
        if ( n == 0 && x == 0 ) break;
        for ( i = 1 ; i < n - 1 ; i++ ) {
            for ( j = i + 1 ; j < n ; j++ ) {
                if ( j == i ) continue;
                for ( k = j + 1 ; k < n + 1; k++ ) {
                    if ( k == i || k == j ) continue;
                    if ( i + j + k == x ) {
                        count++;
                    }
                }
            }
        }
        printf("%d\n", count);
    }
    return 0;
}


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

int main() {
 int N , a , b , c;
 cin >> N;
  a = N / 100;
  N = N % 100;
  b = N / 10;
  N = N % 10;
  c = N;
 cout << a + b + c << endl;
}

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

using namespace std;

int main()
{
    int n,miss=0,a;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        if(a!=i+1)
        miss++;
    }
    string ans=(miss<=2)?"YES":"NO";
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h> 
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<climits>
using namespace std;
typedef long long int lli;
lli mod=1000000007;
int main()
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    lli n,k;
    cin>>n;
    lli ele;
    lli ans[n];
    for(lli i=0;i<n;++i)
    {
        cin>>ele;
        ans[ele-1]=i+1;
    }
    for(lli i=0;i<n;++i)
        cout<<ans[i]<<" ";
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  int n ,m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> a(n, vector<int>(m));
  rep(i, n) {
    cin >> c[i];
    rep(j, m) cin >> a[i][j];
  }
  int ans = INF;

  for (int i = 0; i < (1<<n); ++i) {
    vector<int> skill(m);
    int money = 0;
    rep(j, n) {
      if (((i>>j)&1) == 0) continue;
      money += c[j];
      rep(k, m) {
        skill[k] += a[j][k];
      }
    }

    bool ok = true;
    rep(j, m) {
      if (skill[j] < x) ok = false;
    }
    if(ok) chmin(ans, money);
  }

  if (ans == INF) ans = -1;
  cout << ans << endl;
}

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

struct uft{
    vector<ll> par;
    uft(ll n) {
        par.resize(n);
        rep(i,n)par[i]=i;
    }

    ll find(ll a){
        if(par[a]==a){
            return a;
        }else {
            return find(par[a]);
        }
    }

    void unite(ll a,ll b){
        par[find(a)]=find(b);
    }

    bool same(ll a,ll b){
        return find(a) == find(b);
    }
};

struct edge{
    ll s,t,w;
};

bool sortw(edge a,edge b) {
    return a.w < b.w;
}

int main() {
    const ll inf = 1e12;
    ll v,e;
    cin>>v>>e;
    vector<vector<ll>> matrix(v,vector<ll>(v));
    rep(i,v){
        rep(j,v){
            if(i==j){
                matrix[i][j]=0;
            }else{
                matrix[i][j]=inf;
            }
        }
    }
    rep(i,e){
        ll s,t,w;
        cin>>s>>t>>w;
        matrix[s][t] = w;
    }
    rep(k,v){
        rep(i,v){
            rep(j,v){
                if(matrix[i][k]<inf && matrix[k][j]<inf && matrix[i][j]>matrix[i][k]+matrix[k][j]){
                    matrix[i][j]=matrix[i][k]+matrix[k][j];
                }
            }
        }
    }
    rep(i,v){
        if(matrix[i][i] < 0){
            cout << "NEGATIVE CYCLE" <<endl;
            return 0;
        }
    }
    rep(i,v){
        rep(j,v){
            if(matrix[i][j]==inf){
                cout << "INF";
            }else {
                cout << matrix[i][j];
            }
            if(j < v-1){
                cout << " ";
            }
        }
        cout<<endl;
    }
}



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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100005

ll n, m;
ll A[MAX_N];
ll num[MAX_N];      // お気にが i-1 から i になったときの増加分
ll fav[MAX_N * 2];  // お気にが i-1 から i になったときの減少分
                    // これは A[j]-A[j+1] (j は任意) に i が含まれる回数
ll ans[MAX_N];      // お気にが i だったときのスイッチを押す回数

int main()
{
    ZERO(A);
    ZERO(num);
    ZERO(fav);
    ZERO(ans);

    cin >> n >> m;
    REP(i, n) {
        cin >> A[i];
    }

    REP(i, n) {
        if(i == 0) { continue; }
        int tmp = A[i] + 1;
        if(tmp > m) { tmp = 1; }
        num[tmp] += (A[i] + m - A[i-1]) % m - 1;
    }

    // imos 法
    // m まで行ったら 1 に戻るシステムので少し工夫する
    REP(i, n-1) {
        fav[A[i] + 2]++;
        if(A[i] > A[i + 1]) { fav[A[i + 1] + m + 1]--; }
        else { fav[A[i + 1] + 1]--; }
    }
    for(int i = 1; i <= m * 2; ++i) {
        fav[i] += fav[i - 1];
    }
    for(int i = 1; i <= m; ++i) {
        fav[i] += fav[i + m];
    }
    // DEBUG
    //for(int i = 1; i <= m; ++i) {
    //    printf("fav[%d]: %lld\n", i, fav[i]);
    //}
    //for(int i = 1; i <= m; ++i) {
    //    printf("num[%d]: %lld\n", i, num[i]);
    //}

    // お気にを使わない場合のボタンを押す回数を求める
   // ans[0] = 0;
   // for(int i = 1; i < n; ++i) {
   //     ans[0] += (m - A[i-1] + A[i]) % m;
   // }

    ans[1] = 0;
    for(int i = 1; i < n; ++i) {
        ll nofav = (m - A[i-1] + A[i]) % m;
        ll yesfav = (m - 1 + A[i]) % m + 1;
        ans[1] += min(nofav, yesfav);
    }
    //printf("ans[1]: %lld\n", ans[1]);

    ll ret = ans[1];
    for(int i = 2; i <= m; ++i) {
        ans[i] = ans[i-1];
        ans[i] += num[i];
        ans[i] -= fav[i];
        ret = min(ans[i], ret);
    //    printf("ans[%d]: %lld\n", i, ans[i]);
    }
    printf("%lld\n", ret);

    return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1){r=(r*a)%m;}
        b=b>>1;
        a=(a*a)%m;
    }
    return r%m;
}
int main(){
    ll n;cin>>n;
    vvi arr(n,vi(3));
    rep(i,0,n)rep(j,0,3)cin>>arr[i][j];
    vvi dp(n,vi(3,0));
    dp[0][0] = arr[0][0];dp[0][1] = arr[0][1];dp[0][2] = arr[0][2];
    for(ll i=1;i<n;i++)
    {
        for(ll j=0;j<3;j++)
        {
            dp[i][0] = max(dp[i-1][1]+arr[i][0],dp[i-1][2]+arr[i][0]);
            
            dp[i][1] = max(dp[i-1][2]+arr[i][1],dp[i-1][0]+arr[i][1]);
            
            dp[i][2] = max(dp[i-1][1]+arr[i][2],dp[i-1][0]+arr[i][2]);
        }
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
    return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
double pi=acos(-1);
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
// #define mp make_pair
#define pq priority_queue
const ll mod=1000000007;
// #define f first
// #define s second
#define pii pair< ll, ll >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace boost::multiprecision;
using namespace std;
void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}


const int N=1000005;
ll fact[N],invfact[N];
ll power(ll x,ll y){
  if(y<=0) return 1LL;
  ll z=power(x,y/2);
  if(y%2) return (((z*z)%mod)*x)%mod;
  return (z*z)%mod;
}

void pre(){
  fact[0]=invfact[0]=invfact[1]=fact[1]=1;
  rep(i,2,N) fact[i]=(i*fact[i-1])%mod;
  rep(i,2,N) invfact[i]=(invfact[i-1]*power(i,mod-2))%mod;
}
ll nCr(ll n,ll k){ return (((fact[n]*invfact[n-k])%mod)*invfact[k])%mod; }



const int N1=1e6+1;
vector<int> isprime(N1,1),prime;
void seive(){
  rep(i,2,sqrt(N1)+1){
      if(isprime[i]){
        for(int j=i*i;j<N1;j+=i) isprime[j]=0;
        prime.pb(i);
      }
  }
  rep(i,sqrt(N1)+1,N1) if(isprime[i]) prime.pb(i);
}



struct dsu {
    vector<int> par, rank;
    dsu(int n): par(n+1), rank(n+1) {
        for (int i = 0; i <= n; i++) {
            par[i] = i;
            rank[i]= 1;
        }
    }
    int root(int a) {
        if (a == par[a]) return a;
        return par[a] = root(par[a]);
    }
    void merge(int a, int b) {
        a = root(a);
        b = root(b);
        if (a == b) return;
        if (rank[a] > rank[b]) swap(a, b);
        par[b] = a;
    }
    set<int> parent(int n){
        set<int> s;
        for(int i=1;i<=n;i++){
            s.insert(root(i));
        }
        return s;
    }
};
void solve(){
  int n,k;
  cin>>n>>k;
  int a[n];
  map<int,int> m1;
  rep(i,0,n) {cin>>a[i];m1[a[i]]++;}
  vector<int> v1;
  for(auto i:m1) v1.pb(i.second);
  sort(all(v1));
  if(v1.size()<=k){
    cout<<0<<endl;
    return;
  }
  int cnt=0;
  rep(i,0,v1.size()){
    if(v1.size()-1-i>=k) cnt+=v1[i];
  }
  cout<<cnt<<endl;
}

int main(){
    optimizeIO();
    int r=1;
    {solve();}
}


Measured memory_bytes: 18168
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

int main()
{
    string s; cin>>s;
    if(s.back()=='s'){
        s+="es";
    }else{
        s+="s";
    }
    cout<<s<<endl;
    return 0;
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int n, d, a;

struct node {
  int x,h;
  bool operator<(const node& o) const {
    return x < o.x;
  }
};

vector<node> v;

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

  cin>>n>>d>>a;
  for (int i=0; i<n; i++) {
    int x,h; cin>>x>>h;
    v.push_back({x,h});
  }

  sort(v.begin(), v.end());
  ll ans = 0;
  ll prefix = 0;
  set<pair<ll,ll>> st;
  for (int i=0; i<n; i++) {
    while (!st.empty() && st.begin()->first < v[i].x) {
      prefix -= st.begin()->second;
      st.erase(st.begin());
    }
    ll need = max(0LL, (1LL*v[i].h-1LL*(prefix*a)+a-1)/a);
    ans += need;
    
    prefix += need;
    st.insert({1LL*v[i].x+d+d, need});
  }

  out(ans);
  return 0;
}


Measured memory_bytes: 14320
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <tuple>
#include <utility>
#include <limits>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>

using namespace std;

template<typename T, size_t N>
constexpr size_t NELEMS(T (&)[N]) { return N; }

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

#define DEBUG
#undef DEBUG

using ll = long long;

int N, A, B;
ll V[50];

ll comb[51][51]; // C(n,r)

// v1/k1 - v2/k2 の分子
ll mean_cmp(ll v1, ll k1, ll v2, ll k2)
{
    return v1*k2 - v2*k1;
}

// C(n,r) = C(n-1,r) + C(n-1,r-1)
void comb_init()
{
    REP(i, 50+1) {
        comb[i][0] = 1;
        comb[i][i] = 1;
    }

    FOR(n, 1, 50+1) {
        FOR(r, 1, n) {
            comb[n][r] = comb[n-1][r] + comb[n-1][r-1];
        }
    }

#ifdef DEBUG
    cout << "[comb]\n";
    REP(n, 51) {
        REP(r, 51) {
            cout << comb[n][r] << " ";
        }
        cout << "\n";
    }
#endif
}

void solve()
{
    comb_init();

    sort(V, V+N, greater<ll>());

    ll vsum[50]; // i個選んだ場合の価値の総和の最大値
    ll cn[50];   // i個選ぶ際の最小値の総数
    ll cr[50];   // i個選ぶ際の最小値を実際に選ぶ個数
    vsum[A] = accumulate(V, V+A, 0LL);
    cn[A]   = count(V, V+N, V[A-1]);
    cr[A]   = count(V, V+A, V[A-1]);
    FOR(k, A+1, B+1) {
        vsum[k] = vsum[k-1] + V[k-1];
        cn[k]   = count(V, V+N, V[k-1]);
        cr[k]   = count(V, V+k, V[k-1]);
    }

    vector<int> cands; // 平均価値最大となるkの集合
    cands.push_back(A);
    FOR(k, A+1, B+1) {
        ll cmp = mean_cmp(vsum[cands[0]], cands[0], vsum[k], k);
        if(cmp == 0) {
            cands.push_back(k);
        }
        else if(cmp < 0) {
            cands.clear();
            cands.push_back(k);
        }
    }

    double mean = static_cast<double>(vsum[cands[0]]) / cands[0];

    ll pattern = 0;
    for(int k : cands) {
        pattern += comb[cn[k]][cr[k]];
    }

    //cout << mean << "\n";
    printf("%lf\n", mean);
    cout << pattern << "\n";
}

int main()
{
    cin >> N >> A >> B;
    REP(i, N) {
        cin >> V[i];
    }

    solve();

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
typedef long long ll;
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<int > a1(n, 0);
  vector<int > a2(n, 0);
  int tmp = 0;
  REP(i,n){
    cin >> tmp;
    if(i == 0){
      a1[i] = tmp;
    }else{
      a1[i] = a1[i - 1] + tmp;
    }
  }
  REP(i,n){
    cin >> tmp;
    if(i == 0){
      a2[i] = tmp;
    }else{
      a2[i] = a2[i - 1] + tmp;
    }
  }
  int sum = a2[n - 1];
  for(int i = n -1;i>=0;i--){
    if(i == 0){
      a2[i] = sum;      
    }else{
      a2[i] = sum - a2[i - 1];
    }
  }

  int ans = 0;
  REP(i,n){
    ans = max(ans, a1[i] + a2[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll f(ll b, ll n) { return (n < b ? n : f(b, n / b) + n % b); }
int main() {
    ll n, s;
    cin >> n >> s;
    for (ll i = 2; i * i <= n; i++) {
        if (f(i, n) == s) { cout << i << endl; return (0); }
    }
    for (ll i = ceil(sqrt(n)); i >= 0; i--) {
        ll rem = s - i;
        if (rem < 0) continue;
        ll l = max({i, rem, 1ll}), r = n + 1;
        while (l + 1 < r) {
            ll m = (l + r) / 2;
            if (m * i + rem >= n) r = m;
            else l = m;
        }
        if (r * i + rem == n) {
            cout << r << endl;
            return (0);
        }
    }
    cout << -1 << endl;
    return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;
using ll=long long;


int main() {
  int n;cin >> n;
  int ans=1;
  int m;
  cin >> m;
  rep(i,n-1){
    int p;cin >> p;
    if(p<m){ans++;m=p;}
  }
  cout << ans;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000000;
const int mod = 1000000007;
int test[12345678];
signed main() {
	int n, cnt = 1, sum = 1, ans = 1; cin >> n;
	vector<vector<int>>aa(1000);
	for (int h = 1; h < 1000; h++) {
		test[h * (h + 1) / 2] = h;
	}
	if (test[n] == 0) { cout << "No" << endl; return 0; }
	cout << "Yes" << endl;
	cout << test[n] + 1 << endl;
	for (int h = 0; h <= test[n]; h++) {
		cout << test[n]; cnt = sum;
		for (int i = 0; i < aa[h].size(); i++) {
			cout << ' ' << aa[h][i];
		}
		for (int i = 0; i < test[n] - aa[h].size(); i++) {
			cout << ' ' << ans; aa[cnt].push_back(ans); cnt++; ans++;
		}
		cout << endl; sum++;
	}
	return 0;
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) { os << p.first << " " << p.second; return os; }

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; }return false; }
template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int X, Y, Z; cin >> X >> Y >> Z;
	int K; cin >> K;
	vector<int>A(X); rep(i, 0, X) { cin >> A[i]; }
	vector<int>B(Y); rep(i, 0, Y) { cin >> B[i]; }
	vector<int>C(Z); rep(i, 0, Z) { cin >> C[i]; }

	vector<int>v;
	rep(i, 0, X)rep(j, 0, Y)v.eb(A[i] + B[j]);
	sort(all(v), greater<int>());
	vector<int>w;
	rep(i, 0, min(K, (int)v.size())) {
		rep(j, 0, Z) {
			w.eb(v[i] + C[j]);
		}
	}
	sort(all(w), greater<int>());

	rep(i, 0, K) {
		cout << w[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 42856
#include <iostream>
#include <string>
#include <vector>
#include <utility>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> p(n), idx(n);
    vector<string> s(n);
    for(int i=0; i<n; i++){
        cin >> s.at(i) >> p.at(i);
        idx.at(i) = i+1;
    }

    for(int i=0; i<=n-2; i++){
        for(int j=0; j<n-1-i; j++){
            if(s.at(j) > s.at(j+1)){
                swap(s.at(j), s.at(j+1));
                swap(p.at(j), p.at(j+1));
                swap(idx.at(j), idx.at(j+1));
            }
            else if((s.at(j) == s.at(j+1)) && (p.at(j) < p.at(j+1))){
                swap(s.at(j), s.at(j+1));
                swap(p.at(j), p.at(j+1));
                swap(idx.at(j), idx.at(j+1));
            }
        }
    }

    for(int i=0; i<n; i++){
        cout << idx.at(i) << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"Yes"<<endl
#define cno cout<<"No"<<endl
#define sp <<" "<<
#define CST(x) cout<<fixed<<setprecision(x)
#define PI 3.14159265359
#define MOD 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;

int main(){

    vector<int> a(3);
    rep(i,3) cin >> a.at(i);
    sort(all(a));
    cout << a.at(0) sp a.at(1) sp a.at(2) << endl;
    return 0;
}


Measured memory_bytes: 3152
s=input()
if s[-1]=="2" or s[-1]=="4" or s[-1]=="5" or s[-1]=="7" or s[-1]=="9":
    print("hon")
elif s[-1]=="0" or s[-1]=="1" or s[-1]=="6" or s[-1]=="8":
    print("pon")
else:
    print("bon")

Measured memory_bytes: 9036
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()


int main(){
    ll a,b;
    cin>>a>>b;
    
    if(a==0 || a==1){
        ll ans;
        if(b%4==1) ans=1;
        else if(b%4==2) ans=b+1;
        else if(b%4==3) ans=0;
        else ans=b;
        cout<<ans<<endl;
        return 0; 
    }

    ll tmpb,tmpa;
    if(b%4==1) tmpb=1;
    else if(b%4==2) tmpb=b+1;
    else if(b%4==3) tmpb=0;
    else tmpb=b;

    if((a-1)%4==1) tmpa=1;
    else if((a-1)%4==2) tmpa=a;
    else if((a-1)%4==3) tmpa=0;
    else tmpa=a-1;

    ll ans=tmpb^tmpa;
    cout<<ans<<endl;

}

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

main() {
    int A,B; cin >> A >> B;
    if(B%A==0) cout << A+B << endl;
    else cout << B-A << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int sum_of_digits(int n) {
    int sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }

    return sum;
}

int main() {
    int n;
    cin >> n;
    
    int fn = sum_of_digits(n);

    if (n % fn == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
from __future__ import print_function

import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# import math
# import string
# import fractions
# from fractions import Fraction
# from fractions import gcd

# def lcm(n,m):
#     return int(n*m/gcd(n,m))

# import re
# import array
# import copy
# import functools
# import operator

# import collections
# import itertools
# import bisect
# import heapq


# from heapq import heappush
# from heapq import heappop
# from heapq import heappushpop
# from heapq import heapify
# from heapq import heapreplace

# from queue import PriorityQueue as pq

# def reduce(p, q):
#     common = fractions.gcd(p, q)
#     return (p//common , q//common )
# # from itertools import accumulate
# # from collections import deque

# from operator import mul
# from functools import reduce

# def combinations_count(n, r):
#     r = min(r, n - r)
#     numer = reduce(mul, range(n, n - r, -1), 1)
#     denom = reduce(mul, range(1, r + 1), 1)
#     return numer // denom

# import random

def main():
    n = int(input().strip())
    a = list(map(int, input().strip().split()))
    b = list(map(int, input().strip().split()))

    cnt=0;i=0
    while i<n:
        if b[i]==0 or (a[i]==0 and a[i+1]==0):
            i+=1
            
        else:
            temp=min(a[i],b[i]);a[i]-=temp;b[i]-=temp;cnt+=temp
            if b[i]==0:
                pass
            else:
                temp=min(b[i],a[i+1]);a[i+1]-=temp;b[i]-=temp;cnt+=temp
    print(cnt)
    
        
    return

if __name__ == '__main__':
    main()
'''
for given
n (1<=n<=10**5),
[a_i] (\forall i in [0...(n-1)].1<=a_i<=10**9 ),
[b_i] (\forall i in [0...(n-1)].1<=b_i<=10**9 )

find x_cnt such that
x_cnt:= sum(\for i in [0...(n-1)].b[i]    barahbarahbarah)


(a[i] + a[i+1] <= b[i] then )
min(a[i] + a[i+1] , b[i])

\forall i in [0...(n-1)]. a[i] - c[i]

'''


Measured memory_bytes: 76416
#include <stdio.h>

void moving_north(int *top, int *bottom, int *front, int *back);
void moving_south(int *top, int *bottom, int *front, int *back);
void moving_east(int *top, int *bottom, int *right_side, int *left_side);
void moving_west(int *top, int *bottom, int *right_side, int *left_side);

typedef struct{
	int top;
	int bottom;
	int right_side;
	int left_side;
	int front;
	int back;
}Dice;

int main(void)
{
	Dice dice1;

	int i;
	char input_direction[100];

	scanf("%d %d %d %d %d %d", 
		  &dice1.top, &dice1.front, &dice1.right_side, &dice1.left_side, &dice1.back, &dice1.bottom);

	scanf("%s", input_direction);

	for(i = 0; input_direction[i] != '\0'; i++){
		switch(input_direction[i]){
			case 'N':
				moving_north(&dice1.top, &dice1.bottom, &dice1.front, &dice1.back);
				break;
			case 'S':
				moving_south(&dice1.top, &dice1.bottom, &dice1.front, &dice1.back);
				break;
			case 'E':
				moving_east(&dice1.top, &dice1.bottom, &dice1.right_side, &dice1.left_side);
				break;
			case 'W':
				moving_west(&dice1.top, &dice1.bottom, &dice1.right_side, &dice1.left_side);
				break;
			default:
				break;
		}
	}

	printf("%d\n",dice1.top);
	return 0;
}

void moving_north(int *top, int *bottom, int *front, int *back)
{
	int temp;

	temp = *top;
	*top = *front;
	*front = *bottom;
	*bottom = *back;
	*back = temp;
}

void moving_south(int *top, int *bottom, int *front, int *back)
{
	int temp;

	temp = *top;
	*top = *back;
	*back = *bottom;
	*bottom = *front;
	*front = temp;
}

void moving_east(int *top, int *bottom, int *right_side, int *left_side)
{
	int temp;

	temp = *top;
	*top = *left_side;
	*left_side = *bottom;
	*bottom = *right_side;
	*right_side = temp;
}

void moving_west(int *top, int *bottom, int *right_side, int *left_side)
{
	int temp;

	temp = *top;
	*top = *right_side;
	*right_side = *bottom;
	*bottom = *left_side;
	*left_side = temp;
}


Measured memory_bytes: 2052
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll [[maybe_unused]] = long long;
using ull [[maybe_unused]] = unsigned long long;
using ld [[maybe_unused]] = long double;

[[maybe_unused]] static constexpr ll linf = 1e18;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define pb push_back
#define fst first
#define snd second


int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    ll N;
    ll K;
    cin >> N >> K;
    vector<int> x;
    rep(i, N) {
        int tmp;
        cin >> tmp;
        x.pb(tmp);
    }

    ll ans = linf;
    rep(i, N - K + 1) {
        ll xmin = x[i];
        ll xmax = x[i + K - 1];
        if (xmax <= 0) {
            ans = min(ans, abs(xmin));
        } else if (xmax > 0 && xmin <= 0) {
            ans = min(ans,
                  min(2 * abs(xmin) + xmax,
                      2 * xmax + abs(xmin)));
        } else {
            ans = min(ans, xmax);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
 
const int N = 1e5 + 10, mod = 1e9 + 7;

void add(int& a, int b) {
	a += b;
	if(a < 0) {
		a += mod;
	}
	if(a >= mod)
		a -= mod;
}

int dp[N];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, k;
	cin >> n >> k;
	dp[0] = 1;
	for (int child = 0; child < n; child++) {
		int x;
		cin >> x;
		vector <int> fake(k + 1, 0);
		for (int used = k; used >= 0; used--) {
			int tmp = dp[used];
			int L = used + 1;
			int R = used + min(k - used, x);
			if(L <= R) {
				add(fake[L], tmp);
				if(R + 1 <= k) {
					add(fake[R + 1], -tmp);
				}
			}
		}
		int prefix_sum = 0;
		for (int i = 0; i <= k; i++) {
			add(prefix_sum, fake[i]);
			add(dp[i], prefix_sum);
		}
	}
	cout << dp[k] << endl;
}

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

using namespace std;

int oks[205];

main() {
#ifdef HOME
    freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int x, y;
    cin >> x;
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> y;
        oks[y] = 1;
    }
    for (int d = 0; d <= 100; ++d) {
        if (oks[x - d] == 0) {
            cout << x - d;
            exit(0);
        }
        if (oks[x + d] == 0) {
            cout << x + d;
            exit(0);
        }
    }
    return 0;
}



Measured memory_bytes: 3580
S=input()
N=len(S)

flag=True
for idx in range(0,int((N-1)/2),1):
    if(S[idx]==S[-(idx)-1]):
        pass
    else:
        flag=False
        break

j=0
for idx in range(int((N+3)/2)-1,N,1):
    if(S[idx]==S[j]):
        pass
    else:
        flag=False
        break
    j+=1

if(flag):
    print("Yes")
else:
    print("No")

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

int main(){
  int h, n, sum=0; cin>>h >>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){cin>>a[i]; sum+=a[i];}
  if(sum>=h){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

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

const ll mod = 1000000007;

int main() {
    ll n;
    string s;
    cin >> n >> s;
    map<char, ll> mp;
    for (char c : s) mp[c]++;
    ll ans = 1;
    for (auto p : mp) {
        ans *= p.second + 1;
        ans %= mod;
    }
    cout << ans - 1 << endl;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProblemF
{
    class Program
    {
        // Beg 104 C
        static void Main(string[] args)
        {
            var read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var D = read[0];
            var G = read[1] / 100;

            var ps = new int[D];
            var cs = new int[D];
            var compScores = new int[D];

            for (int i = 0; i < D; i++)
            {
                read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                ps[i] = read[0];
                cs[i] = read[1] / 100;
                compScores[i] = (i + 1) * ps[i] + cs[i];
            }

            var iter = Math.Pow(2, D);
            var res = 1000;
            for (int i = 0; i < iter; i++)
            {
                var tempSum = 0;
                var tempProbNum = 0;
                for (int j = 0; j < D; j++)
                {
                    if((i & 1<<(D - j - 1)) != 0)
                    {
                        tempSum += compScores[j];
                        tempProbNum += ps[j];
                    }
                }
                if (G <= tempSum)
                    res = Math.Min(tempProbNum, res);
                else
                {
                    var notUsedNums = Enumerable.Range(0, D).Where(k => (i & 1 << (D - k - 1)) == 0);
                    if (notUsedNums.Count() == 0)
                        continue;
                    var maxProbNum = notUsedNums.Max() + 1;
                    if(G <= tempSum + maxProbNum * ps[maxProbNum - 1])
                    {
                        var num = (G - tempSum) % maxProbNum == 0 ? (G - tempSum) / maxProbNum : (G - tempSum) / maxProbNum + 1;
                        res = Math.Min(tempProbNum + Math.Min(num, ps[maxProbNum - 1]), res);
                    }
                }
            }
            Console.WriteLine(res);

            //var tempG = G;
            //var resProbNum = 0;
            //for (int i = D; i > 0; i--)
            //{
            //    if(tempG - (compScores[i - 1]) <= 0)
            //    {
            //        var num = tempG % i == 0 ? tempG / i : tempG / i + 1;
            //        resProbNum += Math.Min(num, ps[i - 1]);
            //    }
            //    else
            //    {
            //        resProbNum += ps[i - 1];
            //        tempG -= compScores[i - 1];
            //    }
            //}
        }
    }
}


Measured memory_bytes: 28768
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a < 10) {
            System.out.println(b + 100 * (10 - a));
        } else {
            System.out.println(b);
        }
    }
}


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

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

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

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

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

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

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

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




void solve() {
    int N; cin >> N;
    vec v(N), B(N-1);
    rep(i, N-1){
        cin >> B[i];
    }

    rep(i, N){
        if(i == 0){
            v[i] = B[i];
            continue;
        }
        v[i] = min(B[i-1], B[i]);
        if(i == N-1){
            v[i] = B[i-1];
        }
    }

    ll res=0;
    rep(i, N){
        res += v[i];
    }

    cout << res << endl;
}

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


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

using namespace std;

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

    vector<int> count(m, 0);    

    for(int i = 0; i < n; i++) {
        int k;
        cin >> k ;
        for(int j = 0; j < k; j++) {
            int a;
            cin >> a;
            a--;
            count[a]++;
        }
    }

    int ans = 0;
    for(int i = 0; i < m; i++) {
        if(count[i] == n){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = 5
list=[int(input()) for i in range(n)]
p = int(input())
max = 0
a = 0
for i in range(n):
  for j in range(n):
    a = abs(list[i] - list[j])
    if a > max:
      max = a
      
if max <= p:
  print('Yay!')
else:
  print(':(')

Measured memory_bytes: 3064
# ABC103 C - Modulo Summation
from fractions import gcd
N = int(input())
A = list(map(int,input().split()))
t = 0

def lcm(x,y):
    return (x*y)//gcd(x,y)

for m in range(N):
    if m == 0:
        t = lcm(A[0],A[1])
    t = lcm(t,A[m])

t = t-1
A = [t%a for a in A]
print(sum(A))

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


int main() {
  ll n,a,b;
  cin>>n>>a>>b;
  vector<ll> h(n);
  rep(i,n)cin>>h[i];
  sort(h.begin(),h.end());
  ll hmax=h[n-1];
  ll l=0;
  ll r=hmax/b+1;

  while(l+1<r){
    ll c=(l+r)/2;
    ll cnt=0;
    rep(i,n){
      ll rest=h[i]-(c*b);
      if (rest>0)cnt+=(rest+a-b-1)/(a-b);
    }
    if (cnt<=c)r=c;
    else l=c;
  }

  cout<<r;


}


Measured memory_bytes: 1024
s = input()
words = ['dream','dreamer','erase','eraser']
words_r = [w[::-1] for w in words]
s = s[::-1]

ans = 'NO'
i = 0
while i < len(s):  
  p = i
  for w in words_r:        
    if s[i:i+len(w)] == w:      
      i += len(w)
      if i == len(s):
        ans ='YES'
      break
  if p==i or ans=='YES':
    break

print(ans)    

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 100000000000;

signed main() {
  int N, K;
  cin >> N >> K;
  
  string S;
  cin >> S;
  
  int ans = 0;
  for( int i = 1; i < S.size(); i++ ){
    if( S.at(i) == S.at(i-1) ) ans++;
  }
  
  ans = min(ans+(2*K), N-1);
  cout << ans << endl;
  
}

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

typedef long long ll;
int ara[60];
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t;
    vector<ll>v;
    cin>>t;
    for(int i=0;i<t-1;i++)
    {
        ll a;
        cin>>a;
        v.push_back(a);
    }
    ll sum=0;
    sum+=(v[t-2]+v[0]);
    for(int i=0;i<t-2;i++)
    {
        sum+=(min(v[i],v[i+1]));
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256