akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <type_traits>
using namespace std;

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int h, n; std::cin >> h >> n;
  vi a(n), b(n);
  rep(i, n) {
    std::cin >> a[i] >> b[i];
  }
  vi dp(h+1, inf);
  dp[0] = 0;
  rep(i, n) rrep(j, h) {
    dp[j] = min(dp[j], dp[max(0, j - a[i])] + b[i]);
  }
  std::cout << dp[h] << "\n";
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.algorithm;
void main()
{
  while(1){
    auto n = readln.chomp.to!int;
    if(n==0) break;
    int s=1;
    int max=50000001;
    for(int i=2;i<n/2;++i){
      if(n%i==0){
    if(i<max){
      s+=(i+n/i);
      max = n/i;
      if(i==max)
        s -= i;
    }else break;
      }else if(i>max) break;
    }
    if(s<n || n==1) writeln("deficient number");
    else if(s==n) writeln("perfect number");
    else writeln("abundant number");
  }
}

Measured memory_bytes: 2408
#include <cstdio>
#include <algorithm>
#include <cmath>

using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
template<class T>bool CHMAX(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool CHMIN(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)

int main() {
	int l, r;
	scanf("%d", &l);
	scanf("%d", &r);

	int ans=INF;
	int modl = l % 2019;
	int modr = r % 2019;
	int val;

	if (((r - l) >= 2018) || (modl >= modr)) {
		ans = 0;
	}
	else {
		FOR(i, modl, modr-1) {
			FOR(j, i + 1, modr) {
				val = (i*j)%2019;
				CHMIN(ans, val);
			}
		}
	}
	
	printf("%d\n", ans);
}

Measured memory_bytes: 128
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int H, W, max_ = 0;

	scanf("%d", &H);
	scanf("%d", &W);

	vector<vector<int> > c(H, vector<int>(W));

	vector<vector<int> > dp(H, vector<int>(W, 0));

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			scanf("%d", &c[i][j]);

			if (c[i][j] == 0)
			{
				if (i == 0 || j == 0)
				{
					dp[i][j] = 1;
				}

				max_ = 1;
			}
		}
	}

	for (int i = 1; i < H; i++)
	{
		for (int j = 1; j < W; j++)
		{
			if (c[i][j] == 0)
			{
				dp[i][j] = min({ dp[i - 1][j - 1], dp[i - 1][j], dp[i][j - 1] }) + 1;

				max_ = max(dp[i][j], max_);
			}
		}
	}

	printf("%d\n", max_ * max_);

	return 0;
}

Measured memory_bytes: 17712
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
#define rep1(i,N) for(int i=1;i<=(int)N;i++)
#define pb push_back
#define all(c) c.begin(),c.end()
#define show(x) cout<<#x<<" "<<x<<endl
using namespace std;
int x[10][10];
int calc(vector<int> vc){
	int a=0;
	for(int v:vc) a=x[a][v];
	return a;
}
int main(){
	int ans=0;
	rep(i,10) rep(j,10) cin>>x[i][j];
	rep(i,10000){
		vector<int> ds;
		int tmp=i;
		rep(j,4){
			ds.pb(tmp%10);
			tmp/=10;
		}
		reverse(all(ds));
		int e=calc(ds);
		ds.pb(e);
		bool ok=1;
		rep(j,5){
			rep(k,10) if(ds[j]!=k){
				vector<int> vc=ds;
				vc[j]=k;
				if(calc(vc)==0) ok=0;
			}
		}
		rep(j,4){
			if(ds[j]==ds[j+1]) continue;
			vector<int> vc=ds;
			swap(vc[j],vc[j+1]);
			if(calc(vc)==0) ok=0;
		}
		if(!ok) ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3148
//
//  sublime text 3,
//  emre yazicioglu
//

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair <ll, ll> pll;
typedef vector <ll> vll;
typedef vector <pll> vpll;
#define pb push_back
#define fi first
#define se second
#define INF (ll) (1e18 + 7)
#define MOD (ll) (1e9 + 7)

const int N = 2e6 + 7;
ll mn = INF, mx = -INF;
ll n, m, k, s, q, t;
ll a, b, c, d, e;
ll ans, cur, sum, cnt;
ll ar[N], p[N], dp[N];
string str; bool h[N];
pll pp[N]; vll v;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);

  // freopen("../in.txt","r",stdin);
  // freopen("../out.txt","w",stdout);

  string a, b;
  cin >> a >> b;
  for(int i = 0; i < 3; i++)
    ans += a[i] == b[i];
  cout << ans;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100005

ll N,M;
ll POW[NUM];
ll dp[NUM];

int main(){

	scanf("%lld %lld",&N,&M);

	POW[0] = 1;
	for(int i = 1; i < NUM; i++){

		POW[i] = POW[i-1]*2;
		POW[i] %= MOD;
	}

	dp[0] = 1;

	for(int len = 1; len <= M; len++){

		dp[len] = POW[len];
	}
	dp[M] -= 1;

	for(int len = M+1; len <= N; len++){

		dp[len] = dp[len-1]+(dp[len-1]-dp[len-1-M]);
		dp[len] %= MOD;
	}

	printf("%lld\n",(POW[N]-dp[N]+MOD)%MOD);

	return 0;
}



Measured memory_bytes: 4788
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll x,y,a,b,c,i,j;
	cin>>x>>y>>a>>b>>c;
	vector<ll> p(a),q(b),r(c);
	for(i=0;i<a;i++) cin>>p[i];
	for(i=0;i<b;i++) cin>>q[i];
	for(i=0;i<c;i++) cin>>r[i];
	sort(all(p));
	sort(all(q));
	sort(all(r));
	ll diff = a-x;
	p.erase(p.begin(), p.begin()+diff);
	diff = b-y;
	q.erase(q.begin(), q.begin()+diff);
    ll ans = 0, t = x+y;
    priority_queue<ll> pq;
    for(i=0;i<sz(p);i++) pq.push(p[i]);
    for(i=0;i<sz(q);i++) pq.push(q[i]);
    for(i=0;i<sz(r);i++) pq.push(r[i]);
    while(t--)
    {
        ans+=pq.top();
        pq.pop();
    }
    cout<<ans;
}

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

