akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <unistd.h>
#define ll long long
#define ull unsigned long long
#define inf 1000000007
#define inf16 0x3f3f3f3f
#define INF 1000000000000000007LL
#define VI vector<int>
#define VPII vector<pair<int, int> >
#define VLL vector<ll>
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZE(x) (int)(x).size()
using namespace std;

#define N 2007

int n, k, res;

VI G[N];

int dist[N];
bitset<N> vis;

void dfs(int v)
{
	vis[v] = 1;

	for(auto it:G[v])
	{
		if(dist[it]>dist[v]+1)
		{
			dist[it] = dist[v]+1;
			dfs(it);
		}
	}
}

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	cin >> n >> k;

	for(int i = 1; i < n; ++i)
	{
		int a, b;
		cin >> a >> b;
		G[a].pb(b);
		G[b].pb(a);
	}

	for(int i = 1; i <= n; ++i)
	{
		memset(dist, inf16, sizeof dist);
		dist[i] = 0;
		dfs(i);

		int curr = 0;

		for(int j = 1; j <= n; ++j)
		{
			if(dist[j]<=k/2)
				++curr;
		}

		res = max(res, curr);
	}

	for(int i = 1; i <= n; ++i)
	{
		for(auto it:G[i])
		{
			memset(dist, inf16, sizeof dist);
			dist[i] = 0;
			dfs(i);
			dist[it] = 0;
			dfs(it);

			int curr = 0;

			for(int j = 1; j <= n; ++j)
			{
				if(dist[j]<=(k-1)/2)
					++curr;
			}

			res = max(res, curr);
		}
	}

	cout << n-res;
}


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

#define EPS (1e-7)
#define INF (1<<25)
#define PI (acos(-1))

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

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

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

using ll = long long;

bool f[8];

int main() {
  int n; cin >> n;
  int cnt = 0;
  REP(i,n) {
    int a; cin >> a;
    a/=400;
    if (a < 8) f[a] = true;
    else cnt++;
  }
  int ans = 0;
  REP(i,8) if (f[i]) ans++;
  cout << max(1,ans) << " " << ans+cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
template <typename T, typename E>
struct SegmentTree {
	typedef function<T(T, T)> F;
	typedef function<T(T, E)> G;
	int n, N;
	F f;
	G g;
	T d1;
	E d0;
	vector<T> dat;
	SegmentTree(){};
	SegmentTree(int n_, F f, G g, T d1, vector<T> v = vector<T>()) : f(f), g(g), d1(d1) {
		N = n_;
		init(n_);
		if (n_ == (int)v.size()) build(n_, v);
	}
	void init(int n_) {
		n = 1;
		while (n < n_) n *= 2;
		dat.clear();
		dat.resize(2 * n - 1, d1);
	}
	void build(int n_, vector<T> v) {
		for (int i = 0; i < n_; i++) dat[i + n - 1] = v[i];
		for (int i = n - 2; i >= 0; i--) dat[i] = f(dat[i * 2 + 1], dat[i * 2 + 2]);
	}
	void update(int k, E a) {
		k += n - 1;
		dat[k] = g(dat[k], a);
		while (k > 0) {
			k = (k - 1) / 2;
			dat[k] = f(dat[k * 2 + 1], dat[k * 2 + 2]);
		}
	}
	inline T query(int a, int b) {
		T vl = d1, vr = d1;
		for (int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) {
			if (l & 1) vl = f(vl, dat[(l++) - 1]);
			if (r & 1) vr = f(dat[(--r) - 1], vr);
		}
		return f(vl, vr);
	}

	template <bool (*h)(T)>
	int max_right(int l) {
		return max_right(l, [](T x) { return h(x); });
	}
	template <class H>
	int max_right(int l, H h) {
		assert(0 <= l && l <= N);
		assert(h(d1));
		if (l == N) return N;
		l += n - 1;
		T tm = d1;
		do {
			while (l & 1) l = (l - 1) / 2;
			if (!h(f(tm, dat[l]))) {
				while (l < n - 1) {
					l = (2 * l + 1);
					if (h(f(tm, dat[l]))) {
						tm = f(tm, dat[l]);
						l++;
					}
				}
				return l - n + 1;
			}
			tm = f(tm, dat[l]);
			l++;
		} while (((l + 1) & -(l + 1)) != (l + 1));
		return N;
	}

	template <bool (*h)(T)>
	int min_left(int r) {
		return min_left(r, [](T x) { return h(x); });
	}
	template <class H>
	int min_left(int r, H h) {
		assert(0 <= r && r <= N);
		assert(h(d1));
		if (r == 0) return 0;
		r += n;
		T tm = d1;
		do {
			r--;
			while (r > 1 && (r % 2)) r >>= 1;
			if (!h(f(dat[r], tm))) {
				while (r < n) {
					r = (2 * r + 1);
					if (h(f(dat[r], tm))) {
						tm = f(dat[r], tm);
						r--;
					}
				}
				return r + 1 - n + 1;
			}
			tm = f(dat[r], tm);
		} while ((r & -r) != r);
		return 0;
	}
};
int target;
bool f(int x) { return x < target; }
int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	int n, q;
	cin >> n >> q;
	vector<int> vec(n);
	rep(i, n) cin >> vec[i];
	SegmentTree<int, int> seg(
	    n, [](int a, int b) { return max(a, b); }, [](int a, int b) { return b; }, -1, vec);
	for (int i = 0; i < q; i++) {
		int c, x, y;
		cin >> c >> x >> y;
		if (c == 2)
			cout << seg.query(x - 1, y) << endl;
		else if (c == 1)
			seg.update(x - 1, y);
		else {
			target = y;
			x--;
			cout << seg.max_right<f>(x) + 1 << endl;
		}
	}
	return 0;
}

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

