akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abc174/tasks/abc174_e
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    REP(i, N) { cin >> A[i]; }
    // sort(ALL(A));
    // 二分探索
    int ng = 0, ok = 1e9;
    // 全ての丸太を長さtarget以下にする
    auto fn = [&](int target) {
        int cnt = 0;
        REP(i, N) {
            // 例えば長さ7を7以下にするなら切らなくていい。
            // 7未満にするなら1回切るように数える。
            cnt += DIV(A[i], target) - 1;
            if (cnt > K) {
                break;
            }
        }
        return cnt <= K;
    };
    while (ok - ng > 1) {
        // 2で割る
        int mid = (ng + ok) >> 1;
        (fn(mid) ? ok : ng) = mid;
    }
    cout << ok << endl;

    return 0;
}


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

struct Ps{
  int r,c;
  Ps():r(0),c(0){}
  Ps(int r,int c):r(r),c(c){}
  Ps operator+(const Ps&p)const
  { return Ps(r+p.r,c+p.c);  }
  friend istream& operator>>(istream&is,Ps&p)
  {is >> p.r >> p.c; return is;  }
};

int main(){
  int h,w; cin >> h >> w;
  Ps s,g; cin >> s >> g;
  s = s+Ps(-1,-1);
  g = g+Ps(-1,-1);
  bitset<1000> mz[1000];
  for(int i = 0; i < h; ++i)for(int j = 0; j < w; ++j)
      mz[i][j] = []{char c; cin >> c; return c;}() == '.';
  optional<int> distance[1000][1000];
  deque<pair<Ps,int>> dq;
  dq.emplace_front(s,0);
  constexpr int mr[] = {0,0,1,-1};
  constexpr int mc[] = {1,-1,0,0};
  constexpr int nr[] = {-2,-2,-2,-2,-2,-1,-1,-1,-1, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2};
  constexpr int nc[] = {-2,-1, 0, 1, 2,-2,-1, 1, 2,-2, 2,-2,-1, 1, 2,-2,-1, 0, 1, 2};
  while(!dq.empty()){
    auto [ps,di] = dq.front();
    dq.pop_front();
    if(distance[ps.r][ps.c])continue;
    distance[ps.r][ps.c] = di;
    if(ps.r==g.r && ps.c==g.c)break;
    for(int i = 0; i < 4; ++i){
      Ps nps = ps + Ps(mr[i],mc[i]);
      if(nps.r < 0 || nps.c < 0 || nps.r >= h || nps.c >= w)continue;
      if(!mz[nps.r][nps.c])continue;
      if(distance[nps.r][nps.c])continue;
      dq.emplace_front(nps,di);
      mz[nps.r][nps.c] = 0;
    }
    for(int i = 0; i < 20; ++i){
      Ps nps = ps + Ps(nr[i],nc[i]);
      if(nps.r < 0 || nps.c < 0 || nps.r >= h || nps.c >= w)continue;
      if(!mz[nps.r][nps.c])continue;
      if(distance[nps.r][nps.c])continue;
      dq.emplace_back(nps,di+1);
    }
  }
  cout << (distance[g.r][g.c] ? distance[g.r][g.c].value() : -1) << endl;
}


Measured memory_bytes: 11928
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Stack;

public class Main {

	static class Node {
		int id, parentId, left, right;
		boolean visited;
		public Node(int id) {
			this.id = id;
			parentId = left = right = -1;
			visited = false;
		}
	}

	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		Node[] nodes = new Node[n];
		for (int i = 0; i < n; i++) {
			StringTokenizer st = new StringTokenizer(reader.readLine());
			int id = Integer.parseInt(st.nextToken());
			int left = Integer.parseInt(st.nextToken());
			int right = Integer.parseInt(st.nextToken());
			if (nodes[id] == null) {
				nodes[id] = new Node(id);
			}
			nodes[id].left = left;
			nodes[id].right = right;
			if (left != -1) {
				if (nodes[left] == null) nodes[left] = new Node(left);
				nodes[left].parentId = id;
			}
			if (right != -1) {
				if (nodes[right] == null) nodes[right] = new Node(right);
				nodes[right].parentId = id;
			}
		}

		int rootId = -1;
		for (int i = 0; i < nodes.length; i++) {
			if (nodes[i].parentId == -1) {
				rootId = nodes[i].id;
				break;
			}
		}
		System.out.println("Preorder");
		preOrder(nodes, rootId);
		System.out.println("Inorder");
		inOrder(nodes, rootId);
		resetVisited(nodes);
		System.out.println("Postorder");
		postOrder(nodes, rootId);
	}

	private static void resetVisited(Node[] nodes) {
		for (int i = 0; i < nodes.length; i++) nodes[i].visited = false;
	}

	private static void preOrder(Node[] nodes, int rootId) {
		Stack<Integer> stack = new Stack<Integer>();
		stack.push(rootId);
		while (!stack.isEmpty()) {
			Node node = nodes[stack.pop()];
			System.out.print(" " + node.id);
			if (node.right != -1) stack.push(node.right);
			if (node.left != -1) stack.push(node.left);
		}
		System.out.println("");
	}

	private static void inOrder(Node[] nodes, int rootId) {
		Stack<Integer> stack = new Stack<Integer>();
		stack.push(rootId);
		while (!stack.isEmpty()) {
			Node node = nodes[stack.pop()];
			if (node.right != -1 && !nodes[node.right].visited) stack.push(node.right);
			if (node.left == -1 || nodes[node.left].visited) {
				if (!node.visited) {
					System.out.print(" " + node.id);
					node.visited = true;
				}
			} else {
				stack.push(node.id);
			}
			if (node.left != -1 && !nodes[node.left].visited) stack.push(node.left);
		}
		System.out.println("");
	}

	private static void postOrder(Node[] nodes, int rootId) {
		Stack<Integer> stack = new Stack<Integer>();
		stack.push(rootId);
		while (!stack.isEmpty()) {
			Node node = nodes[stack.pop()];
			if ((node.left == -1 || nodes[node.left].visited) && (node.right == -1 || nodes[node.right].visited)) {
				System.out.print(" " + node.id);
				node.visited = true;
			} else {
				stack.push(node.id);
			}
			if (node.right != -1 && !nodes[node.right].visited) stack.push(node.right);
			if (node.left != -1 && !nodes[node.left].visited) stack.push(node.left);
		}
		System.out.println("");
	}
}