int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++)cin>>a[i];
	
	long long int np=a[0];
	long long int ans=0;
	
	if(np==0){
		np=1;
		ans=1;
	}
	
	for(int i=1;i<n;i++){
		if(np>0){
			if(np+a[i]>=0){
				ans+=abs((np+a[i])+1);
				np=-1;
			}else{
				np+=a[i];
			}
		}else if(np<0){
			if(np+a[i]<=0){
				ans+=abs((np+a[i])-1);
				np=1;
			}else{
				np+=a[i];
			}
		}
	}
	
	long long int ans2;
	if(a[0]<0){
		np=1;
		ans2=abs(a[0]-1);
	}else{
		np=-1;
		ans2=abs(a[0]+1);
	}
	
	
	for(int i=1;i<n;i++){
		if(np>0){
			if(np+a[i]>=0){
				ans2+=abs((np+a[i])+1);
				np=-1;
			}else{
				np+=a[i];
			}
		}else if(np<0){
			if(np+a[i]<=0){
				ans2+=abs((np+a[i])-1);
				np=1;
			}else{
				np+=a[i];
			}
		}
		//cout<<np<<" "<<a[i]<<" "<<ans2<<endl;
	}
	
	//cout<<ans<<" "<<ans2<<endl;
	
	ans=min(ans,ans2);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n,m,a[1005],sum=0;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    cin>>m; 
    while(m--){
        int p,x;
        cin>>p>>x;
        cout<<sum-a[p]+x<<endl;}
    return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    string s;
    cin >> s;
    bool alpha[26] = {};
    rep(i, s.size()) alpha[s[i] - 'a'] = true;
    char c = '.';
    repr(i, 26, 0) if (!alpha[i]) c = (char)('a' + i);
    if (c == '.') cout << "None" << endl;
    else cout << c << endl;
    return 0;
}

