akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>
#include <queue>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define ll long long
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d %d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld %lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
#define SIZE 1000000007

using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long,long long>> vpl;
typedef vector<vector<pair<long long,long long>>> vvpl;
typedef vector<bool> vb;
typedef pair<int,int> pii;
typedef pair <ll,ll> pll;
const  double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
/*ios_base::sync_with_stdio(false);cin.tie(0);*/

ll gcd(ll n,ll m){
    if (n==0)return m;
    return gcd(m%n,n) ;
}

long long fast_exp(long long n,long long k){
    if(k == 0)
        return 1;
    if(k==1)
        return n;

    long long temp = fast_exp(n,k>>1);

    if((k&1)==1)
        return (n*temp*temp)%SIZE;
    return (temp*temp)%SIZE;

}

int main() {
 ll n,k ;
 cin >> n>>k;
 ll up = 1000000;
 ll low = -1000000;
 if ( k - (n-1) > low  )low = k -(n-1);
 if ( k + (n-1) < up )up = k+(n-1);
    for (ll i = low; i <=up ; ++i) {
        cout << i << " ";
    }

    return 0;
}


Measured memory_bytes: 256
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double EPS = 1e-10;


int main(void) {
  ll N, M;
  cin >> N;
  vector<ll> D(N);
  rep(i, N) cin >> D[i];
  cin >> M;
  vector<ll> T(M);
  rep(i, M) cin >> T[i];

  // 対応する点数の問題があるかどうかなので
  //  ソートしてから前から調べる
  // Mapでもいいかも
  sort(D.begin(), D.end());
  sort(T.begin(), T.end());
  int d = 0;
  int t = 0;
  while (t < M && d < N) {
    if (T[t] < D[d]) break;
    if (T[t] == D[d]) {
      ++t;
    }
    ++d;
  }

  if (t == M) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}

Measured memory_bytes: 6352
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll n,m;
  cin>>n>>m;
  ll ans=1;
  while(1){
    if(2*n<=m){
      n*=2;
      ans++;
    }
    else{
      break;
    }
  }
  COUT(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c;
  d = a + b + c;
  
  if(d <= 21){
    cout << "win" << endl;
  } else {
    cout << "bust" << endl;
  }
}

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

#ifdef LOCAL
#include "contest.h"
#else
#define error(args...) 
#endif

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}

bool okA(int N, int C) {
    return N == C;
}
bool okB(int N, int C) {
    return 2*C <= N;
}

bool solve() {
    int N;
    cin >> N;

    map<int, int> m;
    for(int i = 0; i < N; i++) {
        int x;
        cin >> x;
        m[x]++;
    }

    if(m.size() > 2) {
        return false;
    } else if(m.size() == 2) {
        auto it = m.begin();
        int a = it->first;
        int c1 = it->second;
        it++;
        int b = it->first;
        int c2 = it->second;
        if(a+1 != b) {
            return false;
        }
        if(c1 >= b) {
            return false;
        }
        int rest = b - c1;
        return rest*2 <= c2;
    } else {
        auto it = m.begin();
        int a = it->first;
        return okA(N, a+1) || okB(N, a);
    }
}
int main(){
    iostream_init();

    cout << (solve() ? "Yes" : "No") << endl;

    return 0;
}



Measured memory_bytes: 4992
N,M=map(int, input().split())
A=set(int(input()) for _ in range(M))
D=[0]*(N+1)
D[0]=1

for i in range(1,N+1):
 if i in A: continue
 D[i]=D[i-1]+D[i-2]
print(D[-1] % (10**9+7))

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

int main(){
  int K, X;
  cin >> K >> X;
  int k = K-1;
  int x = X-k;
  
  for(int i=x; i<=X+k; i++){
    cout << i <<" ";
    if(i==X+k){
      cout << endl;
    }
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a= sc.nextInt(),b= sc.nextInt();
switch (a) {
	case 1:
   	 if(b==2){
		System.out.println("3");
     }else{
		System.out.println("2");
     }
    break;
	case 2:
   	 if(b==1){
		System.out.println("3");
     }else{
		System.out.println("1");
     }
    break;
    case 3:
   	 if(b==1){
		System.out.println("2");
     }else{
		System.out.println("1");
     }
    break;
	default:
    // 式の値がどのcaseの値とも一致しなかったときの処理
}

	}
}

Measured memory_bytes: 20948
#include <stdio.h>

int main(void) {
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
if(a<=b&&b<=c)
printf("%d %d %d\n",a,b,c);
else if(a>=b&&b>=c)
printf("%d %d %d\n",c,b,a);
else if(a>=b&&a<=c)
printf("%d %d %d\n",b,a,c);
else if(a<=b&&b>=c&&a>=c)
printf("%d %d %d\n",c,a,b);
else if(a<=b&&b>=c&&a<=c)
printf("%d %d %d\n",a,c,b);
else if(a>=b&&a>=c&&c>=b)
printf("%d %d %d\n",b,c,a);
return 0;
}