Measured memory_bytes: 24296
// abc152_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;

    vector<vector<ll>> mp(10, vector<ll>(10));
    REPN(i, 1, N+1){
        string x = to_string(i);
        mp[x[0] - '0'][x.back() - '0']++;
    }

    ll ans = 0;

    REP(i, 10) REP(j, 10){
        if (i == 0 || j == 0) continue;
        if (i == j){
            ans += mp[i][j] * mp[i][j];
        } else {
            ans += mp[i][j] * mp[j][i];
        }
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 256
local mmi, mma = math.min, math.max
local bls, brs = bit.lshift, bit.rshift
local mfl, mce = math.floor, math.ceil

local function getgcd(x, y)
  while 0 < x do
    x, y = y % x, x
  end
  return y
end

local t2, t5 = {}, {}
local t2min, t2max, t5min, t5max = 0, 0, 0, 0

local n = io.read("*n", "*l")
for i = 1, n do
  local s = io.read()
  local c2, c5 = 0, 0
  if s:find("%.") then
    local x, y = s:match("(%d+)%.(%d+)")
    x = tonumber(x)
    local dig = #y
    local denom = 1
    for j = 1, #y do
      denom = denom * 10
    end
    y = tonumber(y)
    local gcd = getgcd(denom, y)
    denom = mfl(denom / gcd)
    y = mfl(y / gcd)
    local a = x * denom + y
    local b = denom

    while a % 2 == 0 do
      a = mfl(a / 2)
      c2 = c2 + 1
    end
    while a % 5 == 0 do
      a = mfl(a / 5)
      c5 = c5 + 1
    end
    while b % 2 == 0 do
      b = mfl(b / 2)
      c2 = c2 - 1
    end
    while b % 5 == 0 do
      b = mfl(b / 5)
      c5 = c5 - 1
    end
  else
    local x = tonumber(s)
    while x % 2 == 0 do
      x = mfl(x / 2)
      c2 = c2 + 1
    end
    while x % 5 == 0 do
      x = mfl(x / 5)
      c5 = c5 + 1
    end
  end
  t2[i] = c2
  t5[i] = c5
  t2min = mmi(t2min, c2)
  t2max = mma(t2max, c2)
  t5min = mmi(t5min, c5)
  t5max = mma(t5max, c5)
end
local t = {}
local wid2 = t2max - t2min + 1
local wid5 = t5max - t5min + 1
local sz = wid2 * wid5
for i = 1, sz do
  t[i] = 0
end
local ret = 0
for i = 1, n do
  local c2, c5 = t2[i], t5[i]
  local need2, need5 = mma(t2min, -c2), mma(t5min, -c5)
  for j = need2, t2max do
    for k = need5, t5max do
      local idx = (j - t2min) * wid5 + (k - t5min + 1)
      ret = ret + t[idx]
    end
  end
  do
    local idx = (c2 - t2min) * wid5 + (c5 - t5min + 1)
    t[idx] = t[idx] + 1
  end
end
print(ret)


Measured memory_bytes: 9436
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
int main()
{
  vector<ll> tmp;
  ll n,m;
  cin>>n>>m;
  tmp.push_back(n);
  tmp.push_back(m);
  sort(tmp.begin(),tmp.end());
  m=tmp[0];
  n=tmp[1];
  ll ans=1;
  if(abs(n-m)==0){
    for(ll i=1;i<=n;i++){
      ans*=i;
      ans%=mod;
    }
    ans*=ans;
    ans%=mod;
    ans*=2;
    ans%=mod;
    cout<<ans;
    return 0;
  }
  else if(abs(n-m)==1){
    for(ll i=1;i<=m;i++){
      ans*=i;
      ans%=mod;
    }
    ans*=ans;
    ans%=mod;
    ans*=n;
    ans%=mod;
    cout<<ans;
    return 0;
  }
  else {
    cout<<0;
    return 0;
  }
}

Measured memory_bytes: 256
//By Tushar Gautam
#include <bits/stdc++.h>
using namespace std;
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 5e5+5, MOD = 1e9+7;
int t,n,m,k,x,y,z,c;
int cost[32][32];
int ze[LIM],o[LIM],tw[LIM];
int co[3][32];
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    cin>>n>>c;
    forn(i,c) forn(j,c) cin>>cost[i][j];
    forn(i,n) forn(j,n){
        cin>>t;//dbg(t);
        if((i+j)%3==0){
            ze[x++]=t;
        }else if((i+j)%3==1){
            o[y++]=t;
        }else tw[z++]=t;
    }
    //dbg(x);dbg(y);dbg(z);
    forn(i,c){
        t=0;
        forn(j,x) t+=cost[ze[j]-1][i];
        co[0][i]=t;
    }
    forn(i,c){
        t=0;
        forn(j,y) t+=cost[o[j]-1][i];
        co[1][i]=t;
    }
    forn(i,c){
        t=0;
        forn(j,z) t+=cost[tw[j]-1][i];
        co[2][i]=t;
    }
    k=MOD;
    forn(i,c){
        forn(j,c){
            if(j==i) continue;
            forn(k1,c){
                if(k1==i || k1==j) continue;
                k=min(k,co[0][i]+co[1][j]+co[2][k1]);
            }
        }
    }
    cout<<k;
    return 0;
}