Measured memory_bytes: 512
/**
 * (iwi)
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

		int count = 0;
		int len = 0;

		line = br.readLine();
		len = line.length();

		if (len % 2 == 1) {
			char c = line.charAt(len / 2);
			if (c == '(' || c == ')') count++;
		}
		for (int i = 0; i < len / 2; i++) {
			char l = line.charAt(i);
			char r = line.charAt(len - 1 - i);
			if (l == 'i' || l == 'w' || r == 'i' || r == 'w') {
				if (l != r) count++;
			} else {
				if (l == r) count++;
			}
		}
		System.out.println(count);
	} // end main
}

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

int main()
{
    string s;
    cin>>s;
    int w;
    cin>>w;
    //cout<<s[0];
    for(int i=0;i<s.size();i+=w)
    {
        cout<<s[i];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = input()
r = [None] * (n + 1)
for i in range(n, 0, -1):
    r[i] = (ord(a[2 * i - 2]) + sum(r[i * 2::i])) % 2
print(r.count(1))
print(*(i for i, x in enumerate(r) if x))


Measured memory_bytes: 12032
H, W, K = map(int, input().split())
X = [input() for _ in range(H)]

res = 0
for i in range(2**H):
    a = bin(i)[2:].zfill(H)
    for j in range(2**W):
        b = bin(j)[2:].zfill(W)

        c = 0

        for (p, x) in enumerate(X):
            for (q, y) in enumerate(x):
                if a[p] != '1' and b[q] != '1' and y == '#':
                    c += 1

        if c == K:
            res += 1

print(res)


Measured memory_bytes: 9200
var
	H,W,A,B,i,j:Longint;
	s:String;
begin
	read(H,W,A,B);
	for i:=1 to H do begin
		s:='';
		for j:=1 to W do begin
			if (i>B)<>(j>A)then s:=s+'0' else s:=s+'1';
		end;
		writeln(s);
	end;
end.


Measured memory_bytes: 1260
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define fast                            ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int                             long long
#define ff                              first
#define ss                              second
#define max3(a,b,c)                     max(a,max(b,c))
#define min3(a,b,c)                     min(a,min(b,c))
#define setbits(x)                      __builtin_popcountll(x)
#define zerobits(x)                      __builtin_ctzll(x)
#define pb                              push_back
#define mkp                             make_pair
#define all(v)                          (v).begin(),(v).end()
#define pii                             pair<int, int>
#define vi                              vector<int>
#define vpi                             vector<pair<int,int>>
#define rev(x)                          reverse(all(x))
#define gcd(m,n)                        __gcd(m, n)
#define negmod(x,m)                     ((x)%(m)+(m))%(m)
#define fr(i, a, b)                     for (int i = (a), _b = (b); i <= _b; i++)
#define rep(i, n)                       for (int i = 0, _n = (n); i < _n; i++)
#define repr(i, n)                      for (int i = n - 1; i >= 0; i--)
#define frr(i, a, b)                    for (int i = (a), _b = (b); i >= _b; i--)
#define M                               1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
ull countBits(ull n){ull count=0;while(n){count++;n>>=1;}return count;}
int updiv(int a,int b)
{
  if(a%b==0)
    return (a/b);
  else
    return (a/b)+1;
}
int mymod(int x,int m)
{
  if(x>0)
    return x%m;
  else
    return negmod(x,m);
}
int binpow(int a, int b)
{
    int res = 1;
    while(b>0)
    {
        if(b&1)
        res=res*a;
        a=a*a;
        b>>=1;
    }
    return res;
}
bool second_sort(const pii & lhs , const pii & rhs)
{
    pii a,b;
    a.ff=lhs.ss;
    a.ss=lhs.ff;
    b.ff=rhs.ss;
    b.ss=rhs.ff;
    return a<b;
}
int32_t main()
{
fast
int t=1,n,W;
//cin>>t;
while(t--)
{
cin>>n>>W;
int w[n+1],v[n+1];
for(int i=1;i<=n;i++)
{
cin>>w[i]>>v[i];
}
int dp[n+1][W+1];
for(int i=0;i<=n;i++)
{
    for(int j=0;j<=W;j++)
    {
        if(i==0||j==0)
        {
            dp[i][j]=0;
            continue;
        }
        else if(j>=w[i])
            dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
        else
            dp[i][j]=dp[i-1][j];
    }
}
cout<<dp[n][W];
}
return 0;
}


Measured memory_bytes: 82396
//
// Created by haofeng on 4/22/20.
//
#include <iostream>
#include <stdio.h>
#include <stack>
#include <string>
using namespace std;
stack<char> ST;
int main(){
    string X;cin>>X;
    for(int i=0;i<X.size();++i){
        if (!ST.empty()){
            if(ST.top()=='S'&&X[i]=='T'){
                ST.pop();
            }
            else{
                ST.push(X[i]);
            }
        }
        else {
            ST.push(X[i]);
        }
    }
    cout<<ST.size()<<endl;
}

Measured memory_bytes: 644
n = input()
n_list = [int(i) for i in n]
ans = 0
if len(n) == 1:
    print(n)
else:
    if sum(n_list[1:]) == (len(n)-1)*9:
        ans = sum(n_list)
    else:
        ans = n_list[0]-1 + (len(n_list)-1)*9
    print(ans)


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

int main() {
    int n,a,b,sum=0;
    cin>>n>>a>>b;
    for(int i=1; i<=n; i++) {
        int tmp_s = i/10000+(i/1000)%10+(i/100)%10+(i/10)%10+i%10;
        if(a<=tmp_s && tmp_s<=b) sum += i;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int M,D;
  cin >> M >> D;
  int loop,loop2;
  int ans=0;
  for(loop=4;loop<=M;loop++){
    if(loop>81||D<22)
      break;
    for(loop2=2;loop2<10;loop2++){
      if(loop%loop2){
        if(loop/loop2){
          continue;
        }else{
          break;
        }
      }else if(loop/loop2>=2){
        if(loop2+(loop/loop2*10)<=D){
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <numeric>
#include <array>
#include <queue>
#include <set>
using namespace std;
using ll = long long int;
using li = long int;
#define REP(i,n) for(int i=0;i<n;i++)

int main()
{
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;

    vector<ll> A(X), B(Y), C(Z);
    REP(i, X) cin >> A[i];
    REP(i, Y) cin >> B[i];
    REP(i, Z) cin >> C[i];
    sort(A.begin(), A.end(), greater<ll>());
    sort(B.begin(), B.end(), greater<ll>());
    sort(C.begin(), C.end(), greater<ll>());

    priority_queue<tuple<li, int, int, int>> q;
    set<tuple<int, int, int>> b;
    //vector<vector<vector<int>>> b(X, vector<vector<int>>(Y, vector<int>()));
    q.push(make_tuple(A[0] + B[0] + C[0], 0, 0, 0));
    b.emplace(make_tuple(0, 0, 0));

    for (int i = 0; i < K; i++)
    {
        tuple<ll, int, int, int> temp;
        temp = q.top();
        cout << get<0>(temp) << endl;
        int min_x = get<1>(temp);
        int min_y = get<2>(temp);
        int min_z = get<3>(temp);
        tuple<int, int, int> x(min_x+1, min_y, min_z), y(min_x, min_y+1, min_z), z(min_x, min_y, min_z+1);
        q.pop();

        if (b.count(x) == 0 and min_x < X-1)
        {
            b.emplace(x);
            q.push(make_tuple(A[min_x+1] + B[min_y] + C[min_z], min_x+1, min_y, min_z));
        }
        if (b.count(y) == 0 and min_y < Y-1)
        {
            b.emplace(y);
            q.push(make_tuple(A[min_x] + B[min_y+1] + C[min_z], min_x, min_y+1, min_z));
        }
        if (b.count(z) == 0 and min_z < Z-1)
        {
            b.emplace(z);
            q.push(make_tuple(A[min_x] + B[min_y] + C[min_z+1], min_x, min_y, min_z+1));
        }
    }
}

Measured memory_bytes: 896
import std.stdio;
import std.algorithm;
import std.conv;
import std.array;
import std.string;
import std.math;
import std.functional;
import std.range;
import std.typecons;
import std.format;

void main(string[] args) {
  solve(readln.chomp, readln.chomp).writeln;
}

auto solve(string line1, string line2) {
  string s_prime = line1.to!(dchar[]).sort!"a < b".to!string;
  string t_prime = line2.to!(dchar[]).sort!"a > b".to!string;
  return s_prime < t_prime ? "Yes" : "No";
} unittest {
  assert(solve("yx", "axy") == "Yes", "1");
  assert(solve("ratcode", "atlas") == "Yes", "2");
  assert(solve("cd", "abc") == "No", "3");
  assert(solve("w", "ww") == "Yes", "4");
  assert(solve("zzz", "zzz") == "No", "5");
}

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

using namespace std;

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

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

int main(){
	int t, x;
	cin >> t >> x;
	cout << t/(double)x << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
   int a[3],t,i;
    for(i=0;i<3;i++)
    {
        scanf("%d",&a[i]);
    }
    t=a[2];
    for(i=(3-1);i>0;i--)
    {
        a[i]=a[i-1];
    }
    a[0]=t;
    for(i=0;i<3;i++)
    {
        printf(" %d ",a[i]);
    }
    return 0;
}

Measured memory_bytes: 128
main :: IO()
main = do
    getLine
    vls <- map read . words <$> getLine
    cls <- map read . words <$> getLine
    print $ getsolve vls cls

getsolve vls [] = 0
getsolve vls cls
    | head vls > head cls			= ((head vls) - (head cls)) + (getsolve (tail vls) (tail cls))
    | otherwise						=(getsolve (tail vls) (tail cls))

Measured memory_bytes: 636
import collections
n=int(input())
a=list(map(int,input().split()))
m=max(a)
c=collections.Counter(a)
c=c.most_common()
l=[0]*n
for i in range(len(c)):
    l[c[i][0]-1]=c[i][1]
print(l[0])
for j in range(1,n):
    print(l[j])

Measured memory_bytes: 44248
#include <cstdio>
#define rg register
#define file(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)
template < class T > inline void read(T& s) {
	s = 0; int f = 0; char c = getchar();
	while ('0' > c || c > '9') f |= c == '-', c = getchar();
	while ('0' <= c && c <= '9') s = s * 10 + c - 48, c = getchar();
	s = f ? -s : s;
}

const int _ = 1e6 + 5, p = 1e9 + 7;

int n, m, cnt, t[233], fac[_], inv[_];

inline void init(int N) {
	fac[0] = inv[0] = inv[1] = 1;
	for (rg int i = 1; i <= N; ++i) fac[i] = 1ll * i * fac[i - 1] % p;
	for (rg int i = 2; i <= N; ++i) inv[i] = 1ll * (p - p / i) * inv[p % i] % p;
	for (rg int i = 1; i <= N; ++i) inv[i] = 1ll * inv[i - 1] * inv[i] % p;
}

inline int C(int N, int M) { return 1ll * fac[N] * inv[M] % p * inv[N - M] % p; }

int main() {
	init(1e6), read(n), read(m);
	for (rg int i = 2; i * i <= m; ++i) {
		if (m % i == 0) { ++cnt;
			while (m % i == 0) ++t[cnt], m /= i;
		}
	}
	if (m > 1) t[++cnt] = 1;
	int ans = 1;
	for (rg int i = 1; i <= cnt; ++i) ans = 1ll * ans * C(n + t[i] - 1, n - 1) % p;
	printf("%d\n", ans);
	return 0;
}
//asdasdadsafdsafdsfdsafdsa

Measured memory_bytes: 7936
#ABC_131_C
import fractions
A,B,C,D=list(map(int,input().split()))
#B以下の答え
CD_lcm=C*D//fractions.gcd(C,D)

underB=B-B//C-B//D+B//CD_lcm
underA_1=A-1-(A-1)//C-(A-1)//D+(A-1)//CD_lcm

print(underB-underA_1)

Measured memory_bytes: 5048
import java.awt.*;
import java.awt.geom.*;
import java.io.*;
import java.util.*;

public class Main{
  public static void main(String args[]) {
    Scanner in  = new Scanner(System.in);
    String word = in.nextLine();
    String str,txt = "";
    int num     = 0;

    word = word.toLowerCase();

    while(true){
      str = in.nextLine();
      if( str.equals("END_OF_TEXT") ) break;
      str = str.toLowerCase();
      txt = str + " " + txt;
    }

    String[] tokens = txt.split(" ");
    for (String token : tokens) {
      if (token.equals(word)) {
          num++;
      }
    }
    System.out.println(num);
  }
}



Measured memory_bytes: 26236
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main() {
    int N; cin >> N;
    string S; cin >> S;

    for(int i=0; i<2*N; i++){
        if(i%2==0){
            if(S[i]=='B') S[i] = 'W';
            else S[i] = 'B';
        }
    }
    
    vector<int> L(2*N+1), R(2*N+1);
    int cR = 0;
    int cL = 0;
    for(int i=0; i<2*N; i++){
        if(S[i]=='B'){
            cR++;
            R[i+1] = R[i] + 1;
            L[i+1] = L[i];
        }else{
            cL++;
            R[i+1] = R[i];
            L[i+1] = L[i] + 1;
        }
    }
    
    if(cR!=cL){
        cout << 0 << endl;
        return 0;
    }
    
    ll ans = 1;
    for(int i=0; i<2*N; i++){
        if(S[i]=='B') ans = ans * (L[i] - R[i]) % MOD;
    }
    
    for(int i=1; i<=N; i++){
        ans = ans * i % MOD;
    }
    
    cout << ans << endl;
    return 0;
    
}





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

using namespace std;

int main() {
  const int N = 10010;

  vector<int> f(N);
  for (int i = 1; i * i < N; i++) {
    for (int j = 1; j * j < N; j++) {
      for (int k = 1; k * k < N; k++) {
        int a = i * i + j * j + k * k;
        int b = i * j + j * k + k * i;
        if (a + b >= N) break;
        f[a + b]++;
      }
    }
  }

  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cout << f[i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

 
///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int a, b;


int main(){
	cin>>a>>b;
	
	if( a > b ) cout<<a-1<<endl;
	else{	  cout<<a<<endl;}
	
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		
		int w = scan.nextInt();
		int h = scan.nextInt();
		int x = scan.nextInt();
		int y = scan.nextInt();
		
		int multi = 0;
		if (x * 2 == w && y * 2 == h) {
			multi = 1;
		}
		
		double ans = (double) w * h / 2;
		
		System.out.printf("%f %d", ans, multi);
		
		scan.close();
	}

}

Measured memory_bytes: 21844
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
//<DEFINE>
void Fast() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
}
void File() {
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
#define ll long long
#define ull unsigned long long
#define mod 1000000007
ll gcd(ll a, ll b) {
	return!b ? a : gcd(b, a % b);
}
#define fix(n) cout << fixed << setprecision(n);
#define numOfOnes(n) __builtin_popcount(n)
#define all(a) a.begin(), a.end()
#define skip continue
#define stop(n) return cout<<n,0
#define pi  acos(-1)
#define endl "\n"
#define ceil(x,y) (x+y-1)/y
//</DEFINE>

/*█▀▀▄░░░░░░░░░░░▄▀▀█
░█░░░▀▄░▄▄▄▄▄░▄▀░░░█
░░▀▄░░░▀░░░░░▀░░░▄▀
░░░░▌░▄▄░░░▄▄░▐▀▀
░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█
░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█
▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█
█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀
░▀▄░░▀░░▀▀▀░░▀░░░▄█▀
░░░█░░░░░░░░░░░▄▀▄░▀▄
░░░█░░░░░░░░░▄▀█░░█░░█
░░░█░░░░░░░░░░░█▄█░░▄▀
░░░█░░░░░░░░░░░████▀
░░░▀█▄▄▄▀▀▀▀▄▄▄█▀*/
int n,k;
vector<vector<int>>v;
int res[100002][4];
int solve(int idx = 0,int current =0) {
	if (idx == n+1)return 0;
	if (~res[idx][current])return res[idx][current];
	int mx = 0;
	for (int i = 1; i <= 3; i++) {
		if (i == current)skip;
		mx = max(v[idx][i] + solve(idx + 1, i),mx);
	}
	return res[idx][current] = mx;
}
//</FUNCTIONS>		
int main() {
	Fast();
	cin >> n;
	v = vector<vector<int>>(n+1, vector<int>(4));
	for (int i = 0; i <= n; i++)
		for(int j=0;j<=3;j++)
			res[i][j] = -1;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= 3; j++)
			cin >> v[i][j];
	}
	cout << solve() << endl;
}


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

