akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt(), m = scan.nextInt(), k = scan.nextInt();
    long totalMin=0;
    int max;
    int i=0,j=0;
    int[] a=new int[n], b = new int[m];
    for(int l=0;l<n;l++)a[l]=scan.nextInt();
    for(int l=0;l<m;l++)b[l]=scan.nextInt();
    while(i<n && totalMin+a[i]<=k){
      totalMin+=a[i];
      i++;
    }
    while(j<m && totalMin+b[j]<=k){
      totalMin+=b[j];
      j++;
    }
    max=i+j;
    i--;
    for(;i>=0;i--){
      totalMin-=a[i];
      while(j<m && totalMin+b[j]<=k){
        totalMin+=b[j];
        j++;
      }
      if(max<=i+j)max=i+j;

    }
    System.out.println(""+max);
  }
}

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

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  vector<int> ra(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    ra[a[i]]=i;
  }
  long long int ans=0;
  set<int> s;
  s.insert(-1);
  s.insert(n);
  for(long long int i=1;i<=n;i++){
    int x=ra[i];
    auto y=s.lower_bound(x);
    int r=*y;
    y--;
    int l=*y;
    ans+=i*(x-l)*(r-x);
    s.insert(x);
  }
  cout<<ans<<endl;
}


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

int main() {
    string s;
    cin >> s; int s_len = s.size();
    string key = "keyence";
    int check = 0;
    for (int i = 0; i < 7; i++) {
        if (key.at(i) == s.at(i)) {
            check++;
        } else break;
    }
    if (check == 7) {
        cout << "YES" << endl;
        return 0;
    }
    for (int i = s_len-7+check; i < s_len; i++) {
        if (key.at(check) == s.at(i)) {
            check++;
        } else break;
    }
    if (check == 7) {
        cout << "YES" << endl;
        return 0;
    } else {
        cout << "NO" << endl;
        return 0;
    }
}

Measured memory_bytes: 3584
#include<stdio.h>
 
#define MAX 10000
#define NIL -1
 
struct node{
  int parent, left, right;
};
 
struct node T[MAX];
int n;
 
void PreOrder(int);
void InOrder(int);
void PostOrder(int);
 
int main(){
  int v, l, r;
  int root;
  int i;
 
  scanf("%d", &n);
  for(i=0;i<n;i++){
    T[i].parent=NIL;
  }
 
  for(i=0;i<n;i++){
    scanf("%d%d%d", &v, &l, &r);
    T[v].left = l;
    T[v].right = r;     
    if(l != NIL) T[l].parent = v;
    if(r != NIL) T[r].parent = v;
  }
 
  for(i=0; i<n; i++)
    if(T[i].parent == NIL)root = i;
  
  printf("Preorder\n");
  PreOrder(root);
  printf("\n");
 
  printf("Inorder\n");
  InOrder(root);
  printf("\n");
 
  printf("Postorder\n");
  PostOrder(root);
  printf("\n");
   
  return 0;
}
 
void PreOrder(int u){
  if(u == NIL)return;
  printf(" %d",u);
  PreOrder(T[u].left);
  PreOrder(T[u].right);
} 
void InOrder(int u){
  if(u == NIL)return;
  InOrder(T[u].left);
  printf(" %d",u);
  InOrder(T[u].right);
}
void PostOrder(int u){
  if(u == NIL) return;   
  PostOrder(T[u].left);
  PostOrder(T[u].right);
  printf(" %d",u);
}



Measured memory_bytes: 2096
#define George_Plover
#include <queue>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
#define MAXN 200001
#define MAXM
#define INF
using namespace std;
int n,m;
LL K;
LL a[MAXN];
bool check(LL v)
{
    LL cnt=0;
    for(int i=m-1,j=n;i>0;i--)
    {
        while(j>=m&&a[i]*a[j]<=v)
            j--;
        cnt+=n-j;
    }
    
    for(int i=1,j=m-1;i<m;i++)
    {
        while(j&&a[i]*a[j]<=v)
            j--;
        cnt+=m-1-j;
    }
    
    for(int i=n,j=m;i>=m;i--)
    {
        while(j<=n&&a[i]*a[j]<=v)
            j++;
        cnt+=j-m;
    }
    
    for(int i=m,j=1;i<=n;i++)
    {
        while(j<m&&a[i]*a[j]<=v)
            j++;
        cnt+=j-1;
    }
    
    for(int i=1;i<=n;i++)
    {
        if(a[i]*a[i]<=v)
            cnt--;
    }
    cnt/=2;
    //cout<<v<<" "<<cnt<<endl;
    return cnt>=K;
}
int main()
{

    scanf("%d%lld",&n,&K);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
    }
    
    sort(a+1,a+n+1);
    
    for(int i=1;i<=n;i++)
    {
        if(a[i]>0)
        {
            m=i;
            break;
        }
    }
    if(m==0)
        m=n+1;
    
    LL L=-1000000000ll,R=1000000000ll;
    R=R*R;
    L=-R;
    
    while(L!=R)
    {
        //cout<<L<<" "<<R<<endl;
        LL mid=(L+R>=0?(L+R)/2:(L+R-1)/2);
        if(check(mid))
        {
            R=mid;
        }
        else
        {
            L=mid+1;
        }
        //cout<<mid<<" "<<check(mid)<<endl;
    }
    cout<<L<<endl;
    return 0;
}