Measured memory_bytes: 2944
#include <cstdio>

#define FOR(i, a, b) for(i=a; i<b; ++i)

#define MAXN

int soler(int n, int k) {
	long long int num;
	long long int odd, even;

	if (k&1) {
		even = n/k;
		num = even*even*even;
	}
	else {
		odd = (n+(k>>1))/k;
		even = n/k;
		num = odd*odd*odd+even*even*even;
	}

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

int main() {
	int n,k;

	scanf("%d %d", &n, &k);

	soler(n, k);
	return 0;
}



Measured memory_bytes: 128
// https://atcoder.jp/contests/abc154/tasks/abc154_e

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  string N;
  ll K;
  cin >> N >> K;

  // dp[i][k][strict]: 上から i 桁目までで k 個使った場合
  V<VVL> dp(N.size() + 1, VVL(K + 1, VL(2)));
  dp[0][0][1] = 1;

  ll len = N.size();
  rep(i, len) {
    // 次の桁
    ll num = N[i] - '0';

    // 今の所
    rep(k, K + 1) {
      if (num == 0) {
        // 0 をとる場合
        dp[i + 1][k][1] += dp[i][k][1];
        dp[i + 1][k][0] += dp[i][k][0];

        // 0 以外
        if (k >= K) continue;

        dp[i + 1][k + 1][0] += 9 * dp[i][k][0];
      } else {
        // 0 をとる場合
        dp[i + 1][k][0] += dp[i][k][0] + dp[i][k][1];

        // 0 以外
        if (k >= K) continue;

        dp[i + 1][k + 1][1] += dp[i][k][1];
        dp[i + 1][k + 1][0] += dp[i][k][0] * 9 + dp[i][k][1] * (num - 1);
      }
    }
  }

  ll res = dp[N.size()][K][1] + dp[N.size()][K][0];
  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

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

    public static void main(String[] args) {
        int n = sc.nextInt();
        boolean hasY = false;
        for (int i = 0; i < n; i++) {
            if (sc.next().equals("Y")) {
                hasY = true;
            }
        }
        System.out.println(hasY ? "Four" : "Three");
    }
}


Measured memory_bytes: 22228
n=int(input())
suji=[]
for i in range (n):
	suji=suji+list(map(int,input().split()))
tlist=[]
alist=[]
for i in range(2*n):
	if i%2==0:
		tlist.append(suji[i])
	else:
		alist.append(suji[i])

for i in range(n-1):
	aaa=alist[i]//alist[i+1]
	ttt=tlist[i]//tlist[i+1]
	if alist[i]%alist[i+1]!=0:
		aaa+=1
	if tlist[i]%tlist[i+1]!=0:
		ttt+=1
	k=max(aaa,ttt)
	tlist[i+1]=tlist[i+1]*k
	alist[i+1]=alist[i+1]*k

print(int(tlist[n-1]+alist[n-1]))

Measured memory_bytes: 3188
public class Main {
    public static void main(String[] args) {
        String x = "x";
        for (int i = 1; i < 10; i++) {
            for (int n = 1; n < 10; n++) {
                System.out.println(i + x + n + "=" + (i * n) );
            }
        }
    }
}


Measured memory_bytes: 24184
#include <iostream>
#include <string>
#include <utility>
#include <map>

using namespace std;

map<pair<int, long long>, long long> dp;
pair<long long, long long> cnt[51];

long long dfs(int n, long long x){
    auto status = make_pair(n, x);
    if(dp.count(status)) return dp[status];
    if(x <= 1) return dp[status] = x == 1 && n == 0;
    if(cnt[n].first - 1 <= x) return cnt[n].second;
    x--;
    long long res = 0;
    if(cnt[n - 1].first - 1 <= x){
        res += cnt[n - 1].second;
    }else{
        return dfs(n - 1, x);
    }
    x -= cnt[n - 1].first;
    if(x){
        res++;
        x--;
    }
    return dp[status] = res + dfs(n - 1, x);
}

