akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>

#define UP_LIMIT 1
#define DOWN_LIMIT 2

using namespace std;

int solve(int limit, const vector<int> &book){
  int ret;
  int pre_w = -1;
  int l = 0;
  int r = 4000000;

  ret = r;
  while(true){
    int st = -1;
    int w = (r+l)/2;
    int maxsw = 0;
    int sw = 0;
    int stair = 0;

    if( w == pre_w )break;

    for(int i = 0; i < book.size(); ++i){
      maxsw = max( maxsw, sw );
      if( sw + book[i] <= w ){
	sw += book[i];
      }else if( stair < limit ){
	sw = book[i];
	stair++;
      }else{
	st = UP_LIMIT;
      }
    }
    maxsw = max( maxsw, sw );

    //cout << "R,L : " << r << ' ' << l << "STAIR : " << stair << " MAXSW : " << maxsw << endl;

    if( st == UP_LIMIT || stair >= limit ){
      l = w;
    }else if( st == -1 ){
      ret = min( ret, maxsw );
      r = w;
    }
    
    pre_w = w;
  }
  return ret;
}

int main(){
  while(true){
    int m,n;
    vector<int> books;

    cin >> m >> n;
    if(m==0&&n==0)break;
    for(int i = 0; i < n; ++i){
      int t;
      cin >> t;
      books.push_back(t);
    }

    cout << solve( m, books ) << endl;

  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#define Pair pair<int,int>
using namespace std;

const int inf = 1e6;


int N,M;
vector<Pair> ba;


void solve(){
	int ans=0;
	int cur=0;
	sort(ba.begin(),ba.end());
	for(int i=0;i<M;i++){
		if(cur <= ba[i].second){
			cur = ba[i].first;
			ans++;
		}
	}

	cout << ans << endl;

}

int main(){
	cin >> N >> M;
	int a,b;
	ba.resize(M);

	for(int i=0;i<M;i++){
		cin >> a >> b;
		ba[i] = {b,a};
	}
	solve();
	return 0;
}

Measured memory_bytes: 1152
//
//  main.cpp
//  AtCoder
//
//  Copyright © 2018年 ユーマ. All rights reserved.
//

#include <iostream>
#include <string>

int main(int argc, const char * argv[]) {
    
    std::string num;
    int count = 0;
    
    std::cin >> num;
    
    for(int i = 0; i < 3; i++){
        if(num[i] == '1'){
            count++;
        }
    }
    
    std::cout << count << std::endl;
    
    return 0;
}


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

using namespace std;

#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, A[101010], B[101010];

int main()
{
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) scanf("%d", A + i);
	for (int i = 0; i < N; ++i) scanf("%d", B + i);

	vector<pair<int, int> > eve;
	for (int i = 0; i < N; ++i) {
		eve.push_back({ A[i], 0 });
	}
	for (int i = 0; i < N; ++i) {
		eve.push_back({ B[i], 1 });
	}
	sort(eve.begin(), eve.end());

	i64 ret = 1;
	int ch = 0;

	for (auto e : eve) {
		int ki = e.second;
		if (ki == 1) {
			if (ch < 0) ret = ret * (-ch) % MOD;
			++ch;
		} else {
			if (ch > 0) ret = ret * ch % MOD;
			--ch;
		}

	}

	printf("%lld\n", ret);
	return 0;
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define ll long long
struct node
{
	int w,s,v;
}a[1010];
int n,b[1010];
ll f[1010][20010];
bool cmp(node x,node y)
{
	return x.s<y.s;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d%d%d",&a[i].w,&a[i].s,&a[i].v);
		a[i].s+=a[i].w;
	}
	sort(a+1,a+n+1,cmp);
	ll ans=0;
	for (int i=1;i<=n;i++)
	{
		for (int j=0;j<=a[i].s;j++)
		{
			f[i][j]=f[i-1][j];
			if (j>=a[i].w)
			{
				f[i][j]=max(f[i][j],f[i-1][j-a[i].w]+a[i].v);
			}
			ans=max(ans,f[i][j]);
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

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

	int N;
	cin >> N;
	queue<ll> Q;
	vector<ll> Lun;
	ll tmp = 1;
	int arr[] = {-1, 0, 1};
	int* it = begin(arr);
	while(Lun.size() < N){
		if(Lun.size() < 9){
			Lun.push_back(tmp);
			Q.push(tmp);
          	tmp++;
		}else{
			tmp = Q.front();
			if(tmp%10 == 9){
				Lun.push_back(tmp*10+tmp%10-1);
				Lun.push_back(tmp*10+tmp%10);
				Q.push(tmp*10+tmp%10-1);
				Q.push(tmp*10+tmp%10);	
			}else if(tmp%10 == 0){
				Lun.push_back(tmp*10+tmp%10);
				Lun.push_back(tmp*10+tmp%10+1);
				Q.push(tmp*10+tmp%10);
				Q.push(tmp*10+tmp%10+1);
			}else{
				for (auto it = begin(arr); it != end(arr); ++it)
				{
					Lun.push_back(tmp*10+tmp%10+(*it));
					Q.push(tmp*10+tmp%10+(*it));
				}
			}
			Q.pop();
		}
		
	}
	cout << Lun[N-1] << endl;
}

Measured memory_bytes: 1656
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

int main()
{
    priority_queue<pair<int, int>> A;
    int N, M;
    cin >> N >> M;

    for(int i = 0; i < N; i++) {
        int a;
        cin >> a;
        A.push(make_pair(a, 1));
    }

    for(int i = 1; i <= M; i++) {
        int B, C;
        cin >> B >> C;
        A.push(make_pair(C, B));
    }

    long long ans = 0;
    int cnt = N;
    while(cnt > 0) {
        auto v = A.top();
        IFD cout << v.first << ": " << v.second << endl;
        A.pop();
        while(cnt > 0 && v.second > 0) {
            ans += v.first;
            v.second--;
            cnt--;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <vector>

int main(){
    int n, max = 0;
    std::cin >> n;
    std::vector<int> h(n), num(n);
    for(int i = 0; i < n; i++){
        std::cin >> h.at(i);
    }

    num.at(n - 1) = 0;
    for(int i = 0; i < n - 1; i++){
        if(h.at(n - i - 1) <= h.at(n - i - 2)) num.at(n - i - 2) = num.at(n - i - 1) + 1;
        else num.at(n - i - 2) = 0;
        max = std::max(max, num.at(n - i - 2));
    }
    std::cout << max << std::endl;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define FOR(i, b, n) for (ll i = b; i < n; ++i)

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

struct HashPair {
  size_t operator() (const P& p) const {
    auto hash1 = hash<int>{}(p.first);
    auto hash2 = hash<int>{}(p.second);
    size_t seed = 0;
    seed ^= hash1 + 0x9e3779b9 + (seed << 6) + (seed >> 2);
    seed ^= hash2 + 0x9e3779b9 + (seed << 6) + (seed >> 2);
    return seed;
  }
};

struct Point {
  P pos;
  int h;
  Point(P pos, P goal, int d) : pos(pos) {
    h = d + abs(goal.first - pos.first) + abs(goal.second - pos.second);
  }
  bool operator<(const Point& r) const {
    return h > r.h;
  }
};

void solve(vector<string> s) {
  int H = s.size();
  int W = s[0].length();

  unordered_map<P, bool, HashPair> closed;
  int num_white(0);
  REP(h, H)
    REP(w, W)
    if (s[h][w] == '#')
      closed[P(h + 1, w + 1)] = true;
    else
      num_white++;
  REP(h, H + 1) {
    closed[P(h, 0)] = true;
    closed[P(h, W + 1)] = true;
  }
  REP(w, W + 1) {
    closed[P(0, w)] = true;
    closed[P(H + 1, w)] = true;
  }
  unordered_map<P, P, HashPair> before;
  unordered_map<P, int, HashPair> distance;
  distance[P(1, 1)] = 1;

  priority_queue<Point> q;
  P goal(H, W);
  q.emplace(Point(P(1, 1), goal, 0));

  const vector<P> neighbors { {0, 1}, {1, 0}, {-1, 0}, {0, -1} };

  while (!q.empty()) {
    Point pnow = q.top();
    P now = pnow.pos;
    q.pop();

    if (now == goal) {
      cout << num_white - distance[now] << endl;
      return;
    }

    for (P n : neighbors) {
      P neighbor(now.first + n.first, now.second + n.second);
      if (closed[neighbor])
	continue;
      closed[neighbor] = true;
      distance[neighbor] = distance[now] + 1;
      q.emplace(Point(neighbor, goal, distance[neighbor]));
      before[neighbor] = now;
    }
  }
  cout << -1 << endl;
}

int main(){
  // int 3E4  long 2E9  ll 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  int H, W;
  cin >> H >> W;

  vector<string> s(H);
  REP(i, H)
    cin >> s[i];

  solve(move(s));

  return 0;
}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
 
int main(){
    int N;
    cin >> N;
    if(N%10==2 || N%10==4 || N%10==5 || N%10==7 || N%10==9){
        cout << "hon" << endl;
    }
    else if(N%10==0 || N%10==1 || N%10== 6 || N%10==8){
        cout << "pon" << endl;
    }
    else{
        cout << "bon" << endl;
    }
 
}

Measured memory_bytes: 3640
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	int n;
	cin >> n;
	vector<int> a(n);
	REP(i, n) cin >> a[i];
	sort(a.begin(), a.end());
	int al= 0, bo = 0;
	REP(i, n){
		if(i % 2 == 0) al += a[n-1-i];
		else bo += a[n-1-i];
	}
	cout << al - bo << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
#define DIV 1000000007
//#define TEST
vector<ll> v;

void dfs(int k, ll x)
{
    // 初期値 x: 1 ~ 9
    v.push_back(x);
    if(k>=9) return;
    // 1の位
	int a=x%10;
    // 桁下がりしない数 0でない
    // x:10倍した数: 10, 20, 30,..., 90 + 前後の数
    if(a){
		dfs(k+1, x*10+a-1);
	}
	dfs(k+1, x*10+a);
    // 桁上がりしない数 9でない
	if(a<9){
		dfs(k+1, x*10+a+1);
	}
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long idx=0;
    ll K;
    cin >> K;
    for(int i=1; i<=9; i++) dfs(0, i);
    // std::unique
    // 隣り合った重複要素を除いた要素を、範囲の先頭に集める
    // この関数によってコンテナから直接要素が削除され、コンテナの要素数が減るようなことはない
    // 戻り値：重複を除いた範囲の、末尾の次を指すイテレータ
	v.erase(unique(v.begin(), v.end()), v.end());
	//手に入れた　v には順序の不整合や重複があるので除く
	sort(v.begin(), v.end());
    cout<<v[K-1]<<endl;

#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <vector>
#include <set>
#include <cassert>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <iomanip>
//#include <windows.h>  //Should be deleted when using AtCoder&POJ
using namespace std;

#define ll long long
#define pq_small priority_queue<int,vector<int>,greater<int> >
#define pii pair<int,int>
/**==Info==
*Program:2
*Problem:Many Formulas
*Date:2017-10-29
*Algorithm:My Slow Bitmask
*Stats:Unknown*/

bool debug=false;

int main(int argc,char* argv[]){
	string s;
	cin>>s;
	ll ans=0;
	for(int i=0;i<(1<<(s.size()-1));i++){
		ll sum=0,num=0;
		for(int j=0;j<s.size();j++){
			num=10*num+s[j]-'0';
			if((i>>j)&1){
				sum+=num;
				num=0;
			}
		}
		sum+=num;
		ans+=sum;
		if(debug) cout<<"When i="<<i<<" Sum="<<sum<<endl;
	}
	
	cout<<ans<<endl;
	return 0;
}


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

int main() {
  int N,M;
  cin >> N;
  vector<string> vec(N);
  vector<string> vek(M);
           for(int i = 0; i < N; i++){
           string x;
          cin >> x;
          vec.at(i) = x;
        }
    cin >> M;
    for(int b = 0; b < M ; b++){
     string x;
     cin >> x;
      vek.at(b) = x;
    }
  int ans = 0;
  for( int i = 0; i < N; i++){
    int sum = 0;
  for(int l = 0; l< N; l++){
   if(vec.at(i) == vec.at(l)){
     sum++;
   }
  }
   for(int j = 0; j < M; j++){
   if(vec.at(i) == vek.at(j)){
     sum--;
   }
   }
  ans = max(sum ,ans);
  }
    cout << ans <<endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<map>
#include<math.h>
#include<queue>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
const int mod = 1000000007;
const int INF = 1000000001;
const long long LINF = 1e18;
const int MAX = 510000;

int main() {
	int n;
	cin >> n;
	vector<string> s(n);
	vector<vector<int>> a(n, vector < int>(26));
	vector<int> mini(26,INF) ;
	for (int i = 0; i < n; i++) {
		cin >> s.at(i);
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < s.at(i).size(); j++) {
			a.at(i).at(s.at(i)[j] - 'a')++;
		}
	}
	for (int i = 0; i < 26; i++) {
		for (int j = 0; j < n; j++) {
			if (a.at(j).at(i) < mini.at(i))mini.at(i) = a.at(j).at(i);
		}
	}

	for (int i = 0; i < mini.at(0); i++) {
		cout << 'a';
	}
	for (int i = 0; i < mini.at(1); i++) {
		cout << 'b';
	}
	for (int i = 0; i < mini.at(2); i++) {
		cout << 'c';
	}
	for (int i = 0; i < mini.at(3); i++) {
		cout << 'd';
	}
	for (int i = 0; i < mini.at(4); i++) {
		cout << 'e';
	}
	for (int i = 0; i < mini.at(5); i++) {
		cout << 'f';
	}
	for (int i = 0; i < mini.at(6); i++) {
		cout << 'g';
	}
	for (int i = 0; i < mini.at(7); i++) {
		cout << 'h';
	}
		for (int i = 0; i < mini.at(8); i++) {
			cout << 'i';
		}
		for (int i = 0; i < mini.at(9); i++) {
			cout << 'j';
		}
		for (int i = 0; i < mini.at(10); i++) {
			cout << 'k';
		}
		for (int i = 0; i < mini.at(11); i++) {
			cout << 'l';
		}
		for (int i = 0; i < mini.at(12); i++) {
			cout << 'm';
		}
		for (int i = 0; i < mini.at(13); i++) {
			cout << 'n';
		}
		for (int i = 0; i < mini.at(14); i++) {
			cout << 'o';
		}
		for (int i = 0; i < mini.at(15); i++) {
			cout << 'p';
		}
		for (int i = 0; i < mini.at(16); i++) {
			cout << 'q';
		}
		for (int i = 0; i < mini.at(17); i++) {
			cout << 'r';
		}
		for (int i = 0; i < mini.at(18); i++) {
			cout << 's';
		}
		for (int i = 0; i < mini.at(19); i++) {
			cout << 't';
		}
		for (int i = 0; i < mini.at(20); i++) {
				cout << 'u';
			}
		for (int i = 0; i < mini.at(21); i++) {
				cout << 'v';
			}
		for (int i = 0; i < mini.at(22); i++) {
				cout << 'w';
			}
		for (int i = 0; i < mini.at(23); i++) {
					cout << 'x';
				}
		for (int i = 0; i < mini.at(24); i++) {
					cout << 'y';
				}
		for (int i = 0; i < mini.at(25); i++) {
			cout << 'z';
				}
		cout << endl;
		
	





		return 0;
}

Measured memory_bytes: 3544
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#include <iomanip>
#define rep(i,x) for(ll i=0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 10010010010;
typedef pair<ll, ll> P;
using graph = vector<vector<ll>>;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
    if (a < b)swap(a, b);
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}/*フィボナッチテンプレ
ll memo[50];
ll fibo(ll n) {
    if (memo[n] != 0)return memo[n];
    if (n <= 1)return memo[n] = n;
    else return memo[n] = fibo(n - 1) + fibo(n - 2);
}
*/
bool isp(ll n) {
    bool res = true;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            res = false;
            break;
        }
    }
    return res;
}
ll ctoi(char c) {
    if (c == '0')return 0;
    else if (c == '1')return 1;
    else if (c == '2')return 2;
    else if (c == '3')return 3;
    else if (c == '4')return 4;
    else if (c == '5')return 5;
    else if (c == '6')return 6;
    else if (c == '7')return 7;
    else if (c == '8')return 8;
    else if (c == '9')return 9;
    else return -1;
}
int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> keta(M);
    ll cnt = 1;
    vector<char> num(M);
    rep(i, M)cin >> keta[i] >> num[i];
    if (N == 1 && M == 0)cout << "0" << endl;
    else {
        bool ok = true;
        rep(i, M - 1) {
            for (int j = i + 1; j < M; j++) {
                if (keta[i] == keta[j] && num[i] != num[j])ok = false;
            }
        }
        ll ans = 0;
        if (N != 1) {
            rep(i, M) {
                if (num[i] == '0' && keta[i] == 1)ok = false;
            }
        }
        if (ok) {
            rep(i, N)cnt *= 10;
            for (int i = cnt / 10; i < cnt; i++) {
                bool c = true;
                string s = to_string(i);
                rep(j, M) {
                    if (s[keta[j] - 1] != num[j]) {
                        c = false;
                        break;
                    }
                }
                if (c) {
                    ans = i;
                    break;
                }
            }
            cout << ans << endl;
        }
        if (!(ok))cout << "-1" << endl;
    }
}

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

using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define P pair<int,int>
#define ll  long long

ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int main(){
	ll x,y;
	cin>>x>>y;
	ll ans=0,now=x,gc=x;

	while(now<=y){
		now*=2;
		ans++;	
		//cout<<now<<endl;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    if (n == 1) {
        cout << "? 1"
             << "\n";
        string ret;
        cin >> ret;
        if (ret == "Red")
            cout << "! RB"
                 << "\n";
        else
            cout << "! BR"
                 << "\n";
        return 0;
    }
    string ret(2 * n, 'Z');
    deque<int> q(n);
    int l = 1, r = n + 1;
    iota(q.begin(), q.end(), 1);
    cout << "? ";
    print(q);
    string left, right;
    string mm;
    cin >> left;
    right = (left == "Red" ? "Blue" : "Red");
    while (l + 1 != r) {
        int mid = (l + r) / 2;
        iota(q.begin(), q.end(), mid);
        cout << "? ";
        print(q);
        cin >> mm;
        if (mm == left)
            l = mid;
        else
            r = mid;
    }
    iota(q.begin(), q.end(), l + 1);
    q.pop_back();
    ret[q.front() - 2] = left[0];
    ret[q.back()]      = right[0];
    string curr        = "zz";
    int idx            = q.back();

    for (int i = idx + 2; i <= idx + n + 1; ++i) {
        int t = i % (2 * n + 1);
        if (ret[t - 1] != 'Z')
            continue;
        cout << "? ";
        q.push_back(t);
        print(q);
        string temp;
        cin >> temp;
        if (temp == "-1")
            return 0;
        else {
            if (temp == "Red")
                ret[t - 1] = 'R';
            else
                ret[t - 1] = 'B';
        }
        q.pop_back();
    }
    deque<int> p;
    for (int i = 1; i < q.front() - 1; ++i) {
        p.push_back(i);
    }
    for (int i = q.back() + 2; i <= 2 * n; ++i) {
        p.push_back(i);
    }
    for (auto &t : q) {
        if (ret[t - 1] != 'Z')
            continue;
        cout << "? ";
        p.push_back(t);
        print(p);
        string temp;
        cin >> temp;
        if (temp == "-1")
            return 0;
        else {
            if (temp == "Red")
                ret[t - 1] = 'R';
            else
                ret[t - 1] = 'B';
        }
        p.pop_back();
    }
    cout << "! " << ret << "\n";
    return 0;
}

Measured memory_bytes: 724
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;
u64 over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  u64 n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  l64 goal = b-a;
  for (u64 up = 0; up < n-1; ++up) {
    u64 down = n-1-up;
    l64 top = up*d-down*c;
    l64 bottom = up*c-down*d;
    if (bottom <= goal && goal <= top) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}


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


int main() {
	int N;
	cin >> N;
	int max_count = 0;

	for (int i = 1; i < N+1; ++i) {
	
		int i1 = i;
		int count = 0;

		while (true) {

			bool flg = false;

			if (i1 == 0 || i1 == 1) break;

			if (i1 % 2 != 0) {
				flg = true;
			}
			
			if (flg) break;

			i1= i1 / 2;
			count += 1;

			if (max_count < count) {
				max_count = count;
			}
		}
		
	}
	cout << pow(2 , max_count) << endl;
}

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

using namespace std;

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

	string s;
	int w;
	cin >> s >> w;

	for (int i = 0;i < s.length();i++){
		if(i%w == 0) cout << s[i];
	}	

	cout << endl;

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  string s;
  cin >> s;
  if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]){
    cout << "Bad" << endl;
  } else {
    cout << "Good" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int v[n][3];
    for(int i=0;i<n;i++)
    {
        cin>>v[i][0]>>v[i][1]>>v[i][2];
    }
    int dp[n][3];
    for(int i=0;i<3;i++)
        dp[0][i]=v[0][i];
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            if(j==0)
            {
                dp[i][j]=v[i][j]+max(dp[i-1][1],dp[i-1][2]);
            }
            if(j==1)
            {
                dp[i][j]=v[i][j]+max(dp[i-1][0],dp[i-1][2]);
            }
            if(j==2)
            {
                dp[i][j]=v[i][j]+max(dp[i-1][1],dp[i-1][0]);
            }
        }
    }
    int mx=INT_MIN;
    for(int i=0;i<3;i++)
    {
        if(dp[n-1][i]>mx)
            mx=dp[n-1][i];
    }
    cout<<mx<<endl;
    return 0;
}


