akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX / 2 + 2], R[MAX / 2 + 2];
int cnt;

void merge(int A[], int n, int left, int mid, int right){
  int n1 = mid - left;
  int n2 = right - mid;
  for(int i = 0 ; i < n1 ; i++) L[i] = A[left + i];
  for(int i = 0 ; i < n2 ; i++) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  int i = 0, j = 0;
  for(int k = left ; k < right ; k++){
    cnt++;
    if(L[i] <= R[j]){
      A[k] = L[i++];
    }
    else{
      A[k] = R[j++];
    }
  }
}

void mergeSort(int A[], int n, int left, int right){
  if(left + 1 < right){
    int mid = (left + right) / 2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

int main(){
  int A[MAX], n, i;
  cnt = 0;

  cin >> n;

  for(i = 0 ; i < n ; i++) cin >> A[i];

  mergeSort(A, n, 0, n);
  
  for(i = 0 ; i < n ; i++){
    if(i) cout << " ";
    cout << A[i];
  }
  cout << endl;

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 6988
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

vector<vector<pair<int, int>>> v;
int main()
{
  ll h,w; cin >> h >> w;
  if(h == 1 || w == 1){
    cout << 1 << endl;
  }
  else if(h % 2 == 0 || w % 2 == 0){
    cout << h*w/2 << endl;
  }else{
    cout << (h*w)/2+1 << endl;
  }
  system("pause");
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int a, b;
    cin >> a >> b;
    OP(max(a - 2 * b, 0));
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;

#define dbg(x) cerr << #x"=" << x << endl;
typedef long long LL;
const int MAX_N = 1e5+100;
LL a[MAX_N];

int main(){
   // freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    for(int i = 1; i <= n+1; ++i) cin >> a[i];
    LL ans = 0;
    LL x;
    for(int i = 1; i <= n; ++i){
        cin >> x;
        for(int j = 0; j <= 1; ++j){
            LL t1 = min(x, a[i+j]);
            x -= t1;
            a[i+j] -= t1;
            ans += t1;
        }
    }
    cout << ans << endl;
    return 0;
}



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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vec;
typedef vector<P> pvec;
typedef vector<vector<int>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<int> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<int,vector<int>,greater<int>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> DX = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> DY = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const ll INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001); // 10^(-10)

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec G(nmax);





void solve4ts()
{
    
    int a,v,b,w,t;
    cin>>a>>v>>b>>w>>t;

    if(a==b){
        cout<<"YES"<<endl;
    }
    else{
        int dist=abs(a-b);
        if(v<=w){
            cout<<"NO"<<endl;
        }
        else{
            int memo=abs(v-w)*t;
            if(memo<dist){
                cout<<"NO"<<endl;
            }
            else{
                cout<<"YES"<<endl;
            }
        }
    }

    
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

Measured memory_bytes: 7820
#include <algorithm>
#include <stdio.h>
#include <functional>
using namespace std;

int N, M, a[300004];

template<typename ...> static inline int gc(void) { return getchar(); }
//static inline void read(int &x){int k=gc();x=0;for(;;k=gc()){if(isdigit(k)){x=k-48;break;}}for(;;){k=gc();if(!isdigit(k))break;x=x*10+k-48;}}
template<typename T> T read(T &x)
{
    int f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar())
        if (ch == '-')
            f = -1;
    for (x = 0; isdigit(ch); ch = getchar())
        x = 10 * x + ch - '0';
    return x *= f;
}
int main(){long long int r = 0;
    read(N);
    M = N;
    M += (N << 1);
    for(int i = 0; i ^ M; ++i){
        read(a[i]);
    }
    sort(a, a + M, greater<int>());
    N <<= 1;
    ++N;
    for(int i = 1; i ^ N; i += 2){
        r += a[i];
    }
    printf("%lld", r);
    return 0;
}


Measured memory_bytes: 1280
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

int f(i64 n)
{
  int ans = 0;
  while(n % 2 == 0) {
    n /= 2;
    ++ans;
  }
  return ans;
}

signed main()
{
  int N;
  i64 a[205];

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

  int ans = INF;
  for (int i = 0; i < N; ++i) {
    chmin(ans, f(a[i]));
  }

  cout << ans << endl;

  return 0;
}


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

string s[100];

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

	int n, q;
	cin >> n >> q;

	for(int i = 0; i < n; i++) {
		int y;
		cin >> y;
		cin >> s[y];
	}
	string ans = "kogakubu10gokan";
	for(int i = 1; i <= q; i++) {
		if(s[i] != "") ans = s[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 3236
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define EPS (1e-10)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

signed main(){
	int a,b;cin>>a>>b;
	cout<<b*2-a<<endl;	
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
struct node
{
    long long v,tag;
}tree[1000000*4+1];
void build(int node,int l,int r)
{
    if(l==r)
    {
        tree[node].v=l;
        return;
    }
    build(node*2,l,(l+r)/2);
    build(node*2+1,(l+r)/2+1,r);
    tree[node].v=max(tree[node*2].v,tree[node*2+1].v);
}
void pushdown(int node,int l,int r)
{
    if(tree[node].tag)
    {
        tree[node*2].v+=tree[node].tag;
        tree[node*2+1].v+=tree[node].tag;
        tree[node*2].tag+=tree[node].tag;
        tree[node*2+1].tag+=tree[node].tag;
        tree[node].tag=0;
    }
}
long long query(int node,int st,int ed,int l,int r)
{
    if(st>r||ed<l)
        return -1;
    if(st>=l&&ed<=r)
        return tree[node].v;
    pushdown(node,st,ed);
    return max(query(node*2,st,(st+ed)/2,l,r),query(node*2+1,(st+ed)/2+1,ed,l,r));
}
void update(int node,int st,int ed,int l,int r,int ind)
{
    if(st>r||ed<l)
        return;
    if(st>=l&&ed<=r)
    {
        tree[node].v+=ind;
        tree[node].tag+=ind;
        return;
    }
    pushdown(node,st,ed);
    update(node*2,st,(st+ed)/2,l,r,ind);
    update(node*2+1,(st+ed)/2+1,ed,l,r,ind);
    tree[node].v=max(tree[node*2].v,tree[node*2+1].v);
}
vector<int> p[200001];
int main()
{
    long long n,m; 
    cin>>n>>m;
    for(int i=1;i<=n;i++)
	{
		int l,r;
		scanf("%d%d",&l,&r);
		p[l].push_back(r);
    }
	long long ans=n-m;
    build(1,1,m+1);
	for(int i=0;i<=m;i++)
	{
		for(int j=0;j<p[i].size();j++)
		{
			int right=p[i][j];
			update(1,1,m+1,1,right,1);
		}
		ans=max(ans,query(1,1,m+1,i+1,m+1)-m-i-1);
	}
	printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 18176
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	vector<string> ans(3);
	rep(i, 3) {
		cin >> ans[i];
	}
	rep(i, 3) {
		cout << ans[i][i];
	}
	return 0;
}

//Ctrl+Aを使わない

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	char X, Y;
	cin >> X >> Y;
	if (X < Y) cout << '<' << endl;
	else if (X > Y) cout << '>' << endl;
	else cout << '=' << endl;

	return 0;
}


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

const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  map<int, int> c;
  for(int i = 0;i < n;i++){
    int tmp;
    cin >> tmp;
    c[tmp] += 1;
  }

  if(n % 2 == 0){
    int a = 1;
    for(int i = 0;i < n / 2;i++){
      if(c.find(a) != c.end() && c[a] == 2){
        a += 2;
      }else{
        cout << 0 << endl;
        return 0;
      }
    }
  }else{
    int b = 0;
    for(int i = 0;i < n / 2 + 1;i++){
      if(b == 0){
        b += 2;
        continue;
      }
      if(c.find(b) != c.end() && c[b] == 2){
        b += 2;
      }else{
        cout << 0 << endl;
        return 0;
      }
    }
  }

  int ans = 1;
  for(int i = 0;i < n/2;i++){
    ans *= 2;
    ans %= mod;
  }
  cout << ans << endl;
}


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

int main() 
{ 
   
   
int a,b;

cin>>a>>b;

string str1{""}, str2{""};
for(int i=0; i<a;i++)
    str1+=to_string( b );

for(int i=0; i<b;i++)
    str2+=to_string( a );

//cout<<str1<<endl;
//cout<<str2<<endl;

if(str1.at(0) <= str2.at(0))
{
    
    cout<<str1<<endl;
    return 0;
}

cout<<str2<<endl;


    return 0; 
} 

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

using ll = long long;

#define int ll

ll f(ll l){
    int cnt = 0;
    while(l != 0){
        ll u = __builtin_popcount(l);
        l %= u;
        cnt++;
    }
    return cnt;
}

void solve(long long N, std::string X){
    reverse(X.begin(), X.end());
    int cnt = count(X.begin(), X.end(), '1');
    if(cnt == 1){
        int plus = cnt + 1;
        vector<int> vplus;
        int p = 1;
        int sum = 0;
        for(int i = 0;i < N;i++){
            if(X[i] == '1'){
                sum += p;
                sum %= plus;
            }
            vplus.push_back(p);
            p *= 2;
            p %= plus;
        }
        sum %= plus;
        vector<int> ans;
        for(int i = 0;i < N;i++){
            if(X[i] == '1'){
                ans.push_back(0);
            }else{
                ans.push_back(f((sum + vplus[i]) % plus) + 1);
            }
        }
        reverse(ans.begin(), ans.end());
        for(auto a : ans){
            cout<<a<<endl;
        }
    }else{
        int plus = cnt + 1;
        int minus = cnt - 1;
        vector<int> vplus;
        vector<int> vminus;
        int p = 1;
        int m = 1;
        int sump = 0;
        int summ = 0;
        for(int i = 0;i < N;i++){
            if(X[i] == '1'){
                sump += p;
                summ += m;
                summ %= minus;
                sump %= plus;
            }
            vplus.push_back(p);
            vminus.push_back(m);
            p *= 2;
            m *= 2;
            p %= plus;
            m %= minus;
        }
        sump %= plus;
        summ %= minus;
        vector<int> ans;
        for(int i = 0;i < N;i++){
            if(X[i] == '1'){
                ans.push_back(f((summ - vminus[i] + minus) % minus) + 1);
            }else{
                ans.push_back(f((sump + vplus[i]) % plus) + 1);
            }
        }
        reverse(ans.begin(), ans.end());
        for(auto a : ans){
            cout<<a<<endl;
        }
    }
}

signed main(){
    long long N;
    scanf("%lld",&N);
    std::string X;
    std::cin >> X;
    solve(N, X);
    return 0;
}


Measured memory_bytes: 9796
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int n,m;
    cin >> n >> m;
    map<int,int>mp;
    rep(i,n){
        int k; cin >> k;
        rep(j,k){
            int t; cin >> t;
            mp[t]++;
        }
    }
    int ans = 0;
    for(auto p : mp){
        if(p.second == n)++ans;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
/*-- ILSH  --*/
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpi vector < pii >
#define vpl vector < pll >
#define fi first
#define se second 
#define sz size 
#define len length 

const ll mod = 1e9+7;
const ll inf=1e18+1e17;
//const ll mod = 998244353;

ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}

const ll N=2e5+6;


void solve(){
	int n;
	cin>>n;
	set< string > s;
	for ( int i=0;i<n;i++){
		string ss;
		cin>>ss;
		s.insert( ss);
	}
	cout<<s.sz()<<'\n';

}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
//	#ifndef ONLINE_JUDGE
	//  freopen ("INPUT.txt" , "r" , stdin);
	//freopen ("OUTPUT.txt", "w" , stdout);
//	#endif	
    ll t=1;
	//cin>>t;
    for (int i=1;i<=t;i++){
    //	cout<<"Case #"<<i<<": ";
    	solve();
 	}
}





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

using namespace std;
//using namespace __gnu_pbds;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int MOD = 1000000007;
double PI = 4*atan(1);

vector<pii> t1, t2;
vector<pair<int,pii>> d1, d2;
int par[100000], sz[100000];
ll ans = 0;

int getpar(int a) {
    if (par[a] != par[par[a]]) par[a] = getpar(par[a]);
    return par[a];
}

void unite(int a, int b, int weight) {
    a = getpar(a), b = getpar(b);
    if (a == b) return;
    ans += weight;
    if (sz[a]<sz[b]) swap(a,b);
    sz[a] += sz[b];
    par[b] = a;
}

int main() {
	int N; cin >> N; t1.resize(N); t2.resize(N);
	F0R(i,N) par[i] = i, sz[i] = 1;
	
	F0R(i,N) {
	    cin >> t1[i].f >> t2[i].f;
	    t1[i].s = t2[i].s = i;
	}
	sort(t1.begin(),t1.end()); sort(t2.begin(),t2.end());
	
	F0R(i,t1.size()-1) d1.pb({t1[i+1].f-t1[i].f,{t1[i].s,t1[i+1].s}});
	sort(d1.begin(),d1.end());
	
	F0R(i,t2.size()-1) d2.pb({t2[i+1].f-t2[i].f,{t2[i].s,t2[i+1].s}});
	sort(d2.begin(),d2.end());
	
	int i1 = 0, i2 = 0;
	while (i1 < d1.size() || i2 < d2.size()) {
	    if (i1 == d1.size()) {
	        unite(d2[i2].s.f,d2[i2].s.s,d2[i2].f);
	        i2++;
	    } else if (i2 == d2.size()) {
	        unite(d1[i1].s.f,d1[i1].s.s,d1[i1].f);
	        i1++;
	    } else {
    	    if (d1[i1].f <= d2[i2].f) {
    	        unite(d1[i1].s.f,d1[i1].s.s,d1[i1].f);
    	        i1++;
	        } else {
	            unite(d2[i2].s.f,d2[i2].s.s,d2[i2].f);
	            i2++;
	        }
	    }
	}
	cout << ans;
}

Measured memory_bytes: 6132
import java.util.Scanner;

public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int N = in.nextInt();
      int T = in.nextInt();
      int minCost = Integer.MAX_VALUE;

      while (N-- > 0) {
        int c = in.nextInt();
        int t = in.nextInt();

        if (t <= T) {
          minCost = Math.min(minCost, c);
        }
      }

      if (minCost == Integer.MAX_VALUE) {
        System.out.println("TLE");
      } else {
        System.out.println(minCost);
      }
    }
  }
}