int main(){
    int n;
    long long x;
    cin >> n >> x;
    cnt[0] = make_pair(1ll, 1ll);
    for(int i = 1; i <= 50; i++){
        cnt[i] = make_pair(2 * cnt[i - 1].first + 3, 2 * cnt[i - 1].second + 1);
    }
    long long ans = dfs(n, x);
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define st first
#define nd second

using ll = long long ;
using namespace std;
using pii = pair<ll,int>;
std::vector<pii> v;
int a[60], b[60];

int main(){
	ll n, d;
	scanf("%lld", &n);
	d = n;
	int ans = 0;
	for(int i = 2; 1LL * i * i<= n; i++){
		int po = 0;
		while(n % i == 0){
			n /= i;
			po++;
		}
		if(po > 0) v.push_back({1LL * i, po});
	}
	if(n != 1) v.push_back({n, 1});
	int sz = (int)v.size();
	for(int i = 1; i < (1 << sz); i++){
		ll cur = d;
		int g = 0;
		for(int j = 0; j < sz; j++){
			if((1 << j) & i){
				g = __gcd(g, v[j].nd);
				for(int i = 0; i < v[j].nd; i++) cur /= v[j].st;
			}
		}
		for(int ii = 1; ii <= g; ii++){
			if(g % ii) continue;
			ll val = 1;
			for(int j = 0; j < sz; j++){
				if((1 << j) & i){
					for(int k = 0; k < v[j].nd / ii; k++){
						val *= v[j].st;
					}
				}
			}
			if(cur % val == 1) ans++;
		}
	}
	d--;
	if(d != 1) ans ++;
	for(int i = 2; 1LL * i * i <= d; i++){
		if(d % i == 0) ans += (1LL * i * i == d? 1 : 2);
	}
	printf("%d",ans);
}

Measured memory_bytes: 256
import numpy as np


def solve():
    N, T = map(int, input().split())
    ab_l = [[0, 0] for _ in range(N)]
    for i in range(N):
        ab_l[i][0], ab_l[i][1] = map(int, input().split())
    ab_l.sort()
    dp = np.zeros(T, dtype=int)
    ans = 0

    for a, b in ab_l:
        ans = max(ans, dp[-1] + b)
        dp[a:] = np.maximum(dp[a:], dp[:-a]+b)

    print(ans)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 12520
/* 
chirag11032000
Chirag Thakur
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

vector < int > pos[4];

void testCase();

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	testCase();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void testCase() {
	int n;
	cin >> n;
	vector < string > v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
		if (v[i].back() == 'A' && v[i].front() == 'B') {
			pos[1].eb(i);
		} else if (v[i].back() == 'A') {
			pos[0].eb(i);
		} else if (v[i].front() == 'B') {
			pos[2].eb(i);
		} else {
			pos[3].eb(i);
		}
	}
	vector < int > ctr(4, 0);
	string pref;
	if (pos[0].size() != 0) {
		pref = v[pos[0][0]];
		++ctr[0];
	}
	string res = pref;
	while (ctr[1] != pos[1].size()) {
		res += v[pos[1][ctr[1]++]];
	}
	string suff;
	if (pos[2].size() != 0) {
		suff = v[pos[2][0]];
		++ctr[2];
	}
	res = res + suff;
	while (ctr[0] != pos[0].size() && ctr[2] != pos[2].size()) {
		res += v[pos[0][ctr[0]++]] + v[pos[2][ctr[2]++]];
	}
	for (int i = 0; i < 4; ++i) {
		while (ctr[i] != pos[i].size()) {
			res += v[pos[i][ctr[i]++]];
		}
	}
	int cnt = 0;
	for (int i = 0; i < res.size() - 1; ++i) {
		if (res[i] == 'A' && res[i + 1] == 'B') {
			++cnt;
		}
	}
	cout << cnt << "\n";
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>
#include <math.h>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define RREP(i,n) for(int i=(n)-1; i>=0; --i)
#define SREP(i,s,n) for(int i=(s), i##_len=(n); i<i##_len; ++i)


using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

bool comp(pair<ll, ll> a, pair<ll, ll> b) {
    return (a.first*a.first + a.second*a.second) > (b.first*b.first + b.second*b.second);
}

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    
    UnionFind(int n = 1) {
        init(n);
    }
    
    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
        }
    }
    
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

#define MOD (1000000007)

ll d2(pair<ll, ll> p) {
    return p.first*p.first+p.second*p.second;
}

int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N;
    cin >> N;
    vector<int> B(N+1);
    REP(i, N-1) cin >> B[i+1];
    B[0] = 100000;
    B[N] = 100000;
    ll ans = 0;
    REP(i, N) {
        ans += min(B[i], B[i+1]);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 888
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if l[i] == l[j] or l[j] == l[k] or l[i] == l[k]: continue
            if l[i] + l[j] > l[k]: ans -= -1
print(ans)

Measured memory_bytes: 67972
<?php
fscanf(STDIN, '%d', $n);
$numbers = fgets(STDIN);
$exploded_numbers = explode(' ', trim($numbers));

foreach ($exploded_numbers as $number) {
  if ($number % 2 == 0) {
    if ($number % 3 != 0 && $number % 5 != 0) {
      echo 'DENIED';
      exit;
    }
  }
}
echo 'APPROVED';

Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n+1); i++)
int main() {
 int N;
 cin>>N;
 string S;
 cin>>S;
 int cnt=0;
 rep(i,S.size()){
     if(i!=0){
         if(S[i]=='W'){
         }
         else{
             cnt++;
         }
     }
 }
 int ans=cnt;
 rrep(i,S.size()-1){
     if(S[i-1]=='W'){
         cnt++;
     }
     if(S[i]=='E'){
         cnt--;
     }
     if(cnt<ans){
         ans=cnt;
     }
 }
 cout<<ans<<endl;
}

Measured memory_bytes: 3872
(function(stdin){
	var lines = stdin.toString().split('\n').map(Number);
	var x = lines[0];
	var h = ~~(x /(60 * 60));
	var m = ~~(x %(60 * 60)/60);
	var s = ~~(x % 60);
	console.log(h+":"+m+":"+s);
}(require('fs').readFileSync('/dev/stdin','utf8')));

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

int main() {
    ll a, b, x;
    cin >> a >> b >> x;
    ll ans1, ans2;
    ans1 = b / x;
    ans2 = a / x;
    if (a % x == 0) ans1++;
    cout << ans1 - ans2 << endl;
}

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

    int main(int argc, char* argv[])
    {
        long long a, b, k;
        std::cin >> a >> b >> k;
        if (k <= a)
        {
            std::cout << a - k << ' ' << b << "\n";
        }
        else if (k <= a +b )
        {
            std::cout << 0 << ' ' << b - (k-a) << "\n";
        }
        else {
            std::cout << 0 << ' ' << 0 << "\n";
        }
        return 0;
    }


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int x, y, r, w, h;
    cin >> w >> h >> x >> y >> r;
    if (x - r >= 0 && y - r >= 0 && x + r <= w && y + r <= h) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 3112
#include<stdio.h>
int main()
{
	int n;
	long a=2,b=1,t;

	scanf("%d",&n);

	if(n==1){
		printf("1");
		return 0;
	}
	while(n>1){
		t=a+b;
		a=b;
		b=t;
		n--;
	}
	printf("%ld",t);
	return 0;
}

Measured memory_bytes: 128
drm(x) = x=="dream"?true:false
drme(x) = x=="dreamer"?true:false
ers(x) = x=="erase"?true:false
erse(x) = x=="eraser"?true:false


function main()
	x = chomp(readline())
	t = length(x)
	flg = 0
	while t > 0
		if t <= 4
			flg = 1
			break
		elseif drm(x[t-4:t]) || ers(x[t-4:t])
			t -= 5
		elseif t <= 5
			flg = 1
			break
		elseif erse(x[t-5:t])
			t -= 6
		elseif t <= 6
			flg = 1
			break
		elseif drme(x[t-6:t])
			t -= 7
		else
			flg = 1
			break
		end
	end
	if flg == 1
		print("NO")
	else
		print("YES")
	end
end

main()

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

int main(void) {
  int n;
  scanf("%d", &n);
  map<ll, ll> m;
  ll res = 0LL;
  for(int i = 0;i < n;++i) {
    ll a;
    scanf("%lld", &a);
    m[a]++;
    res += a;
  }
  int q;
  scanf("%d", &q);
  for(int i = 0;i < q;++i) {
    ll b,c;
    scanf("%lld %lld", &b, &c);
    res += (c - b) * m[b];
    m[c] += m[b];
    m[b] = 0;
    printf("%lld\n", res);
  }
  return 0;
}


Measured memory_bytes: 9596
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




int main(){
    int N,M;
    cin >> N >> M;
    int a = 1;
    rep(i,M) a*=2;
    cout << a*((N-M)*100+1900*M) << endl;

    
    
    
    

    return 0;
}


Measured memory_bytes: 256
n = list(map(int,input().split())) 
K = n[1] 
n1 = list(map(int,input().split())) 
n1.sort()
if K < n[0] : 
    n1 = n1[0:len(n1)-K] 
    print(sum(n1))
else : 
    print("0")

Measured memory_bytes: 26360
#include<stdio.h>
int main(){while(1){
int a,b;
char op;
scanf("%d %c %d",&a,&op,&b);
if(op=='+')printf("%d\n",a+b);
if(op=='-')printf("%d\n",a-b);
if(op=='*')printf("%d\n",a*b);
if(op=='/')printf("%d\n",a/b);
if(op=='?')break;}return 0;}

Measured memory_bytes: 600
#include<iostream>
    using namespace std;
     
    int main()
    {
        int x,a,b,c;
        while(cin>>a>>b>>c>>x){
            x/=50;
            int sum=0;
            for(int i=0;i<=a;i++){
                for(int j=0;j<=b;j++){
                    for(int k=0;k<=c;k++){
                        if(i*10+j*2+k==x) sum++;
                    }
                }
            }
            cout<<sum<<endl;
        }
        return 0;
    }

Measured memory_bytes: 888
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり


N,K = MI()
A = LI()

from itertools import accumulate

for _ in range(min(K,100)):
    B = [0]*(N+1)
    for i in range(N):
        a = A[i]
        B[max(i-a,0)] += 1
        B[min(N,i+a+1)] -= 1
    C = list(accumulate(B))
    A = C

print(*[A[i] for i in range(N)])


Measured memory_bytes: 185184
#include <iostream>
#include <algorithm>
using namespace std;
#define int long long
#define MAX 51

int edge[MAX][MAX];
bool visited[MAX];
int n, m;

void dfs(int v) {
    if (visited[v]) return;
    visited[v] = true;
    for (int j = 1; j <= n; j++) {
        if (edge[v][j]) dfs(j);
    }
}

bool connected() {
    for (int i = 1; i <= n; i++) {
        if (!visited[i]) return false;
    }
    return true;
}

signed main() {
    for (int i = 0; i < MAX; i++) {
        for (int j = 0; j < MAX; j++) {
            edge[i][j] = 0;
        }
    }
    cin >> n >> m;
    int a[m], b[m];
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        edge[a[i]][b[i]] = 1;
        edge[b[i]][a[i]] = 1;
    }

    int ans = 0;
    for (int i = 0; i < m; i++) {
        edge[a[i]][b[i]] = 0;
        edge[b[i]][a[i]] = 0;
        for (int i = 0; i < MAX; i++) {
            visited[i] = false;
        }
        dfs(1);
        if (!connected()) ans++;
        edge[a[i]][b[i]] = 1;
        edge[b[i]][a[i]] = 1;
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
    int n, q, a[200000], b[200000], p[200000], x[200000], route[200000], result[200000];
    scanf("%d", &n);
    scanf("%d", &q);
    route[0] = 0;
    result[0] = 0;
    for (int i = 0; i < n - 1; i++)
    {
        scanf("%d", &a[i]);
        scanf("%d", &b[i]);
        route[b[i] - 1] = a[i];
        result[i] = 0;
    }
    for (int i = 0; i < q; i++)
    {
        scanf("%d", &p[i]);
        scanf("%d", &x[i]);
        result[p[i] - 1] += x[i];
    }
    for (int i = 0; i < n; i++)
    {
        if (route[i])
        {
            result[i] += result[route[i] - 1];
        }
        printf("%d\n", result[i]);
    }
    return 0;
}

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


using namespace std;

int main(){
    
    
    int N, A, B;
    cin >> N >> A >> B;
    
    if (N*A < B) {
        cout << N*A << endl;
    }else{
        cout << B << endl;
        
    }
        
        
    
    
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
    using namespace std;
    using namespace __gnu_pbds;
    #define endl "\n"
    #define fi first
    #define se second
    #define pb push_back
    #define ll long long
    #define ld long double
    #define pii pair<ll,ll>
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define For(i,n) for(ll i=0;i<n;i++)
    #define what(x) cerr << #x << " is " << x << endl;
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;
    typedef tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> ordered_mset;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
/*.....................................................................................................................*/

    const ll mod=(ll)1e9+7;
    ll add(ll x,ll y) {return (x+y)%mod;}
    ll mult(ll x, ll y){return ((x%mod )* (y%mod)) % mod;}
    long long binpow(long long x, long long p) 
    {
        if (p == 0) {return 1;}
    	if (p == 2 || (p & 1)) {return mult(x, binpow(x, p - 1));}
    	return binpow(binpow(x, p / 2), 2);
    }
    ll modinv(ll a) {return binpow(a,mod-2);}
    double pi=3.141592653589793238462641;
    ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
    const ll man=(ll)1e5+5;
/*........................................................................................................................*/

signed main()
{
    fast;
    ll k,x;
    cin>>k>>x;
    if(k*500>=x)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}   


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
string st;
string rev(int);
int main(){
  while(1){
    cin >> st;
    if(st==".")break;
    st+=']';
    string an=rev(0);
    cout << an;
    cout << endl;
  }
  return 0;
}
string rev(int I){
  int c=0;
  int kc=0;
  string re="";
  while(I<st.size()){
    //cout << I<< endl;;
    if(st[I]==']'){
      kc--;
      if(kc==-1)return re;
    }
    else if(st[I]=='['){
      kc++;
      if(kc==1){
	string rst=rev(I+1);
	for(int i=rst.size()-1;i>=0;i--){
	  re+=rst[i];
	}
      }
      //cout << re << endl;
    }
    else if(kc){I++;continue;}
    else if(st[I]=='+')c++;
    else if(st[I]=='-')c--;
    else if('A'<=st[I]&&st[I]<='Z'){
      int ch=st[I]+c;
      while(ch>'Z')ch-=26;
      while(ch<'A')ch+=26;
      c=0;
      re+=(char)ch;
    }

    else if(st[I]=='?'){
      re+='A';
      c=0;
    }
    I++;
  }
}

Measured memory_bytes: 3156
bit_ary = [1, 2, 4, 8, 16, 32, 64, 128, 256]
check_ary = [7, 56, 448, 73, 146, 292, 273, 84]
map_ = []
selecter = range(9)
player = 0

def checker(p):
    for check in check_ary:
        if ((check & p) == check):
            return True
    return False

for _ in range(3):
    a, b, c = map(int, input().split())
    map_.append(a)
    map_.append(b)
    map_.append(c)

    
n = int(input())
for _ in range(n):
    b = int(input())
    try:
        player += bit_ary[map_.index(b)]
        map_[map_.index(b)] = 'done'
    except:
        pass

if checker(player):
    print("Yes")
else:
    print("No")

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

using namespace std;

#define ll					long long
#define vi					vector<int>
#define vii					vector<vi>
#define ALL(s)			(s).begin(),(s).end()
#define pii					pair<int, int>
#define pll					pair<ll, ll>
#define si					set<int>
#define mp					make_pair
#define F						first
#define S						second
#define pb					push_back
#define tc(t)				int t; cin >> t; while(t--)
#define _						ios_base::sync_with_stdio(false); cin.tie(NULL); 
const ll MOD = 1e9 + 7;
const ll INF = 1<<29;
const ll MAX_N = 1e6 + 7;


int main() {_
	int a,b;
	cin >> a >> b;

	float ans1, ans2;

	ans1 = (float)round((float)a/0.08);

	if(b == (int)floor((float)ans1*0.1))
		ans2 = ans1;
	else {
		ans2 = (float)round((float)b/0.1);
		if(a == (int)floor((float)ans2*0.08))
			ans1 = ans2;
	}
	
	//cout << ans1 << " " << ans2 << "\n";
	if(ans1 == ans2)
		cout << ans1 << "\n";
	else
		cout << "-1\n";

	
	
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define popCnt(x) (__builtin_popcountll(x))
typedef long long Long;
typedef unsigned long long ULong;

const int MOD = round(1e9 + 7);
const int N = 1e5 + 5;

Long fact[N];
Long ways_to_be_placed_after_less_numbers[N];
Long ways_y[N];

Long power(int b, int p) {
  if (p == 0) return 1;
  Long tmp = power(b, p / 2);
  tmp = 1LL * tmp * tmp % MOD;
  if (p & 1) {
    tmp = 1LL * tmp * b % MOD;
  }
  return tmp;
}

int n;

void build() {
  fact[0] = 1;
  for (int i = 1; i < N; ++i) {
    fact[i] = 1LL * fact[i - 1] * i % MOD;
  }

  for (int i = 1; i <= n; ++i) {
    ways_to_be_placed_after_less_numbers[i] = 1LL * fact[n] * power(i, MOD - 2)
      % MOD;
  }

  ways_y[2] = ways_to_be_placed_after_less_numbers[2];
  for (int i = 3; i <= n; ++i) {
    ways_y[i] = (ways_y[i - 1] + ways_to_be_placed_after_less_numbers[i]) % MOD;
  }
}

Long arr[N];

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#else
#define endl '\n'
#endif

  cin >> n;
  build();

  Long res = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> arr[i];
    res = (res
      + 1LL * arr[i]
        * (ways_y[i] + ways_y[n - i + 1]
          + ways_to_be_placed_after_less_numbers[1])) % MOD;
  }
  cout << res;

}



Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9
#define MAXN 10000001
bool is_prime[MAXN];
void make(){
    fill(is_prime,is_prime+MAXN,true);
    is_prime[0] = is_prime[1] = false;
    for(int i=2;i<MAXN;i++){
	if(!is_prime[i])continue;
	for(int j=2 ; j*i<MAXN;j++) is_prime[i*j] = false;
    }
}
//bool is_prime2[MAXN];
int main(){
    make();
    //fill(is_prime2,is_prime2+MAXN,true);
    vector<int> ans;
    for(int i=13;i<MAXN;i++){
	if(is_prime[i]){
	    if(is_prime[i] && is_prime[i-2] && is_prime[i-6] &&is_prime[i-8] ){
		ans.push_back(i);
	    }
	}
    }
    while(1){
	int n;
	cin>>n;
	if(n==0)break;
	auto it = upper_bound(ans.begin() , ans.end() ,n);
	it--;
	cout<<*it<<endl;
    }
    return 0;
}