Measured memory_bytes: 2560
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
template<class T> using vv=vector<vector<T> >;

template<class T>
int SearchVectorForN(T x, vector<T> &v) {
  return distance(lower_bound(v.begin(), v.end(), x), upper_bound(v.begin(), v.end(), x));
}

int main() {
  vi results;
  while (true) {
    int n, m;
    cin >> n >> m;
    if (n == 0) { break; }
    vi h = {0};
    for (int in = 1 ; in <= n ; in++) {
      int tmp;
      cin >> tmp;
      h.push_back(tmp + h[in-1]);
    }
    vi w = {0};
    for (int im = 1 ; im <= m ; im++) {
      int tmp;
      cin >> tmp;
      w.push_back(tmp + w[im-1]);
    }
    vi d_h;
    for (int in0 = 0 ; in0 < n ; in0++) {
      for (int in1 = in0 + 1 ; in1 <= n ; in1++) {
        d_h.push_back(h[in1] - h[in0]);
      }
    }
    sort(d_h.begin(), d_h.end());
    vi d_w;
    for (int im0 = 0 ; im0 < m ; im0++) {
      for (int im1 = im0 + 1 ; im1 <= m ; im1++) {
        d_w.push_back(w[im1] - w[im0]);
      }
    }
    sort(d_w.begin(), d_w.end());
    int result = 0;
    for (int itr = 0 ; itr < d_h.size() ; ) {
      result += SearchVectorForN(d_h[itr], d_h) * SearchVectorForN(d_h[itr], d_w);
      itr = distance(d_h.begin(), upper_bound(d_h.begin(), d_h.end(), d_h[itr]));
    }
    results.push_back(result);
  }

  for (int i = 0 ; i < results.size() ; i++) {
    printf("%d\n", results[i]);
  }

  return 0;
}

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