int a[5][5];
bool vis[5][5];

int main()
{
	ios::sync_with_stdio(false),cin.tie(0);
	for(int i=1;i<=3;i++){
		for(int j=1;j<=3;j++){
			cin>>a[i][j];
		}
	}
	int n;cin>>n;
	int num;
	for(int i=1;i<=n;i++){
		cin>>num;
		for(int k=1;k<=3;k++){
			for(int j=1;j<=3;j++){
				if(num==a[k][j])vis[k][j]=1;
			}
		}
	}
	bool flag=0;
	for(int i=1;i<=3;i++){
		if(vis[i][1]+vis[i][2]+vis[i][3]==3){
			flag=true;break;
		}
	}
	for(int i=1;i<=3;i++){
		if(flag)break;
		if(vis[1][i]+vis[2][i]+vis[3][i]==3){
			flag=true;break;
		}
	}
	if(!flag&&(vis[1][1]+vis[2][2]+vis[3][3]==3||vis[3][1]+vis[2][2]+vis[1][3]==3))flag=true;
	if(flag)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main()
{
	vector<bool> ls(101,true);
	int x, n;
    cin>>x>>n;
	while(n--)
    {
      	int a;cin>>a;ls[a]=false;
    }
	int a=x,b=x;
	while(!ls[x])
    {
		a++;b--;
		if(ls[a]) x=a;
		if(ls[b]) x=b;
    }
	cout<<x;
}

Measured memory_bytes: 3596
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>




using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;


void solve() {
    int n;
    cin >> n;
    int x = 1;
    while (x < n) {
        x *= 2;
    }
    if (x == n) {
        cout << "No\n";
        return;
    }
    cout << "Yes\n";
    for (int i = 2; i + 1 <= n; i += 2) {
        cout << i << " " << i + 1 << "\n";
        cout << 1 << " " << i + 1 << "\n";
        cout << 1 << " " << i + n << "\n";
        cout << i + n << " " << i + n + 1 << "\n";
    }
    if (n % 2 == 0) {
        cout << n << " " << n - 1 << "\n";
        int k = n ^ (n - 1) ^ 1;
        cout << k + n << " " << 2 * n << "\n";
    }
    cout << 2 << " " << n + 1 << "\n";
}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    solve();


#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
//T+N
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl

map<int, int> found;

signed main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    string arr;
    cin >> arr;
    ll pref = 0;
    ll ans = 0;
    found[0] ++;
    int pw = 1;
    for(int i = arr.size() - 1; i >= 0; i --) {
        int curr = (arr[i] - '0') * pw;
        pw = (pw * 10) % 2019;
        pref = (pref + curr) % 2019;
        ans += found[pref];
        found[pref] ++;
        //cout << pref << endl;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3736
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};

int ans;
int n,m;
int f[111111];
signed main(){
	
	cin>>n>>m;
	rep(i,m){
		int d;
		cin>>d;
		f[d]=1;
	}
	rep(i,111111){
		string s=to_string(i);
		int ok=1;
		rep(j,s.size()){
			if(f[s[j]-'0'])ok=0;
		}
		if(ok && i>=n){
			cout<<i<<endl;
			break;
		}
	}


}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        long sum = 0;

        for(int i = 1; i <= N; i++) {
            if(i % 3 != 0 && i % 5 != 0) {
                sum += (long)i;
            }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 27152
//code written by a living bruh moment
import java.io.*;
import java.lang.*;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;
import java.util.Random;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
    static InputReader in = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = in.nextInt();
        String s = in.next();
        String s2 = in.next();
        String ans = "";
        for(int i = 0; i<n; i++){
            ans+=s.charAt(i);
            ans+=s2.charAt(i);
        }
        out.println(ans);
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong()
        {
            return Long.parseLong(next());
        }
        public double nextDouble()
        {
            return Double.parseDouble(next());
        }
        public String nextLine()
        {
            try
            {
                return reader.readLine();
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
            return null;
        }
        public boolean hasNext()
        {
            String next=null;
            try
            {
                next=reader.readLine();
            }
            catch(Exception e)
            {
            }
            if(next==null)
            {
                return false;
            }
            tokenizer=new StringTokenizer(next);
            return true;
        }
    }
}

Measured memory_bytes: 37404
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll N=1e5+5;
ll n,k,ans,a[N],best[N],sum[N];
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>n>>k;
    for(ll i=1;i<=n;i++){
        cin>>a[i];
        sum[i]=sum[i-1]+a[i];
        best[i]=best[i-1];
        if(a[i]>0)best[i]+=a[i];
    }
    for(ll i=1;i+k-1<=n;i++){
        ll r = i+k-1;
        ans = max(ans , max(sum[r]-sum[i-1],0ll) + best[i-1] + best[n]-best[r]);
    }
    cout<<ans;
}