Measured memory_bytes: 12828
from collections import deque

H, W, K = map(int, raw_input().split())

MAP = [raw_input() for _ in xrange(H)]
visited = [[False for _ in xrange(W)] for _ in xrange(H)]

for y in range(H):
    x = MAP[y].find('S')
    if x != -1:
        sx = x
        sy = y

Q = deque()
Q.append((0, (sx, sy)))
visited[sy][sx] = True
while len(Q) > 0:
    cost, [x, y] = Q.popleft()
    for dx, dy in [(-1, 0), (1, 0), (0, 1), (0, -1)]:
        px, py = x+dx, y+dy
        if 0 <= px < W and 0 <= py < H:
            if not visited[py][px] and MAP[py][px] != "#":
                visited[py][px] = True
                if cost + 1 < K:
                    Q.append((cost + 1, (px, py)))

d = 10000
for x in xrange(W):
    for y in xrange(H):
        if visited[y][x]:
            d = min(d, x, W-1-x)
            d = min(d, y, H-1-y)

print (d + K - 1) / K + 1


Measured memory_bytes: 11256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=3e5+10;
int n,m;
struct point{
	int l,r;
}a[maxn];
struct szsz{
	int c[maxn];
	inline int lowbit(int x){
		return x&(-x);
	}
	inline int sum(int x){
		int res=0;
		while(x){
			res+=c[x];
			x-=lowbit(x);
		}
		return res;
	}
	inline void add(int x,int y){
		while(x<=n){
			c[x]+=y;
			x+=lowbit(x);
		}
	}
}bit;
vector<int> ve[maxn];
int main(){
	m=read(),n=read();
	int tag=m;
	REP(i,1,m){
		a[i].l=read(),a[i].r=read();
		if(a[i].l!=0) ve[a[i].r-a[i].l+1].push_back(i);
	}
	REP(i,1,n){
		int ans=0;
		REP(j,1,n/i) ans+=bit.sum(i*j);
		printf("%d\n",tag+ans);
		for(auto v:ve[i]) bit.add(a[v].l,1),bit.add(a[v].r+1,-1),--tag;
	}
	return 0;
}


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