int main(){
  int n,i;
  cin >> n;
  vector<int> a(n);
  for(i=0;i<n;++i){
    cin >> a[i];
  }
  vector<ll> s(n+1);
  for(i=0;i<n;++i){
    s[i+1]=s[i]+a[i];
  }
  ll x,y;
  ll mi=1000000000000+7;
  int right,left;
  right=n;
  left=0;
  for(i=1;i<n;++i){
    left=i;
    x=s[left];
    y=s[right]-s[left];
    mi=min(mi,abs(x-y));
  }
  cout << mi << endl;
  return 0;
}


Measured memory_bytes: 2560
import string


n = int(input())

Ss = list()
for i in range(n):
    Ss.append(input())

# import random
# n = 100000
# Ss = list()
# for i in range(n):
#     Ss.append(random.sample(string.ascii_lowercase, 10))

count_dict = dict()
for s in Ss:
    count = [0 for i in range(len(string.ascii_lowercase))]
    for j in range(len(s)):
        count[ord(s[j]) - ord('a')] += 1
    count = tuple(count)
    if count in count_dict:
        count_dict[count] += 1
    else:
        count_dict[count] = 1
# print(count_dict)
ans = 0
for value in count_dict.values():
    ans += value * (value - 1) // 2
print(ans)
    
        