Measured memory_bytes: 2560
from bisect import bisect_left
from collections import defaultdict
N=int(input())
D=[[] for i in range(2*10**5+1)]
U=[[] for i in range(2*10**5+1)]
L=[[] for i in range(2*10**5+1)]
R=[[] for i in range(2*10**5+1)]
arr=[]

for i in range(N):
    X,Y,v=input().split()
    X,Y=int(X),int(Y)
    arr.append((X,Y,v))
    if v=='U':
        U[X].append(Y)
    if v=='D':
        D[X].append(Y)
    if v=='L':
        L[Y].append(X)
    if v=='R':
        R[Y].append(X)
ans=float('inf')
for i in range(2*10**5+1):
    D[i].sort()
    for u in U[i]:
        b=bisect_left(D[i],u)
        if b==len(D[i]):
            continue
        ans=min(ans,5*(D[i][b]-u))
        
    L[i].sort()
    for r in R[i]:
        b=bisect_left(L[i],r)
        if b==len(L[i]):
            continue
        ans=min(ans,5*(L[i][b]-r))
        
def check(R,U):
    res=float('inf')
    for A,B in U.items():
        B.sort()
    for xr,yr in R:
        b=bisect_left(U[xr+yr],xr)
        if b==len(U[xr+yr]):
            continue
        res=min(res,10*(U[xr+yr][b]-xr))
    return res

for t in range(4):
    r2,u2=[],defaultdict(list)
    for x,y,v in arr:
        if v=='U':
            if t==0:
                u2[x+y].append(x)
            if t==3:
                r2.append((y,-x))
        if v=='D':
            if t==2:
                u2[-y-x].append(-x)
            if t==1:
                r2.append((-y,x))
        if v=='R':
            if t==0:
                r2.append((x,y))
            if t==1:
                u2[x-y].append(-y)
        if v=='L':
            if t==2:
                r2.append((-x,-y))
            if t==3:
                u2[y-x].append(y)
    ans=min(ans,check(r2,u2))
print(ans if ans!=float('inf') else 'SAFE')

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

#define rep(i, u) for (int i = 0; i < u; i++)

using ll = long long;
using ull = unsigned long long;

int main() {
  list<int> ls;
  int n;
  string s; int a;
  cin >> n;
  rep(i, n) {
    cin >> s;
    if (s == "insert") {
      cin >> a;
      ls.push_front(a);
    } 
    else if (s == "delete") {
      cin >> a;
      for (auto itr = ls.begin(); itr != ls.end(); itr++) if (*itr == a) {ls.erase(itr); break;}
    } 
    else if (s == "deleteFirst") ls.pop_front();
    else if (s == "deleteLast") ls.pop_back();  
  }
  for (auto itr = ls.begin(); itr != ls.end(); itr++) {
    if (itr != ls.begin()) cout << ' ';
    cout << *itr;
  }
  cout << endl;
  return 0;
}



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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