int main(){
  int N, a[110];
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  int ans=0;
  for(int i = 0; i < N; i++){
    for(int j = N-1; j >= i-1; j--){
      if(a[j] < a[j-1] && j-1 >= 0){
	int tmp = a[j];
	a[j] = a[j-1];
	a[j-1] = tmp;
	ans++;
      }
    }
  }
  for(int i = 0; i < N;i++){
    if(i < N-1) cout << a[i] << " ";
    else cout << a[i] << endl;
  }
  cout << ans << endl;
  return 0;
}

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

#define cn count;
#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define len length
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
using ll = long long;
const ll inf = 1e9+7; 
const double PI =  3.141592653589793;

int main(){
	ll w,h,x,y;
	cin>>w>>h>>x>>y;
	double ans = w*h*1.0/2;
	printf("%.6f ",ans);
	(x*1.0 == w*1.0/2 && y*1.0 == h*1.0/2)?cout<<"1\n":cout<<"0\n";
	return 0;
}

// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""


Measured memory_bytes: 3724
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> yakusu(int n){
  vector<int> result;
  for(int i=1; i*i<=n;i++){
    if(n%i==0){
      result.push_back(i);
      if(i!=n/i){
        result.push_back(n/i);
      }
    }
  }
  sort(result.begin(), result.end());
  return result;
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n+1);
  for(int i=1;i<n+1;i++){
    cin >> a[i];
  }
  
  vector<int> b(n+1, 0);
  vector<int> y;
  for(int i=n;i>0;i--){
    b[i] ^= a[i];
    y = yakusu(i);
    for(int e=0;e<y.size()-1;e++){
      b[y[e]] += b[i];
      b[y[e]] %= 2;
      //cout << e << " " <<b[e] << "\n";
    }
  }
  cout << count(b.begin(), b.end(), 1) << "\n";
  string s = "";
  for(int i=1;i<n+1;i++){
    if(b[i]==1){
      s += to_string(i) + " ";
    }
  }
  cout << s.substr(0,s.length()-1);
  return 0;
}

