akhauriyash/Code-Regression huggingface dataset:
S=(input())
 
N = len(S)
 
one = S[0:((N-1)//2)]
two = S[(N+3)//2-1:N]
 
def check_kai(text):
    left = len(text)//2
    
    for i in range(left):
 
        if text[i] != text[len(text)-1-i]:
            print('No')
            exit(0)
 
check_kai(S)
check_kai(one)
check_kai(two)
print('Yes')

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;

int n;
int x[100000];

signed main() {
	int i, j;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> x[i];
	for (i = 0; i < n; i++) x[i] -= 2 * i + 1;
	for (i = 0; i < n; i++) x[i] = max(0LL, -x[i]);
	for (i = 0; i < n; i++) x[i] = (x[i] + 1) / 2;
	for (i = 1; i < n; i++) x[i] = max(x[i - 1], x[i]); //ロボットi+1をゴールさせるには最低何体のロボットをゴールさせる必要があるか？
	
	int ans = 1;
	for (i = 1; i < n; i++) {	//ロボットiをゴールさせる
		ans *= i + 1 - x[i - 1];
		ans %= 1000000007;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>

using namespace std;

using lli = long long int;

int main() {
    int n;

    cin >> n;

    vector<lli> v(n);
    vector<pair<lli, lli>> sumPair(n - 1);  //i番目の要素まで左に取ったときの和

    for(int i = 0; i < n; ++i)
    {
        cin >> v[i];

        if(i == 0)
        {
            sumPair[0].first = v[i];
        }
        else
        {
            sumPair[0].second += v[i];
        }
    }

    lli minDiff = abs(sumPair[0].first - sumPair[0].second);
    

    for(int i = 1; i < n - 1; ++i)
    {
        sumPair[i].first = sumPair[i - 1].first + v[i];
        sumPair[i].second = sumPair[i - 1].second - v[i];

        lli diff = abs(sumPair[i].first - sumPair[i].second);

        if(diff < minDiff)
        {
            minDiff = diff;
        }
    }

    cout << minDiff << endl;
    
    return 0;
} 

Measured memory_bytes: 4992
N = int(input())
CSF = [list(map(int, input().split())) for _ in range(N - 1)]
for i in range(len(CSF)):
    ans = 0
    ans += CSF[i][1] + CSF[i][0]
    for j in range(i + 1, len(CSF)):
        if ans < CSF[j][1]:
            ans += CSF[j][1] - ans
        if ans % CSF[j][2] == 0:
            pass
        else:
            ans += CSF[j][2] - ans % CSF[j][2]
        ans += CSF[j][0]

    print(ans)
print(0)


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

void solve(){
  int a, b, c; cin >> a >> b >> c;
  if(c >= a && c <= b) cout << "Yes\n";
  else cout << "No\n";
  return;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
    long long int k, a, b, c;
    cin>>a>>b>>c>>k;
    if(k<=a)
        cout<<k;
    else if(k<=a+b)
        cout<<a;
    else
        cout<<2*a+b-k;
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    int A,B,T;
    cin>>A>>B>>T;
    cout<<B*(T/A)<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,x,a1,a2,a3,score=0;
  
  scanf("%d%d",&n,&x);
  while(n!=0||x!=0){
    score=0;
    for(a1=1;a1<n+1;a1++){
      for(a2=1;a2<n+1;a2++){
	for(a3=1;a3<n+1;a3++){
	  if(a1!=a2 && a2!=a3 && a3!=a1){
            if(a1+a2+a3==x)
	      score = score + 1;
	  }
	}
      }
    }
      printf("%d\n",score/6);
      scanf("%d%d",&n,&x);
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	ll ans=0LL;
	cin >>n;
	string s;
	V dis(5,0LL);
	rep(i,n){
		cin>>s;
		switch (s[0])
		{
		case 'M':
			dis[0]++;
			break;
		case 'A':
			dis[1]++;
			break;
		case 'R':
			dis[2]++;
			break;
		case 'C':
			dis[3]++;
			break;
		case 'H':
			dis[4]++;
			break;
		default:
			break;
		}
	}
	for(int i=0;i<4;i++){
		for(int j=i+1;j<5;j++){
			for(int k=j+1;k<5;k++){
				ans+=dis[i]*dis[j]*dis[k];
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3584
#include <stdio.h>
#include <string.h>

int main(){
  int n;
  scanf("%d",&n);
  char w[n][12];
  int i = 0;
  int ans = 1;
  char last = 'a';
  for(i=0;i<n;i++){

    scanf("%s",w[i]);
    if((i!=0) && (last != w[i][0])){
      ans = 0;
    }
    int j = 0;
    for(j=0;j<i;j++){
      if(strcmp(w[i],w[j]) == 0){
        ans = 0;
      }
    }
    j=0;
    while(w[i][j]!='\0'){
      last = w[i][j];
      j++;
    }
  }
  if(ans==1){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
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 revstr(s) reverse(s.begin(),s.end())
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef unsigned long long ul;


int main() {
	ll n; cin >> n;
	ll p; cin >> p;
	if (n == 1)cout << p << endl;
	else if(n>50){
		cout << 1 << endl;
	}
	else {
		int out = 0;
		rep1(i, 1000000) {
			bool f = true;
			ll pr = 1;
			rep(j, n) {
				pr *= i; if (pr > p) {
					f = false; break;
				}
			}
			if (p%pr == 0)out = i;
		}
		cout << out << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#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()

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

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int h, w;
	cin >> h >> w;
	vector<string> a(h);
	rep(i, h) cin >> a[i];

	rep(i, w + 2) cout << '#';
	cout << endl;
	rep(i, h){
		cout << '#';
		cout << a[i];
		cout << '#' << endl;
	}
	rep(i, w + 2) cout << '#';
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
alphabet = [chr(i) for i in range(97,123)]
f = open(0)
alphabet_list = [0]*26

for line in f.readlines():
    for ch in alphabet:
        ch_count = line.lower().count(ch)
        alphabet_list[alphabet.index(ch)] += ch_count

for i in range(26):
    print("{} : {}".format(alphabet[i],alphabet_list[i]))    


Measured memory_bytes: 5572
n = int(input())
x = list(map(int, input().split()))
x_square = [num ** 2 for num in x]
sum_x = sum(x)
sum_x_square = sum(x_square)
minVal = 1000000
for p in range(101):
    minVal = min(minVal, sum_x_square - 2 * p * sum_x + n * p ** 2)
print(minVal)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n],b[n-1];
	int ans =0 ;
	for (int i=0;i<n-1;i++)
	{
	    cin>>b[i];
	    if (!i)
	    {
	        a[i]=b[i];
	        a[i+1]=b[i];
	    }
	    else
	    {
	        if (b[i]<a[i])
	        {
	            a[i]=b[i];
	            a[i+1]=b[i];
	        }
	        else
	        {
	            a[i+1]=b[i];
	        }
	    }
	    ans+=a[i];
	}
	ans+=a[n-1];
	cout<<ans;
	
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define L(i,u) for (int i=head[u]; i!=0; i=nxt[i])
#define rep(i,a,b) for (register int i=a; i<=b; i++)
#define per(i,a,b) for (register int i=a; i>=b; i--)
typedef long long ll;
using namespace std;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(ll &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
const int N = 223333;
ll t,a,b,c,d;
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
bool ck(ll x){return x>=c+1&&x<=b-1;}
int main() {
	read(t);while(t--){
		read(a);read(b);read(c);read(d);
		if(b>d||a<b)puts("No");
		else {
			ll g=gcd(b,d);ll x=a+((b-a-1)/g)*g;
		//	printf("QW %lld %lld\n",x,g);
			if(ck(x)||ck(x-g)||ck(x+g))puts("No");
			else puts("Yes");
		}
	}
	return 0;
}


Measured memory_bytes: 256
from heapq import heapify,heappop,heappush
N,M = map(int,input().split())
A = list(map(lambda x:-int(x),input().split()))
heapify(A)

# while(A): print(heappop(A))

for i in range(M):
    t = -heappop(A) // 2
    heappush(A,-t)
    # print(A)

# while(A): print(heappop(A))

print(-sum(A))

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int a[100001];
ii arr[200003];

ll power(ll a, ll b){ // to calculate a^b %mod
    if(b == 0)
        return 1;
    ll temp = power(a,b>>1)%mod;
    temp = (temp*temp)%mod;
    if(b&1)
        temp = temp*a%mod;
    return temp;
}

void buildtable(void){
    ll count=1;
    for(ll i=1;i<=200002;i++){
        count*=i;
        if(count>mod){
            count=count%mod;
        }
        arr[i].fi=count;
        ll invmod=power(count,mod-2);
        arr[i].se=invmod;
    }
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    vi v;
    int l,r;
    for(int i=1;i<=n+1;i++){
        int k;
        cin>>k;
        if(a[k]==0){
            a[k]=i;
        }
        else{
            l=a[k];
            r=i;
        }
        v.pb(k);
    }
    arr[0].fi=1;
    arr[0].se=1;
    buildtable();

    for(int i=1;i<=n+1;i++){
        ll c1=arr[n+1].fi*arr[i].se;
        c1=c1%mod;
        c1=c1*arr[n+1-i].se;
        c1=c1%mod;
        
        ll c2=0;
        if(l+n-r-i+1>=0){
            c2=arr[l+n-r].fi*arr[i-1].se;
            c2=c2%mod;
            c2=c2*arr[l+n-r-i+1].se;
            c2=c2%mod;
        }
        
        if(c1-c2>0){
            cout<<c1-c2<<endl;
        }
        else{
            cout<<c1-c2+mod<<endl;
        }
    }

    return 0;
}


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

int r, l, m, n;
vector<int> v;

int dfs(int a, int b, int c, int dep) {
  if(r == dep) {
    return min({a, b, c}) > 0
      ? (abs(a - l) + abs(b - m) + abs(c - n) - 30)
      : 2e9;
  }
  int t = v[dep++];
  int t1 = dfs(a + t, b, c, dep) + 10;
  int t2 = dfs(a, b + t, c, dep) + 10;
  int t3 = dfs(a, b, c + t, dep) + 10;
  int t4 = dfs(a, b, c, dep);
  return min({t1, t2, t3, t4});
}

int main() {
  cin >> r >> l >> m >> n;
  
  v.resize(r);
  for(int i = 0; i < r; i++) {
    cin >> v[i];
  }
  
  cout << dfs(0, 0, 0, 0) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	string a, b;
	cin >> a >> b;
	int x = stoi(a + b);
	bool flag = false;
	for (int i = 1; i <= 1000; i++) {
		if (i*i == x) {
			flag = true;
			break;
		}
	}
	if (flag)cout << "Yes";
	else cout << "No";
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000
#define LLINF 1e18

void solve_abc_d() {
	ll n, m;
	//ll a, b;
	ll x, y, z;
	ll h, w;
	ll k;
	ll l_ans = 0;

	cin >> x >> y >> z >> k;

	V a, b, c;
	ll tmp;
	rep(i, x) {
		cin >> tmp;
		a.push_back(tmp);
	}
	rep(i, y) {
		cin >> tmp;
		b.push_back(tmp);
	}
	rep(i, z) {
		cin >> tmp;
		c.push_back(tmp);
	}

	V ab;
	rep(i, x) rep(j, y) {
		ab.push_back(a[i] + b[j]);
	}

	sort(RALL(ab));

	priority_queue<ll> ans;
	rep(i, min(x*y, k)) {
		rep(j, z) {
			ans.push(ab[i] + c[j]);
		}
	}

	rep(i, k) {
		cout << ans.top() << "\n";
		ans.pop();
	}

	return;
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(15);

	solve_abc_d();

	return 0;
}


Measured memory_bytes: 44084
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=1e5+5;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
int main()
{
    int a,b,c;
    while(cin>>a>>b>>c)
    {
        if(a+b+c>=22)cout<<"bust\n";
        else cout<<"win\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N;
    cin >> N;
    cout << "ABC" << N << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <iomanip>
using namespace std;

int main() {
  int n = 0;
  int p[25] = {0};

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }

  int ans = 0;
  for (int i = 1; i < n-1; i++) {
    if (p[i-1] < p[i] && p[i] < p[i+1]) {
      ans++;
    }
    if (p[i-1] > p[i] && p[i] > p[i+1]) {
      ans++;
    }
  }

  cout << ans << endl;
}


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

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

int N;
char S[300001];

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

  int mincost, cost = 0;
  FOR(i,1,N) if (S[i] == 'E') ++cost;
  
  mincost = cost;
  FOR(i,1,N) {
    if (S[i-1] == 'W') ++cost;
    if (S[i] == 'E') --cost;
    if (cost < mincost) mincost = cost;
  }
  
  printf("%d\n", mincost);
  return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>

void push(int);
void pop(int);

int stack[50];
int arryN = 0;

int main(){
  char input[50];
  int bre1 = 0, bre2 = 0;

  while(scanf("%50s",input) != EOF){

    if(input[0] == '+'){
      pop(1);
      bre1++;
    }
    else if(input[0] == '-'){
      pop(2);
      bre1++;
    }
    else if(input[0] == '*'){
      pop(3);
      bre1++;
    }
    else{
     push(atoi(input));
     bre2++;
    }

    if((bre1 > 99) || (bre2 > 100) || ((int)input[0] > 100000) ) break;

  }
  printf("%d\n",stack[0]);

  return 0;
}

void push(int input){
  stack[arryN] = input;
  arryN++;
}
void pop(int ks){
  switch(ks){
    case 1:
    stack[arryN - 2] = stack[arryN - 2] + stack[arryN - 1];
    arryN--;
    break;

    case 2:
    stack[arryN - 2] = stack[arryN - 2] - stack[arryN - 1];
    arryN--;
    break;

    case 3:
    stack[arryN - 2] = stack[arryN - 2] * stack[arryN - 1];
    arryN--;
    break;

  }
}



Measured memory_bytes: 2128
#include<iostream>

using namespace std;

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

		cin >> a>>b>>c;

		if (a == 5 && b == 5 && c == 7)
			cout << "YES" << endl;
		else if (a == 5 && b == 7 && c == 5)
			cout << "YES" << endl;
		else if (a == 7 && b == 5 && c == 5)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
		return 0;
}

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

b=[0] + a + [0]
now=0
dist=0


for i in range(n+1):
    dist += abs(b[i+1] - b[i])

for i in range(1,n+1):
    ans=0
    
    d1 = abs(b[i-1] - b[i+1])
    d2 = abs(b[i]-b[i-1])
    d3 = abs(b[i+1]-b[i])

    ans = dist+d1-(d2+d3) 

    print(ans)






Measured memory_bytes: 13920
#include <iostream>
#include <string>
#include <algorithm>
#include<vector>

using namespace std;

int main() {
	string s;
	cin >> s;
	int n = 0;
	if (s.at(0) == '1') {
		n++;
	}
	if (s.at(1) == '1') {
		n++;
	}
	if (s.at(2) == '1') {
		n++;
	}
	cout << n << endl;
	return 0;
}

Measured memory_bytes: 256
def permutation(n,r)
	result=1
	for i in 0..r-1 do
		result*=n-i
	end
	return result
end

def factorial(x)
	result=1
	for i in 1..x do
		result*=i
	end
	return result
end

def solve(n,m,r)
	if n+r-n*m-1<n-1||n+r-n*m-1<0||n-1<0 then
		return 0
	end
	return permutation(n+r-n*m-1,n-1)/factorial(n-1)
end

n,m,r=gets.split(/\s/).map{|x|x.to_i}
puts solve(n,m,r)

Measured memory_bytes: 10056
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

ll c[51][51];

void comb(int n){
  for(int i=0;i<=n;i++){
    for(int j=0;j<=i;j++){
      if(j==0||j==i) c[i][j]=1ll;
      else c[i][j]=c[i-1][j-1]+c[i-1][j];
    }
  }
}

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

  comb(n);
  sort(v,v+n,greater<ll>());

  double ave=0.0;
  for(int i=0;i<a;i++){
    ave+=v[i];
  }
  ave/=a;

  int num=0,tmp=0;
  for(int i=0;i<n;i++){
    if(v[i]==v[a-1]){
      num++;
      if(i<a){
        tmp++;
      }
    }
  }

  ll ans=0;
  if(tmp==a){
    for(tmp=a;tmp<=b;tmp++){
      ans+=c[num][tmp];
    }
  }else{
    ans+=c[num][tmp];
  }

  cout<<fixed<<setprecision(9)<<ave<<endl;
  cout<<ans<<endl;

  return 0;
}


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

#define rep(ver,n) rep2(ver,0,n)
#define rep2(ver,m,n) for(int ver=m;ver<(n);ver++)
#define loop while(true)
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(v) (v).begin(), (v).end()
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

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

int n;
ll a[210000]={};

int main(){
  cin>>n;
  rep(i,n)cin>>a[i];
  
  ll max=a[0];
  ll sum=0;
  
  rep2(i,1,n){
    if(max>a[i]){
      sum+=max-a[i];
    }
    else{
      max=a[i];
    }
  }
  
  cout<<sum;
  
  return 0;
}


Measured memory_bytes: 5180
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	y := nextInt()

	// a: 10000円札
	for a := 0; a <= n; a++ {
		// b: 5000円札
		for b := 0; b <= n-a; b++ {
			// c: 1000円札
			c := n - (a + b)
			money := 10000*a + 5000*b + 1000*c
			if money == y {
				fmt.Printf("%d %d %d\n", a, b, c)
				return
			}
		}
	}
	fmt.Println("-1 -1 -1")
}


Measured memory_bytes: 640
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=998244353;
//const ll mod=1000000007;
const vector<int> dy={-1,0,1,0},dx={0,-1,0,1};
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T>void debag(const vector<T> &a){cerr<<"debag :";for(auto v:a)cerr<<v<<" ";cerr<<"\n";}
template<class T>void print(const vector<T> &a){for(auto v:a)cout<<v<<" ";cout<<"\n";}
int main(){
    ll n,q;
    cin>>n>>q;
    ll res=(n-2)*(n-2);
    set<P> x,y;
    x.insert(P(n,n));
    y.insert(P(n,n));
    ll t,v;
    while(q--){
        cin>>t>>v;
        if(t==1){
            auto ite=x.lower_bound(P(v,-1));
            P p=*ite;
            res-=(p.se-2);
            y.insert(P(p.se,v));
        }else{
            auto ite=y.lower_bound(P(v,-1));
            P p=*ite;
           // cout<<p.se<<"\n";
            res-=(p.se-2);
            x.insert(P(p.se,v));           
        }
       // cout<<res<<"\n";
    }
    cout<<res<<"\n";
}


Measured memory_bytes: 16144
// iostream のscanf, printf では間に合わなかった
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

#define INF (1<<29)
#define mp make_pair
#define pb push_back

typedef pair<int,int> pii;

int main(){
	int n, m;
	cin >> n >> m;
	vector<pii> treasure;
	for( int i = 0; i < n; i++ ){
		int x, y;
		//cin >> x >> y;
		scanf("%d %d", &x, &y);
		treasure.pb( mp(x,y) );
	}
	sort(treasure.begin(), treasure.end());
	for( int i = 0; i < m; i++ ){
		int x1, y1, x2, y2;
		//cin >> x1 >> y1 >> x2 >> y2;
		scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
		// search
		int ans = 0;
		vector<pii>::iterator it = lower_bound(treasure.begin(),treasure.end(),mp(x1,y1));
		vector<pii>::iterator ite = upper_bound(treasure.begin(),treasure.end(),mp(x2,y2));
		while( 1 ){
			//if( it == treasure.end() || *it > mp(x2,y2) ) break;
			if( it == ite ) break;
			if( x1 <= (*it).first && (*it).first <= x2 && y1 <= (*it).second && (*it).second <= y2 ) ans++;
			it++;
		}
		//cout << ans << endl;
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 1336
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
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;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m; cin >> n >> m;
    vi X(m); for(auto& e : X) cin >> e;
    sort(_all(X));

    vi a(m-1);
    rep(i, m-1){
        a[i] = X[i+1] - X[i];
    }
    sort(_all(a));

    int res = 0;
    rep(i, m - n){
        res += a[i];
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1024
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


n = I()
s = LI()
q = I()
t = LI()
c = 0


def is_bin_search(l, v):
    left = 0  # 探索範囲の左端
    right = len(l) - 1  # 探索範囲の右端
    mid = (left + right) // 2
    while left <= right:
        mid = (left + right) // 2
        if l[mid] == v:
            return True
        elif v < l[mid]:
            right = mid - 1  # 真ん中の左隣
        else:
            left = mid + 1  # 真ん中の右隣
        mid = (left + right) // 2
    return False


for ti in t:
    if is_bin_search(s, ti):
        c += 1

print(c)



Measured memory_bytes: 16732
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> v;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        if (a <= m) v.push_back({a, b});
    }
    sort(v.begin(), v.end());

    long long ret = 0;
    int index = 0;
    priority_queue<int> que;
    for (int i = 1; i <= m; i++) {
        for (; index < v.size() && v[index][0] == i; index++) {
            que.push(v[index][1]);
        }
        if (!que.empty()) {
            ret += que.top();
            que.pop();
        }
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 7216
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<algorithm>
#include<list>
#include<cstring>
#include <numeric>
#include <iomanip>

#define ll long long
#define int long long
#define ld long double
#define endl "\n"
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(p) cerr<<#p<<'='<<(p.first)<<" "<<p.second<<endl;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
const ll MOD = 1e9 + 7;
const int N = 'Z'+5;
const int demo = 10;
using namespace std;
const ll cfmod=998244353;
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
char button[4]={'L','R','U','D'};

// Ahhiya thi lakhvanu chalu thasse....

signed main() {
    FAST
    int q = 1;
    //cin>>q;
    while (q--) {
        int n;
        cin>>n;
        int ans=0;
        for(int i=1;i<=n;i++){
            int x;
            cin>>x;
            if(x%2 && i%2){
                ans++;
            }
        }
        cout<<ans;
    }
}

Measured memory_bytes: 3176
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<numeric>

typedef long long LL;

using namespace std;

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

int main(void) {
	int n, p;
	cin >> n >> p;
	vector<int>a(n);
	int even = 0, odd = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] % 2 == 0) {
			even++;
		}
		else {
			odd++;
		}
	}
	LL ans = 0;
	if (odd == 0) {
		if (p == 0) {
			ans = pow(2, odd + even);
		}
		else {
			ans = 0;
		}
	}
	else {
		ans = pow(2, odd + even - 1);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
// Har Har Mahadev
#include <bits/stdc++.h>
#define debug(x) cout << #x << " -> " << x << endl
#define booga cout << "booga" << endl
#define ll long long int
#define pb push_back

using namespace std;

void testcase(){
	int x;
	cin >> x;
	if(x <= 599){
		cout << 8;
		return;
	}
	if(x <= 799){
		cout << 7;
		return;
	}
	if(x <= 999){
		cout << 6;
		return;
	}
	if(x <= 1199){
		cout << 5;
		return;
	}
	if(x <= 1399){
		cout << 4;
		return;
	}
	if(x <= 1599){
		cout << 3;
		return;
	}
	if(x <= 1799){
		cout << 2;
		return;
	}
	if(x <= 1999){
		cout << 1;
		return;
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	while(t--){
		testcase();
	}
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)
#define INF 1<<29;


int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    vector<i64> l(n);
    l[0] = a[0];
    rep2(i,1,n) l[i] = l[i-1] + a[i];

    int c = 1;
    int d = 2;
    int e = 3;
    i64 p = a[0];
    i64 q = a[1];
    i64 r = a[2];
    i64 s = l[n-1] - l[2];

    i64 r_tmp = r;
    i64 s_tmp = s;
    i64 min_rs = abs(r-s);
    rep2(j,e,n-1)
    {
        r_tmp += a[j];
        s_tmp -= a[j];
        i64 tmp_rs = abs(r_tmp-s_tmp);
        if(tmp_rs < min_rs)
        {
            min_rs = tmp_rs;
            r = r_tmp;
            s = s_tmp;
            e = j+1;
        }
        else
        {
            break;
        }            
    }    

    i64 ret = max(max(p,q),max(r,s)) - min(min(p,q),min(r,s));

    while(d < n-2)
    {        
        q += a[d];
        i64 p_tmp = p;        
        i64 q_tmp = q;
        i64 min_pq = abs(p-q);
        rep2(j,c,d)
        {
            p_tmp += a[j];
            q_tmp -= a[j];
            i64 tmp_pq = abs(p_tmp-q_tmp);
            if(tmp_pq < min_pq)
            {
                min_pq = tmp_pq;
                p = p_tmp;
                q = q_tmp;
                c = j+1;
            }
            else
            {
                break;
            }            
        }        
        
        d++;
        if(d == e)
        {
            e++;
            r = r + a[d];
            s = s - a[d];
        }
        r -= a[d-1];
        i64 r_tmp = r;
        i64 s_tmp = s;
        i64 min_rs = abs(r-s);
        rep2(j,e,n-1)
        {
            r_tmp += a[j];
            s_tmp -= a[j];
            i64 tmp_rs = abs(r_tmp-s_tmp);
            if(tmp_rs < min_rs)
            {
                min_rs = tmp_rs;
                r = r_tmp;
                s = s_tmp;
                e = j+1;
            }
            else
            {
                break;
            }            
        }
        

        ret = min(ret, max(max(p,q),max(r,s)) - min(min(p,q),min(r,s)));
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 2560
import collections
dic = collections.defaultdict(int)
n = int(input())
a = [int(i) for i in input().split()]
for i in range(n):
	dic[a[i]] += 1
ans = 0
for key in dic.keys():
    if dic[key] >= key:
    	ans += (dic[key] - key)
    else:
        ans += dic[key]
print(ans)


Measured memory_bytes: 101372
from operator import itemgetter
n = int(input())
lst = list(map(int, input().split()))
lst2 = []
for i in range(n):
  lst2.append((i + 1, lst[i]))
lst2.sort(key=itemgetter(1))
s = ''
for i in lst2:
  s = s + str(i[0]) + ' '
print(s[:-1])

Measured memory_bytes: 25084
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>

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

int main(){
    // cout << __gcd(34, 51) << endl;

    while(cin >> a >> b >> c, a||b||c){
        //cout << "a\n";
        int D = b*b-4*a*c;
        int root = (int) (sqrt(D) + 0.5);
        if (root * root != D) {
            cout << "Impossible" << endl;
            continue;
        }
        int p, q, r, s;
        q = b-root;
        p = 2*a;
        s = b+root;
        r = 2*a;

        
        int gpq, grs;
        gpq = __gcd(p, q);
        grs = __gcd(r, s);
        p /= gpq;
        q /= gpq;
        r /= grs;
        s /= grs;
        if(p <= 0) {
            p = -p;
            q = -q;
        }
        if(r <= 0) {
            r = -r;
            s = -s;
        }        
        if(p <= r){
            int tmp;
            tmp = p;
            p = r;
            r = tmp;
            tmp = q;
            q = s;
            s = tmp;
        }
        if(p == r && q < s){
            swap(p, r);
            swap(q, s);
        }
        cout << p << " " << q << " " << r << " " << s << endl;
    }
}

Measured memory_bytes: 1172
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCode
{
    class Class1
    {
        static void Main(string[] args)
        {
            string A = Console.ReadLine();
            string[] SplitA = A.Split(' ');
            int N = Convert.ToInt32(SplitA[0]);
            int K = Convert.ToInt32(SplitA[1]);
            int Total = K;
            for(int i = 0; i < N - 1; i++)
            {
                Total = Total * (K - 1);
            }

            Console.WriteLine(Total);
        }

       
    }
    
}


Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <cctype>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <map> // pair
#include <set>
#define MAXSIZE 200000
#define PI 3.141592653589
using namespace std;

template<typename T>
T add(T a,T b){
  return a+b;
}

namespace A
{
  int f(void){
    return 1;
  }
}

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

  for(int i=0;i<n;i++){
    int a,b,c;
    std::cin >> a>>b>>c;

    if(a*a+b*b==c*c||b*b+c*c==a*a||c*c+a*a==b*b){
      std::cout << "YES" << '\n';
    }else{
      std::cout << "NO" << '\n';
    }
  }

}


Measured memory_bytes: 3032
<?php

$bing_card = array();

//入力
for($i=0;$i<3;$i++){
    $bing_card[] = explode(" ",trim(fgets(STDIN))) ;
}

fscanf(STDIN,"%d",$N);

for($j=0;$j<$N;$j++){
    $random_bing[] = trim(fgets(STDIN));
}


$hit_bing = array();
//var_dump($bing_card);
//var_dump($random_bing);

//正解の穴あけ作業
for($m=0;$m<3;$m++){
    for($n=0;$n<3;$n++){
        for($l=0;$l<$N;$l++){
            if($random_bing[$l] == $bing_card[$m][$n]){
                $hit_bing[] = $m.$n;
            }
        }
    }
}


$yoko1 = 0;
$yoko2 = 0;
$yoko3 = 0;
$tate1 = 0;
$tate2 = 0;
$tate3 = 0;
$naname1 = 0;
$naname2 = 0;




for($p=0;$p<count($hit_bing);$p++){
    if($hit_bing[$p] == "00" || $hit_bing[$p] == "01" || $hit_bing[$p] == "02"){
        $yoko1++;
    }
    if($hit_bing[$p] == "10" || $hit_bing[$p] == "11" || $hit_bing[$p] == "12"){
        $yoko2++;

    }
    if($hit_bing[$p] == "20" || $hit_bing[$p] == "21" || $hit_bing[$p] == "22"){
        $yoko3++;
    }
    if($hit_bing[$p] == "00" || $hit_bing[$p] == "10" || $hit_bing[$p] == "20"){
        $tate1++;
    }
    if($hit_bing[$p] == "01" || $hit_bing[$p] == "11" || $hit_bing[$p] == "21"){
        $tate2++;

    }
    if($hit_bing[$p] == "02" || $hit_bing[$p] == "12" || $hit_bing[$p] == "22"){
        $tate3++;

    }
    if($hit_bing[$p] == "00" || $hit_bing[$p] == "11" || $hit_bing[$p] == "22"){
        $naname1++;

    }
    if($hit_bing[$p] == "02" || $hit_bing[$p] == "11" || $hit_bing[$p] == "20"){
        $naname2++;

    }
}

if($yoko1 >=3 ||$yoko2 >=3 ||$yoko3 >=3 ||$tate1 >=3 ||$tate2 >=3||$tate3 >=3 ||$naname1>=3 ||$naname2>=3){
    echo "Yes\n";
}else{
    echo "No\n";
}



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

long long int n, m;

int main() {
    cin >> n >> m;
    if (n * 2 >= m) cout << (m / 2) << endl;
    else {
        cout << (n + ((m - 2 * n) / 4)) << endl;
    }

    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl
#define first(v) get<0>(v)
#define second(v) get<1>(v)
#define third(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;



int main(){
    string s;
    cin >> s;
    ll n=s.size();
    ll K;
    cin >> K;
    set<string> X;
    for(ll i=0;i<n;i++){
       for(ll j=0;j<5&&i+j<n;j++){
            X.insert(s.substr(i,j+1))
       ;}
    ;}
    auto p=X.begin();
    advance(p,K-1);
    print(*p);

    
    return 0;
}


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

int main() {
	int N, M;
	cin >> N >> M;

	int a;

	for (int i = 0; i < M; i++)
	{
		cin >> a;
		N -= a;
	}

	if (N < 0)
	{
		cout << -1 << endl;
	}
	else
	{
		cout << N << endl;
	}
}

Measured memory_bytes: 3636
<?php
list($n, $k) = explode(" ", trim(fgets(STDIN)));
$a = explode(" ", trim(fgets(STDIN)));
foreach($a as $num){
    @$map[$num]++;
}
rsort($map);
for($i = 0; $i < $k; $i++){
    @array_shift($map);
}
echo @array_sum($map);


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

int main() {
	string S;
	cin >> S;
	int n = 0;
	for (int i = 0; i < 4; ++i) {
		if (S[i] == '+') {
			++n;
		} else if (S[i] == '-') {
			--n;
		}
	}
	cout << n << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long LCM(long long a,long long b);
long long ans=1;
int main(){
    int n;
    cin>>n;
    long long t[n+2]={};
    for(int i=0;i<n;i++){
        cin>>t[i];
    }
    for(int i=0;i<n;i++){
        ans=LCM(t[i],ans);
    }
    cout<<ans<<endl;
    return(0);

}
long long LCM(long long a,long long b){
    return a/__gcd(a,b)*b;
}

Measured memory_bytes: 3560
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

ll a[100];//a[i]は一定の高さの下でi本の間に引ける線の数
ll dp[1000][100];//dp[i][j]は高さiまで見たときの,1がjに移るものの数

int main(){
  int h,w,k;
  cin >> h >> w >> k;
  a[0]=1,a[1]=1;
  rep(i,w)a[i+2]=a[i+1]+a[i];
  dp[0][1]=1;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      if(j==1){
        dp[i][j]=(dp[i-1][j]*a[w-1])%mod+(dp[i-1][j+1]*a[w-2])%mod;
      }
      else if(j==w){
        dp[i][j]=(dp[i-1][j-1]*a[w-2])%mod+(dp[i-1][j]*a[w-1])%mod;
      }
      else if(j==2){
        dp[i][j]=(dp[i-1][j-1]*a[w-2])%mod+(dp[i-1][j]*a[w-2])%mod+(dp[i-1][j+1]*a[w-3])%mod;
      }
      else if(j==w-1){
        dp[i][j]=(dp[i-1][j-1]*a[w-3])%mod+(dp[i-1][j]*a[w-2])%mod+(dp[i-1][j+1]*a[w-2])%mod;
      }
      else{
        dp[i][j]=(dp[i-1][j-1]*a[j-2]*a[w-j])%mod+(dp[i-1][j]*a[j-1]*a[w-j])%mod+(dp[i-1][j+1]*a[j-1]*a[w-j-1])%mod;
      }
      dp[i][j]%=mod;
    }
  }
  cout << dp[h][k] << endl;
return 0;}

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


int main(){
  int n,i,j,k,p,x,hi[N+1],M[N+1][N+1];
  
  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d%d",&hi[i-1],&hi[i]);

  }

  for(i=1;i<=n;i++)
    M[i][i]=0;
  
  for(p=2;p<=n;p++){
    for(i=1;i<=n-p+1;i++){
      j=i+p-1;
      M[i][j]=100000;

      for(k=i;k<=j-1;k++){
	x=M[i][k]+M[k+1][j]+hi[i-1]*hi[k]*hi[j];
	if(M[i][j]>x)
	  M[i][j]=x;

      }
     
    }
  }
  printf("%d\n",M[1][n]);

  return 0;
}
	



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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<long double> xs(n);
    for (auto& x : xs) {
        cin >> x;
    }
    long double sum = 0;
    for (auto x : xs) {
        sum += 1/x;
    }
    cout << setprecision(30) << 1/sum << endl;
    return 0;
}


Measured memory_bytes: 256
// This code wrote by chtholly_micromaker(MicroMaker)
#pragma GCC optimize(3,"Ofast","inline")
#pragma GCC target("avx,avx2")
#include <bits/stdc++.h>
#define reg register
#define ALL(x) (x).begin(),(x).end()
#define mem(x,y) memset(x,y,sizeof x)
#define sz(x) (int)(x).size()
#define ln puts("")
#define lsp putchar(32)
#define pb push_back
#define dbg(x) cerr<<"From "<<__func__<<"\t"<<"Line: "<<__LINE__<<"\t "<<#x<<" : "<<x<<endl
using namespace std;
template <class t> inline void read(t &s)
{
	s=0;
	reg int f=1;
	reg char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c))s=(s<<3)+(s<<1)+(c^48),c=getchar();
	s*=f;
	return;
}
template<class t,class ...A> inline void read(t &x,A &...a)
{
	read(x);read(a...);
	return;
}
template <class t> inline void write(t x)
{
	if(x<0)putchar('-'),x=-x;
	int buf[21],top=0;
	while(x)buf[++top]=x%10,x/=10;
	if(!top)buf[++top]=0;
	while(top)putchar(buf[top--]^'0');
	return;
}
inline void checkmin(int &x,int y){if(x>y)x=y;return;}
inline void checkmax(int &x,int y){if(x<y)x=y;return;}
inline int lowbit(int x){return x&(-x);}
string s[200050];
char inp[1000050];
int ch[2000050][26],ed[2000050],ndn;
int n;
inline void READ()
{
	read(n);
	for(int i=1;i<=n;++i)
	{
		scanf("%s",inp+1);
		reg int len=strlen(inp+1);
		s[i]="";
		for(int j=1;j<=len;++j)
			s[i]+=inp[j];
		reverse(ALL(s[i]));
	}
	return;
}
inline void insert(string s)
{
	reg int p=0;
	for(int i=0;i<(int)s.length();++i)
	{
		reg int d=s[i]-'a';
		if(!ch[p][d])
			ch[p][d]=++ndn;
		p=ch[p][d];
	}
	++ed[p];
	return;
}
inline int query(string s)
{
	reg int p=0,res=0;
	int t[26];
	mem(t,0);
	for(int i=0;i<(int)s.length();++i)
		++t[s[i]-'a'];
	for(int i=0;i<(int)s.length();++i)
	{
		reg int d=s[i]-'a';
		--t[d];
		for(int j=0;j<26;++j)
			if(t[j]&&j!=d&&ch[p][j])
				res+=ed[ch[p][j]];
		res+=ed[p];
		p=ch[p][d];
	}
	return res;
}
signed main(void)
{
	READ();
	reg long long ans=0;
	for(int i=1;i<=n;++i)
		insert(s[i]);
	for(int i=1;i<=n;++i)
		ans+=query(s[i]);
	write(ans),ln;
	return 0;
}





Measured memory_bytes: 115824
#include <iostream>
#include <math.h>
using namespace std;

int main() {
	long long a, b, c;
	cin >> a >> b >> c;
	
	long long pre_sq = c - a - b;
	long long sq = (c-a-b)*(c-a-b);
	
	if (pre_sq > 0 && 4 * a * b < sq) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
s = input()
t = input()

a = len(s)
b = len(t)
ans = []

if a-b < 0:
    print("UNRESTORABLE")
    exit()

for i in range(a-b+1):
    frag = True
    for j in range(b):
        if s[i+j] != t[j] and s[i+j] != "?":
            frag = False
    if frag == True:
        code = s[:i] + t + s[i+b:]
        ans.append(code.replace("?","a"))

if len(ans) == 0:
    print("UNRESTORABLE")
    exit()
else:
    ans.sort()
    print(ans[0])

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



int main() {

    int n,k; cin >> n >> k;
    int b = 0,a = -1;
    int count = 0;
    vector<int> A(n);
    rep(i,n){
        cin >> A[i];
        if(a == -1 && A[i] != 1) b ++;
        else a ++;
    }
    k --;

    if((a+b) % k == 0) cout <<(a+b)/k;
    else cout << (a+b)/k+1;
    return 0;
}











Measured memory_bytes: 3724
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = [0] * (N)
temp = 1
# for i in range(K):
#     temp *= A[i]
# ans[K - 1] = temp
for i in range(K, N):
    if A[i] > A[i - K]:
        # ans[i] = ans[i - 1] * A[i] // A[i - K]
        # if ans[i] > ans[i - 1]:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 31700
#include <stdio.h>
int main(void)
{
  int i,j,k,n,s;
  char ca[201],can[201];
  while(1){
    scanf("%s\n%d", ca, &n);
    if(!strcmp(ca, "-")) break;
    for(i=0;i<n;i++){
      scanf("%d", &s);
      for(j=s;ca[j]!='\0';j++)
        can[j-s] = ca[j];
      for(k=0;k<s;k++)
        can[j-s+k] = ca[k];
     
      for(j=0;ca[j]!='\0';j++)
        ca[j] = can[j];
    }
    printf("%s\n", ca);
  }
  return 0;
}



Measured memory_bytes: 2044
def gcd(a, b):
  if b == 0:
    return a
  return gcd(b, a%b)

n = int(input())

li = [[0 for i in range(n+1)] for j in range(n+1)]
for i in range(n+1):
  for j in range(0, i+1):
    li[i][j] = gcd(i, j)

ans = 0
for i in range(1, n+1):
  for j in range(1, i+1):
    for k in range(1, j+1):
      if i == j and j == k:
        ans += li[i][li[j][k]]
      elif i == j or j == k:
        ans += 3*li[i][li[j][k]]
      else:
        ans += 6*li[i][li[j][k]]
print(ans)

Measured memory_bytes: 9456
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
int a[MAXN];
int main(){
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) scanf("%d", a + i);
    int mn = MAXN, mx = -MAXN;
    for(int i = 0; i < n; i++){
        mn = min(mn, a[i]);
        mx = max(mx, a[i]);
    }
    if(mx - mn > 1) {
        cout << "No" << endl;
        return 0;
    }
    if(mx == mn){
        if(2 * mx <= n || n == mx + 1) cout << "Yes" << endl;
        else cout << "No" << endl;
        return 0;
    }
    int cntMn = 0;
    for(int i = 0; i < n; i++)
        if(a[i] == mn) cntMn++;
    int cntMx = n - cntMn;
    if(cntMn >= mx) {
        cout << "No" << endl;
        return 0;
    }
    int val = cntMn + 2 * (mx - cntMn);
    if(val <= n) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 640