Measured memory_bytes: 1792
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args){

		solve_abc157_b();
	}
  	public static void solve_abc157_b(){

		Scanner sc = new Scanner(System.in);
		
		int A[][] = new int[3][3];
		boolean c[][] = new boolean[3][3];
		
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				A[i][j] = sc.nextInt();
			}
		}
		
		
		int N = sc.nextInt();
		
		int b = 0;
		
		for(int i=0;i<N;i++){
			
			b = sc.nextInt();
			
			for(int x=0;x<3;x++){
				for(int y =0;y<3;y++){
					
					if(A[x][y] == b){
						c[x][y] = true;
					}
				}
			}
		}
		
		boolean ans = false;
		
		if(c[0][0] && c[0][1] && c[0][2]) ans = true; 
		if(c[1][0] && c[1][1] && c[1][2]) ans = true; 
		if(c[2][0] && c[2][1] && c[2][2]) ans = true; 
		if(c[0][0] && c[1][0] && c[2][0]) ans = true; 
		if(c[0][1] && c[1][1] && c[2][1]) ans = true; 
		if(c[0][2] && c[1][2] && c[2][2]) ans = true; 
		if(c[0][0] && c[1][1] && c[2][2]) ans = true; 
		if(c[2][0] && c[1][1] && c[0][2]) ans = true; 
		
		if(ans) System.out.println("Yes");
		else System.out.println("No");


		sc.close();

	}
}

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

long int match(string,int);
long int value_min(string,long int);

string item_list[100],recipe_to[100];
string recipe_from[100][100];
long int item_value[100];
//long int value_min;

int recipe_num,list_num;
int recipe_to_num[100];


int main(){
//	string recipe_from[100][100];
//	int recipe_num,list_num;//,value_min;
//	int recipe_to_num[100];
	string purpose,item;

	while(cin >> list_num && list_num != 0){
		//		cout << list_num << endl;
		//f[^ÌÇÝÝ
		for(int i=0;i<list_num;i++){
			cin >> item_list[i] >> item_value[i];
			//			cout << item_list[i] << item_value[i] << endl;
		}
		cin >> recipe_num;
		for(int i=0;i<recipe_num;i++){
			cin >> recipe_to[i];
			cin >> recipe_to_num[i];
			for(int j=0;j<recipe_to_num[i];j++){
				cin >> recipe_from[i][j];
			}
		}
		//
		//		for(int i=0;i<recipe_num;i++){
		////			cout << recipe_to[i] << ":";
		//			for(int j=0;j<recipe_to_num[j];j++){
		////				cout << recipe_from[i][j] << " ";
		//			}
		////			cout << endl;
		//		}
		cin >> purpose;
		//		cout << purpose << endl;
		//±±ÜÅf[^ÌÇÝÝ



		cout << value_min(purpose,match(purpose,list_num)) << endl;
	}

}

long int match(string item,int num){
	for(int i=0;i<num;i++){
		if(item == item_list[i]){
			return item_value[i];
		}
	}
}

long int value_min(string item,long int value){
	for(int i=0;i<recipe_num;i++){
		//value = 0;
			if(item == recipe_to[i]){
				long int sum = 0;
				for(int j=0;j<recipe_to_num[i];j++){
					sum += value_min(recipe_from[i][j],match(recipe_from[i][j],list_num));
//					sum += match(recipe_from[i][j],list_num)
				}
				value = (sum > value ? value :  sum);
			}
		}
	return value;
}

