akhauriyash/Code-Regression huggingface dataset:
//#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define MAX_INT 2100000000
#define ex5 (100000+10)
using namespace std;
typedef long long int ll;
#ifdef COMPILE_IN_VCPP
#include <windows.h>
HWND GetConsoleHwnd(void)
{
#define MY_BUFSIZE 1024 // Buffer size for console window titles.
	HWND hwndFound;         // This is what is returned to the caller.
	char pszNewWindowTitle[MY_BUFSIZE]; // Contains fabricated// WindowTitle.
	char pszOldWindowTitle[MY_BUFSIZE]; // Contains original// WindowTitle.
	ULARGE_INTEGER nt;
	nt.QuadPart = GetTickCount64();
	GetConsoleTitle(pszOldWindowTitle, MY_BUFSIZE);
	wsprintf(pszNewWindowTitle, "%d%d/%d",nt.HighPart,nt.LowPart,GetCurrentProcessId());
	SetConsoleTitle(pszNewWindowTitle);
	Sleep(40);
	hwndFound = FindWindow(NULL, pszNewWindowTitle);
	SetConsoleTitle(pszOldWindowTitle);
	return(hwndFound);
}
#endif
int main()
{
#ifdef COMPILE_IN_VCPP
	SetWindowPos(GetConsoleHwnd(), HWND_TOPMOST, 0, 0, 0, 0,
		(SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW));
#endif
	int w, h, x, y, a, b, c;
	cin >> w >> h >> x >> y;
	cout << (double)w * h / 2.0;
	if (x * 2 == w && y * 2 == h) a = 1;
	else a = 0;
	cout <<' '<<a << endl;
}


Measured memory_bytes: 256
#include <iostream>

long long DivisibleCount(long long, long long);

using namespace std;

int main()
{
	long long a, b, x;

	cin >> a >> b >> x;

	cout << DivisibleCount(b, x) - DivisibleCount(a - 1, x) << endl;

	return 0;
}

long long DivisibleCount(long long n, long long x)
{
	if (n == -1)
		return 0;
	else
		return n / x + 1;
}


Measured memory_bytes: 256
#include<cstdio>
#include<stack>
using namespace std;

stack<int> a;

int getnum(char *s){
    int num = 0;
    for(int i = 0; s[i] != '\0'; i ++){
        num = num * 10 + s[i] - '0';
    }
    return num;
}

int main(){
    char s[10];
    int x, y;
    while(~scanf("%s", s)){
        if(s[0] == '+'){
            y = a.top();
            a.pop();
            x = a.top();
            a.pop();
            a.push(x + y);
        }
        else if(s[0] == '-'){
            y = a.top();
            a.pop();
            x = a.top();
            a.pop();
            a.push(x - y);
        }
        else if(s[0] == '*'){
            y = a.top();
            a.pop();
            x = a.top();
            a.pop();
            a.push(x * y);
        }
        else{
            a.push(getnum(s));
        }
    }
    printf("%d\n", a.top());
    return 0;
}



Measured memory_bytes: 2744
#include <bits/stdc++.h>
using namespace std;
#define INF 1001001001