Measured memory_bytes: 2104
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int S = sc.nextInt();
		List<Integer> list1 = new ArrayList<>();
		int count = 0;
		for(int i = 0; i < N; i++){
			int a = sc.nextInt();
			list1.add(a);
			if(a==1){
				count =i;
			}
		}
		if(count%(S-1)+ (N-count-1)%(S-1) ==0){
			System.out.println(count/(S-1)+(N-count-1)/(S-1));
		}else if( count%(S-1)+ (N-count-1)%(S-1) <= S-1){
			System.out.println(count/(S-1)+(N-count-1)/(S-1)+1);
			return;
		}else {
			System.out.println(count/S+(N-count-1)/(S-1)+2);
		}
	}
}

Measured memory_bytes: 64328
#include"bits/stdc++.h"

using namespace std;

int main() {
	double A, B;
	cin >> A >> B;
	if (A > B) {
		cout << "GREATER";
	}
	else if (A < B) {
		cout << "LESS";
	}
	else {
		cout << "EQUAL";
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fname "NAME"
#define ll long long
#define ui unsigned int
#define ull unsigned long long
#define bug(x) cerr << (#x) << " = " << (x) << endl;
#define REP0(i, n) for(int i = 0, _n = (n); i < _n; ++i)
#define REP1(i, n) for(int i = 1, _n = (n); i <= _n; ++i)
#define REPB0(i, n) for(int i = (n) - 1; i >= 0; --i)
#define REPB1(i, n) for(int i = (n); i > 0; --i)
#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; ++i)
#define FORB(i, a, b) for(int i = (a), _b = (b); i >= _b; --i)
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define X first
#define Y second

using namespace std;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef pair<double, double> dd;
typedef pair<float, float> ff;

int main()
{
	if (fopen(fname".INP", "r")) {
		freopen(fname".INP", "r", stdin);
		freopen(fname".OUT", "w", stdout);
	}
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int a;
	string s;
	cin >> a >> s;
	if (a < 3200) cout << "red";
	else cout << s;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <vector>
#include <chrono>
#include <iostream>

using namespace std;
using namespace std::chrono;

struct TPoint {
  int x;
  int y;
};

istream& operator >>(istream& in, TPoint& p) {
  in >> p.x >> p.y;
  return in;
}

int main() {
  auto start = high_resolution_clock::now();

  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  size_t n, k;
  cin >> n >> k;

  vector<TPoint> v(n);
  for (size_t i = 0; i < n; ++i)
    cin >> v[i];

  long long ans = (1LL << 63) - 1;
  for (size_t i1 = 0; i1 < n; ++i1) {
    for (size_t i2 = 0; i2 < n; ++i2) {
      for (size_t i3 = 0; i3 < n; ++i3) {
        int lx = min(v[i1].x, min(v[i2].x, v[i3].x));
        int dy = min(v[i1].y, min(v[i2].y, v[i3].y));
        int uy = max(v[i1].y, max(v[i2].y, v[i3].y));

        vector<int> x;
        for (const TPoint& it : v) {
          if (lx <= it.x && dy <= it.y && it.y <= uy) {
            x.push_back(it.x);
          }
        }

        sort(x.begin(), x.end());

        if (x.size() >= k) {
          ans = min(ans, 1LL * (x[k - 1] - lx) * (uy - dy));
        }
      }
    }
  }

  cout << ans << endl;

  cerr << "Total execution time : " << duration_cast<milliseconds>(high_resolution_clock::now() - start).count() << " ms" << endl;

  return 0;
}


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

int main(){
    int N; cin >> N;
    int M;
    if(N%2){
//(1,N-1) (2,N-2),..,(N-1/2, N+1/2), (N)と分ける
        M = N*(N-1)/2 -N/2;
        cout << M << endl;
        for(int i=1; i<N; i++){
            for(int j=i+1;j<=N;j++){
                if(i+j!=N) cout << i << " " << j << endl;
            }
        }
        return 0;
    }
// (1,N) (2,N-1) ... (N/2,N/2+1)
    M = N *(N-1)/2 -N/2;
    cout << M << endl;

    for(int i=1; i<N; i++){
        for(int j=i+1; j<=N; j++){
            if((i+j)!=(N+1)){
                cout << i << " " << j << endl;
            }
        }
    }
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.lang.Math;
import java.util.Arrays;

public class Main {
    public static void main(final String[] args) {

        Scanner sc = new Scanner(System.in);

        int cnt = 1;
        String s;
        while(!(s = sc.next()).equals("0")){
            System.out.println("Case " + cnt + ": " + s);
            cnt++;
        }
    }
  
}


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

#define M 1000000007
#define MM 998244353 
#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define sz(a) (ll)a.size()
#define F first
#define S second
#define PI 3.1415926536
#define INF 2000000000000000000
#define endl "\n"
#define _time_ 1.0 * clock() / CLOCKS_PER_SEC
#define popcount(x) __builtin_popcountll(x)
//RNG based on mersenne_twister 
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}
template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }

vector<pair<ll,pair<ll,ll>>> ed[55];
ll c[60],d[60];
map<pair<ll,ll>,ll> hh;
ll dis[250200];
vector<pair<ll,ll>> v[250200];
ll s;
void djikstra()
{
	set<pair<ll,ll>> ss;
	ss.insert({0,hh[{1,s}]});
	dis[hh[{1,s}]]=0;
	while(!ss.empty())
	{
		pair<ll,ll> p=*ss.begin();
		ss.erase(*ss.begin());
		ll u=p.S;
		for(auto j:v[p.S])
		{
			ll w=j.F;
			if(dis[j.S]>dis[u]+w)
			{
				if(dis[j.S]!=INF)
					ss.erase({dis[j.S],j.S});
				dis[j.S]=dis[u]+w;
				ss.insert({dis[j.S],j.S});
			}
		}
	}
}
int _runtimeTerror_()
{
	ll n,m,i,j;
	ll k=1;
	cin>>n>>m>>s;
	s=min(s,5000LL);
	for(i=0;i<m;++i)
	{
		ll u,v,a,b;
		cin>>u>>v>>a>>b;
		ed[u].pb({v,{a,b}});
		ed[v].pb({u,{a,b}});
	}
	for(i=1;i<=n;++i)
	{
		for(j=0;j<=5000;++j)
			hh[{i,j}]=k++;
	}
	for(i=1;i<=250199;++i)
		dis[i]=INF;
	for(i=1;i<=n;++i)
		cin>>c[i]>>d[i];
	for(i=1;i<=n;++i)
	{
		for(j=0;j<=5000-c[i];++j)
		{
			v[hh[{i,j}]].pb({d[i],hh[{i,j+c[i]}]});
		}
		for(j=0;j<=5000;++j)
		{
			for(auto k:ed[i])
			{
				if(k.S.F<=j)
				{
					v[hh[{i,j}]].pb({k.S.S,hh[{k.F,j-k.S.F}]});
				}
			}
		}
	}
	djikstra();
	ll ans[n+1];
	for(i=1;i<=n;++i)
	{
		ans[i]=INF;
		for(j=0;j<=5000;++j)
			amin(ans[i],dis[hh[{i,j}]]);
	}
	for(i=2;i<=n;++i)
		cout<<ans[i]<<endl;
	return 0;
}

int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#ifdef runSieve
		sieve();
	#endif
	#ifdef NCR
		initialize();
	#endif
	int TESTS=1;
	//cin>>TESTS;
	while(TESTS--)
		_runtimeTerror_();
	cerr<<"\n"<<_time_;
	return 0;
}


Measured memory_bytes: 62212
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
#define intt long long
#define PI 3.14159265358979323846

using namespace std;
int main() {
    std::string s1 = "";
    std::string s2 = "";
    std::string S; std::cin >> S;
    intt TTT = 0;
    intt Q; std::cin >> Q;
    for (intt i = 0; i < Q; ++i) {
        intt t; std::cin >> t;
        if (t == 1) {
            std::swap(s1, s2);
            ++TTT;
        }
        else if (t == 2) {
            intt tt; std::cin >> tt;
            char c; std::cin >> c;
            if (tt == 1)
                s1 += c;
            else if (tt == 2)
                s2 += c;
        }
    }
    if (TTT % 2 == 1)
        std::reverse(S.begin(), S.end());
    std::reverse(s1.begin(), s1.end());
    std::cout << s1 + S + s2 << std::endl;

    return 0;
}

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

#include <fstream>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  //*/
  int N;
  cin >> N;
  if(N % 2 == 0) cout << N <<endl;
  else cout << N * 2 <<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    int n,m,x; cin >> n >> m >> x;
    int c[n],a[n][m];
    rep(i,n){
        cin>>c[i];
        rep(j,m)cin>>a[i][j];
    }
    int ans=1e9;
    rep(i,(1<<n)){
        int res=0;
        vector<int> v(m,0);
        rep(j,n){
            if(i&(1<<j)){
                res+=c[j];
                rep(k,m){
                    v[k]+=a[j][k];
                }
            }
        }
        bool ok=1;
        rep(j,m){
            if(v[j]<x) ok=0;
        }
        if(ok) chmin(ans,res);
    }
    if(ans==1e9)cout<<-1<<endl;
    else cout << ans << endl;
}