Measured memory_bytes: 0
import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner in=new Scanner(System.in);
        char s[]=in.next().toCharArray(),t[]=in.next().toCharArray();;
        int n=s.length,l=t.length,max=l,cnt=0;
        for(int i=0;i<n-l+1;i++){
            cnt=0;
            for(int j=0;j<l;j++){
                if(s[i+j]!=t[j])    cnt++;
            }
            max=Math.min(max,cnt);
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 35576
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<28)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, m, d[105][105];
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n >> m;
    vector<P> edge;
    vector<int> cost;
    rep(i, 0, n) rep(j, 0, n) {
        d[i][j] = INF;
        if (i == j) d[i][j] = 0;
    }
    rep(i, 0, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        d[a][b] = c;
        edge.pb(mp(a, b));
        cost.pb(c);
    }

    rep(i, 0, m) {
        int a = edge[i].first, b = edge[i].second;
        d[a][b] = min(d[a][b], cost[i]);
        d[b][a] = min(d[b][a], cost[i]);
    }
    rep(k, 0, n) {
        rep(i, 0, n) {
            rep(j, 0, n) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    int ans = 0;
    rep(i, 0, m) {
        bool flag = false;
        rep(j, 0, n) {
            if (d[j][edge[i].first] + cost[i] == d[j][edge[i].second]) flag = true;
        }
        if (flag) ans++;
    }
    cout << m - ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
//using Graph = vector<vector<Edge>>;
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;
const double PI = acos(-1.0);

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

const int MOD = 1000000007;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  double L;
  cin >> L;
  double ans = 0.0;
  ans = (L / 3.0) * (L / 3.0) * (L / 3.0);
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
a = [input() for i in range(0, h)]

while True:
    for i in range(0, h):
        if all([a[i][j]=='.' for j in range(0, w)]):
            del a[i]
            h -= 1
            break
    else:
        for j in range(0, w):
            if all([a[i][j]=='.' for i in range(0, h)]):
                for i in range(0, h):
                    a[i] = a[i][:j] + a[i][j+1:]
                w -= 1
                break
        else:
            for k in range(0, h):
                print(a[k])
            exit()

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <ctime>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
typedef double D;
typedef complex<D> P;
typedef pair<P,P> L;
int N;
vector<P> vc;
D eps=1e-9;
bool comp(const P& l,const P& r){
	if(l.real()!=r.real()) return l.real()<r.real();
	return l.imag()<r.imag();
}
inline D dot(P a, P b) { return real(conj(a)*b);};
inline D cro(P a, P b) { return imag(conj(a)*b);};
inline P perp(L l, P p){		//垂線の足
	D t=dot(p-l.fs,l.fs-l.sc)/norm(l.fs-l.sc);
	return l.fs+t*(l.fs-l.sc);
}
inline P refl(L l, P p){
	return p+2.0*(perp(l,p)-p);
}
int exist(P p){
	int x=ceil(p.real()-eps),y=ceil(p.imag()-eps);
	if(abs(p-P(x,y))>eps) return N;
	return lower_bound(all(vc),P(x,y),comp)-vc.begin();
}
int main(){
	srand((unsigned int)time(NULL));
	cin>>N;
	rep(i,N){
		int x,y;
		cin>>x>>y;
		vc.pb(P(x,y));
	}
	sort(all(vc),comp);
	bool safe=false;
	for(int i=2;i<N;i++){
		if(abs(cro(vc[1]-vc[i],vc[0]-vc[i]))>eps) safe=true;
	}
	if(!safe){
		cout<<"No\n";
		return 0;
	}
//	rep(i,N) show(vc[i]);
//	cout<<endl;
	rep(tt,20*N){
		bool can=true;
		int x=rand()%N,y=rand()%N;
		if(x==y) continue;
		P p=vc[x],q=vc[y],m=(p+q)/2.0;
		L l=L((p-m)*P(0,1)+m,(p-m)*P(0,-1)+m);
/*		if(x==0&&y==3){
			show(l.fs);
			show(l.sc);
		}*/
		int cnt=0;
		rep(i,N){
			P ref=refl(l,vc[i]);
			int id=exist(ref);
/*			if(x==0&&y==3){
				show(i);
				show(id);
			}*/
			if(id==N||abs(vc[id]-ref)>eps){
				can=false;
				break;
			}
			if(id==i) cnt++;
		}
		if(cnt>=3) can=false;
		if(can){
			cout<<"Yes\n";
			return 0;
		}
	}
	cout<<"No\n";
	return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <iomanip>
#include <math.h>
#include <map>
#include <list>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <iterator>
#include <string>
#include <sstream>
#include <bitset>
#include <string.h>
// #include <limits.h>

#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long        ll;
typedef unsigned long long    ull;

#define INTMAX  99999999

#define DEBUG 1

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;

#define MAX_N (200*1000)
int N;
int a[MAX_N+1];
// int minR[MAX_N][MAX_N];
int pos[MAX_N];
set<int> posSet;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);
	cin >> N;
	FORULE(n,1,N) {
		cin >> a[n];
		pos[a[n]] = n;
	}

	// 最小値として含む区間を足し算すればよい
	// ある数が最小値として採用されるrangeの数 * そのある数 の総和
	// ある数が最小値として採用されるrangeの数 = そのある数より小さい数の配置された左側の場所とその数との距離 * そのある数より小さい数の配置された右側場所とその数との距離
	// そのある数より小さい数の配置された左側の場所とその数との距離 = 小さい数からに配置場所indexを set に追加していく。その追加された場所より小さい数は先に set に追加されており、indexの 差分をみれば距離が求まる
	// そのある数より小さい数の配置された右側の場所とその数との距離 = 小さい数からに配置場所indexを set に追加していく。その追加された場所より小さい数は先に set に追加されており、indexの 差分をみれば距離が求まる
	ll sumMin = 0;
	FORULE(n,1,N) {
		pair<set<int>::iterator, bool> it_pair = posSet.insert(pos[n]);
		set<int>::iterator it = it_pair.first;
		set<int>::iterator it_prev = it; it_prev--;
		set<int>::iterator it_next = it; it_next++;
		// DOUT << "---- pos["<<n<<"]="<<pos[n]<<endl;
		int leftAlt = 0;
		if(it!=posSet.begin()) {
			// DOUT << "*it_prev="<<(*it_prev)<<", *it="<<(*it)<<endl;
			leftAlt = (*it)-(*(it_prev));
		}
		else {
			// DOUT << "*it_prev="<<"END"<<", *it="<<(*it)<<endl;
			leftAlt = (*it)-0;
		}
		int rightAlt = 0;
		if((it_next)!=posSet.end()) {
			// DOUT << "*it="<<(*it)<<", *it_next="<<(*it_next) <<endl;
			rightAlt = (*(it_next))-(*it);
		}
		else {
			// DOUT << "*it="<<(*it)<<", *it_next="<<"END"<<endl;
			rightAlt = N+1 - (*it);
		}
		// DOUT << "leftAlt="<<leftAlt<<", rightAlt="<<rightAlt<<endl;
		sumMin += 1LL * n * leftAlt * rightAlt;
	}
	
	cout << sumMin << endl;

	return 0;
}
 


Measured memory_bytes: 11136
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

signed main()
{
  ll K, A, B;
  cin >> K;
  cin >> A >> B;

  string ans = "NG";
  FOR(i, A, B)
  {
    if (i % K == 0)
    {
      ans = "OK";
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>

int a,b,c;
int main(){
  std::cin>>a>>b>>c;
  auto tmp1=a+10*b+c;
  auto tmp2=10*a+b+c;
  auto tmp3=a+b+10*c;
  std::cout<<std::max({tmp1,tmp2,tmp3})<<std::endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
      
      //０が何番目にいるのか探す
       for(int i=1;i<=5;i++) {
         
		 int X = sc.nextInt();
         
		 if(X==0) {
	     	System.out.println(i);
           
         }
       }
    }
}

Measured memory_bytes: 35700
#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;

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

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

    vector<vector<long long int>> dp(n+1, vector<long long int>(k+1));// dp[i][j] = dp'[i][0] + ... + dp'[i][j]
    dp[0][0] = 1;
    for(int j=0; j<k; j++){
        dp[0][j+1] += dp[0][j];
    }
    for(int i=0; i<n; i++){
        // dp'[i][j]
        for(int j=0; j<=k; j++){
            dp[i+1][j] = dp[i][j];
            if(j > a[i]){
                dp[i+1][j] -= dp[i][j-a[i]-1];
            }
            dp[i+1][j] %= MOD;
        }
        for(int j=0; j<k; j++){
            dp[i+1][j+1] += dp[i+1][j];
            dp[i+1][j+1] %= MOD;
            //cout << "dp[" << i+1 << "][" << j+1 << "] = " << dp[i+1][j+1] << endl;
        }
    }
    long long int ans = dp[n][k];
    if(k >= 1) ans -= dp[n][k-1];
    ans = (ans % MOD + MOD) % MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 80256
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
#define REP(i, a, b) for (int i = a; i < b; ++i)
#define rep(i, n) REP(i, 0, n)
int memo[11][1024][300];
int func(int k, int used_n, int n, int s, int goal)
{
	if (k == n) return s == goal;

	int& res = memo[k][used_n][s];
	if (res >= 0) return res;
	res = 0;
	rep(j, 10) if (!(used_n & (1<<j))) {
		res += func(k+1, used_n+(1<<j), n, s+(k+1)*j, goal);
	}
	return res;
}
int main()
{
	int n, s;
	while (cin >> n >> s) {
		memset(memo, -1, sizeof(memo));
		int res = n > 10 ? 0 : func(0, 0, n, 0, s);
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 0
use std::cmp::min;

const MOD: i64 = 1000000007;


fn main() {
    let (n, k) = read_tuple();

    let c = Comb::new(2 * n + 1, MOD);

    let mut ans = 0;
    for m in 0..(min(n, k + 1)) {
        ans += (c.nck(n, m) * c.nck(n - 1, m)) % MOD;
        ans %= MOD;
    }
    
    println!("{:?}", ans);
}


/// for nCk
pub struct Comb {
    max: usize,
    m: i64,
    fac: Vec<i64>,
    finv: Vec<i64>,
}

impl Comb {
    /// initialize table 
    /// max: maximum that n as nCk takes
    /// m: MOD, a prime number
    /// O(n)
    pub fn new(max: usize, m: i64) -> Comb {
        let n = max;
        let mut fac = Vec::with_capacity(n);
        fac.push(1);
        fac.push(1);
        let mut finv = Vec::with_capacity(n);
        finv.push(1);
        finv.push(1);
        let mut inv = Vec::with_capacity(n);
        inv.push(1);
        inv.push(1);

        for i in 2..n {
            let i = i as i64;
            let tmp = fac.last().unwrap() * i % m;
            fac.push(tmp);
            let tmp = m - inv[(m % i) as usize] * (m / i) % m;
            inv.push(tmp);
            let tmp = finv.last().unwrap() * inv.last().unwrap() % m;
            finv.push(tmp);
        }

        Comb {
            max: max,
            m: m,
            fac: fac,
            finv: finv
        }
    }

    /// nCk
    pub fn nck(&self, n: usize, k: usize) -> i64 {
        // since n, k are usize, do not need to check `n < 0 || k < 0`
        if n < k || n > self.max {
            panic!("Invalid query (n, k) = ({}, {})", n, k);
        } else {
            self.fac[n] * (self.finv[k] * self.finv[n - k] % self.m) % self.m
        }
    }
}


fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_tuple<T: std::str::FromStr + Copy>() -> (T, T) {
    let temp = read_vec();
    (temp[0], temp[1])
}



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

using namespace std;

int main() {
    string s;   cin >> s;
    long long ans = 0;
    int ls = s.length();
    for (int bit = 0; bit < (1<<(ls-1)); bit++) {
        vector<int> v;
        for (int i = 0; i < s.length(); i++) {
            if (bit & (1<<i)) {
                v.push_back(i);
            }
        }
        int lv = v.size();
        int cnt = 0;    //後ろから何個まで使ったか
        for (int i = 0; i < lv; i++) {
            long long tmp = 0;
            while (cnt <= v[i]) {
                tmp = 10 * tmp + (s[cnt] - '0');
                cnt++;
            }
            ans += tmp;
        }
        long long t = 0;
        while (cnt < ls) {
            t = t * 10 + (s[cnt]-'0');
            cnt++;
        }
        ans += t;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/*
Sometimes I feel like I don't have a partner
Sometimes I feel like my only friend
It's the city I live in, the City of Angels
Lonely as I am, together we cry

I drive on her streets 'cause she's my companion
I walk through her hills cause she knows who I am
She sees my good deeds and she kisses me windy
I never worry, now that is a lie

I dont ever wanna feel like I did that day
Take me to the place I love, take me all the way
I dont ever wanna feel like I did that day
Take me to the place I love, take me all the way
Yeah, yeah, yeah

It's hard to believe that there's nobody out there
It's hard believe that I'm all alone
At least I have her love the city, she loves me
Lonely as I am, together we cry

And I dont ever wanna feel like I did that day
Take me to the place I love, take me all the way
And I dont ever wanna feel like I did that day
Take me to the place I love, take me all the way
Yeah, yeah, yeah, oh, no, no, no
Yeah, yeah, love me I say yeah, yeah

Under the bridge downtown is where I drew some blood
Under the bridge downtown I could not get enough
Under the bridge downtown forgot about my love
Under the bridge downtown I gave my life away
Yeah, yeah, yeah

Yeah, yeah, yeah, oh, no, no, no
Yeah, yeah, oh, no, no
I said yea yeah, Ill stay
*/

//#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS

#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd

#define eps 1e-9
#define M_PI 3.141592653589793
#define bs 1000000007
#define bsize 350

using namespace std;

const int INF = 1e9;
const int N = 500031;

int n, ar[N];
int ans;

int main(){
	//freopen("fabro.in","r",stdin);
	//freopen("fabro.out","w",stdout);
	//freopen("F:/in.txt", "r", stdin);
	//freopen("F:/output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);
	
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> ar[i];
	}
	for (int i = 1; i <= n; i++)
	{
		if (ar[ar[i]] == i&&ar[i] > i)
			++ans;
	}
	cout << ans << endl;

	cin.get(); cin.get();
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;

const int INF = 200000000;
const int MOD = 1e9 + 7;

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

    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    vector<int> num;
    REP(i, N) { num.push_back(S[i] - '0'); }

    vector<int> r;
    int state = num[0];
    r.push_back(0);
    FOR(i, 1, N) {
        if (state != num[i]) {
            r.push_back(i);
            state = num[i];
        }
    }

    vector<int> x;
    REP(i, r.size()) {
        if (num[r[i]]) {
            if (i + 2 * K + 1 < r.size()) {
                x.push_back(r[i + 2 * K + 1] - r[i]);
            } else {
                x.push_back(N - r[i]);
            }

        } else {
            if (i + 2 * K < r.size()) {
                x.push_back(r[i + 2 * K] - r[i]);
            } else {
                x.push_back(N - r[i]);
            }
        }
    }

    cout << *max_element(ALL(x)) << endl;

    return 0;
}


Measured memory_bytes: 1864
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,y,d,i,j,k;
    cin>>x>>y;
    d=y/x;
    if(y%2!=0)
        cout<<"No"<<endl;
    else
    {
        if(y>=(2*x)&&y<=(4*x))
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
}


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

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		for (int i = 1; i <= 50000; i++) {
			int x = (int) (i * 1.08);

			if (x == n) {
				System.out.println(i);
				return;
			}
		}
		System.out.println(":(");
	}
}


Measured memory_bytes: 21076
N,K=map(int,input().split())
A=list(map(int,input().split()))

count=0
k=1
countlist={}
#countlist[1]=A[0]
count=1
while True:    
    k=A[k-1]
    
    if k in countlist:
        cycle=count-countlist[k]
        rest=K-count
        move=rest%cycle
        for i in range(min(rest,move)):
            k=A[k-1]
        print(k)
        break
    
    countlist[k]=count
    
    if count==K:
        print(k)
        break
    
    count+=1

Measured memory_bytes: 32384
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
		   vst c(2);
           rep(i,0,2)cin>>c[i];
           bool ans=true;
           if(c[0][0]!=c[1][2])ans=false;
           if(c[0][1]!=c[1][1])ans=0;
           if(c[0][2]!=c[1][0])ans=0;
           YES(ans);
}

Measured memory_bytes: 3576
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int N;
   cin >> N;
   int a[N];
   int MIN = N, MAX = 0;
   for (int i = 0; i < N; i++) {
      cin >> a[i];
      chmin(MIN, a[i]);
      chmax(MAX, a[i]);
   }
   if (MAX - MIN >= 2) {
      cout << "No" << endl;
      return 0;
   } else if (MAX == MIN) {
      if (!(MAX == N - 1 || 2 * MAX <= N)) {
         cout << "No" << endl;
         return 0;
      }
   } else {
      int x = 0, y = 0;
      int A = MAX;
      for (int i = 0; i < N; i++) {
         if (a[i] == A) y++;
         else x++;
      }
      if (!(x < A && 2 * (A - x) <= y)) {
         cout << "No" << endl;
         return 0;
      }
   }
   cout << "Yes" << endl;
   return 0;
}


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

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

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

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

int main(){
    ll H,W,M;
    cin>>H>>W>>M;
    vector<pllll> Hidx(0);
    vector<pllll> Widx(0);
    ll MAX=300010;
    for(ll i=0;i<MAX;i++){
        Hidx.push_back(make_pair(0,i));
        Widx.push_back(make_pair(0,i));
    }
    vll target(0);
    for(ll i=0;i<M;i++){
        ll h,w;
        cin>>h>>w;
        h--;w--;
        Hidx[h].first++;
        Widx[w].first++;
        target.push_back(h*1000000+w);
    }
    sort(ALL(Hidx));
    reverse(ALL(Hidx));
    sort(ALL(Widx));
    reverse(ALL(Widx));
    sort(ALL(target));
    ll Hmax=Hidx[0].first;
    ll Wmax=Widx[0].first;
    ll Hmaxcount=0,Wmaxcount=0;
    for(ll i=0;i<MAX;i++){
        if(Hidx[i].first==Hmax){
            Hmaxcount++;
        }else{
            break;
        }
    }
    for(ll i=0;i<MAX;i++){
        if(Widx[i].first==Wmax){
            Wmaxcount++;
        }else{
            break;
        }
    }
    if(Hmaxcount*Wmaxcount>300002){
        cout<<Hmax+Wmax<<endl;
    }else{
        bool ok=false;
        for(ll i=0;i<Hmaxcount;i++){
            for(ll j=0;j<Wmaxcount;j++){
                ll key=Hidx[i].second*1000000+Widx[j].second;
                if(upper_bound(ALL(target),key)-lower_bound(ALL(target),key)==0){
                    ok=true;
                }
            }
            if(ok)break;
        }
        if(ok){
            cout<<Hmax+Wmax<<endl;
        }else{
            cout<<Hmax+Wmax-1<<endl;
        }
    }
}


Measured memory_bytes: 19196
/*

*/
#include<iostream>
#include<iomanip>
#include<ios>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)
#define MAX_N 100000

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;
const ll MOD = ll(1e9+7);

int parent[MAX_N+1], depth[MAX_N+1];

int root(int a){
  if(parent[a]==a)return a;
  return parent[a]=root(parent[a]);
}

bool same(int a, int b){
  return root(a)==root(b);
}

void unite(int a, int b){
  a = root(a);
  b = root(b);
  if(depth[a]>=depth[b]){
    parent[b] = a;
    if(depth[a]==depth[b])depth[a]++;
  }else{
    parent[a] = b;
  }
}

int main(){
  int n, m;cin>>n>>m;
  vector<int> p(n);
  rep(i, n){
    parent[i] = i;
    depth[i] = 0;
  }
  rep(i, n){
    cin>>p[i];
    p[i]--;
  }
  rep(i, m){
    int x, y;cin>>x>>y;
    unite(--x, --y);
  }
  int ans = 0;
  rep(i, n){
    if(same(p[i], i))ans++;
  }
  cout<<ans<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long s64;
const int ONE = 1000005;
const s64 INF = 1e18;
#define next nxt

int get() {
	int res = 1, Q = 1;
	char c;
	while( (c = getchar()) < 48 || c > 57) if(c == '-') Q = -1;
	if(Q) res = c - 48;
	while( (c = getchar()) >= 48 && c <= 57) res = res * 10 + c - 48;
	return res * Q;
}
struct power {
	s64 a, b;
	bool operator <(power A) const {
		if(A.a != a) return a < A.a;
		return b < A.b;
	}
};
vector <power> A[ONE], R;
int n;
int x, y;
s64 l, r, K;
int next[ONE], first[ONE], go[ONE], w[ONE], tot;
int size[ONE], fat[ONE];
void Add(int u, int v, int z) {
	next[++tot] = first[u], first[u] = tot, go[tot] = v, w[tot] = z;
	next[++tot] = first[v], first[v] = tot, go[tot] = u, w[tot] = z;
}
int dist[ONE];
int len_x, len_y;
s64 a1, b1, a2, b2;
int Find() {
	if(len_y == 0) return len_y;
	int l = 0, r = len_y - 1;
	while(l < r - 1) {
		int mid = l + r >> 1;
		a2 = A[y][mid].a, b2 = A[y][mid].b;
		if(b1 + a2 + dist[x] + dist[y] <= K) l = mid;
		else r = mid;
	}
	a2 = A[y][r].a, b2 = A[y][r].b;
	if(b1 + a2 + dist[x] + dist[y] <= K) return r;
	a2 = A[y][l].a, b2 = A[y][l].b;
	if(b1 + a2 + dist[x] + dist[y] <= K) return l;
	return len_y;
}
void Update(int u) {
	x = 0, y = 0;
	for(int e = first[u]; e; e = next[e]) if(go[e] != fat[u]) if(!x) x = go[e];
			else y = go[e];
	if(size[x] > size[y]) swap(x, y);
	len_x = A[x].size(), len_y = A[y].size();
	R.clear();
	for(int i = 0; i < len_x; i++) {
		a1 = A[x][i].a, b1 = A[x][i].b;
		if(Find() >= len_y) continue;
		R.push_back((power) {
			a1 + dist[x], b2 + dist[y]
		});
		R.push_back((power) {
			b2 + dist[y], a1 + dist[x]
		});
	}
	sort(R.begin(), R.end());
	int len = R.size();
//	for(int i=0;i<len;i++)cout<<"R[i].a="<<R[i].a<<" "<<"R[i].b="<<R[i].b<<endl;
//	cout<<"break"<<endl;
	s64 maxx = INF;
	for(int i = 0; i < len; i++) if(R[i].b < maxx) A[u].push_back(R[i]), maxx = R[i].b;
}
void Dfs(int u, int father) {
	size[u] = 1;
	int pd = 0;
	for(int e = first[u]; e; e = next[e]) {
		int v = go[e];
		if(v == father) continue;
		fat[v] = u, dist[v] = w[e];
		Dfs(v, u);
		size[u] += size[v], pd++;
		if(pd == 2) Update(u);
	}
	if(!pd) A[u].push_back((power) {
		0, 0
	});
}
int Check() {
	for(int i = 1; i <= n; i++) A[i].clear();
	Dfs(1, 0);
	return A[1].size() > 0;
}
int main() {
	n = get();
	for(int i = 2; i <= n; i++) {
		x = get(), y = get();
		Add(i, x, y), r += y;
	}
	while(l < r - 1) {
		K = l + r >> 1;
		if(Check()) r = K;
		else l = K;
	}
	K = l;
	if(Check()) printf("%lld", l);
	else printf("%lld", r);
}

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

int n,c;
int mp[525][525];
int d[35][35];
int sum[3][35];

int main(){
  scanf("%d%d", &n,&c);
  REP(i,c)REP(j,c)scanf("%d",&d[i][j]);
  REP(i,n)REP(j,n)scanf("%d",&mp[i][j]);
  REP(i,n)REP(j,n)mp[i][j]--;
  REP(col,c)REP(i,n)REP(j,n)sum[(i+j)%3][col] += d[mp[i][j]][col];
  int ans = 1<<30;
  REP(x,c)REP(y,c)REP(z,c)if(x!=y && y!=z && z!=x){
    ans = min(ans, sum[0][x] + sum[1][y] + sum[2][z]);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl '\n'
#define pb push_back
#define PI 3.14159265
int M = 998244353;
vector<int> v;
void primeFactors(int n)
{
  while (n % 2 == 0)
  {
    v.pb(2);
    n = n / 2;
  }
  for (int i = 3; i <= sqrt(n); i = i + 2)
  {
    while (n % i == 0)
    {
      v.pb(i);
      n = n / i;
    }
  }
  if (n > 2)
    v.pb(n);
}
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  primeFactors(n);
  vector<int> sum(1000001);
  sum[0] = 0;
  for (int i = 1; i < 1000001; ++i)
  {
    sum[i] = sum[i - 1] + i;
  }
  int out = 0;
  for (int i = 0; i < v.size(); ++i)
  {
    if (n == 1)
      break;
    int x = v[i];
    int f = 0;
    while (n % x == 0)
    {
      n = n / x;
      f++;
    }
    auto j = lower_bound(sum.begin(), sum.end(), f) - sum.begin();
    if (sum[j] != f)
      j--;
    // cout << f << " " << n << endl;
    out += j;
  }
  cout << out;
}

Measured memory_bytes: 11148
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int n;
ll num[100010];
int main()
{
    cin>>n;
    ll res=1;
    for(int i=1;i<=n;i++) cin>>num[i];
    sort(num+1,num+1+n);
    for(int i=1;i<=n;i++)
    {
        ll a=num[i];
        if(a==0)
        {
            res=0;
            break;
        }
        else if(res>(ll)(((ll)1e18)/a)) 
            {
                res=-1;
                break;
            }
        else res=res*a;
    }
    
    cout<<res<<endl;
   return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}


signed main() {
  int n;
  map<int, int> mp;
  cin >> n;
  int ans = 0;
  rep(i, 0, n) {
    int a;
    cin >> a;
    mp[a]++;
    if(mp[a] == 1) ans++;
  }
  int am = 0;
  for(auto it = mp.begin(); it != mp.end(); it++) {
    if(it->second % 2 == 0) am++;
  }
  if(am % 2) ans--;
  cout << ans << endl;
}


Measured memory_bytes: 6528
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>

using namespace std;
typedef long long ll;

int main()
{
	int N, C;
	ll K;
	cin >> N >> C >> K;
	vector<ll> T(N);
	for (int i = 0; i < N; i++) {
		cin >> T[i];
	}
	sort(T.begin(), T.end());
	int ans = 0;
	for (int i = 0; i < N; ans++) {
		auto last = min(N, i + C);
		auto k = T[i] + K + 1;
		i = lower_bound(T.begin() + i, T.begin() + last, k) - T.begin();
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
	int N, COUNT = 0;;
	cin >> N;
	for (int i = 1; i <= N; i++) {
		int X = log10(i);
		if (X % 2 == 0) COUNT++;
	}
	cout << COUNT << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,T,A;cin>>N>>T>>A;
    double aa = 10000;
    int re = 0;
    for(int i=0;i<N;i++){
        int H;cin>>H;
        double num = abs(A-T+H*0.006);
        if(num < aa){
            re = i+1;
            aa = num;
        }
    }
    cout<<re<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define gcd __gcd
#define F first
#define B begin()
#define E end()
#define ln length()
#define sz size()
#define S second
#define em empty()
#define mp make_pair
#define pb push_back
#define pq priority_queue
#define um unordered_map
#define us unordered_set
#define lb lower_bound
#define ub upper_bound
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
#define sbits(a) __builtin_popcount(a)
#define lcm(a, b) ((a * b) / gcd(a, b))
#define nani(x) cerr << #x << " is " << x << endl;
#define adde(g, u, v) g[u].pb(v), g[v].pb(u);
#define addew(g, u, v, w) g[u].pb({ v, w }), g[v].pb({ u, w });
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define inf 10000000000
#define mod 1000000007

typedef long long ll;

const int N = 1e5 + 5;

int A[N];

int main()
{
    fast;

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll a, b;
    cin >> a >> b;

    cout << lcm(a, b);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

const int N = 200005;
int k, n, ans[N], a[N];

int main() {
	cin >> k >> n;
	for (register int i =1; i <=n; ++i)
		scanf("%d", &a[i]);
	ans[0] = a[n] - a[1];
	for (int i = n, j = 1; i > 1; --i, ++j)
		ans[j] = k - a[i] + a[i - 1];
	sort(ans, ans + n-1);
	printf("%d", ans[0]);
	return 0;
}

Measured memory_bytes: 1792
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
A = [0]+l()+[0]
d = []
for i in range(N+1):
    d.append(abs(A[i+1]-A[i]))
ans = sum(d)
for i in range(N):
    print(ans+abs(A[i]-A[i+2])-d[i]-d[i+1])

Measured memory_bytes: 21148
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using ll = long long;
using ld = long double;
void resolver();
inline void fast_io()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}
template <class T>
inline std::vector<T> read_vector()
{
    ll n;
    std::cin >> n;
    std::vector<T> ret(n);
    for (T &i : ret) {
        std::cin >> i;
    }
    return ret;
}
void t_case()
{
    ll t;
    std::cin >> t;
    while (t--) {
        resolver();
    }
}
void single_case()
{
    resolver();
}

int main(int argc, char *argv[])
{
    fast_io();
    // t_case();
    single_case();
}

void resolver()
{
    using namespace std;

    ll n;
    string s;
    vector<int> r;
    vector<int> g;
    vector<int> b;
    cin >> n >> s;
    ll num = 0;
    for (ll i = 0; i < n; i++) {
        if (s[i] == 'R')
            r.push_back(i + 1);
        if (s[i] == 'G')
            g.push_back(i + 1);
        if (s[i] == 'B')
            b.push_back(i + 1);
    }
    for (auto i : r)
        for (auto j : g)
            for (auto k : b) {
                if (2 * j == i + k)
                    continue;
                if (2 * k == i + j)
                    continue;
                if (2 * i == j + k)
                    continue;
                num++;
            }
    cout << num;
}


Measured memory_bytes: 3204
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <set>
#include <utility>
using namespace std;

int main() {
  string s; cin >> s;
  cout << s[0] << (s.length()-2) << s[s.length()-1] << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<set>
#include<map>
#include<time.h>
#include<cstring>
#include<iomanip>
#include<numeric>
#define ll long long
#define h 0.000000001
#define pf push_front
#define pb push_back
#define ub upper_bound
#define lb lower_bound
using namespace std;
int main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
 ll int n, cnt=0,i, j, k;
 cin>>n;
 vector<ll int>a(n);
 for(i=0;i<n;i++) 
 cin>>a[i];
 sort(a.begin(),a.end());
 for(i=0;i<n;i++) 
 {
 	for(j=i+1;j<n;j++) 
 	{
 		if(a[i]!=a[j]) 
 		{
 			for(k=j+1;k<n;k++) 
 			{
 				if(a[k]!=a[j] && (a[i]+a[j])>a[k]) cnt+=1;
 			} 
 		} 
 	} 
 } 
 cout<<cnt<<endl;
  return 0;
} 


Measured memory_bytes: 3664
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
using namespace std;

const int MOD = int(1e9)+7;

int main(void)
{
	int n;
	scanf("%d", &n);
	int a;
	multiset<int> res;
	for(int i = 0;i < n;i++) res.insert(abs(n-i-1-i));
	for(int i = 0;i < n;i++)
	{
		scanf("%d", &a);
		if(res.find(a) == res.end())
		{
			printf("0\n");
			return 0;
		}
		else res.erase(res.find(a));
	}
	if(res.empty())
	{
		int ans = 1;
		for(int i = 0;i < n/2;i++)
		{
			ans <<= 1;
			ans %= MOD;
		}
		printf("%d\n", ans);
	}
	else printf("0\n");
}

Measured memory_bytes: 4992
from sys import stdin
#入力
readline=stdin.readline
N,K=map(int,readline().split())
A=list(map(int,readline().split()))
A.sort()

mod=10**9+7
fact=[1]*(N+1)
finv=[1]*(N+1)
inv=[1]*(N+1)
inv[0]=0
for i in range(2,N+1):
    fact[i]=(fact[i-1]*i%mod)
    inv[i]=(-inv[mod%i]*(mod//i))%mod
    finv[i]=(finv[i-1]*inv[i])%mod

def com(N,K,mod):
    if (K<0) or (N<K):
        return 0
    return fact[N]*finv[K]*finv[N-K]%mod

s=0
for i in range(N-1,K-2,-1):
    s+=A[i]*com(i,K-1,mod)
for i in range(N-K+1):
    s-=A[i]*com(N-i-1,K-1,mod)
s%=mod
print(s)

Measured memory_bytes: 18868
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=1e7+1;
ll fac[N];
int main()
{
	
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   for(int i=1;i<N;i++)
   {
   	 for(ll j=i;j<N;j+=i)
   	 fac[j]++;
   	 
   }
   int n;
   cin>>n;
   ll ans=0;
   for(ll i=1;i<=n;i++)
   ans+=(i*fac[i]);
   cout<<ans<<endl;
}

Measured memory_bytes: 81696