int main() {
  
  int64_t N, M; cin >> N >> M;
  
  int64_t MOD = 1000000007;
  
  if (1 < abs(N - M)) { cout << 0 << endl; return 0; }
  
  if (abs(N - M) == 1) {
    
    int64_t tmpN = 1, tmpM = 1;
    
    for (int i = 1; i <= N; i++) {
      tmpN *= i; tmpN %= MOD;
    }
    
    for (int i = 1; i <= M; i++) {
      tmpM *= i; tmpM %= MOD;
    }
    
    cout << tmpN * tmpM % MOD << endl;
    
  }
  
  if (N == M) {
    
    int64_t tmpN = 1, tmpM = 1;
    
    for (int i = 1; i <= N; i++) {
      tmpN *= i; tmpN %= MOD;
    }
    
    for (int i = 1; i <= M; i++) {
      tmpM *= i; tmpM %= MOD;
    }
    
    cout << tmpN * tmpM % MOD * 2 % MOD << endl;
    
  }
  
}

Measured memory_bytes: 3540
#include <iostream>

int main() {
int a, b;
std::cin >> a >> b;

if(a < b){
std::cout<< "a < b" << std::endl;
}

else if(a > b){
std::cout<< "a > b" << std::endl;
}

else if(a == b){
std::cout<< "a == b" << std::endl;
}
}