Measured memory_bytes: 43768
let () =
  Scanf.scanf "%d\n" @@ fun n ->
  let arr = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a in
  let brr = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun b -> b in
  let crr = Array.init (n-1) @@ fun _ -> Scanf.scanf "%d " @@ fun c -> c in
  let ans = ref 0 in
  let bfr = ref arr.(0) in
  for i = 0 to n - 1 do
    ans := !ans + brr.(arr.(i)-1);
    if i <> 0 && arr.(i) - !bfr = 1 then ans := !ans + crr.(!bfr-1);
    bfr := arr.(i)
  done;
  Printf.printf "%d\n" !ans

Measured memory_bytes: 3756
w, h, n = map(int, input().split())
XYA = []
for _ in range(n):
    x, y, a = map(int, input().split())
    XYA.append((x,y,a))

x_one_max = 0
x_two_min = w
y_three_max = 0
y_four_min = h

for i in range(n):
    if XYA[i][2] == 1:
        x_one_max = max(XYA[i][0], x_one_max)
    elif XYA[i][2] == 2:
        x_two_min = min(XYA[i][0], x_two_min)
    elif XYA[i][2] == 3:
        y_three_max = max(XYA[i][1], y_three_max)
    elif XYA[i][2] == 4:
        y_four_min = min(XYA[i][1], y_four_min)