string s,t;
int dp[3003][3003];
void solve(){
    cin>>s>>t;
    int n=sz(s);
    int m=sz(t);
    rep(i,1,n+1){
        rep(j,1,m+1){
            if(s[i-1]==t[j-1]) dp[i][j]=dp[i-1][j-1]+1;
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    string ans;
    while(n and m){
        if(s[n-1]==t[m-1]) ans+=s[n-1],n--,m--;
        else if(dp[n-1][m]>dp[n][m-1]) n--;
        else m--;
    }
    reverse(all(ans));
    cout<<ans<<endl;
}

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

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

#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define ss second
#define ff first
#define sz(s) (int)s.size()
#define all(a) a.begin(),a.end()

#ifndef ONLINE_JUDGE
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}

#else
#define trace(args...) { }
#endif

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;

int main()
{
  IOS;
  int a, b, c;
  cin >> a >> b >> c;
  cout << min(c, b / a) << '\n';
  return 0;
}

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

using namespace std;

using ll = long long;

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

    ll n, k;
    cin >> n >> k;

    ll cnt = 0;
    for (ll b = k + 1; b <= n; ++b) {
        ll block = (b == 1 ? n :(n / b) + 1);
        if (k <= n % b) cnt += (n % b) - k + 1;
        if (2 <= block) {
            cnt += (b - k) * (block - 1);
            if (k == 0 && b != 1) --cnt;
        }
    }

    cout << cnt << endl;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x=0,y=0;
    char ch;
    cin>>n;
    getchar();
    while(n--)
    {
        cin>>ch;
        if(ch=='I')
            x++;
        else if(ch=='D')
            x--;
        y=max(y,x);
    }
    cout<<y<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n;
vector <vector <long long> > v;
vector <vector <long long> > dp;

int main () {
	cin >> n;
	long long l = n;
	while (l--) {
		vector <long long> day;
		for (int i = 0;i < 3;i ++) {
		    long long x;
		    cin >> x;
		    day.push_back(x);
		}
		v.push_back(day);
		dp.push_back(day);
	}
	
	for (int i = 0;i < 3;i++)dp[v.size()-1][i] = v[v.size()-1][i];
	
	for (int i = v.size()-2;i >= 0;i--) {
		dp[i][0] = max(dp[i+1][1],dp[i+1][2]) + v[i][0];
		dp[i][1] = max(dp[i+1][0],dp[i+1][2]) + v[i][1];
		dp[i][2] = max(dp[i+1][1],dp[i+1][0]) + v[i][2];
	}
	
	long long ma = -1;	
	for (int i = 0;i < 3;i++) ma = max(ma,dp[0][i]);
	cout << ma;
	
	return 0;
}

Measured memory_bytes: 14280
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);

		int h1 = getInt(sc);
		int m1 = getInt(sc);
        int h2 = getInt(sc);
		int m2 = getInt(sc);
		int k = getInt(sc);
      
      System.out.println((h2*60+m2)-(h1*60+m1)-k);

	}

	/**
	 * *汎用メソッド<br>
	 * 入力した配列に対する順列を取得
	 *
	 * @param numArray
	 * @return
	 */
	private static List<Integer[]> getPermutation(int[] numArray) {
		List<Integer[]> permutation = new ArrayList<>();
		Integer[] ans = new Integer[numArray.length];
		boolean[] used = new boolean[numArray.length];

		return buildPermutaion(permutation, numArray, ans, used, 0);
	}

	/**
	 * *汎用メソッド(内部)<br>
	 * 入力した配列に対する順列を作成
	 *
	 * @param list
	 * @param numArray
	 * @param ans
	 * @param used
	 * @param depth
	 * @return
	 */
	private static List<Integer[]> buildPermutaion(List<Integer[]> list, int[] numArray, Integer[] ans, boolean[] used,
			int depth) {

		// 全部使い切った時=>できた順列を返す
		if (depth == numArray.length) {
			list.add(ans.clone());
			return list;
		}
		// 使い切っていない場合

		for (int i = 0; i < numArray.length; i++) {
			if (used[i]) {
				continue;
			}
			ans[depth] = numArray[i];
			used[i] = true;
			list = buildPermutaion(list, numArray, ans, used, depth + 1);

			used[i] = false;
		}

		return list;
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

}


Measured memory_bytes: 35720
N = int(input())
A = list(map(int,input().split()))
A = list(map(str,list(map(bin,A))))
for i in range(N):
    if i ==0:
        ans =len(A[i])-A[i].rfind("1")-1
    else:
        ans = min(ans,len(A[i])-A[i].rfind("1")-1)
print(ans)


Measured memory_bytes: 9216
#include <stdio.h>
int main()
{ 
	long long n;
	scanf("%lld", &n);
	for(long long i=-1003; i<=1003; i++)
		for(long long j=-1003; j<=1003; j++)
			if(i * i * i * i * i - j * j * j * j * j == n)
			{
				printf("%lld %lld", i, j);
				return 0;
			}
    return 0;
}

Measured memory_bytes: 1704
#include <bits/stdc++.h>
using namespace std;
// clang-format off

using LL = long long;
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
 
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
// clang-format on

void solve(long long N, std::vector<std::string> S) {
  // solver code

  map<string, int> m;

  for (int i = 0; i < N; i++) {
    m[S[i]] = 1;
  }

  cout << m.size() << endl;

  // for (auto e : m) {
  //   cout << e << endl;
  // }
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<std::string> S(N);
  for (int i = 0; i < N; i++) {
    std::cin >> S[i];
  }
  solve(N, std::move(S));
  return 0;
}


Measured memory_bytes: 25164
#include <cstdio>
#include <vector>

using namespace std;

int main(){
vector<int> data(101,0);
int v;
while(scanf("%d",&v)!=-1)data[v]++;
int mxvl=0;
vector<int> res;
for(int i=0;i<=100;++i){
if(mxvl < data[i]){
mxvl = data[i];
res.clear();
}
if(mxvl == data[i])res.push_back(i);
}
for(int i=0;i<res.size();++i)printf("%d\n",res[i]);
return 0;
}

Measured memory_bytes: 1048
import bisect
import operator
import collections