Measured memory_bytes: 4340
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		int A = in.nextInt();
		int B = in.nextInt();
		int C = in.nextInt();
		
		
				
		if(A >= B && A >= C) {
			A = A*10;
		}else if(B >= A && B >= C) {
			B = B*10;
		}else if(C >= A && C >= B) {
			C = C*10;
		}
		System.out.println(A+B+C);
		in.close();
	}
}


Measured memory_bytes: 21844
#include<cstdio>
#include<set>
#include<utility>
#include<climits>
#include<cstring>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pii;

set<pii> S;

const int maxn=128;
int f[maxn][maxn];

int N;

int curi[maxn],curn;
int curv[16];
int best;

inline bool in(int i,const pii& p){
	if(i<60)
		return ((1ll<<i)&p.first)!=0;
	return ((1ll<<(i-60))&p.second)!=0;
}

pii add(int i,const pii& p){
	pii q=p;
	if(i<60)
		q.first |= (1ll<<i);
	else
		q.second |= (1ll<<(i-60));
	return q;
}

void search(pii p,int k){
	if(S.count(p))return;
	S.insert(p);
	//printf("-- %lld\n",p.first);
	for(int i=k;i<N;++i){
		if(in(i,p))continue;
		int j;
		curv[curn]=INT_MAX;
		for(j=0;j<curn;++j){
			curv[curn]=min(curv[curn],f[i][curi[j]]);
			if(curv[curn]==0)break;
		}
		if(j!=curn)continue;
		int d[16];
		memcpy(d,curv,sizeof(d));
		int now=curv[curn];
		for(j=0;j<curn;++j){
			curv[j]=min(curv[j],f[curi[j]][i]);
			now+=curv[j];
		}
		curi[curn++]=i;
		if(curn>1){
			if(now>best)best=now;
		}
		/*if(curn==2){
			for(int i=0;i<curn;++i)
				printf("%d %d\n",curi[i],curv[i]);
		}*/
		pii q=add(i,p);
		search(q,i+1);
		--curn;
		memcpy(curv,d,sizeof(d));
	}
}