x_dif = x_two_min - x_one_max
y_dif = y_four_min - y_three_max
if x_dif <= 0 or y_dif <= 0:
    ans = 0
else:
    ans = x_dif * y_dif
print(ans)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#define N 101

enum COLOR{WHITE,BLACK,GRAY}color[N];
int G[N][N],time,d[N],f[N],n,A[N][N],edg[N];


void DFS_visit(int u){
  int v,i;
  color[u]=GRAY;
  d[u]=++time;
  for(i=1;i<=edg[u];i++){
    v=A[u][i];
    if(color[v]==WHITE)
      DFS_visit(v);
  }
  color[u]=BLACK;
  f[u]= ++time;
}

void DES(){
  int i;
  for (i=1;i<=n;i++){
    color[i]=WHITE;
    time=0;
  }
  for(i=1;i<=n;i++){
    if(color[i]== WHITE)
      DFS_visit(i);
    printf("%d %d %d\n",i,d[i],f[i]);
  }
}

int main(){
  int i ,j,k,ver,fff;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&ver,&edg[i]);
    for(j=1;j<=edg[i];j++){
      scanf("%d",&fff);
      G[i][fff]=1;
      A[i][j]=fff;
    } 
  }
  DES();
  return 0;
}

Measured memory_bytes: 676
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 7;