class RAQ():
    
    def __init__(self, size):
        """初期化"""
        self.size = size
        self.sub = [0 for i in range(size + 1)]
        self.r = 0
        self.v = 0
    
    @classmethod
    def from_array(cls, a):
        st = cls(len(a))
        for i, x in enumerate(a):
            st.add(i, i+1, x)
        return st

    def add(self, a, b, value):
        """区間[a, b) に対する加算"""
        if a > b:
            raise ValueError("a must be less than equal b.")
        self.sub[a] += value
        self.sub[b] -= value

    def get(self, key):
        """値の取得"""
        if key < self.r - 1:
            self.r = 0
            self.v = 0
        for i in range(self.r, key):
            self.v += self.sub[i]
        self.r = key
        return self.v + self.sub[key]


def read():
    N, D, A = list(map(int, input().strip().split()))
    XH = list()
    for i in range(N):
        x, h = list(map(int, input().strip().split()))
        XH.append((x, h))
    return N, D, A, XH


def solve(N, D, A, XH):
    XH = sorted(XH)
    X = [x for x, h in XH]
    H = [h for x, h in XH]

    st = RAQ.from_array(H)

    ans = 0
    i = 0
    while i < N:
        x = XH[i][0]
        h = st.get(i)
        c = h // A + (h % A > 0)
        ans += c
        v = c * A
        lidx = bisect.bisect_left(X, x)
        ridx = bisect.bisect_left(X, x + 2 * D + 1)
        st.add(lidx, ridx, -v)
        m = -1
        i += 1
        while i < N:
            h = st.get(i)
            if h > 0:
                break
            i += 1
    return ans


if __name__ == "__main__":
    inputs = read()
    print("%s" % solve(*inputs))


Measured memory_bytes: 43108
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)

const ll INF = 10010001010;
const int inf = 1000034000;
typedef vector<ll> vecl;
typedef vector<int> veci;
typedef tuple<string, int, int> TUP;

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

int main()
{
    string S;
    cin >> S;
    bool ok = false;
    string T;
    for (int i = 0; i < S.size(); i++)
    {
        for (int j = 0; j < S.size();j++)
        {
            T = S;
            T.erase(i,j);
            if (T == "keyence")
            {
                ok = true;
            }
            //cout << T << endl;
        }
    }
    if(ok){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}


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

int main(){
  int x[100];
  int i=0;
  char s[100];
  
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      x[i-2] = x[i-2] + x[i-1];
      i--;
    } else if ( s[0] == '-' ){
      x[i-2] = x[i-2] - x[i-1];
      i--;
    } else if ( s[0] == '*' ){
      x[i-2] = x[i-2] * x[i-1];
      i--;
    } else {
      x[i] = atoi(s);
      i++;
    }
  }
  printf("%d\n",x[i-1]);
  return 0;
}

Measured memory_bytes: 548
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main()
{
  string a;
  cin>>a;
  a[3]++;
  cout<<a;
  system("pause");
  return 0;
}


Measured memory_bytes: 504
<?php

$n = (int)trim(fgets(STDIN));
list($s, $t) = explode(" ", trim(fgets(STDIN)));
$sArr = str_split($s);
$tArr = str_split($t);

$str = '';
for ($i=0; $i<$n; $i++) {
    $str .= $sArr[$i].$tArr[$i];
}

echo $str."\n";

Measured memory_bytes: 4728
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

#define mod 1e9+7
#define ll long long int
#define epsilon 1e-7

ll min(ll x, ll y){
    if(x<y)return x;
    return y;
}
struct hoge
{
    int a, b;
};
int compare_int(const void *a, const void *b){
	struct hoge *A = (struct hoge *)a;
	struct hoge *B = (struct hoge *)b;
    return (A->a) - (B->a);
}
struct hoge ab[100000];
int main(void){
    int n, m;
    scanf("%d %d", &n, &m);
    for(int i = 0;i < n;i++){
        scanf("%d %d", &ab[i].a, &ab[i].b);
    }
    qsort(ab, n, sizeof(struct hoge), compare_int);
    ll money = 0;
    int count = 0;
    int i = 0;
    while(count < m){
        count += ab[i].b;
        money += (ll)ab[i].a * ab[i].b;
        i++;
    }
    i--;
    money -=(ll)(count - m) * ab[i].a;
    printf("%lld\n", money);
    return 0;
}

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