int main(){
	int M;
	while(2==scanf("%d%d",&N,&M)){
		memset(f,0,sizeof(f));
		best=0;
		S.clear();
		while(M--){
			int a,b,x;
			scanf("%d%d%d",&a,&b,&x);
			--a,--b;
			f[a][b]=f[b][a]=x;
		}
		curn=0;
		search(pii(0,0),0);
		printf("%d\n",best);
	}
}

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

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

using namespace std;

map<char,set<int> > S;
set<int> U;
string parse;
int pos;

set<int> expression();

set<int> term(){
  if( parse[pos] == '(' ){
    ++pos;
    set<int> p = expression();
    ++pos;
    return p;
  } else if( parse[pos] == 'c' ) {
    ++pos;
    set<int> p = term();
    set<int> ret = U;
    for(set<int>::iterator it = p.begin();it!=p.end();it++) ret.erase(*it);
    return ret;
  } else {
    char c = parse[pos++];
    return S[c];
  }
}

set<int> expression(){
  set<int> a = term();

  while( parse[pos] == 'u' || parse[pos] == 'i' || parse[pos] == 'd' || parse[pos] == 's' || parse[pos] == 'c' ){
    char opr = parse[pos++];
    set<int> b = term();
    if( opr == 'u' ){
      set<int> tmp = a;
      for(set<int>::iterator it = b.begin() ; it != b.end(); it++ ) tmp.insert(*it);
      a = tmp;
    } else if( opr == 'i' ) {
      map<int,int> counter;
      set<int> tmp;
      for(set<int>::iterator it = a.begin() ; it != a.end(); it++ ) counter[*it]++;
      for(set<int>::iterator it = b.begin() ; it != b.end(); it++ ) counter[*it]++;
      for(auto& i : counter)if( i.second == 2 ) tmp.insert(i.first);
      a = tmp;
    } else if( opr == 'd' ) {
      set<int> tmp = a;
      for(auto& i : b)tmp.erase(i);
      a = tmp;
    } else if( opr == 's' ) {
      map<int,int> counter;
      set<int> tmp;
      for(set<int>::iterator it = a.begin() ; it != a.end(); it++ ) counter[*it]++;
      for(set<int>::iterator it = b.begin() ; it != b.end(); it++ ) counter[*it]++;
      for(auto& i : counter)if( i.second != 2 ) tmp.insert(i.first);
      a = tmp;
    }
  }
  return a;
}

int main(){

  char c;
  int n,tmp;
  while(cin >> c >> n){
    pos = 0;
    S.clear();
    U.clear();
    rep(i,n){
      cin >> tmp;
      S[c].insert(tmp);
    }

    while(true){
      cin >> c >> n;
      if( c == 'R' && n == 0 ) break;
      rep(i,n){
	cin >> tmp;
	S[c].insert(tmp);
      }
    }

    for(map<char,set<int> >::iterator it = S.begin(); it != S.end(); it++){
	for(set<int>::iterator it2 = (it->second).begin(); it2 != (it->second).end();it2++){
	  U.insert(*it2);
	}
    }

    cin >> parse;

    set<int> answer = expression();
    int i = 0;
    bool output = false;
    for(set<int>::iterator iter = answer.begin() ; iter != answer.end() ; iter++,i++ ){
      if( i ) cout << ' ';
      output = true;
      cout << *iter;
    } 
    if( !output ) cout << "NULL";
    cout << endl;

  }
  return 0;
}

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