Measured memory_bytes: 23124
import java.io.*;
import java.util.*;

class Main
{
    public static void main(String[] args)throws IOException
    {
        Reader in = new Reader();
        long n = in.nextLong();
        long a = in.nextLong();
        long b = in.nextLong();
        long ans = n / (a + b) * a + Math.min(n % (a + b), a);
        System.out.println(ans);
    }
}
class Reader
{
    final private int BUFFER_SIZE = 1 << 16;
    private DataInputStream din;
    private byte[] buffer;
    private int bufferPointer, bytesRead;

    public Reader()
    {
        din = new DataInputStream(System.in);
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public Reader(String file_name) throws IOException
    {
        din = new DataInputStream(new FileInputStream(file_name));
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public String readLine() throws IOException
    {
        byte[] buf = new byte[64]; // line length
        int cnt = 0, c;
        while ((c = read()) != -1)
        {
            if (c == '\n')
                break;
            buf[cnt++] = (byte) c;
        }
        return new String(buf, 0, cnt);
    }

    public int nextInt() throws IOException
    {
        int ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do
        {
            ret = ret * 10 + c - '0';
        }  while ((c = read()) >= '0' && c <= '9');

        if (neg)
            return -ret;
        return ret;
    }

    public long nextLong() throws IOException
    {
        long ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');
        if (neg)
            return -ret;
        return ret;
    }

    public double nextDouble() throws IOException
    {
        double ret = 0, div = 1;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();

        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');

        if (c == '.')
        {
            while ((c = read()) >= '0' && c <= '9')
            {
                ret += (c - '0') / (div *= 10);
            }
        }

        if (neg)
            return -ret;
        return ret;
    }

    private void fillBuffer() throws IOException
    {
        bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
        if (bytesRead == -1)
            buffer[0] = -1;
    }

    private byte read() throws IOException
    {
        if (bufferPointer == bytesRead)
            fillBuffer();
        return buffer[bufferPointer++];
    }

    public void close() throws IOException
    {
        if (din == null)
            return;
        din.close();
    }
}

Measured memory_bytes: 24660
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef pair<int, int> pint;



vstr str;

int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}




int main() {
	int A, B;


	cin >> A >> B;

	if (A % 2 == 0 || B % 2 == 0) {

		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}


	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N = int(input())
S = input()

# R, G, Bの数をカウント
R_count = 0
G_count = 0
B_count = 0
for s in list(S):
    if s == 'R':
        R_count += 1
    elif s == 'G':
        G_count += 1
    elif s == 'B':
        B_count += 1

# R, G, Bの全組み合わせ数を求める
ans = R_count * G_count * B_count

# 3文字が等間隔に存在する組み合わせがあれば引いていく
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        k = j + (j - i)
        if k >= N:
            break
        if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
            ans -= 1

print(ans)

Measured memory_bytes: 9208
n = int(input())
a = list(map(int,input().split()))
A = sum(a[:n-1])-a[n-1]
c = n*(10**9)
c = min(c,abs(A))
if n == 2:
    print(abs(a[0]-a[1]))
else:
    for i in range(1,n-2):
        A=A-2*a[n-1-i]
        c = min(c,abs(A))
    print(c)

Measured memory_bytes: 24824
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
void solve(){
    int n,w;
    cin>>n>>w;
    vector<int> wt(n),val(n);
    for(int i=0;i<n;i++)
        cin>>wt[i]>>val[i];
    vector<vector<ll>> dp(w+1,vector<ll>(n+1,0));
    for(int i=1;i<=w;i++){
        for(int j=1;j<=n;j++){
            dp[i][j]=dp[i][j-1];
            if(i>=wt[j-1])
                dp[i][j]=max(dp[i][j],dp[i-wt[j-1]][j-1]+val[j-1]);
        }
    }
    cout<<dp[w][n];
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    solve(); cout<<endl;
    return 0;
}

Measured memory_bytes: 85080
// きさま！ 見ているなッ！

#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>
#include<string>
#include<thread>

using namespace std;
using ll = long long;
using vec = vector<int>;
using mat = vector<vec>;
using lst = list<ll>;

const ll MOD = 1000000007;


int main()
{
	double L; cin >> L;

	printf("%.10f", (L / 3)*(L / 3)*(L / 3));

	return 0;
}

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

using namespace std;

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


Measured memory_bytes: 3636
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.nextLine().toCharArray();
		int x = sc.nextInt();
		int y = sc.nextInt();

		List<Integer> xa = new ArrayList<>();
		List<Integer> ya = new ArrayList<>();
		boolean isX = true;
		for (int i = 0; i < s.length; i++) {
			if (s[i] == 'T') {
				isX = !isX;
				continue;
			}

			int t = 0;
			while (i < s.length && s[i] == 'F') {
				i++;
				t++;
			}

			if (t == 0) continue;
			if (isX) xa.add(t);
			else ya.add(t);
			i--;
		}

		boolean[][] dpx = new boolean[xa.size() + 1][16010];
		boolean[][] dpy = new boolean[ya.size() + 1][16010];
		dpx[0][8005] = true;
		dpy[0][8005] = true;

		if (s[0] == 'F') {
			dpx[1][8005 + xa.get(0)] = true;
			for (int i = 1; i < xa.size(); i++) {
				for (int j = 0; j < dpx[0].length; j++) {
					if (dpx[i][j]) {
						dpx[i + 1][j + xa.get(i)] = true;
						dpx[i + 1][j - xa.get(i)] = true;
					}

				}
			}
		} else {
			for (int i = 0; i < xa.size(); i++) {
				for (int j = 0; j < dpx[0].length; j++) {
					if (dpx[i][j]) {
						dpx[i + 1][j + xa.get(i)] = true;
						dpx[i + 1][j - xa.get(i)] = true;
					}
				}
			}
		}

		for (int i = 0; i < ya.size(); i++) {
			for (int j = 0; j < dpy[0].length; j++) {
				if (dpy[i][j]) {
					dpy[i + 1][j + ya.get(i)] = true;
					dpy[i + 1][j - ya.get(i)] = true;
				}

			}
		}

		if (dpx[xa.size()][8005 + x] && dpy[ya.size()][8005 + y]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 129872
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <map>
#include <list>
#include <math.h>
#include <algorithm>
#include <chrono>
#include <random>
#include <queue>
#include <fstream>
#include <iterator> // std::back_inserter
#include <chrono>
#include <string>
#include <stdio.h>
#include <iomanip>
#include <float.h>
#include <cassert>
#include <functional>

using namespace std;

int main()
{
    long long int N, A, B;
    long long int ans=2;
    long long cap = 1000000000 + 7;
    long long int check = 1;

    cin >> N >> A >> B;

    for(long long int i=N; i>0; i >>= 1, ans = ans*ans % cap){
        if(i % 2 == 1) check = check*ans % cap;
    }

    ans = check-1;

    //cout << ans << " ";

    long long int bunsi_a = 1;
    long long int bunbo_a = 1;

    for(long long int i=0; i<A; i++){
        bunsi_a *= (N-i);
        bunsi_a %= cap;
        bunbo_a = bunbo_a * (i+1) % cap;
    }

    check=1;

    for(long long int i=(cap-2); i>0; i >>= 1,bunbo_a=bunbo_a*bunbo_a % cap){
        if(i % 2 == 1) check = check*bunbo_a % cap;
    }

    bunbo_a = check;

    long long int a_num = 0;

    a_num = (bunbo_a * bunsi_a) % cap;

    //cout << bunsi_a << bunbo_a << a_num << " ";

    long long int bunsi_b = 1;
    long long int bunbo_b = 1;

    for(long long int i=0; i<B; i++){
        bunsi_b *= (N-i);
        bunsi_b %= cap;
        bunbo_b = bunbo_b * (i+1) % cap;
    }

    check=1;
    for(long long int i=(cap-2); i>0; i >>= 1, bunbo_b = bunbo_b*bunbo_b % cap){
        if(i % 2 == 1) check = check*bunbo_b % cap;
    }

    bunbo_b = check;

    long long int b_num = 0;

    b_num = (bunbo_b * bunsi_b) % cap;

    //cout << b_num << " ";

    ans -= (a_num + b_num);

    ans %= cap;

    if(ans < 0) ans += cap;

    cout << ans;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define int long long
#define mod 1000000007
#define fi first
#define se second
#define be begin()
#define en end()
#define re reverse
#define Set setprecision 
const int INFi=2147483647;
const long long INFl=9223372036854775807LL;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a,b;
    int c,d,e=-1;
    cin>>a>>b;
   for(int i=0;i<a.size();i++){
     if(a[i]==b[0]||a[i]=='?'){
       d=1;
       for(int j=0;j<b.size();j++){
         if(a[i+j]!=b[j]){
           if(a[i+j]!='?') d=0;
         }
       }
       if(d) e=i;
     }
   }
	if(e!=-1){
       for(int i=0;i<a.size();i++){
         if(e==i){
           for(i;i<e+b.size();i++) cout<<b[i-e];
           i--;
         }
         else{
           if(a[i]=='?') cout<<"a";
           else cout<<a[i];
         }
       }
     }
     else cout<<"UNRESTORABLE";
     cout<<"\n";
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,a[110];
	cin >> n;
	for(int i = 0;i < n;i++) cin >> a[i];
	bool isOK = true;
	for(int i = 0;i < n;i++){
		if(a[i] % 2 == 0 && a[i] % 3 && a[i] % 5) isOK = false;
	}
	if(isOK) cout << "APPROVED" << endl;
	else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
const unsigned long long h = 1e9+7;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MAX = 100010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    int ans = 0;
    if (a+b <= 2*c) ans = a*x+b*y;
    else{
        ans += min(x,y)*2*c;
        if (x > y){
            if (a <= 2*c) ans += a*(x-y);
            else ans += 2*c*(x-y);
        }
        if (x < y){
            if (b <= 2*c) ans += b*(y-x);
            else ans += 2*c*(y-x);
        }
    }
    PRINT(ans);
}    


Measured memory_bytes: 256
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


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


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def main():
    N, A, B = li_input()
    X = li_input()

    ans = 0
    for i in range(len(X) - 1):
        if (X[i+1] - X[i]) * A < B:
            ans += (X[i+1] - X[i]) * A
        else:
            ans += B
    
    print(ans)


main()


Measured memory_bytes: 16456
#include <iostream>

using namespace std;
const int lim = 1e7 + 1;
int lp[lim] , n;
void sieve(){
    for (int i = 1; i <= n; i++)
        for (int j = i; j <= n; j += i)
            lp[j] += 1;
}
int main(){
    cin >> n;
    sieve();
    long long ans = 0;
    for (int i = 1; i <= n; i++)
        ans = ans + 1LL * lp[i] * i;
    cout << ans;
    return 0;
}

Measured memory_bytes: 42676
N = int(input())
num = [1, 2, 3, 4, 5, 6, 7, 8, 9]
x = 0
for i in range(9):
  if N/(9-i) in num:
    x += 1
  else:
    x += 0
    
if x!= 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define fo(i, x, y) for(int i = x, B = y; i <= B; i ++)
#define ff(i, x, y) for(int i = x, B = y; i <  B; i ++)
#define fd(i, x, y) for(int i = x, B = y; i >= B; i --)
#define ll long long
#define pp printf
#define hh pp("\n")
using namespace std;

const int N = 1e5 + 5;

int k, n, a[N];

int divs(int x, int y) {
	return x / y + (x % y != 0);
}
int dg(int n, int k) {
	if(n < k) return 0;
	if(n % k == 0) return n / k;
	int m = divs(n % k, n / k + 1);
	return dg(n - (n / k + 1) * m, k);
}

int main() {
	scanf("%d", &n);
	int ans = 0;
	fo(i, 1, n) {
		int x;
		scanf("%d %d", &x, &k);
		ans ^= dg(x, k);
	}
	pp("%s\n", ans ? "Takahashi" : "Aoki");
}

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


int main() {
  string s,t;
  int l,r,d;
  cin>>l>>r>>d;
  int ans=0;
  for(int i=l;i<=r;i++){
    if(i%d==0)ans++;
  }
  cout<<ans<<"\n";
  
  return 0;
}


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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> vec(N);
  for (int i=0; i<M; ++i) {
    int A,B;
    cin >> A >> B;
    vec.at(A-1) += 1;
    vec.at(B-1) += 1;
  }
  for (int i=0; i<N; ++i) {
    cout << vec.at(i) << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cassert>
#include <cstring>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

int main(void) {
    string s;
    string y = "YAKI";
    cin >> s;
    if (s.substr(0,4) == y) {
        puts("Yes");
    }
    else {
        puts("No");
    }
    return 0;
}

Measured memory_bytes: 256
S = input()
T = input()
ok = False
ans = []

for i in range(len(S)-len(T),-1,-1):
	tmpS = list(S)
	for j in range(len(T)):
		if tmpS[i+j] == "?":
			tmpS[i+j] = T[j]

	if "".join(tmpS[i:i+len(T)]) == T:
		ans = tmpS
		ok = True
		break

ans = "".join(ans)
if ok == False:
	print("UNRESTORABLE")
else:
	print(ans.replace("?","a"))

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    ArrayList<Integer> list = new ArrayList<>();
    try {
      while(true){
        int n = sc.nextInt();
        if(n == 0)break;
        for(int i=0;i<n;i++){
          int s = sc.nextInt();
          list.add(s);
        }
        Collections.sort(list);
        list.remove(0);
        list.remove(list.size()-1);
        int Avg = 0;
        for(Integer num : list){
          Avg += num;
        }
        System.out.println(Avg/list.size());
        list.clear();
      }
      
    } catch (Exception e) {
    }
    sc.close();
  }
}


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

int main()
{
  int x;cin>>x;
  vector<bool> prime(200000,true);
  prime.at(0)=false;
  prime.at(1)=false;
  int i;
  for(i=2;i<150000;i++)
  {
    int k=2;
    while(i*k<150000)
    {
      prime.at(i*k)=false;
      k++;
    }
  }
  while(!prime.at(x))
  {
    x++;
  }
  cout<<x<<endl;
}


Measured memory_bytes: 256
N = int(input())
L = list(map(int,input().split()))
A = []
B = []
for i in range(N) :
    if L[i] % 2 == 0 :
        A.append(L[i])
    else :
        B.append(L[i])
if len(B) % 2 == 0 :
    print("YES")
else :
    print("NO")
    

Measured memory_bytes: 14112
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int n;  cin >> n;
    vector<int>a(n);
    rep(i, n)   cin >> a[i];
    vector<vector<ll> >dp(n+1, vector<ll>(2));
    const ll INF = 1001001001001001;
    dp[0][1] = -INF;
    rep(i, n){
        dp[i+1][0] = max(dp[i][0] + a[i], dp[i][1] - a[i]);
        dp[i+1][1] = max(dp[i][0] - a[i], dp[i][1] + a[i]);
    }
    cout << dp[n][0] << endl;
}


Measured memory_bytes: 6144
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();
        int k = std.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = std.nextInt();
        }

        Map<Integer, Integer> counting = new HashMap<>();
        for (int i = 0; i < n; i++) {
            counting.put(a[i], counting.getOrDefault(a[i], 0) + 1);
        }

        Iterator<Map.Entry<Integer, Integer>> it = counting.entrySet().iterator();
        PriorityQueue<Map.Entry<Integer, Integer>> pq = new PriorityQueue<>(new Comparator<Map.Entry<Integer, Integer>>() {
            @Override
            public int compare(Map.Entry<Integer, Integer> o1, Map.Entry<Integer, Integer> o2) {
                return o1.getValue() - o2.getValue();
            }
        });

        while (it.hasNext()) {
            pq.add(it.next());
        }

        long sum = 0;
        while (pq.size() > k) {
            sum += pq.poll().getValue();
        }

        System.out.println(sum);
    }
}