int main(){
	int n,k,s;
	scanf("%d %d %d",&n,&k,&s);
	int su;
	if(s == 1000000000) su = s-1;
	else su = s+1;
	if(k == 0){
		printf("%d",su);
		for(int i = 2;i <= n;i++)
			printf(" %d",su);
		printf("\n");
	}else{
		int cnt = 0;
		printf("%d",s);
		cnt++;
		while(cnt < k){
			printf(" %d",s);
			cnt++;
		}
		for(int i = k+1;i <= n;i++){
			printf(" %d",su);
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 1280
#include<stdio.h>
#include<string.h>
int main(){
	int i;
	char w[200];
	int a[30];
	scanf("%s",w);
	for(i=0;i<26;i++){
		a[i]=0;
	}
	for(i=0;i<strlen(w);i++){
		a[w[i]-'a']++;
	}
	for(i=0;i<26;i++){
		if(a[i]%2==0)
			continue;
		else{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int x=sc.nextInt();
        int a=sc.nextInt();
		
 	if(x<a){
    		System.out.println(0);
    	}else{
     		System.out.println(10);
   	 }

    	
    }
}

Measured memory_bytes: 22612
h,k = map(int, input().split())
enemies = list(map(int, input().split()))

atack_number = len(enemies) - k

if atack_number <= 0:
    print(0)
else:
    #敵を体力少ない順に並び替え
    enemies.sort()
    atack_select = enemies[:atack_number]
    print(sum(atack_select))

Measured memory_bytes: 26764
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
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; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  ll n,m,k; cin >> n >> m >> k;
  vector<ll> a(n),b(m);
  REP(i,n) cin >> a[i];
  REP(i,m) cin >> b[i];

  // 累積和
  vector<ll> sa(n+1), sb(m+1);
  REP(i,n) sa[i+1] = sa[i] + a[i];
  REP(i,m) sb[i+1] = sb[i] + b[i];

  int ans = 0;
  REP(i, m+1) {
    if (sb[i] > k) break;
    auto it = std::upper_bound(sa.begin(), sa.end(), k-sb[i]);
    ans = max(ans, max(0, (int)(it-sa.begin()-1) ) + i);
  }
  COUT(ans);
  return 0;
}

Measured memory_bytes: 9544
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long  n,s[1000009];
long long sum=0;
cin>>n;
for(int i=1;i<=n;i++)
{
    if(i%3==0||i%5==0)
        s[i]=0;
        else
            s[i]=i;

}
    for(int i=1;i<=n;i++)
        sum+=s[i];
    cout<<sum<<endl;
}

Measured memory_bytes: 11424
#include<stdio.h>
 
int main() {
    int d[101][101] = { 0 };
    int c, r, i, j;
    scanf("%d%d", &c, &r);
    for (i = 0; i < c; i++) {
        for (j = 0; j < r; j++) {
            scanf("%d", &d[i][j]);
            d[i][r] += d[i][j];
            d[c][j] += d[i][j];
        }
        d[c][r] += d[i][r];
    }
    for (i = 0; i < c + 1; i++)
        for (j = 0; j < r + 1; j++)
            printf("%d%c", d[i][j],j<r?' ':'\n');
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int n,m;
int a[52525], b[52525], c[52525];

ll dp[125252][16];

ll modpow(ll a, ll b){
  ll r = 1;
  while(b){
    if(b&1)r=r*a%MOD;
    a=a*a%MOD;
    b>>=1;
  }
  return r;
}

int main(){
  scanf("%d%d",&n,&m);
  REP(i,m)scanf("%d%d%d",a+i,b+i,c+i),a[i]--,b[i]--;
  map<pii,int> M;
  REP(i,m)M[pii(a[i],b[i])] = c[i];
  REP(j,16){
    if(__builtin_popcount(j)%2==1)continue;
    pii a = pii(0,0);
    pii b = pii(0,1);
    pii c = pii(1,0);
    pii d = pii(1,1);
    if(M.count(a) && M[a] != (j>>0&1))continue;
    if(M.count(b) && M[b] != (j>>1&1))continue;
    if(M.count(c) && M[c] != (j>>2&1))continue;
    if(M.count(d) && M[d] != (j>>3&1))continue;
    dp[0][j] = 1;
  }
  REP(i,n-2)REP(j,16)if(dp[i][j]){
    int r2 = (j>>3&1);
    int ci = i+1;
    REP(ld,2){
      int ru = r2 ^ ld;
      if(M.count(pii(ci-1,ci+1)) && M[pii(ci-1,ci+1)] != ld)continue;
      if(M.count(pii(ci+1,ci-1)) && M[pii(ci+1,ci-1)] != ru)continue;
      REP(to,8){
        int nj = to*2+r2;
        if(__builtin_popcount(nj)%2==1)continue;
        if(M.count(pii(ci+1,ci+0)) && M[pii(ci+1,ci+0)] != (nj>>1&1))continue;
        if(M.count(pii(ci+0,ci+1)) && M[pii(ci+0,ci+1)] != (nj>>2&1))continue;
        if(M.count(pii(ci+1,ci+1)) && M[pii(ci+1,ci+1)] != (nj>>3&1))continue;
        (dp[i+1][nj] += dp[i][j]) %= MOD;
      }
    }
  }
  ll base = 0;
  REP(i,16)(base += dp[n-2][i]) %= MOD;
  ll fr = (ll)n*n;
  if(n<=3){
    fr = 0;
  }else{
    fr -= 3ll*2;
    fr -= 4ll*2;
    fr -= 5ll*(n-4);
    fr /= 2;
  }
  // DEBUG(fr);
  REP(i,m){
    int x = a[i];
    int y = b[i];
    int z = c[i];
    if(abs(x-y)<=2)continue;
    if(M.count(pii(y,x))){
      // mirror available
      if(M[pii(y,x)] != z){
        base = 0;
      }else{
        if(x<y)fr--;
      }
    }else{
      // no mirror
      fr--;
    }
  }
  ll ans = base * modpow(2ll, fr) % MOD;
  // DEBUG(ans);
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 18432
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#pragma warning( disable:4996 )
#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define MIN(a, b) ((a) < (b) ? (a) : (b))


int main(void) {
	char s[200002];
	scanf("%s", s);

	unsigned long long count = 0;
	int len = strlen(s);
	int found = 0;
	while (1) {
		int acount = 0;
		int astart = -1;
		int i = 0;
		while (i < len - 2) {
			if (s[i] == 'A') {
				if (acount == 0) {
					astart = i;
				}
				acount++;
			}
			else {
				acount = 0;
			}
			if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
				if (acount > 1) {
					s[astart] = 'B';
					s[astart + 1] = 'C';
					/*for (int j = astart + 2; j <= i+2; j++) {
						s[j] = 'A';
					}*/
					//s[i + 2] = 'A';
					memset(s + astart + 2, 'A', i - astart + 1);
					count += acount;
					astart = astart + 2;
					acount--;
					i++;
				}
				else {
					count++;
					s[i] = 'B';
					s[i + 1] = 'C';
					s[i + 2] = 'A';
				}

				found = 1;
				/*int j = i;
				while (j>=1) {
					if (s[j - 1] == 'A') {
						s[j - 1] = 'B';
						s[j] = 'C';
						s[j + 1] = 'A';
						count++;
						j--;
					}
					else {
						break;
					}
				}*/
				
			}
			i++;
		}
		if (!found) {
			break;
		}
		else {
			found = 0;
		}
	}
	printf("%lld\n", count);

	return 0;
}

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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            for(int i = 0; i < line.Length; i++)
            {
                Console.Write("x");
            }
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 13140
#include <stdio.h>
int main(void){
  int n,a,b;
  int p[50001];
  int ans;
  for (int i = 0; i < 2; i++) {
    p[i] = 0;
  }
  for (int i = 2; i <= 50000; i++) {
    p[i] = 2;
  }
  for (int i = 2; i <= 50000; i++) {
    if (p[i] != 0) {
      p[i] = 1;
      for (int j = i + 1; j <= 50000; j++) {
        if (j % i == 0) {
          p[j] = 0;
        }
      }
    }
  }
  scanf("%d",&n );
  while (n != 0) {
    ans = 0;
    a = 2;
    b = n - a;
    for (int i = 2; a <= b; i++) {
      if (p[a] == 1 && p[b] == 1) {
        ans++;
      }
      a++;
      b--;
    }
    printf("%d\n",ans );
    scanf("%d", &n);
  }
  return 0;
}


Measured memory_bytes: 2100
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
	int n, t, c[100], y[100], ans = 114514;
	cin >> n >> t;
	rep(i, n) {
		cin >> c[i] >> y[i];
		if (y[i] <= t) {
			ans = min(ans, c[i]);
		}
	}
	if (ans == 114514) cout << "TLE" << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    S = [int(i) for i in input().split()]
    q = int(input())
    T = [int(i) for i in input().split()]
    
    count = 0
    for t in T:
        for s in S:
            if t == s:
                count += 1
                break

    print(count)

if __name__ == '__main__':
    main()

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

int main(){
    int K, A, B;
    bool ok=false;
    cin >> K >> A >> B;
    for(int i=A; i<=B; i++){
        if(i%K == 0){
            ok=true;
            break;
        }
    }
    if(ok) cout << "OK" << endl;
    else cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N,d,e,f;
  cin>>N;
  if(N>=100 && N<=999){

      d=N/100;
      e=(N-d*100)/10;
      f=N%10;
      if(d==7 || e==7 || f==7)
      {
          printf("Yes\n");
      }
      else
      {
          printf("No\n");
      }
  }

    return 0;
}

Measured memory_bytes: 3544
N, M = map(int, input().split())
x_list = list(map(int, input().split()))
x_list.sort()

margin = []
prev = x_list[0]
for i in range(1, M):
    margin.append(x_list[i] - prev)
    prev = x_list[i]

margin.sort(reverse=True)
print(x_list[-1] - x_list[0] - sum(margin[:N-1]))


Measured memory_bytes: 13968
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())

LL dp[100][100010];
LL n, k;

LL nn, start[100010], cnt[100010];

LL MOD = 1000000007;

void solve() {
  cin >> n >> k;

  nn = 0;
  int ptr = 1;
  while(1) {
    nn++;
    start[nn-1] = ptr;
    if (n/ptr == 1) {
      cnt[nn-1] = n-ptr+1;
      break;
    }
    ptr += (n%ptr) / (n/ptr) + 1;
    cnt[nn-1] = ptr - start[nn-1];
  }

  REP(i, nn) dp[0][i] = 1;
  REP(i, k-1) {
    LL sum = 0;
    REP(j, nn) {
      sum = (sum + dp[i][j]*cnt[j]) % MOD;
      dp[i+1][nn-j-1] = (dp[i+1][nn-j-1] + sum) % MOD;
    }
  }
  LL res = 0;
  REP(i, nn) res = (res + dp[k-1][i]*cnt[i]) % MOD;
  cout << res << endl;

}

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


Measured memory_bytes: 78464
fun readInts() = readLine()!!.split(' ').map(String::toInt)

fun main(args: Array<String>) {
    val (n, y) = readInts()
    val x = y / 1000 - n
    for (a in 0..n) {
        val z = x - 9 * a
        for (b in 0..n - a) {
            if (4 * b == z) {
                println("$a $b ${n - a - b}")
                return
            }
        }
    }
    println("-1 -1 -1")
}


Measured memory_bytes: 38172
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int A, B, C;

  cin >> A >> B >> C;

  cout << max(0, C - (A - B)) << endl;

  return 0;
}


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

 int gcd(int x, int y) {
  return (x % y == 0 ? y : gcd(y, x % y));
}

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

  string T;
  cin >> T;

  string Q = "??";
  long long pos_Q = T.find(Q);
  long long len_Q = Q.length();
  string QQ = "?";
  long long pos_QQ = T.find(QQ);
  long long len_QQ = QQ.length();
  if (pos_Q == 0) {
    T.replace(pos_Q, len_Q, "PD");
  }
  else if (pos_QQ == 0) {
    T.replace(pos_QQ, len_QQ, "D");
  }

  for(int i = 0; i < T.size(); ++i) {
    if(T.at(i) == '?') {
      if(T.at(i - 1) == 'P') T.replace(i, 1, "D");
      else if(i < T.size() - 1 && T.at(i + 1) == 'D') T.replace(i, 1, "P");
      else if(i < T.size() - 1 && T.at(i + 1) == '?') {
        T.replace(i, 1, "P");
        T.replace(i + 1, 1, "D");
      }
      else T.replace(i, 1, "D");
    }
  }

  cout << T << endl;

  return 0;
}


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