int main() {
    string s;
    cin>>s;

    if(s[0]==s[2]){
        cout<<"Yes"<<endl;
    }
    else {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int a,b;
  cin >> a >> b;
  if(a%3&&b%3&&(a+b)%3) pr("Impossible");
  else pr("Possible");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

typedef long long ll;
ll inf = 1e9+7;
ll n,m;
int main(){
	cin >> n >> m;
	ll X[n+1],Y[m+1];
	for(int i=1;i<=n;i++){
		cin >> X[i];
	}
	for(int i=1;i<=m;i++){
		cin >> Y[i];
	}
	ll x = 0, y = 0;
	for(ll i=1;i<=n;i++){
		x = (x + (i-1)*X[i] - (n-i)*X[i])%inf;
	}
	for(ll i=1;i<=m;i++){
		y = (y + (i-1)*Y[i] - (m-i)*Y[i])%inf;
	}
	cout << (x*y)%inf << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <stdlib.h>
#include <map>
using namespace std;

int main() {
	int N;
	cin >> N;
	int A;
	bool flag = true;
	for (int i = 0; i < N; i++)
	{
		cin >> A;
		if (A % 2 == 0) {
			if (A % 3 != 0 && A % 5 != 0) {
				flag = false;
					break;
			}
		}
	}
	if (flag) {
		cout << "APPROVED" << endl;
	}
	else {
		cout << "DENIED" << endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e10;
const long double PI = (acos(-1));

int N;
vector<int>h;
vector<int>dp;

int rec(int i) {
	if (dp[i] != -1)return dp[i];
	if (i == 0)return 0;
	int res = INF;
	chmin(res, rec(i - 1) + abs(h[i] - h[i - 1]));
	if (i - 2 >= 0)chmin(res, rec(i - 2) + abs(h[i] - h[i - 2]));
	return dp[i] = res;
}

signed main() {
	cin >> N;
	h.resize(N);
	dp.resize(N);
	rep(i, N)cin >> h[i];
	rep(i, N)dp[i] = -1;
	cout << rec(N - 1) << endl;
}

Measured memory_bytes: 4992
// AOJ 2787 Pipe Fitter and the Fierce Dogs
// 2018.4.15 bal4u

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

// バッファを経ずstdinから数値を得る
//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

#define INF 0x10101010
int dp[10002];
char dog[5002][10002]; int max[5002];
 
int main()
{
	int W, H, K, N, x, y, s, t, w, lim, ans;

	W = in(), H = in(), K = in(), N = in();
	H >>= 1;
	K -= (W>>1)+1; if (K < 0) { puts("-1"); return 0; }
	while (N--) {
		x = in()-1, y = in()-1;
		if (y & 1) {
			y >>= 1;
			dog[y][x] = 1;
			if (x > max[y]) max[y] = x;
		}
	}

	s = 0, w = (W+1)<<2;
	for (y = 0; y < H; y++) {
		memset(dp, INF, w);
		dp[0] = 0;
		lim = max[y]+3; if (lim > W) lim = W;
		for (x = 0; x < lim; x++) {
			if (x & 1) dp[x+1] = dp[x];
			else {
				t = dp[x] + dog[y][x];
				if (dp[x+1] > t) dp[x+1] = t;
				if (x >= 2) {
					t = dp[x-2] + (dog[y][x-1]<<1);
					if (dp[x+1] > t) dp[x+1] = t;
				}
			}
		}
		s += dp[lim];
	}
	ans = H*((W>>1)+1) + s;
	if (s > K) s = K;
	ans -= s<<1, K -= s;
	if (ans > K) ans -= K; else ans = 0;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 50572
N, M = map(int, input().split())
a = [tuple(map(int, input().split())) for i in range(M)]
a.sort(key=lambda x:x[1])
divided = [0 for i in range(N-1)]

p = 0
for i in a:
    # 分断済みなら次の関係へ
    if p >= i[0]:
        continue
    
    # 分断
    p = i[1]-1
    divided[p -2]=1
    
print(sum(divided))

Measured memory_bytes: 67032
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

struct Graph{
    struct Node{
        vector<int> dests;
    };
    vector<Node> nodes;
    Graph(int num): nodes(num){ }
    int id(Node* n){ return n - &nodes[0]; }
    int id(Node& n){ return &n - &nodes[0]; }
    void print(){ for(auto& node : nodes){ prints(id(node), node.dests); } }
    void add1Edge(int from, int dest){
        nodes[from].dests.push_back(dest);
    }
    void add2Edge2(int from, int dest){
        add1Edge(from, dest);
        add1Edge(dest, from);
    }
    //len idx
    pair<int, int> dfs(int idx, int from = -1, int len = 0){
        pair<int, int> ret(len, idx);
        for(int didx : nodes[idx].dests){
            if(didx == from){ continue; }
            auto p = dfs(didx, idx, len + 1);
            ret = max(ret, p);
        }
        printde(idx, ret);
        return ret;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    Graph g(n);
    for(int i = 0; i < n - 1; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g.add2Edge2(a, b);
    }
    auto p1 = g.dfs(0);
    auto p2 = g.dfs(p1.second);
    cout << (p2.first % 3 == 1 ? "Second" : "First") << '\n';
}


Measured memory_bytes: 29952
x = int(input())

if x == 1:
    print("1")
    exit()


def func(p):
    q = p
    while q < x:
        q *= p
        if q == x:
            return q
    if q / p == p:
        return 1
    else:
        return q // p


z = []
a = 2

while a <= x:
    z.append(func(a))
    a += 1

print(max(z))


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

const int MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
    int N;
    cin >> N;

    int i = 0;
    while (true) {
        int min = pow(2, i);
        int max = pow(2, i + 1);

        if (N >= min && N < max) {
            cout << min << endl;
            break;
        }
        i++;
    }
}

Measured memory_bytes: 256
while 1:
	try:
		stack = []
		for s in raw_input().split():
			if s == "-":
				stack.append(stack.pop(-2) - stack.pop())
			elif s == "+":
				stack.append(stack.pop(-2) + stack.pop())
			elif s == "/":
				stack.append(stack.pop(-2) / stack.pop())
			elif s == "*":
				stack.append(stack.pop(-2) * stack.pop())
			else:
				stack.append(float(s))
	
		print "%.6f" % (stack[0])
	except:
		break

Measured memory_bytes: 4240
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
const int maxn = 2005, mod = 924844033;
 
inline int gi()
{
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	int sum = 0;
	while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}
 
int n, k, fac[maxn << 2], ifac[maxn << 2], f[maxn];
 
struct edge
{ 
	int to, next;
} e[maxn << 3];
int h[maxn << 2], tot, cnt;
bool vis[maxn << 2];
 
inline void add(int u, int v)
{
	e[++tot] = (edge) {v, h[u]}; h[u] = tot;
	e[++tot] = (edge) {u, h[v]}; h[v] = tot;
}
 
void dfs(int u)
{
	vis[u] = 1; cnt += u > (n << 1);
	for (int i = h[u], v; v = e[i].to, i; i = e[i].next)
		if (!vis[v]) dfs(v);
}
 
inline int C(int n, int m)
{
	return (ll)fac[n] * ifac[m] % mod * ifac[n - m] % mod;
}
 
int main()
{
	n = gi(); k = gi();
	fac[0] = ifac[0] = ifac[1] = 1;
	for (int i = 1; i <= n << 2; ++i) fac[i] = (ll)fac[i - 1] * i % mod;
	for (int i = 2; i <= n << 2; ++i) ifac[i] = (ll)(mod - mod / i) * ifac[mod % i] % mod;
	for (int i = 1; i <= n << 2; ++i) ifac[i] = (ll)ifac[i - 1] * ifac[i] % mod;
 
	cnt = n << 1;
	for (int i = 1; i <= n; ++i) {
		if (i > k) ++cnt, add(cnt, i - k), add(cnt, n + i);
		if (i <= n - k) ++cnt, add(cnt, i + k), add(cnt, n + i);
	}
 
	f[0] = 1;
	for (int i = 1; i <= n << 1; ++i)
		if (!vis[i]) {
			cnt = 0; dfs(i);
			for (int i = n; i >= 1; --i)
				for (int j = 1; j <= i && (j << 1) <= cnt + 1; ++j) f[i] = (f[i] + (ll)f[i - j] * C(cnt - j + 1, j)) % mod;
		}
 
	int ans = 0;
	for (int i = 0; i <= n; ++i)
		if (~i & 1) ans = (ans + (ll)fac[n - i] % mod * f[i]) % mod;
		else ans = (ans + (ll)(mod - fac[n - i]) * f[i]) % mod;
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();

            string ichi = input.Substring(input.Length - 1, 1);
            string ans = "hon";

            if (ichi.Equals("3")) ans = "bon";
            else if (ichi.Equals("0") || ichi.Equals("1") || ichi.Equals("6") || ichi.Equals("8")) ans = "pon";

            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 25888
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

typedef struct {
    string city;
    int score;
    int index;
} record;

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

    int N; cin >> N;
    vector<record> DB(N);
    rep(i, 0, N) {
        cin >> DB[i].city >> DB[i].score;
        DB[i].index = i;
    }

    stable_sort(DB.begin(), DB.end(), [](const record &a, const record &b) {
        return a.score > b.score;
    });

    stable_sort(DB.begin(), DB.end(), [](const record &a, const record &b) {
        return a.city < b.city;
    });

    for (auto record : DB) {
        cout << record.index+1 << "\n";
    }
}


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

int main(){
  string s,t;
  cin >> s >> t;
 
  bool flag = false;
  int n = s.size();
  rep(i,n){
    for(int i = n-1; i > 0; i--) swap(s[i],s[i-1]);
    if(s==t) flag = true;
  }
  if(flag) cout << "Yes" << endl;
  if(!flag)cout << "No" << endl;
}

Measured memory_bytes: 3572
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"

n = k()

m = math.ceil(math.sqrt(n))

val = []
for i in range(m):
    if n % (i+1) == 0:
        val.append(len(str(n//(i+1))))
print(min(val))


Measured memory_bytes: 10416
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		char[] s = sc.next().toCharArray();
		char[] t = sc.next().toCharArray();

		Arrays.sort(s);
		Arrays.sort(t);

		for(int i = 0; i < s.length; i++){
			for(int j = i; j < t.length; j++){
				if(s[i] < t[j]){
					System.out.println("Yes");
					return;
				}
			}
		}

		if(new String(t).contains(new String(s)) && s.length < t.length){
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}

	}
}


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

int main(){
  int N;
  cin >> N;

  int sum_keta = 0;
  while(N > 0){
    sum_keta += N % 10;
    N /= 10;
  }
  if(sum_keta == 1){
    sum_keta = 10;
  }

  cout << sum_keta << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <bitset>
#include <tuple>
#include <stack>
#include <utility>

using namespace std;
typedef long long ll;

int main(){
    int K, a=0, b=0;
    cin >> K;
    for(int i=1; i<=K; i++){
        if(i%2==0) a+=1;
        else b+=1;
    }
    cout << a*b << endl;
    return 0;
}

Measured memory_bytes: 256