Measured memory_bytes: 92856
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
if N == 0:
    print(0)
    exit()

ans = ''
odd = False
while abs(N) > 0:
    if N & 1:
        ans += '1'
    else:
        ans += '0'
    if odd:
        N += 1
    N >>= 1
    odd = not odd
print(ans[::-1])


Measured memory_bytes: 21196
def main():
    N, K = map(int, input().split())

    ret = K
    for _ in range(N - 1):
        ret *= K - 1
    print(ret)


if __name__ == '__main__':
    main()

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


Measured memory_bytes: 2940
// 参考
// https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let 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! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

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

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r"999
" => r"ABC",

r"1000
" => r"ABD",

r"1481
" => r"ABD"
}

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: i32,
    }

    let ans = if n > 999 { "ABD" } else { "ABC" };

    ans.to_string()
}


Measured memory_bytes: 4352
n=int(input())
s=list(map(int,list(input())))
data=[]
for i in range(10):
    for j in range(10):
        for k in range(10):
            data.append([i,j,k])
count=0
for u in data:
    l=0
    for v in s:
        if u[l]==v:
            l+=1
            if l==3:
                count+=1
                break
print(count)

Measured memory_bytes: 42860
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

vector<int> bfs(int n, int s, int t, vector<vector<int>>& to){
    vector<int> res(n*3, INF);
    queue<int> q;
    q.push(s);
    res[s] = 0;
    while(!q.empty()){
        int f = q.front();q.pop();
        for(auto&& c : to[f]){
            if(res[c] == INF){
                res[c] = res[f] + 1;
                q.push(c);
            }
        }
    }
    return res;
}

int main(void)
{
    int n,m;
    cin >> n >> m;
    vector<vector<int>> to(n*3);
    REP(i, m){
        int u,v;
        cin >> u >> v;
        u--;v--;
        to[u].pb(n+v);
        to[n+u].pb(2*n+v);
        to[2*n+u].pb(v);
    }
    int s,t;
    cin >> s >> t;
    s--;t--;

    auto ans = bfs(n, s, t, to);
    if(ans[t] == INF) pr(-1);
    else pr(ans[t]/3);
}

Measured memory_bytes: 17792
#include <bits/stdc++.h>
using namespace std;
int n,m;
string s;
int main() {
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++) {
        for(int j=0;j<m;j++) {
            cin>>s;
            if(s == "snuke") {
                cout << char('A'+j) << i+1 << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256