int main(){
  int n,k;
  cin >> n >> k;
  int cnt=k-(n-1)*(n-2)/2;
  if(cnt>0){
    cout << -1 << endl;
    return 0;
  }
  cout << -cnt+(n-1) << endl;
  for(int i=2;i<=n;i++){
    cout << 1 << ' ' << i << endl;
  }
  for(int i=2;i<=n-1;i++){
      for(int j=i+1;j<=n;j++){
        if(cnt<0){
          cout << i << ' ' << j << endl;
          cnt++;
        }
      }
  }
return 0;}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N;
ll fact[1010101];
ll mo=1000000007;

ll combi(ll N_, ll C_) {
	const int NUM_=1400001;
	static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
	if (fact[0]==0) {
		inv[1]=fact[0]=factr[0]=1;
		for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
		for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
	}
	if(C_<0 || C_>N_) return 0;
	return factr[C_]*fact[N_]%mo*factr[N_-C_]%mo;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	fact[0]=1;
	for(i=1;i<=1010000;i++) fact[i]=fact[i-1]*i%mo;
	N--;
	
	ll tot=fact[N]*N%mo;
	ll pr=0;
	for(i=N-1;i>=1;i--) {
		ll pat=combi(N-1-i,i);
		if(pat==0) continue;
		tot-=pat*fact[N-i]%mo*fact[i]%mo%mo;
	}
	
	cout<<(tot%mo+mo)%mo<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}