Measured memory_bytes: 3076
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = (1ll<<31)-1;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w,d,a;
    cin >> h >> w >> d;
    vector<P> grid(h*w);
    rep(i,h){
        rep(j,w){
            cin >> a;
            grid[a-1] = P(i,j);
        }
    }
    vector<ll> cost(h*w);
    rep(i,d){
        cost[i] = 0;
        int index = i;
        while(index+d < h*w){
            index += d;
            cost[index] = cost[index-d]+abs(grid[index].first-grid[index-d].first)+abs(grid[index].second-grid[index-d].second);
        }
    }
    int q,l,r;
    cin >> q;
    rep(i,q){
        cin >> l >> r;
        PRINT(cost[r-1]-cost[l-1]);
    }
}


Measured memory_bytes: 3200
<?php
list($n) = ints();
list($s) = strs();
$max = $x = 0;
for ($i = 0; $i < $n; ++$i) {
    if ($s[$i] === 'I') ++$x;
    elseif ($s[$i] === 'D') --$x;
    $max = max($max, $x);
}
echo $max;
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


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

int main() {
    int n;
    cin >> n;
    map<string, int> mp;
    int ma = 0;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        mp[s]++;
        ma = max(ma, mp[s]);
    }
    vector<string> v;
    for (auto e : mp) {
        if (e.second == ma) v.push_back(e.first);
    }
    sort(v.begin(), v.end());
    for (auto e : v) {
        cout << e << endl;
    }
    return 0;
}