int main() {
    int N,M;
    cin >> N >> M;
    int a[1000], b[1000],c[1000];
    int dist[100][100];
    for(int i=0; i<M; ++i) {
        cin >> a[i] >> b[i] >> c[i];
        --a[i]; --b[i];
    }

    for(int i=0; i<N; ++i) {
        for(int j=0; j<N; ++j) {
            dist[i][j] = INF;
        }
        dist[i][i] = 0;
    }
    for(int i=0; i<M; ++i) {
        dist[a[i]][b[i]] = c[i];
        dist[b[i]][a[i]] = c[i];
    }
    
    for(int k=0; k<N; ++k) {
        for(int i=0; i<N; ++i) {
            for(int j=0; j<N; ++j) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    int ans = M;
    for(int i=0; i<M; ++i) {
        for(int s=0; s<N; ++s) {
            if(dist[s][a[i]] + c[i] == dist[s][b[i]]) {
                --ans;
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <utility>
#include <vector>
 
using namespace std;
 
using P = pair<int, int>; // (dist, node's id)
using PPI = pair<P, int>;
 
const int inf = 1 << 28;
 
int N, A, B, C;
 
P cost[3][20000];
vector<int> G[20000];
int old_id[20000];
 
void dijkstra(int s) {
    for (int v = 0; v < N; v++) {
        cost[s][v] = {inf, inf};
    }
 
  cost[s][s] = {0, old_id[s]};
 
  priority_queue<PPI, vector<PPI>, greater<PPI>> Q;
  Q.push({{0, old_id[s]}, s});
  while (!Q.empty()) {
        auto q = Q.top();
        Q.pop();
        P val = q.first;
        int v = q.second;
    
        if (cost[s][v] < val) continue;
 
        for (int to : G[v]) {
            P nval = make_pair(val.first + 1, min(val.second, old_id[to]));
            if (cost[s][to] > nval) {
                cost[s][to] = nval;
                Q.push({nval, to});
            }
        }
    }
}
 
int main() {
  cin >> N >> A >> B >> C;
 
  int mina = inf, minb = inf, minc = inf;
 
  static int group[20000];
  memset(group, -1, sizeof(group));
  for (int i = 0; i < A; i++) {
    int a;
    cin >> a;
    a--;
    group[a] = 0;
 
    mina = min(mina, a);
  }
  for (int i = 0; i < B; i++) {
    int b;
    cin >> b;
    b--;
    group[b] = 1;
 
    minb = min(minb, b);
  }
  for (int i = 0; i < C; i++) {
    int c;
    cin >> c;
    c--;
    group[c] = 2;
 
    minc = min(minc, c);
  }
  map<int, int> mp;
  int id = 3;
 
  old_id[0] = mina;
  old_id[1] = minb;
  old_id[2] = minc;
 
  for (int v = 0; v < N; v++) {
    if (0 <= group[v] and group[v] < 3)
      mp[v] = group[v];
    else {
      mp[v] = id++;
      old_id[mp[v]] = v;
    }
}
  // static bool state[3][3];
 
  int M;
  cin >> M;
  for (int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
 
    G[mp[x]].emplace_back(mp[y]);
    G[mp[y]].emplace_back(mp[x]);
 
    /*
    if (mp[x] < 3 and mp[y] < 3) {
      state[mp[x]][mp[y]] = state[mp[y]][mp[x]] = true;
    }
    */
  }
 
  // (1) 3 group is connected
  // state[0][0] = state[1][1] = state[2][2] = true;
  /*
  for (int r = 0; r < 3; r++) {
    int cnt = 0;
    for (int c = 0; c < 3; c++) {
      cnt += state[r][c];
    }
    if (cnt == 3) {
      cout << 2 << " " << min({mina, minb, minc}) + 1 << endl;
      return 0;
    }
}
*/
  // (2) 2 group is connected
  /*
  int g1 = -1, g2 = -1;
  for (int r = 0; r < 3; r++) {
    for (int c = 0; c < 3; c++) {
      if (r != c and state[r][c]) {
        g2 = c;
        break;
      }
    }
    if (g2 >= 0) {
      g1 = r;
      break;
    }
}
*/
  // Dijkstra
    for (int s = 0; s < 3; s++) {
        dijkstra(s);
    }
 
    P score = {inf, inf};
    for (int v = 0; v < id; v++) {
        score =
            min(score,
                {cost[0][v].first + cost[1][v].first + cost[2][v].first,
                min({cost[0][v].second, cost[1][v].second, cost[2][v].second})});
    }
    cout << score.first << " " << score.second + 1 << endl;

    return 0;
}

Measured memory_bytes: 9856
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <fstream>

#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
#include <functional>
#include <stack>
#include <cassert>

using namespace std;

constexpr int MAX = 10*40;
constexpr int MXVAL = 1 << 29;

class atD {
public:
    void solve(istream &in, ostream &out) {
        int N, Ma, Mb;
        in >> N >> Ma >> Mb;
        
        vector<int> a(N), b(N), c(N);
        for (int i = 0; i < N; ++i) {
            in >> a[i] >> b[i] >> c[i];
        }
        
        vector<vector<int>> dp(MAX + 1, vector<int>(MAX + 1, MXVAL));
        dp[0][0] = 0;
        
        for (int m = 0; m < N; ++m) {
            vector<vector<int>> dpnew(MAX + 1, vector<int>(MAX + 1, MXVAL));
    
            for (int i = 0; i <= MAX; ++i) {
                for (int j = 0; j <= MAX; ++j) {
                    dpnew[i][j] = min(dpnew[i][j], dp[i][j]);
                    
                    if (i - a[m] >= 0 && j - b[m] >= 0) {
                        dpnew[i][j] = min(dpnew[i][j], dp[i - a[m]][j - b[m]] + c[m]);
                    }
                }
            }
            
            dp = dpnew;
        }
        
        /*for (int i = 0; i <= 20; ++i) {
            for (int j = 0; j <= 20; ++j) {
                cout << (dp[i][j] == MXVAL ? -1 : dp[i][j]) << " ";
            }
            cout << endl;
        }*/
        
        int res = MXVAL;
        /*for (int i = 0; i <= MAX; ++i) {
            for (int j = 0; j <= MAX; ++j) {
                if (i && i * Ma == j * Mb) {
                    res = min(res, dp[i][j]);
                }
            }
        }*/
        for (int i = 1; i * Ma <= MAX && i * Mb <= MAX; ++i) {
            res = min(res, dp[i * Ma][i * Mb]);
        }
        
        out << (res == MXVAL ? -1 : res) << endl;
    }
};


int main() {
	std::ios::sync_with_stdio(false);

	atD solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1604
N = int(input())
a = list(map(int, input().split()))
b = [ (a[i], i, 0) for i in range(N)]

b.sort(key= lambda x: (-x[0], x[1]))

# print(b)

mini = 0

for i in range(N-1):
    if b[i][1] < b[mini][1]:
        mini = i

    b[mini] = b[mini][0], b[mini][1], b[mini][2] + (b[i][0]-b[i+1][0])*(i+1)

if b[N-1][1] < b[mini][1]:
    mini = N-1
b[mini] = b[mini][0], b[mini][1], b[mini][2] + (b[N-1][0])*N

b.sort(key = lambda x: x[1])

for x in b:
    print(x[2])


Measured memory_bytes: 29696
#define _GLIBCXX_DEBUG
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;

/*int P[10010];
void init(int n){
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対set,グラフ？
//セグメント木？？？
*/

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

#define mod 1000000007
/*ll f[2001];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination//ただしfは用意してね
*/

struct BIT{
    vector<int> dat;
    int sz;
    BIT(int n){
        for(sz=1;sz<n;sz *= 2);
        dat.resize(++sz);
    }
    int q(int n){
        int ret = 0;
        for(int i=n;i>0;i-=i&-i)ret +=dat[i];//和の計算　iから最後の１のbit(i&-i 多分＆はビット積)を減算
        for(int i=n;i<sz;i+=i&-i) dat[i]++;//値の加算　iから最後mの１のbitを加算
        return ret;
    }
};

int main(){
    int n , k;
    cin >> n>> k;
    double ans=0;
    rep2(i,n){
        int c=i;
        int num=0;
        while(c<k){
            c*=2;
            num++;
        }
        double l=1.0;
        while(num){
            l*=0.5;
            num--;
        }
        ans+=l/n;
    }
    printf("%.12f\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

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

int main() {
    ll n, c, k;
    cin >> n >> c >> k;
    vector<ll> t;
    for(int i = 0; i < n; i++){
        ll in;
        cin >> in;
        t.push_back(in);
    }
    sort(t.begin(), t.end());
    ll ans = 0;
    ll time = 0;
    ll passenger = c;
    for(int i = 0; i < n; i++){
        if((passenger == c) || (t[i] > time + k)){
            ans++;
            time = t[i];
            passenger = 0;
        }
        passenger++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> PII;
typedef queue<int> QI;

const LL mod=1000000007;
LL powmod(LL a,LL b) {LL res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head
int m,mi,a[23333];

int main(){
    int n;scanf("%d",&n);m=0;mi=999;memset(a,0,sizeof(a));rep(i,0,n){int x;scanf("%d",&x);a[x]++;if(x>m)m=x;if(x<mi)mi=x;}
    if(a[m]==1)cout<<"Impossible"<<endl;
    else{
        int now=m/2;if(m%2){
            now++;
            if(mi!=now)cout<<"Impossible"<<endl;
            else{
                if(a[now]!=2)cout<<"Impossible"<<endl;
                else {
                        bool flag=false;
                        rep(i,now+1,m)if(a[i]<1)flag=true;
                        if(flag)cout<<"Impossible"<<endl;else cout<<"Possible"<<endl;
                }
            }
        }else{
            if(mi!=now)cout<<"Impossible"<<endl;
            else{
                if(a[now]!=1)cout<<"Impossible"<<endl;
                else {
                        bool flag=false;
                        rep(i,now+1,m)if(a[i]<1)flag=true;
                        if(flag)cout<<"Impossible"<<endl;else cout<<"Possible"<<endl;
                }
            }
        }
    }
	return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define NMAX 100
#define INF 100000000

//??????????????¢??????????????¨debug()??????????????????
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef pair<int ,int > P;
typedef long long ll;

int N,ans = 0;
int d[NMAX] = {};
vector<P> connect[NMAX];

void solve(){
	d[0] = 0;
	priority_queue<P, vector<P>, greater<P> > que;
	que.push(P(0,0));
	while(!que.empty()){
		P p = que.top();
		// cout << "P(" << p.first << "," << p.second << ")\n";
		que.pop();
		int v = p.first;
		if(d[v] < p.second) continue;
		for (int i = 0; i < connect[v].size(); ++i)
		{
			if(d[connect[v][i].first] > d[v] + connect[v][i].second){
				d[connect[v][i].first] = d[v] + connect[v][i].second;
				que.push(P(connect[v][i].first,d[connect[v][i].first]));
			}
		}
	}
}

void debug(){

}

void answer(){
	for (int i = 0; i < N; ++i)
	{
		cout << i << " " << d[i] << "\n";
	}
}

int main(){
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		int a,b;
		cin >> a >> b;
		for (int j = 0; j < b; ++j)
		{
			int k,l;
			cin >> k >> l;
			connect[a].push_back(P(k,l));
		}
	}
	Fill(d,INF);
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

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

using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  if (A == 1) A = 14;
  if (B == 1) B = 14;
  if (A < B) cout << "Bob" << endl;
  else if (A > B) cout << "Alice" << endl;
  else cout << "Draw" << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main() {
	string s; cin >> s;
	int res = 500;
	for (int i = 0; i < 26; i++)
	{
		string t = s;
		int cnt = 0;
		while (true)
		{
			bool ok = true;
			char c = 'a' + i;
			for (int j = 0; j < t.size(); j++)
			{
				if(t[j] != c) ok = false;
			}
			if(ok) break;
			else {
				cnt++;
				for (int j = 0; j < t.size() - 1; j++)
				{
					if(t[j] == c || t[j+1] == c) t[j] = c;
				}
				t.erase(t.size() - 1);
			}
//			cout << t << endl;
		}
		res = min(res, cnt);
	}

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main() {
    double N; cin>>N;
    double T,A; cin>>T>>A;
    vector<double> H(N);
    for(int i=0;i<N;i++){
        cin>>H[i];
    }
    double sa;
    double minimum=9999999;
    int ans=0;
    for(int i=0;i<N;i++){
        sa=abs(A-(T-(H[i]*0.006)));
        if(minimum>sa){
            ans=i+1;
        }
        minimum=min(sa,minimum);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>



using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,b,a) for(int i = (b) - 1; i>= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a)

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef  long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const double EPS = 1e-7;
const int MAX = 20 * 1000 + 47;
const int MAS = 1e5 * 6;
const int MOD = 1000 * 1000 * 1000 + 7;

double DIST(double x1, double x2, double y1, double y2)
{
    return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
}






int main()
{
    int n, w;
    cin >> n >> w;
    vector<pair<int,int >>  v(n);
    vector<LL> dp(w + 1);
   rep(i,n)
   {
       int v, cost;
       cin >> v >> cost; 
      RFOR(i,w-v + 1,0)
       {
           dp[i + v] = max(dp[i + v], dp[i] + cost);
       }

   }
   LL ans = 0; 
    rep(i, w+ 1)
    {
        //cout << dp[i] << endl; 
        ans = max((LL)ans, dp[i]); 
    }
    cout << ans << endl; 


}










Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int A[4];
void output(int i,int j,int k){
     string ans="";
     ans.push_back('0'+A[0]);
     if(i==0){
        ans.push_back('+');
     }else{
        ans.push_back('-');
     }
     ans.push_back('0'+A[1]);
     if(j==0){
        ans.push_back('+');
     }else{
        ans.push_back('-');
     }
     ans.push_back('0'+A[2]);
     if(k==0){
        ans.push_back('+');
     }else{
        ans.push_back('-');
     }
     ans.push_back('0'+A[3]);
     ans=ans+"=7";
     cout<<ans<<endl;
}

int main(){
    string s;
    cin>>s;
    REP(i,4){
        A[i]=s[i]-'0';
    }
    REP(i,2){
        REP(j,2){
            REP(k,2){
LL a=A[0];
        if(i==0){
           a+=A[1];
        }else{
           a-=A[1];
        }
            if(j==0){
               a+=A[2];
            }else{
               a-=A[2];
            }
               if(k==0){
                  a+=A[3];
               }else{
                  a-=A[3];
}
               if(a==7){
                  output(i,j,k);
                  return 0;
               }
            }
        }
    }
	return(0);
}

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

int main() {
  vector<int> a(3);
  rep(i,3) cin>>a.at(i);
  sort(a.begin(),a.end());
  cout<<a.at(0)+a.at(1)<<endl;
}

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

int main(){
int n;
  cin >> n;
int j=0;  
int a[100000];
  for(int i=0;i<n;i++) cin >> a[i];
sort(a,a+n);
  int res=0;
  int f;
  while(j<n){
   int cc=a[j];
   f=0;
    while(j<n && a[j]==cc){
      j++;
      f++;     
      }
    res+=f%2;
  
  }
 cout << res << endl; 


}


Measured memory_bytes: 3940
#include <stdio.h>
#include <math.h>

#define MAX 1000000

int checkPrime(int);
void init(void);
void printAnswer(int);

int prime[MAX],num;

int main(int argc, char const* argv[])
{
	init();

	char s[128];
	int i;

	while(fgets(s,sizeof(s),stdin) != NULL){
		sscanf(s,"%d",&i);
		printAnswer(i);
	}

	return 0;
}

void init(void){

	int i;

	prime[num++] = -1;			//ツ氾板閉コ

	for(i = 2;i <= MAX;i++){
		if(checkPrime(i)){
			prime[num++] = i;
		}
	}
	prime[num] = 10000000;		//ツ氾板閉コ
}

int checkPrime(int n){

	if(n < 2)return 0;

	int r = (int)sqrt(n);
	int i;


	for(i = 2;i <= r;i++){
		if(n % i == 0)return 0;
	}
	return 1;

}

void printAnswer(int n){

	int ans,num = 0;
	while(1){
		if((prime[num] <= n) && (prime[num+1] > n)){
			ans = num;
			break;
		}
		num++;
	}
	printf("%d\n",ans);

}

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

int longestPath(vector<vector<int>> &graph,vector<bool> &vis,vector<int> &dp,int i,int n){
    vis[i] = true;
    
    if(dp[i] != -1){
        return dp[i];
    }
    dp[i] = 0;
    for(int j:graph[i]){
        dp[i] = max(dp[i],longestPath(graph,vis,dp,j,n) + 1);
    }
    
    return dp[i];
}


int main() {
    int n,m,x,y;
    cin>>n>>m;
    vector<vector<int>> graph(n+1);
    vector<bool> vis(n+1,false);
    vector<int> dp(n+1,-1);
    for(int i=0;i<m;i++){
        cin>>x>>y;
        graph[x].push_back(y);
    }
    int ans = 0;
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            ans = max(ans,longestPath(graph,vis,dp,i,n));
        }else{
            ans = max(ans,dp[i]);
        }
    }
    cout<<ans<<endl;
	return 0;
}

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

bool ok(string s) {
    int len = s.size();
    bool ok = true;
    for(int i = 0; i < len/2; i++) {
        if(s.at(i) != s.at(len-i-1))
            return false;
    }
    return true;
}

int main() {
    string S,s1,s2;
    s1 = "";
    s2 = "";
    cin >> S;
    int len = S.size();
    for(int i = 0; i < (len-1)/2; i++) {
        s1 += S.at(i);
    }
    for(int i = (len+3)/2 -1 ; i < len; i++) {
        s2 += S.at(i);
    }
    //cout << s1 << " " << s2 << endl;
    //cout << kaibun_ok(S) << endl;
    if(ok(S) && ok(s1) && ok(s2)) {
        cout << "Yes" << endl;
    } else cout << "No" << endl;
}

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

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int n;cin>>n;

  cout << n*(n-1)/2 << endl;
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


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

int N,M,Q,m;
const int maxn=600000+5;
int siz;
int C[maxn],a[maxn],ret[maxn];
struct node{
	int l,r,id;
	bool operator<(const node& other)const{
		return other.r > r;
	}
}x[maxn],y[maxn];

void add(int x,int v){
	for(int i=x;i<=m;i+=i&-i) C[i]+=v;
}

int sum(int x){
	int ret=0;
	for(int i=x;i;i-=i&-i) ret+=C[i];
	return ret;
}

int main(){
	cin>>N>>M>>Q;
	for(int i=0;i<M;i++){
		cin>>x[i].l>>x[i].r;
		a[siz++]=x[i].l;
		a[siz++]=x[i].r;
	}
	for(int i=0;i<Q;i++){
		cin>>y[i].l>>y[i].r;
		y[i].id=i;
		a[siz++]=y[i].l;
		a[siz++]=y[i].r;
	}
	sort(a,a+siz);
	m=unique(a,a+siz)-a;
	for(int i=0;i<M;i++){
		x[i].l=lower_bound(a,a+m,x[i].l)-a+1;
		x[i].r=lower_bound(a,a+m,x[i].r)-a+1;
	}
	for(int i=0;i<Q;i++){
		y[i].l=lower_bound(a,a+m,y[i].l)-a+1;
		y[i].r=lower_bound(a,a+m,y[i].r)-a+1;
	}
	sort(x,x+M);
	sort(y,y+Q);
	int j=0;
	for(int i=0;i<Q;i++){
		while(j<M&&x[j].r<=y[i].r) add(x[j++].l,1);
		ret[y[i].id]=j-sum(y[i].l-1);
	}
	for(int i=0;i<Q;i++) cout<<ret[i]<<endl;
	return 0;
}

Measured memory_bytes: 9864
import sys
from collections import defaultdict

class UnionFind:
    def __init__(self, n):
        self.root = [i for i in range(n)]
        self.rank = [0] * n

    def find(self, x):
        if self.root[x] == x:
            return x
        else:
            y = self.find(self.root[x])
            self.root[x] = y
            return self.root[x]

    def unite(self, x, y):
        if self.is_same(x, y):
            return
        rx = self.find(x)
        ry = self.find(y)
        if self.rank[rx] < self.rank[ry]:
            self.root[rx] = ry
        else:
            self.root[ry] = rx
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    def is_same(self, x, y):
        return self.find(x) == self.find(y)
    

def main():
    input = sys.stdin.readline
    V = 10**5  # max size of x
    N = int(input())
    uft = UnionFind(2*V)
    for _ in range(N):
        x, y = map(int, input().split())
        x -= 1
        y += V - 1
        uft.unite(x, y)

    cnt_x = defaultdict(lambda: 0)
    cnt_y = defaultdict(lambda: 0)
    for i in range(2*V):
        root = uft.find(i)
        if i < V:  # node of x coordinate.
            cnt_x[root] += 1
        else:
            cnt_y[root] += 1

    ans = 0
    for root in cnt_x.keys():
        ans += cnt_x[root] * cnt_y[root]

    return ans - N


if __name__ == '__main__':
    print(main())


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

int main() {

  long long int n;
  cin >> n;

  for ( long long int i = 0; i < n; i++ ) {

    string o, in;
    cin >> o >> in;

    for ( long long int j = o.size() - 1; j >= 0; j-- ) {

      if ( o[j] == 'J' ) {
	in = in[ in.size() - 1 ] + in.substr( 0, in.size() - 1 );
      }else if ( o[j] == 'C' ) {
	in = in.substr( 1, in.size() - 1 ) + in[0];
      }else if ( o[j] == 'E' ) {
	long long int k = in.size() / 2;
	if ( ( in.size() % 2 ) == 0 ) {
	  in = in.substr( k, k ) + in.substr( 0, k );
	}else {
	  in = in.substr( k + 1, k ) + in[k] + in.substr( 0, k );
	}
      }else if ( o[j] == 'A' ) {
	string s = "";
	for ( long long int x = in.size() - 1; x >= 0; x-- ) {
	  s += in[x];
	}
	in = s;
      }else if ( o[j] == 'M' ) {
	for ( long long int x = 0; x < in.size(); x++ ) {
	  if ( in[x] >= '0' && in[x] < '9' ) {
	    in[x]++;
	  }else if ( in[x] == '9' ) {
	    in[x] = '0';
	  }
	}
      }else if ( o[j] == 'P' ) {
	for ( long long int x = 0; x < in.size(); x++ ) {
	  if ( in[x] > '0' && in[x] <= '9' ) {
	    in[x]--;
	  }else if ( in[x] == '0' ) {
	    in[x] = '9';
	  }
	}
      }

    }

    cout << in << endl;

  }

  return 0;

}

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

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

typedef long long ll;

const int INF = 1e8;

int main() {
  int w, h, n; cin >> w >> h >> n;
  int x[n], y[n], a[n]; rep(i, n) cin >> x[i] >> y[i] >> a[i];
  
  int xl = 0, xu = w, yl = 0, yu = h;
  rep(i, n){
    switch(a[i]){
      case 1:
        if(xl < x[i] && x[i] < xu) xl = x[i];
        else if(xu <= x[i]) xl = xu;
        break;
      case 2:
        if(x[i] <= xl) xu = xl;
        else if(xl < x[i] && x[i] < xu) xu = x[i];
        break;
      case 3:
        if(yl < y[i] && y[i] < yu) yl = y[i];
        else if(yu <= y[i]) yl = yu;
        break;
      case 4:
        if(y[i] <= yl) yu = yl;
        else if(yl < y[i] && y[i] < yu) yu = y[i];
        break;
    }
  }
  
  // cout << xu << " " << xl << endl;
  // cout << yu << " " << yl << endl;
    
  cout << (xu-xl)*(yu-yl) << endl;
}


Measured memory_bytes: 256
import numpy as np
n = int(input())
A =sorted([int(input()) for _ in range(n)])
l = n//2
if n%2:
  a = 2*sum(A[n-(l-1):]) + A[n-l] + A[n-(l+1)] - 2*sum(A[:n-(l+1)])
  b = 2*sum(A[n-l:]) - A[n-(l+1)] - A[n-(l+2)] - 2*sum(A[:n-(l+2)])
  print(max(a, b))
else:
  t = 2*sum(A[n-(l-1):]) + A[n-l] - A[n-(l+1)] - 2*sum(A[:n-(l+1)])
  print(t)

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

#define ll long long
#define deb(x) cerr << #x << ":" << x << "\n"
#define all(x) x.begin(),x.end()
#define sz(x) x.size()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int n,q;
vector<int> v;
vector<pair<int,int>> queries;
int block_size;
map<pair<int,int>,int> mp;

void process(){
    int curL=0,curR=-1;
    vector<int> cur(n+1);
    int ans=0;
    for(auto P:queries){
        int l=P.first-1,r=P.second-1;
        while(curL<l){
            cur[v[curL]]--;
            ans-=(cur[v[curL]]==0);
            curL++;
        }
        while(curL>l){
            cur[v[curL-1]]++;
            ans+=(cur[v[curL-1]]==1);
            --curL;
        }
        while(curR<r){
            cur[v[curR+1]]++;
            ans+=(cur[v[curR+1]]==1);
            ++curR;
        }
        while(curR>r){
            cur[v[curR]]--;
            ans-=(cur[v[curR]]==0);
            --curR;
        }
        mp[P]=ans;
    }
}

void solve()
{
    cin>>n>>q;
    v.resize(n);
    for(auto &x:v)cin>>x;
    queries.resize(q);
    for(auto &P:queries)cin>>P.first>>P.second;
    vector<pair<int,int>> dummy(queries);
    block_size=int(sqrt(n));
    sort(all(queries),[&](pair<int,int> a,pair<int,int> b){
        if((a.first/block_size)!=(b.first/block_size))return (a.first/block_size)<(b.first/block_size);
        return a.second<b.second;
    });
    process();
    for(auto P:dummy)cout<<mp[P]<<"\n";
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 46136
l = input().split(" ")
a = int(l[0])
b = int(l[1])
c = int(l[2])
k = int(input())
i = 0
while b <= a :
    b = b * 2
    i = i + 1
while c <= b :
    c = c * 2
    i = i + 1
if i <= k :
    print("Yes")
else:
    print("No")

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

using namespace std;
const int maxn = 1e5+10;
int main()
{
	int n;
	cin >> n;
	string s[maxn];
	int cnt = 0;
	int x = 0,y = 0, z = 0; 
	for(int i = 0;i < n;i ++){
		cin >> s[i];
		int l =s[i].size();
		for(int j = 1;j < l;j ++){
			if(s[i][j - 1] =='A' && s[i][j] == 'B'){
				cnt ++;
			}
		}
		if(s[i][0] == 'B') x ++;
		if(s[i][l-1] == 'A') y++;
		if(s[i][l-1] == 'A' && s[i][0] =='B') z ++;
	}
	if(x < y)  cnt += x;
	else cnt += y;
	if(x == y && y == z && z != 0) cnt --;
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b,c;
    cin >> a >> b >> c;
    
    set<int> s;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    if(s.size()==2) cout <<"Yes"<<"\n";
    else cout << "No" << "\n";

    



}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);


int d;
int s[365][26];
int c[26];


int calc(vector<int> &v) {
	int sum = 0;
	int las[26]; rep(i, 26)las[i] = 0;
	

	int dec = 0;
	rep(j, 26)dec += c[j];

	int aldec = 0;

	rep(i, d) {
		aldec -= c[v[i]] * (i - las[v[i]]);

		sum += s[i][v[i]];
		las[v[i]] = i;

		sum -= aldec;
		aldec += dec;
	}
	return max(sum, 0);
}

void query(vector<int> v) {
	rep(i, d) {
		cout << v[i] + 1 << "\n";
	}
}
void solve() {
	cin >> d;
	rep(i, 26)cin >> c[i];
	rep(i, d)rep(j, 26)cin >> s[i][j];

	//init_answer
	vector<int> v;
	int las[26]; rep(j, 26)las[j] = 0;
	int sum = 0;

	rep(i, d) {
		int ma = -mod;
		int chk = -1;
		rep(j, 26) {
			int ad = s[i][j];
			ad += c[j] * (i - las[j]);
			if (ma < ad) {
				ma = ad;
				chk = j;
			}
		}
		v.push_back(chk);
		las[chk] = i;

		sum += s[i][chk];
		rep(j, 26){
			sum -= c[j] * (i - las[j]);
		}
	}

	random_device rnd;
	mt19937 mt(rnd());
	uniform_int_distribution<> ud(0, d - 1);
	uniform_real_distribution<> rd(0.0,1.0);
	vector<int> alt = v;


	int cur=sum;

	int ans = cur;
	vector<int> out = v;

	const int tm = 30000;
	double arfa = 0.99;
	rep(i, tm) {
		int id = ud(mt);
		rep(j, 26) {
			if (j == v[id])continue;
			alt[id] = j;
			int val = calc(alt);
			if (ans < val) {
				v=alt;
				cur = val;

				out = alt;
				ans = val;
				break;
			}
			double d = rd(mt);
			double d1 = exp((cur - val) / pow(arfa, (i / (double)tm)));
			if (d <= d1) {
				v = alt;
				cur = val;
				break;
			}
		}
		alt = v;
	}

	query(v);
}


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


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

int main() {
	int N; cin >> N;
	int A[100010], B[100010], C[100010];
	for(int i=0; i<N; ++i) cin >> A[i];
	for(int i=0; i<N; ++i) cin >> B[i];
	for(int i=0; i<N; ++i) cin >> C[i];
	sort(A, A+N);
	sort(B, B+N);
	sort(C, C+N);
	long b[100010], c[100010];
	int j=0;
	for(int i=0; i<N; ++i){
	    while(j<N){
	        if(A[j]>=B[i]) break;
	        ++j;
	    }
	    b[i]=j;
	}
	j=0; c[0]=0;
	for(int i=0; i<N; ++i){
	    if(i) c[i]=c[i-1];
	    while(j<N){
	        if(B[j]>=C[i]) break;
	        c[i] += b[j];
	        ++j;
	    }
	}
	long ans=0;
	for(int i=0; i<N; ++i) ans += c[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2944
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

string s;
int ans=1e9;

int main()
{
	cin>>s;
	int co=0,cnt=0;
	rep(i,s.size())
	{
		if(s[i]-'0'!=co) cnt++;
		co^=1;
	}
	ans=min(ans,cnt);
	cnt=0;
	co=1;
	rep(i,s.size())
	{
		if(s[i]-'0'!=co) cnt++;
		co^=1;
	}
	ans=min(ans,cnt);
	cout<<ans<<endl;
	rt0;
}

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

int main(){
  string s,t;cin >> s >> t;
  map<char,int> m;
  int ans = 0;
  
  for(int i=0;i < s.length();++i){
    if(s[i] != t[i]){
      ans += 1;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3848
def solve(s, t):
    c = 0
    for i, j in enumerate(s):
        if j != t[i]:
            c += 1
    return c


S = input()
T = input()

count = 0
ans = float("inf")
while count + len(T) <= len(S):
    a = solve(S[count:count + len(T)], T)
    if ans > a:
        ans = a
    count += 1

print(ans)

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

int main() {
    ll n, x, m;
    cin >> n >> x >> m;
    vector<ll> ans;
    vector<bool> visit(m, false);
    while(1) {
        if (visit[x]) {
            ans.push_back(x);
            break;
        }
        visit[x] = true;
        ans.push_back(x);
        x = x * x % m;
    }
    bool herasu = true;
    ll mae = 0;
    ll sum = 0;
    ll roopsize = 0;
    int roopstart;
    rep(i, ans.size() - 1) {
        if (ans[ans.size() - 1] == ans[i]) {
            roopstart = i;
            herasu = false;
        }
        if (herasu) {
            mae += ans[i];
            n--;
        }
        else {
            sum += ans[i];
            roopsize++;
        }
    }
    mae += n / roopsize * sum;
    n %= roopsize;
    for (int i = roopstart; i < roopstart + n; i++) {
        mae += ans[i];
    }
    cout << mae << endl;
    return 0;
}


Measured memory_bytes: 3816
n, a, b = map(int, input().split())
mod = 10 ** 9 + 7
ans = pow(2, n, mod) - 1


def comb(n, r):
    p, q = 1, 1
    for i in range(r):
        p = p * (n - i) % mod
        q = q * (r - i) % mod
    return p * pow(q, mod - 2, mod) % mod


print((ans - comb(n, a) - comb(n, b)) % mod)

Measured memory_bytes: 3064
N,M=map(int,input().split())
ans=['WA' for i in range(N)]
crt=0
mis=0
A=[0 for i in range(N)]
for i in range(M):
    p,S=map(str,input().split())
    if ans[int(p)-1]=='WA':
        if S=='WA':
            A[int(p)-1]+=1
        else:
            crt+=1
            ans[int(p)-1]='AC'
            mis+=A[int(p)-1]
    else:
        continue
print(crt,mis)

Measured memory_bytes: 4776
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

template<typename T>
struct BIT {
	int n;
	vector<T>dat;
	BIT(int n = 0) {
		initialize(n);
	}
	void initialize(int temp) {
		n = temp;
		dat.resize(n);
		rep(i, 0, n)dat[i] = 0;
	}
	T sum(int i) {
		T s = 0;
		while (i >= 0) {
			s += dat[i];
			i = (i & (i + 1)) - 1;
		}
		return s;
	}
	T sum_between(int i, int j) {
		if (i > j)return 0;
		return sum(j) - sum(i - 1);
	}
	void plus(int i, T x) {
		while (i < n) {
			dat[i] += x;
			i |= i + 1;
		}
	}
	int lower_bound(T x) {
		if (sum(n - 1) < x)return -1;
		else if (sum(0) >= x)return 0;
		int ng = 0, ok = n - 1;
		while (ok - ng > 1) {
			int mid = (ok + ng) / 2;
			if (sum(mid) >= x)ok = mid;
			else ng = mid;
		}
		return ok;
	}
};


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

	int N, M;
	cin >> N >> M;
	vector<vector<int>>v;
	for (int i = 0; i < N; i++) {
		int l, r;
		cin >> l >> r;
		v.pb({ r-l,l,r });
	}
	sort(all(v));

	BIT<ll> bitover(101010);
	BIT<ll> bitseg(101010);
	for (int i = 0; i < N; i++)bitover.plus(v[i][0], 1);
	

	int cur = 0;
	for (int d = 1; d <= M; d++) {
		ll ans = 0;
		ans += bitover.sum_between(d,101000);
		while (cur < N && v[cur][0] < d) {
			bitseg.plus(v[cur][1],1);
			bitseg.plus(v[cur][2]+1, -1);
			cur++;
		}
		for (int k = 0; k*d <= M; k++)ans += bitseg.sum_between(0,k*d);
		puts(ans);
	}

	return 0;
}


Measured memory_bytes: 22700
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test int t;cin>>t;while(t--)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define MOD 1000000007
#define ll long long
#define ld long double
#define int ll
#define pb push_back
#define ii pair<int,int>
#define llll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<ii>
#define vllll vector<llll>
#define ff first
#define ss second
#define INF 1000000000
#define HINF 1000000000000000
#define mem(a,b) memset(a,b,sizeof(a))
#define arrin(x,n) int x[n]; for(int o=0;o<n;o++) cin>>x[o]
#define arrout(x,n) for(int o=0;o<n;o++) cout<<x[o]<<" "; cout<<endl
#define vecin(x,n); vi x;int hool; for(int o=0;o<n;o++) {cin>>hool; x.pb(hool);}
#define vecout(x,n) for(int o=0;o<n;o++) cout<<x[o]<<" "; cout<<endl
#define all(x) x.begin(),x.end()
#define deb(x) cout<<#x<<'='<<x<<endl
#define deb2(x,y) cout<<#x<<'='<<x<<" "<<#y<<'='<<y<<endl
#define deb3(x,y,z) cout<<#x<<'='<<x<<" "<<#y<<'='<<y<<" "<<#z<<'='<<z<<endl
#define debarr(arr,n) for(int o=0;o<n;o++) deb2(o,arr[o])
#define IO freopen("input.txt", "r", stdin); freopen("output.txt", "w+", stdout)
const double pi = 3.14159265358979323846;

int powersimple(int a, int b){//a^b
    int res=1;
    while(b>0){
        if(b&1)
		{res=(res*a);
		b--;}
        a=(a*a);
        b>>=1;
    }
    return res;
}

int ncr(int n,int k)
{
	int ans=1;
	if(k>n-k)
	k=n-k;
	for(int i=1;i<=k;i++)
	ans*=(n-i+1),ans/=i;
	return ans;
}


int power(int x,int y,int p) 
{ 
    int res = 1;  
    x = x % p;   
    while (y > 0) { 
        if (y & 1) 
            res = (res * x) % p;  
        y = y >> 1; 
        x = (x * x) % p; 
    } 
    return res; 
} 

int modInverse(int n, int p) 
{ 
    return power(n, p - 2, p); 
} 

int ncrModPFermat(int n,int r, int p) 
{ 

    if (r == 0) 
		return 1; 
    
    int fac[n + 1]; 
    fac[0] = 1; 
    for (int i = 1; i <= n; i++) 
        fac[i] = (fac[i - 1] * i) % p; 
  
    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; 
} 

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



void solve()
{

	int i=0,j=0,k=0,m,n,p,sum=0,cnt=0;
	cin>>n;
	vii tab;
	for(i=0;i<n;i++)
	{
	    cin>>j>>k;
	    tab.pb({j,k});
	}
	for(i=0;i<n-2;i++)
	{
	    if(tab[i].ff==tab[i].ss and tab[i+1].ff==tab[i+1].ss and tab[i+2].ff==tab[i+2].ss)
	    {
	        cout<<"Yes";
	        return;
	    }
	}
	cout<<"No";
	
	
	
	 
}
int32_t main() {
    fast
    //IO;
	//cout<<fixed<<setprecision(6);
    //test
    {
        
        solve();
		
		      
    }
    return 0;
}
  




Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b, c;
    cin >> a >> b >> c;

    if((a == b && a != c) || (a == c && b != c) || (c == b && a != c)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main()
{
	int a;
	vector<int> vec;

	while (1)
	{
		cin >> a;
		if (a != 0){
			vec.push_back(a);
		}
		else{
			break;
		}
	}

	for (unsigned int i = 0; i < vec.size(); ++i)
	{
		cout << "Case " << i + 1 << ": " << vec[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1320
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

		int A = cin.nextInt();
		int tmp;
		int list[] = new int[8];
		Arrays.fill(list, 0);
		int target=0;
		for(int i=0;i<A;i++){
			tmp = cin.nextInt();
			if(tmp<3200){
				list[tmp/400]++;
			}else{
				target++;
			}
		}
		int min;
		int max;
		int type = 0;
		for(int j=0;j<=7;j++){
			if(list[j]>0)
			type++;
		}
		if(target==0){
			min=type;
			max=type;
		}else{
			if(type>0){
				min=type;
			}else{
				min=1;
			}
			max=type+target;
		}

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


Measured memory_bytes: 23892
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const stc& lhs, const stc& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N; cin >> N;
    cout << pow(N, 3) << endstr;
    return 0;
}


Measured memory_bytes: 512
//package aoj;

import java.util.Scanner;
import java.util.Stack;

class Main {
    public static boolean solve(String sentence) {
        Stack<Character> stk = new Stack<>();
        for (int i = 0; i < sentence.length(); i++) {
            if(sentence.charAt(i) == '[' || sentence.charAt(i) == '(') stk.push(sentence.charAt(i));
            else if(sentence.charAt(i) == ']') {
                if(stk.empty()) return false;
                if(stk.peek() != '[') return false;
                stk.pop();
            }
            else if(sentence.charAt(i) == ')') {
                if(stk.empty()) return false;
                if(stk.peek() != '(') return false;
                stk.pop();
            }
        }
        return stk.empty();
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()) {
            String sentence = sc.nextLine();
            if(sentence.equals(".")) return;
            System.out.println(solve(sentence) ? "yes" : "no");
        }
    }
}



Measured memory_bytes: 49992
#include <stdio.h>
int main(void)
{
	int a[5],b,i,j;
	for(i=0;i<5;i++)scanf("%d",&a[i]);
	b=a[0]+a[3];
	for(i=0;i<3;i++)
	for(j=3;j<5;j++)
	if(b>a[i]+a[j])b=a[i]+a[j];
	printf("%d\n",b-50);
	return 0;
}



Measured memory_bytes: 2104