Measured memory_bytes: 40960
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#include <cmath>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define uid uniform_int_distribution<lli>
#define lli long long int
#define ff first
#define ss second
#define pb push_back
#define popf pop_front()
#define popb pop_back()
#define all(vec) vec.begin(), vec.end()
#define fol(i,a,b) for(int i=a;i<b;i++)
#define forr(x,arr) for(auto& x:arr)
#define sz(x) (x.size())
#define mod 1000000007
#define INF 1000000000000000010
#define vi vector<int>
#define vlli vector<lli>
#define endl "\n"
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

template<class my>
inline my aabs (const my& a)   { return (a > 0)  ? a : -a;         }
inline lli gcd(lli a, lli b)   { return (b == 0) ? a : gcd(b,a%b); }
inline lli LSOne(lli k)        { return (k&(-k));                  }

inline int inv(lli o, int m = mod) {
  int b = m, u = 0, v = 1, t, a=o%m;
  while (a) {
    t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  if (u < 0) u += m;
  return u;
}
inline int add(const int &a, const int &b) { return a + b >= mod ? a + b - mod : a + b; }
inline int sub(const int &a, const int &b) { return a - b < 0 ? a - b + mod : a - b; }
inline int mul(const int &a, const int &b) { return int(a * 1ll * b % mod); }
inline int _div(const int &a, const int &b) { return mul(a, inv(b)); }
inline int pow(int a, int b) {
    int ans = 1;
    while (b) {
        if (b & 1) ans = mul(ans, a);
        a = mul(a, a);
        b >>= 1;
    }
    return ans;
}

int fac[100050], infac[100050];
int nCk (int n, int k)
{
    if(n<0||k<0||n<k) return 0;
    return mul(fac[n],mul(infac[k],infac[n-k]));
}

void solve()
{
    lli n=0, m=0, k=0, q=0, temp=0, u=0, v=0, ans=0, ans1=0, ans2=0, val=0, mini=INF, maxi=-INF;
    cin>>n;
    int arr[n+5]={};
    fol(i,0,n) cin>>arr[i];
    sort(arr,arr+n);
    temp=n/2;
    cout<<arr[temp]-arr[temp-1]<<endl;
}

int main()
{
    fastio cout<<endl;
    int t=1;
    //cin>>t;
    while(t--)
        solve();
}

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

typedef int ll;
typedef string str;

int main ()
{
	// ios::sync_with_stdio(0);
 //    cin.tie(0);
 //    cout.tie(0);
	ll t,n,m,k,i,a,b,j;
	cin >> n;
	ll arr[n+2];
	for(i=0;i<n;i++)
	{
		cin >> arr[i];
	}
	sort(arr,arr+n);
	k=arr[n-1]+3;
	ll h[1000005]={0};
	for(i=0;i<n;i++)
	{
		a=arr[i];
		ll cnt=0;
		while(i<n && arr[i]==a)
		{
			i++;
			cnt++;
		}
		i--;
		for(j=a;j<k;j+=a)
		{
			h[j]+=cnt;
		}
	}
	ll ans=0;
	for(i=0;i<n;i++)
	{
		if(h[arr[i]]==1)
			ans++;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 8280