Measured memory_bytes: 27252
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
typedef long long int ll;
const int MOD=1000000007;
using Graph = vector<vector<int>>;
#define rep(i,n) for (int i = 0; i < (n); ++i)

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){
  int n;cin>>n;
  vector<int> a(n+1);
  rep(i,n+1)cin>>a[i];
  vector<int> b(n);
  rep(i,n) cin>>b[i];
  ll ans = min(a[0],b[0]);
  int sub = max(b[0]-a[0],0);
  for(int i=1;i<n;i++){
    ans += min(a[i],b[i]+sub);
    a[i] = max(0,a[i]-sub);
    sub = max(b[i]-a[i],0);
    
  }
  ans += min(a[n],sub);
cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1024
# https://atcoder.jp/contests/abc155/tasks/abc155_b



N = gets.to_i
As = gets.split.map(&:to_i)

cond = As.all? do |a|
  a.odd? || (a.even? && (a % 3 == 0 || a % 5 == 0))
end
puts cond ? 'APPROVED' : 'DENIED'


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int i,j;
    int N,M,X;
    int left=0,right=0;
    cin>>N>>M>>X;
    vector<int> A(M);
    
    for(i=0;i<M;i++)cin>>A.at(i);
    
    
    for(i=X-1;i>=0;i--){
        for(j=0;j<M;j++){
            if(i==A.at(j)){
                left++;
            }
        }
    }
    
    for(i=X+1;i<=N;i++){
        for(j=0;j<M;j++){
            if(i==A.at(j)){
                right++;
            }
        }
    }
    
    
    if(right>=left)cout<<left<<endl;
    else cout<<right<<endl;
    
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
      	int minDivTwo = 1000;
    	for(int i=0; i<n; i++){
          	int v = sc.nextInt();
			int c = 0;
          	while(v > 0 && v%2 == 0)	{
            	v/=2;
	            c++;
	        }
            minDivTwo = Math.min(c, minDivTwo);
        }
        System.out.println(minDivTwo);
    }
}


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

#define int long long 
#define sz size
#define pb push_back

 
const int N = 1e5 + 123;
 
int n, a[N], sum, ans;
main() {
	//freopen("input.txt", "r", stdin);
	cin >> n;
	for(int i = 1; i <= n; ++i) {
		cin >> a[i];
		sum += a[i];
		if(a[i] == 0) {
			ans += (sum / 2);
			sum = 0;
		}
	}
	ans += (sum / 2);
	cout << ans;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int input;
int f, v;
int Ans[45], Acnt;

int main(){
	ios_base::sync_with_stdio(false);
	
	cin >> input;
	if(input==0){
		cout << "0" << endl;
		return 0;
	}
	if(input<0)	{f=-1;v=-input;}
	else	{f=1;v=input;}
	while(v!=0){
		if(v&1){
			Ans[++Acnt]=1;
			if(f<0)	v=(v+1)>>1;
			else	v=(v-1)>>1;
		}
		else{
			Ans[++Acnt]=0;
			v>>=1;
		}
		f=-f;
	}
	
	for(int i=Acnt;i>=1;--i)	cout << Ans[i];
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
//#include<studio.h>
#include<iostream>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	if (a > b) { cout << "a > b" << endl; }
	if (a == b) { cout << "a == b" << endl; }
	if (a < b) { cout << "a < b" << endl; }

	return 0;
}

Measured memory_bytes: 3076
#include <stdio.h>

int main()
{

    int a;
    long long d;
    //int datax[200000];
    //int datay[200000];

    long long  x;
    long long y;
    int sum = 0;
    scanf("%d", &a);
    scanf("%lld", &d);

    for (int i = 0; i < a; i++)
    {
        scanf("%lld", &x);
        scanf("%lld", &y);
        if((long long)x*x+y*y-d*d<=0)
        sum++;
    }
    printf("%d\n", sum);

}

Measured memory_bytes: 2148