Measured memory_bytes: 3624
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

int main()
{
  vector<pair<int,int> > a;
  int i,j,n,x,y;
  _int64 tot,k;
  scanf("%d%lld",&n,&k);
  a.clear();
  for (i=0;i<n;i++)
  {
    scanf("%d%d",&x,&y);
    a.push_back(make_pair(x,y));
  }
  sort(a.begin(),a.end());
  tot=0;
  for (i=0;i<a.size();i++)
  {
    tot+=a[i].second;
    if (tot>=k)
    {
      printf("%d\n",a[i].first);
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

int main() {
    string S;
    cin >> S;
    ll ans=0, c=1;
    REP(i, S.size()) {
        if(S[i]=='1') {
            ans = (ans+c*modpow(3,S.size()-i-1))%MOD;
            c=(c*2)%MOD;
        }
    }
    ans = (ans+c)%MOD;
    cout << ans << endl;
	return 0;
}

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

typedef long long ll;
const int MM = 1e9 + 7;
const int MAXN = 2e6 + 10;

int n, m;
int b[MAXN], c[MAXN];

int main(){
	cin>>n; 
	int cnt = 0;
	for(int i = 2; i <= n; i++){
		int flag = 1;
		for(int j = 2; j * j <= i; j++)
			if (i % j == 0){
				flag = 0;
				break;
			}
		if (flag){
			b[++cnt] = i;
			c[cnt] = 0;
		}
	}
	for(int i = 2; i <= n; i++){
		int x = i;
		for(int j = 1; j <= cnt && b[j] <= x && x != 1; j++){
			while(x % b[j] == 0){
				x /= b[j];
				c[j]++;
			}
		}
	}
	ll ans = 1;
	for(int i = 1; i <= cnt; i++)
		ans = (ans * (c[i] + 1)) % MM;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;

static inline ll mod(ll x, ll m)
{
    ll y = x % m;
    return (y >= 0 ? y : y+m);
}

// }}}

string K;
int D;
ll dp[10001][2][100];

void solve()
{
    int d = K.size();
    dp[0][0][0] = 1;
    REP (i, d) {
        REP (j, 2) {
            REP (k, D) {
                int lim = (j == 1 ? 9 : K[i] - '0');
                REP (l, lim + 1) {
                    dp[i+1][(j == 1 || l < lim ? 1 : 0)][(k+l)%D] += dp[i][j][k];
                    dp[i+1][(j == 1 || l < lim ? 1 : 0)][(k+l)%D] %= MOD;
                }
            }
        }
    }
    cout << mod(dp[d][0][0] + dp[d][1][0] - 1, MOD) << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> K >> D;
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 15872
#include<iostream>
#include<cstdio>
using namespace std;
int h,w,ans;
bool ice[100][100];
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void rec(int x,int y,int counter){
  bool fin = true;
  for(int i=0;i<4;i++){
    int NX = x+dx[i],NY = y+dy[i];
    if(ice[NY][NX] && 0<=NX && NX < h && 0<= NY && NY<w)fin = false;
  }
  if(fin){
    ans = max(ans,counter);
    return;
  }
  //cout << x << " " << y << endl;
  //used[y][x] = true;
  for(int i=0;i<4;i++){
    int nx = x+dx[i],ny = y+dy[i];
    if(ice[ny][nx] && 0<= nx && nx<h && 0<= ny && ny <w){
      ice[ny][nx] = false;
      rec(nx,ny,counter+1);
      ice[ny][nx] = true;
    }
  }  
}

int main(){
  //cout << sizeof(bool) << " " << sizeof(char) << " " << sizeof(int) << endl;
  while(cin >> h >> w && h && w){
    ans = 0;

    for(int i=0;i<w;i++){
      for(int j=0;j<h;j++){
	cin >> ice[i][j];
      }
    }

    for(int i=0;i<w;i++){
      for(int j=0;j<h;j++){	
	if(ice[i][j]){
	  ice[i][j] = false;
	  rec(j,i,1);
	  ice[i][j] = true;
	}
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1168
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

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

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

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }
  public static boolean isPalindrome(String s) {
    int i = 0;
    int j = s.length() - 1;
    while (i < j) {
      if (s.charAt(i) != s.charAt(j)) return false;
      i++;
      j--;
    }
    return true;
  }
  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    String s = sc.next();
    if (!isPalindrome(s)) {
      System.out.println("No");
      return;
    }
    String left = s.substring(0, s.length() / 2);
    String right = s.substring(s.length() / 2 + 1);
    if (isPalindrome(left) && isPalindrome(right)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 22612
// AOJ 2212 Stolen Jewel
// 2018.3.14 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int H, W;
char map[52][52];
int SR, SC, GR, GC;
typedef struct { int ban, len; } T;
T t[12]; int P, max;
int mv[4][2] = { {-1,0},{0,1},{1,0},{0,-1} };
char visited[50][50][16][73];
int tbl[73][4]; int root = 1, sz;

#define QMAX 200000
typedef struct { int r, c, w, p; } Q;
Q q[QMAX+5]; int top, end;

int check(int w, int p)
{
	int k, n;

	k = root;
	while (w--) {
		n = tbl[k][p & 3];
		if (n < 0) return 0;
		if (n == 0) break;
		p >>= 2, k = n;
	}
	return k;
}

int cmp(const void *a, const void *b) {
	return ((T *)a)->len - ((T *)b)->len;
}

void mkpat()
{
	int i, j, k, b, n;
	char f[12];

	memset(tbl, 0, sizeof(tbl));
	if (P == 0) return;

	memset(f, 1, sizeof(f));
	qsort(t, P, sizeof(T), cmp);
	for (i = 0; i < P; i++) if (f[i]) {
		for (j = i + 1; j < P; j++) if (f[j]) {
			for (k = 0; k <= t[j].len - t[i].len; k++) {
				if (((t[j].ban >> 2 * k) & ((1 << 2 * t[i].len) - 1)) == t[i].ban) {
					f[j] = 0;
					break;
				}
			}
		}
	}
	i = 0; for (j = 0; j < P; j++) if (f[j]) {
		if (j != i) t[i] = t[j];
		i++;
	}
	P = i;
	if (P == 0) max = 0;
	else max = t[0].len;
	for (i = 1; i < P; i++) {
		if (t[i].len > max) max = t[i].len;
	}

	sz = root + 1;
	for (i = 0; i < P; i++) {
		k = root, b = t[i].ban;
		for (j = 0; ; j++) {
			int bb = b & 3;
			if (j == t[i].len - 1) { tbl[k][bb] = -1; break; }
			if ((n = tbl[k][bb]) == 0) tbl[k][bb] = n = sz++;
			k = n;
			b >>= 2;
		}
	}
}

int bfs(int sr, int sc, int gr, int gc)
{
	int i, k, r, c, w, p, rr, cc, ww, pp, x, mask;
	int last = 0;

	memset(visited, 0, sizeof(visited));
	mask = (1 << (2 * max)) - 1;
	top = 0, end = 1;
	q[0].r = sr, q[0].c = sc, q[0].p = 0, q[0].w = 0;
	while (top != end) {
		r = q[top].r, c = q[top].c, w = q[top].w, p = q[top].p;
		top++;   // if (++top == QMAX) top = 0;
		if (r == gr && c == gc) return w;

		ww = w + 1; x = (ww > max) ? max : ww;
		p = (p & mask) << 2;
		for (i = 0; i < 4; i++) {
			rr = r + mv[i][0], cc = c + mv[i][1];
			if (rr < 0 || rr >= H || cc < 0 || cc >= W || map[rr][cc] == '#') continue;
			pp = p | i;
			if (!(k = check(x, pp))) continue;
			if (!visited[rr][cc][(pp>>1) & 0xf][k]) {
				visited[rr][cc][(pp>>1) & 0xf][k] = 1;
				q[end].r = rr, q[end].c = cc, q[end].w = ww, q[end].p = pp;
				end++;    // if (++end == QMAX) end = 0;
			}
		}
	}
	return -1;
}

int main()
{
	int i, j, r, c, p;
	char pat[12];

	while (scanf("%d%d", &H, &W) && (H | W)) {
		for (r = 0; r < H; r++) {
			scanf("%s", map[r]);
			for (c = 0; c < W; c++) {
				if (map[r][c] == 'S') SR = r, SC = c, map[r][c] = '.';
				else if (map[r][c] == 'G') GR = r, GC = c, map[r][c] = '.';
			}
		}
		scanf("%d", &P);
		for (i = 0; i < P; i++) {
			scanf("%s", pat);
			p = 0;
			for (j = 0; pat[j]; j++) {
				p <<= 2;
				switch (pat[j]) {
				case 'U': break;
				case 'R': p |= 1; break;
				case 'D': p |= 2; break;
				case 'L': p |= 3; break;
				}
			}
			t[i].ban = p, t[i].len = j;
		}

		mkpat();
		printf("%d\n", bfs(SR, SC, GR, GC));
	}
	return 0;
}


Measured memory_bytes: 6212
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
#define rp(i, f, t) for (int i = f; i < t; i++)
#define pr(i, f, t) for (int i = t - 1; i >= f; i--)
int main()
{
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
}

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

int main(){
	vector <int> n;
	int t;
	for(int i=0;i<4;i++){
		cin>>t;
		n.push_back(t);
	}
	sort(n.begin(),n.end());
	if(n[0]==1&&n[1]==4&&n[2]==7&&n[3]==9){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<tuple<string,int,int>> a;
    for(int i=0;i<n;i++){
        string s;
        int p;
        cin>>s>>p;
        a.push_back(make_tuple(s,100-p,i+1));
    }
    sort(a.begin(),a.end());
    
    for(auto x:a){
        cout<< get<2>(x) <<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
using namespace std;


int main(void){
    int N;
    cin >> N;
    int A,B;
    cin >> A >> B;
    vector<int> P(N);
    rep(i,N){
      cin >> P[i]; 
    }
    int ans = 0;
    sort(all(P));
  while(!P.empty()){
    if(P[0] > A){
      cout << ans << endl;
      return 0;
    }
    else{
      P.erase(P.begin());
    }
    if(*lower_bound(all(P), A + 1) > B || lower_bound(all(P), A + 1) == P.end()){
      cout << ans << endl;
      return 0;
    } else{
      P.erase(lower_bound(all(P), A + 1));
    }
    if(lower_bound(all(P), B + 1) == P.end()){
      cout << ans << endl;
      return 0;
    } else{
      P.erase(lower_bound(all(P), B + 1));
      ans++;
    }
  }
  cout << ans << endl;
}


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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(200001);

int main() {
  ll n, a, b; cin >> n >> a >> b;
  mint t = 1, s = 1;
  mint ans = mint(2).pow(n) - 1;
  for (int i = n - a + 1; i <= n; i++) t *= i;
  for (int i = 1; i <= a; i++) t /= i;
  for (int i = n - b + 1; i <= n; i++) s *= i;
  for (int i = 1; i <= b; i++) s /= i;
  ans = ans - t - s;
  cout << ans.x;
  return 0;
}


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

int main(){
  long long int a, b, c;
  cin >> a >> b >>c;
  int ans=0;
  long long ab=abs(a-b);
  long long ac=abs(a-c);
  
  if(a*b*c%2!=0) ans=0;
  
  else if(a==b && b==c) ans=-1;
  else{
    int j=0; int k=0;
    while(ab%2==0){
      ab=ab/2;
      j++;
    }
    while(ac%2==0){
      ac=ac/2;
      k++;
    }
    ans=min(j, k);
  }
  cout << ans << endl;
}


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

#define CMD_NUM 7

typedef struct {
    int cursor;
    char text[1001];
    char buf[1001];
} editor_t;

void skip_space(editor_t *e) {
    int len = strlen(e->text);
    while (e->cursor < len &&
           e->text[e->cursor] == ' ')
        e->cursor++;
}

void forward_char(editor_t *e, const char *command) {
    if (e->cursor >= strlen(e->text)) return;
    e->cursor++;
}

void forward_word(editor_t *e, const char *command) {
    int len = strlen(e->text);
    skip_space(e);
    while (e->cursor < len &&
           e->text[e->cursor] != ' ')
        e->cursor++;
}

void backward_char(editor_t *e, const char *command) {
    if (e->cursor == 0) return;
    e->cursor--;
}

void backward_word(editor_t *e, const char *command) {
    while (e->cursor > 0 &&
           e->text[e->cursor-1] == ' ')
        e->cursor--;

    while (e->cursor > 0 &&
           e->text[e->cursor-1] != ' ')
        e->cursor--;
}

void delete_char(editor_t *e, const char *command) {
    int len = strlen(e->text);
    if (e->cursor >= len) return;
    strncpy(e->buf, e->text + e->cursor + 1, len - e->cursor); // include null
    strncpy(e->text + e->cursor, e->buf, len - e->cursor);
}

void delete_word(editor_t *e, const char *command) {
    int cur_pos = e->cursor;
    int len = strlen(e->text);
    skip_space(e);
    if (e->cursor == len) {
        e->cursor = cur_pos;
        return;
    }
    forward_word(e, "");
    strncpy(e->buf, e->text + e->cursor, len - e->cursor + 1);
    strncpy(e->text + cur_pos, e->buf, len - e->cursor + 1);
    e->cursor = cur_pos;
}

void insert(editor_t *e, const char *command) {
    int len = strlen(e->text);
    int cmd_len = strlen(command);
    int a_pos = 8, a_len = cmd_len - 9;
    strncpy(e->buf, e->text + e->cursor, len - e->cursor + 1);
    strncpy(e->text + e->cursor, command + a_pos, a_len);
    strncpy(e->text + e->cursor + a_len, e->buf, len - e->cursor + 1);
    e->cursor += a_len;
}

int main () {
    editor_t editor;
    char command[120];
    int i, j, k, n, m; 
    const char *commands[] = {
        "forward char",
        "forward word",
        "backward char",
        "backward word",
        "delete char",
        "delete word",
        "insert"
    };
    void (*handlers[])(editor_t*, const char*) = {
        forward_char,
        forward_word,
        backward_char,
        backward_word,
        delete_char,
        delete_word,
        insert
    };

    scanf("%d\n", &n);
    for (i = 0; i < n; i++) {
        editor.cursor = 0;
        gets(editor.text);
        scanf("%d\n", &m);
        for (j = 0; j < m; j++) {
            gets(command);
            for (k = 0; k < CMD_NUM; k++) {
                const char *cmd = commands[k];
                if (strncmp(cmd, command, strlen(cmd)) == 0) {
                    handlers[k](&editor, command);
                    break;
                }

            }
        }
        insert(&editor, "insert \"^\"");
        printf("%s\n", editor.text);
    }

    return 0;
}

Measured memory_bytes: 612
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <math.h>


long int merge(long int a1[], long int a2[], long int b1[], long int b2[], long int a1_size, long int a2_size, long int b1_size, long int b2_size, long int a[], long int b[]);
long int mergeSort(long int a[], long int a_size, long int b[], long int b_size);

int main(void)
{
	long int n;
	long int i, j;
	long int work;
	long int a[200000];
	long int b[200000];
	
	scanf("%ld", &n);
	
	for(i = 0; i < n; i++) {
		scanf("%ld", &a[i]);
		b[i] = i + 1;
	}
	
	if(n <= 30) {
		for(i = 0; i < n - 1; i++) {
			for(j = 0; j < n - 1 - i; j++) {
				if(a[j] > a[j + 1]) {
					work = a[j];
					a[j] = a[j + 1];
					a[j + 1] = work;
					
					work = b[j];
					b[j] = b[j + 1];
					b[j + 1] = work;
				}
			}
		}
		
		for(i = 0; i < n; i++) {
			printf("%ld ", b[i]);
		}
		return 0;
	}
	
	mergeSort(a, n, b, n);
	
	for(i = 0; i < n; i++) {
		printf("%ld ", b[i]);
	}
	//printf("%ld", b[n - 1]);
	
	return 0;
}

long int merge(long int a1[], long int a2[], long int b1[], long int b2[], long int a1_size, long int a2_size, long int b1_size, long int b2_size, long int a[], long int b[])
{
	long int i = 0, j = 0;
	
	while( (i < a1_size ) || (j < a2_size) ) {
		if( (j >= a2_size ) || ( (i < a1_size) && (a1[i] < a2[j]) ) ) {
			a[i + j] = a1[i];
			b[i + j] = b1[i];
			i++;
		} else {
			if( (a1[i] == a2[j]) && (b1[i] > b2[j]) ) {
				//printf("Ok\n");
				a[i + j]  = a1[i];
				b[i + j]  = b1[i];
				i++;
			} else {
				a[i + j] = a2[j];
				b[i + j] = b2[j];
				j++;
			}
		}
	}
	
	return 0;
}

long int mergeSort(long int a[], long int a_size, long int b[], long int b_size)
{
	long int m = a_size / 2, n = a_size - m;
	long int a1[m];
	long int a2[n];
	long int b1[m];
	long int b2[n];
	long int i, j;
	
	if(a_size > 1) {
		for(i = 0; i < m; i++) {
			a1[i] = a[i];
			b1[i] = b[i];
		}
		for(i = 0; i < n; i++) {
			a2[i] = a[m + i];
			b2[i] = b[m + i];
		}
		mergeSort(a1, m, b1, m);
		mergeSort(a2, n, b2, n);
		merge(a1, a2, b1, b2, m, n, m, n, a, b);
	}
	
	return 0;
}


Measured memory_bytes: 6016
#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(a, b) for(int unsafe_cnt=a; unsafe_cnt < b;unsafe_cnt++)
#define fn auto
#include <iostream>
#include <stdio.h>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;

void newline() {cout << endl;}
template <typename T> void display(T input){cout << input;}
template <typename T> void put(T input){display(input); newline();}
void iput(int input) {put(input);}

fn main() -> int {
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  bool flag=false;
  char prev;
  for(auto iter=s.begin(); iter != s.end(); iter++){
    if(iter!=s.begin()){
      if(*iter == prev){
        flag|=true;
      }
    }
    prev = *iter;
  }
  if(flag==true){
    put("no");
  } else {
    put("yes");
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, k;
const int maxN = (int)1e5 + 10;
int b[maxN];
int a[maxN];
int pref[maxN];
int f[maxN];
void upd(int i, int d) {
    if (i == 0) return;
    while (i <= n + 2) {
        f[i] += d;
        i = (i | (i - 1)) + 1;
    }
}
int sum(int r) {
    int ans = 0;
    while (r > 0) {
        ans += f[r];
        r &= (r - 1);
    }
    return ans;
}
int ge(int l, int r) {
    if (l > r) return 0;
    return sum(r) - sum(l - 1);
}
ll cnt(int mid) {
    memset(f, 0, sizeof f);
    for (int i = 1; i <= n; i++) {
        if (a[i] >= mid) b[i] = 1;
        else b[i] = 0;
        pref[i] = pref[i - 1] + b[i];
    }
    vector < pair < int, int > > all;
    for (int i = 0; i <= n; i++) {
        all.push_back(make_pair(2 * pref[i] - i, i));
    }
    sort(all.begin(), all.end());
    ll ans = 0;
    for (int i = 0; i < all.size(); i++) {
        auto t = all[i];
        upd(t.second + 2, 1);
        ans += ge(1, t.second + 1);
    }
    return ans;
}
int main() {
    srand(time(0));
    ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    int l = 1;
    int r = (int)1e9 + 1;
    ll val = (1LL * (n) * (n + 1)) / 2;
    ll lim = (val + 1) / 2;
    // l - ok
    while (r - l > 1) {
        int mid = (l + r) / 2;
        if (cnt(mid) >= lim) l = mid;
        else r = mid;
    }
    cout << l;
    return 0;
}

Measured memory_bytes: 3696
#include<bits/stdc++.h>
 
#define REP(i,s,N) for (int i=s;i<(N); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;


ll ans=0;

int main(){
	ll N;
	cin >> N;
	ll d[N];
  ll a;
	ll D = 0;
	REP(i,0,N){
		cin >> a;
		d[i] = a;
		D += d[i];
	}
	REP(i,0,N){
		D = D - d[i];
		ans += d[i]*D;
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};


int main(){
  int a,b,c,d; cin>>a>>b>>c>>d;
  int A=a*b;
  int B=c*d;
  if(a*b>c*d)
  cout<<A<<endl;
  else
  cout<<B<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int h,w;cin>>h>>w;
  char a[100][100];
  REP(i,h){
    REP(j,w){
      cin>>a[i][j];
    }
  }
  REP(i,w+2){
    cout<<'#';
  }
  cout<<"\n";
  REP(i,h){
    cout<<'#';
    REP(j,w){
      cout<<a[i][j];
    }
    cout<<'#'<<"\n";
  }
  REP(i,w+2){
    cout<<'#';
  }
  cout<<"\n";
  return 0;
}


Measured memory_bytes: 256
Imports System

Public Class Test
	Public Shared Sub Main()
        Dim s() As String
        Dim t() As String
        s = Split(Console.ReadLine())
        Dim n, z, w As Integer
        n = s(0)
        z = s(1)
        w = s(2)
        t = Split(Console.ReadLine())
        Dim a(n - 1) As Integer
        For i As Integer = 0 To n - 1
            a(i) = t(i)
        Next i
  		If n=1 then
    		Console.Writeline(math.abs(a(0)-w))
		Else
  			Console.Writeline(Math.Max(Math.Abs(a(n-1)-w),Math.Abs(a(n-1)-a(n-2))))
		End if
        End Sub
End Class

Measured memory_bytes: 13664
#include <stdio.h>
#define N 100005

typedef struct{
  int p;
  int l;
  int r;
} Node;

Node T[N];
int n,  D[N];

int rec(int u, int p){
  D[u] = p;
  if(T[u].r != -1) rec(T[u].r, p);
  if(T[u].l != -1) rec(T[u].l, p+1);
}

int main(){

  int i, j ,d, v, c, l ,r, k;
  
  scanf("%d", &n);
  for(i=0; i<n; i++){
    T[i].p = -1;
    T[i].l = -1;
    T[i].r = -1;
  }

  for(i=0; i<n; i++){
    scanf("%d", &v);
    scanf("%d", &d);
    for(j=0; j<d; j++){
      scanf("%d", &c);
      if(j == 0) T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }

  for(i=0; i<n; i++){
    if(T[i].p == -1) r = i;
  }
  rec(r, 0);
    
  for(i=0; i<n; i++){
    printf("node %d: ", i);
    printf("parent = %d, ", T[i].p);
    printf("depth = %d, ", D[i]);

    if(T[i].p == -1) printf("root, ");
    else if(T[i].l == -1) printf("leaf, ");
    else printf("internal node, ");

    printf("[");
    for(j=0, k = T[i].l; k != -1; j++, k = T[k].r){
      if(j) printf(", ");
      printf("%d", k);
    }
    printf("]\n");
  }
  
  return 0;
}

Measured memory_bytes: 5300
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)





int main() {
    ll h, w, k;
    cin >> h >> w >> k;
    vector<vector<ll>> c(h, vector<ll>(w));
    REP(i, h){
        string s;
        cin >> s;
        REP(j, w){
            c[i][j] = s[j] - '0';
        }
    }
    
    ll ans = 0;
    REP(i, h){REP(j, w){
        vector<vector<ll>> v = c;
        v[i][j] = 0;
        for(ll l = i - 1; l >= 0; l--){
            v[l + 1][j] = v[l][j];
            v[l][j] = 0;
        }
        
        bool deleted = true;
        ll sum = 0;
        for(ll r = 1; deleted; r *= 2){
            deleted = false;
            ll s = 0;
            for(ll l = 0; l < h; l++){
                for(ll m = 0; m <= w - k; m++){
                    if(v[l][m] == 0) continue;
                    ll n;
                    for(n = m + 1; n < w; n++){
                        if(v[l][m] != v[l][n]){
                            break;
                        }
                    }
                    if(n - m >= k){
                        ll t = v[l][m];
                        for(ll o = m; o < n; o++){
                            v[l][o] = 0;
                            s += t;
                        }
                        deleted = true;
                    }
                }
            }
            s *= r;
            sum += s;
            
            for(ll l = h - 1; l > 0; l--){
                for(ll m = 0; m < w; m++){
                    if(v[l][m] == 0){
                        ll n;
                        for(n = l - 1; n >= 0; n--){
                            if(v[n][m] != 0){
                                break;
                            }
                        }
                        if(n >= 0){
                            v[l][m] = v[n][m];
                            v[n][m] = 0;
                        }
                    }
                }
            }
        }
        
        ans = max(ans, sum);
    }}
    cout << ans << endl;
}


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

int main() {
	int N;
	cin >> N;
	vector<int> H(N);
	for(int i=0; i<N; i++){
	    cin >> H[i];
	}
	int flag = 0, count = 1;
	for(int i=1; i<N; i++){
	    flag = 0;
	    for(int j=0; j<i; j++){
	        if(H[j] > H[i]){
	            flag = 1;
	            break;
	        }
	    }
	    if(flag == 0)
	    count++;
	}
	
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <time.h>

int
main(void)
{
	char line[80];

	int m, d;
	
	while (true) {
		if (fgets(line, sizeof line, stdin) == NULL) {
			return 0;
		}
		if (sscanf(line, "%d %d", &m, &d) != 2) {
			return 0;
		}

		if (m == 0) {
			return 0;
		}
		
		struct tm tm0;
		memset(&tm0, 0, sizeof tm0);
		
		tm0.tm_year = 2004-1900;
		tm0.tm_mon = m - 1;
		tm0.tm_mday = d;

		time_t t = mktime(&tm0);
		
		struct tm* tm1 =localtime(&t);
		
		strftime(line, sizeof line, "%A", tm1);

		printf("%s\n", line);
	}

	return 0;
}

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

using namespace std;

bool ispossible(int div,int n,int k,vector<int> &a){
	vector<int> md(n,0);
	for(int i=0;i<n;i++){
		md[i]=a[i]%div;
	}
	sort(md.rbegin(),md.rend());
	/*if(div==7){
		for(int i=0;i<n;i++){
			printf("%d ",md[i]);
		}
		printf("\n");
	}*/
	int left=0,right=0,i=0,j=n-1;
	while(i<=j){
		/*if(div==7){
			printf("%d %d\n",left,right);
		}*/
		if(left<right){
			left+=div-md[i];
			i++;
		}
		else{
			right+=md[j];
			j--;
		}
	}
	/*if(div==7){
		printf("%d\n",left);
	}*/
	return left<=k;
}

int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	vector<int> a(n,0);
	for(int &i:a){
		scanf("%d",&i);
	}	
	int sum=0;
	for(int i=0;i<n;i++){
		sum+=a[i];
	}
	int ans=1;
	for(int div=1;div<=floor(sqrt(sum));div++){
		if(sum%div){
			continue;
		}
		if(ispossible(div,n,k,a)){
			ans=max(ans,div);
		}
		if(ispossible(sum/div,n,k,a)){
			ans=max(ans,sum/div);
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256