namespace ABC117
{
    class Program
    {
        static void Main(string[] args)
        {
            int A, B, X;
            var word = Console.ReadLine().Split(' ');

            A = int.Parse(word[0]);
            B = int.Parse(word[1]);

            if (B % A == 0)
                X = A + B;
            else
                X = B - A;

            Console.WriteLine(X);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	    
		String x = "";
		try {
			x = in.readLine();
			String[] ab = x.split(" ");

			int a = Integer.parseInt(ab[0]);
			int b = Integer.parseInt(ab[1]);
			
			int tmp = 0;
			if (a > b) {
				tmp = b;
				b = a;
				a = tmp;
			}
			
			while ((tmp = (b % a)) != 0) {
				b = a;
				a = tmp;
			}
			System.out.println(a);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 24348
#include<bits/stdc++.h>
using namespace std;
int main ()
{
	int a,k;
	cin>>a;
	if(a%2==0)
	{
		cout<< a/2;
	}
	if(a%2==1)
	{
		cout<< a/2 +1;
	}
	return 0;
}

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


Measured memory_bytes: 3632
using System;
using System.Linq;

namespace ABC157C
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[][] sc = new int[nm[1]][];
            for (int i = 0; i < nm[1]; i++)
            {
                sc[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
            }
            int res = 0;
            int[] resArr = new int[nm[0]];
            resArr = resArr.Select(e => e = -1).ToArray();
            for (int i = 0; i < nm[1]; i++)
            {
                int s = sc[i][0];
                int c = sc[i][1];
                if (s>nm[0])
                {
                    res = -1;
                    break;
                }

                if (resArr[s-1] == -1 || resArr[s-1] == c)
                {
                    resArr[s-1] = c;
                }
                else
                {
                    res = -1; break;
                }
            }


            if (res == 0)
            {
                if (resArr[0] == -1 && nm[0]>1)
                {
                    resArr[0] = 1;
                }
                if (resArr[0] == 0 && nm[0] > 1)
                {
                    res = -1;
                }

               for (int i = resArr.Length-1; i >= 0; i--)
                {
                    if (resArr[i] == -1)
                    {
                        resArr[i] = 0;
                    }
                    res += resArr[(nm[0]-1) - i] * (int)Math.Pow(10, i);
                }
            }
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 13396
import sys

count = [0 for _ in range(26)]

for line in sys.stdin:
    array = line
    char = ["" for _ in range(len(array))]
    for i in range(len(array)):
        char[i] = array[i:i+1]
    for c in char:
        for i in range(26):
            if c == chr(i+ord("A")) or c == chr(i+ord("a")):
                count[i] += 1


for i in range(26):
    print("{0} : {1}".format(chr(i+ord("a")), count[i]))

Measured memory_bytes: 7472
n,m = map(int,input().split())

ans_list = ['' for _ in range(n)]

def ans(n,m,ans_list):
    ans_list_tmp = ans_list
    for _ in range(m):
        s,c = map(int,input().split())
        s -= 1
        if s == 0 and c == 0 and n!=1:
            return -1
        elif ans_list_tmp[s] not in ['', c]:
            return -1
        else:
            ans_list_tmp[s] = c

    ans = [i if i!='' else 0 for i in ans_list_tmp]
    if ans[0] == 0 and n!=1:
        ans[0] = 1
    ans = map(str,ans)

    ans = ''.join(ans)
    return ans

print(ans(n,m,ans_list))

Measured memory_bytes: 38356
import numpy as np

N, K = map(int, input().split())
p = np.array(list(map(int, input().split())))
p = (p+1) / 2

ans = pre = sum(p[:K])
for i in range(K, N):
    pre = p[i]-p[i-K]+pre
    ans = max(ans, pre)
print(ans)

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

int main(){
  int a,b;
  cin>>a>>b;
  int sum = 0;
  if(a>=2){
    sum += a*(a-1)/2;
  }
  if(b>=2){
    sum += b*(b-1)/2;
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define debug(x_) cerr << #x_ << ":" << x_ << endl;
#define debug2(x__) for(auto a__ : x__) cerr << a__ << " "; cerr << endl;
#define debug3(x___ , sx___) rep(i, sx___) cerr << x___[i] << " "; cerr << endl;

vector<pii> around = {MP(1, 0), MP(-1, 0), MP(0, 1), MP(0, -1)};

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> x(n), y(n), h(n);
    rep(i, n) cin >> x[i] >> y[i] >> h[i];
    for (int cx = 0; cx <= 100; cx++) {
        for (int cy = 0; cy <= 100; cy++) {
            int H;

            rep(i, n) {
                if (h[i] != 0) {
                    H = h[i] + abs(cx - x[i]) + abs(cy - y[i]);
                    break;
                }
            }
            bool valid = true;

            rep(i, n) {
                if (h[i] != max(H - abs(cx - x[i]) - abs(cy - y[i]), 0)) {
                    valid = false;
                    break;
                }
            }
            if (valid) {
                printf("%d %d %d\n", cx, cy, H);
                return 0;
            }
        }
    }

    return 0;
}



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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1


#ifndef ONLINE_JUDGE
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
						 stringstream _ss(_s); \
						 istream_iterator<string> _it(_ss); \
						 err(_it, args); }
#else
#define error(args...)		42
#endif


void err(istream_iterator<string> it) { cerr << endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "; ";
	err(++it, args...);
}


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("debug.txt", "w", stderr);
#endif
}


int32_t main()
{
	c_p_c();

	int x,y; cin>>x>>y;

	bool ans=0;

	for (int c = 0; c < x+1; ++c)
	{
		if(2*c + (x-c)*4 == y)
		{
			ans=1;
			break;
		}
	}

	if(ans)
		cout << "Yes";
	else
		cout << "No";
	
	return 0;
}

Measured memory_bytes: 3636
import scala.collection.mutable.ArrayBuffer
import scala.io.StdIn

object Main extends App {

  val Array(n, m) = StdIn.readLine().split(' ').map(_.toInt)
  val groupIndex = Array.fill[Int](n)(-1)
  val friends = Array.fill[ArrayBuffer[Int]](n)(ArrayBuffer.empty[Int])
  
  (0 until m).foreach { _ =>
    val a = StdIn.readLine().split(' ').map(_.toInt)
    friends(a(0)) += a(1)
    friends(a(1)) += a(0)
  }

  def depthFirstSearch(u: Int, grpId: Int): Unit = {
    groupIndex(u) = if(groupIndex(u) == -1) grpId else groupIndex(u)
    friends(u).foreach { v =>
      if(groupIndex(v) == -1){
        depthFirstSearch(v, grpId)
      }
    }
  }


  var idx = 1
  (0 until n).foreach { v =>
    if(groupIndex(v) == -1){
      depthFirstSearch(v, idx + 1)
      idx += 1
    }
  }

  val q = StdIn.readLine().toInt
  val sbbuff = new StringBuilder
  //println(s"q: $q")
  (0 until q).foreach { _ =>
    val ql = StdIn.readLine().split(' ').map(_.toInt)
    sbbuff.append(if(groupIndex(ql(0)) == groupIndex(ql(1))){
      f"yes%n" 
    } else {
      f"no%n"
    })
  }
  
  print(sbbuff.toString())
  
}



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

using namespace std;
#define int long long


#define ff first
#define ss second
// #define endl "\n"
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
#define PI 3.1415926535897932384626433832795
int MOD=1e9+7;
int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
int binpow(int a,int l){int res=1;while(l){if(l&1)res=res*a;l/=2;a=a*a;}return res;}
typedef long long ll; typedef vector<ll> vi; typedef pair<ll, ll> ii; typedef vector<ii> vii;
#define pb push_back
int __set(int b, int i) {return b|(1<<i);} //set ith bit
int __unset(int b, int i) {return b&(~(1UL<<i));}
int __check(int b, int i) {return b&(1<<i);} //returns 0 if ith bit is 0
int mulmod(int a, int b, int md) {return ((a%md)*(b%md))%md;}
int addmod(int a, int b, int md) {return (a+b)%md;}
int submod(int a, int b, int md) {return (((a-b)%md)+md)%md;}
int divmod(int a, int b, int md) {return mulmod(a, powmod(b, md-2, md), md);} //if md is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
	uniform_int_distribution<int> uid(l, r);
	return uid(rng);
}
int md = 1e9 + 7;
void manacher(vi& d1, vi& d2, int n, string& s) {
	for(int i = 0, l = 0, r = -1; i < n; i++) {
		int k = (i > r) ? 1 : min(d1[l + r - i], r - i + 1);
		while (0 <= i - k && i + k < n && s[i - k] == s[i + k])
			k++;
		d1[i] = k--;
		if (i + k > r) {
			l = i - k;
			r = i + k;
		}
	}
	for(int i = 0, l = 0, r = -1; i < n; i++) {
		int k = (i > r) ? 0 : min(d2[l + r - i + 1], r - i + 1);
		while (0 <= i - k - 1 && i + k < n && s[i - k - 1] == s[i + k])
			k++;
		d2[i] = k--;
		if (i + k > r) {
			l = i - k - 1;
			r = i + k ;
		}
	}
}

#define arr (int)(4e5+10)

int f[arr];
int rf[arr];

int C(int l,int k, int md) 
{
    if (k<0||k>l){
        return 0;
    }
    return f[l]*rf[k]%md*rf[l-k]%md;
}

void precfac() {
    f[0]=1;
    for (int i=1;i<arr;i++){
        f[i]=f[i-1]*i%MOD;
    }
    rf[arr-1]=powmod(f[arr-1],MOD-2, MOD);
    for (int i=arr-2;i>=0;i--){
        rf[i]=rf[i+1]*(i+1)%MOD;
    }
}

signed main(void)
{
	IOS;
	precfac();
	int n;
	cin>>n;
	vi x(n);int ans=0;
	for(int i = 0; i < n; i++)
		cin>>x[i];
	for(int i = 0; i < n-1; i++) {
		int j = n-1;
		int tp = ((((x[j]-x[i])*C(n-1,j-i,md))%MOD)*((f[j-i-1]*f[n-(j-i)-1])%MOD))%MOD;
		ans = (ans+tp)%MOD;
	}
	// cout<<ans<<endl;
	int pre[n-1]; int suf[n-1];
	suf[n-2]=x[n-2]; pre[0]=x[0];
	for(int i = 1; i < n-1; i++)
		pre[i]=pre[i-1]+x[i];
	for(int i = n-3; i >= 0; i--)
		suf[i]=suf[i+1]+x[i];
	for(int p = 1; p < n-1; p++) {
		int i = 0, j = p;
		int p1 = (suf[n-1-p]-pre[p-1])%MOD;
		int p2 = (((C(n-1,j-i+1,md)*(f[j-i-1]))%MOD)*f[n-1-(j-i+1)])%MOD;
		int tp = (p1*p2)%MOD;
		ans = (ans+tp)%MOD;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 8960
from collections import Counter

N, K = map(int, input().split())

An = Counter(input().split())


def main():
    # 要素数(v) 昇順
    # 先頭 から インデックス len(An) - K - 1 まで
    # 要素数(v) 合計
    print(sum(sorted(An.values())[:len(An) - K]))

    return


main()


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    set<string> s;
    rep(i,n){
        string ss;cin>>ss;
        s.insert(ss);
    }
    cout<<s.size()<<endl;
    return 0;
}


Measured memory_bytes: 19276
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>
using namespace std;
#define inf 2000000000
int v,e;
int d[1000][1000];
int f(){
    for(int k=0;k<v;k++){
        for(int i=0;i<v;i++){
            if(d[i][k]!=inf){
                for(int j=0;j<v;j++){
                    if(d[k][j]!=inf){
                        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
                        if(j==k&&d[j][k]<0){
                            cout<<"NEGATIVE CYCLE"<<endl;
                            return 1;
                        }
                    }
                }
            }
        }
    }
    return 0;
}
int main(void){
    cin >> v>>e;
    
    for(int i=0;i<v;i++){
        for(int j=0;j<v;j++){
            if(i==j){
                d[i][j]=0;
            }else{
                d[i][j]=inf;
            }
        }
    }
    for(int i=0;i<e;i++){
        int s,t;
        cin>>s>>t;
        cin>>d[s][t];
    }
    if(f()){
        return 0;
    }
    for(int i=0;i<v;i++){
        for(int j=0;j<v;j++){
            if(j==v-1){
                if(d[i][j]==inf){
                    cout<<"INF"<<endl;
                }else{
                    cout << d[i][j]<<endl;   
                }
            }else{
                if(d[i][j]==inf){
                    cout << "INF"<<" ";
                }else{
                    cout <<d[i][j]<<" ";
                }
            }
        }
    }
}



Measured memory_bytes: 3484
#include <stdio.h>
#include <string.h>
int main(void)
{
	char a[11],b[11],c[11];
	int A,B;
	scanf("%s%s%s",a,b,c);
	A=strlen(a);
	B=strlen(b);
	if(a[A-1]==b[0] && b[B-1]==c[0]){
		printf("YES\n");
	}else{
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>  
using namespace std; 
int n,l;
int a[100005];
int b=0;
int main()  
{  
    cin>>n>>l;
    cin>>a[1];
    for(int i=2;i<=n;i++)
    {
        cin>>a[i];
        if(a[i]+a[i-1]>=l)
            b=i;
    }
    if(!b)
    {
        cout<<"Impossible"<<endl;
        return 0;
    }
    b--;
    cout<<"Possible"<<endl;
    for(int i=1;i<=b-1;i++)
        cout<<i<<endl;
    for(int i=n-1;i>=b+1;i--)
        cout<<i<<endl;
    cout<<b<<endl;
    return 0;
}

Measured memory_bytes: 1152
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	[ n, a, b ] <- readIntegers
	let
		m = a + b
		res1 = n `div` m * a
		res2 = min a $ n `mod` m
	print $ res1 + res2

Measured memory_bytes: 380
// RAKSHIT KADAM
 
//  -- Declare array globally...
 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
// find_by_order returns iterator to  element present at that index...
// order_of_key returns no. of elements having value stricktly less than that given in the order_of_key();
#warning !!!check the size of arrayss!!!
 
// NUMERIC DEFINITIONS :
    #define INF 1000000000000000005
    #define inf 1000000003
    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 200006
    #define pi 3.1415926535897932384626433832795
#define ld long double
 #define ll long long
 #define int long long
 
 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>
 
 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;return (y%2 == 0)? p : (x * p) % m;}
ll modInverse(int a, int m){{ return power(a, m-2, m);}}
const int maxn = 500066;


void solve()
{
    ll ans =0;
    ll a,b;cin>>a>>b;
    ll c= gcd(a,b);
    while(c%2==0)
    {
        ans=1;
        c/=2;
    }
    for(ll i=3;i*i<=c;i+=2)
    {
        if(c%i==0)
        {
            ans++;
            while(c%i==0)c/=i;
        }
    }
    if(c>1)ans++;
    cout<<1+ans<<endl;
}

signed main()
{
   Need_for_speed(activated);

//satisfy
//    {
//  solve();
//   }
   
    solve();
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<math.h>
using namespace std;
typedef long long int ll;

void solve(){
    int x;cin>>x;
    if(x>=400 && x<600) cout<<8;
    if(x>=600 && x<800) cout<<7;
    if(x>=800 && x<1000) cout<<6;
    if(x>=1000 && x<1200) cout<<5;
    if(x>=1200 && x<1400) cout<<4;
    if(x>=1400 && x<1600) cout<<3;
    if(x>=1600 && x<1800) cout<<2;
    if(x>=1800 && x<2000) cout<<1;
    cout<<"\n";
}

int main()
{
    int t;//cin>>t;
    t=1;
    while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 3588