akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <ctime>
#include <cassert>
#include <unordered_map>
#include <fstream>
#include <random>
#include <cstring>
#include <bitset>
#include <functional>
#include <tuple>
#include <complex>

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef unsigned int uint;

mt19937 rnd(random_device{}());

const int MAXN = 555;
ll a[MAXN][MAXN];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

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

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

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int n;
    cin >> n;
    vector<ll> u, v;


    for (int k = 3; sz(v) < n; ++k) {
        bool ok = true;
        for (int i = 2; i * i <= k; ++i) {
            if (k % i == 0) {
                ok = false;
                break;
            }
        }
        if (ok) {
            if (sz(u) < n) {
                u.push_back(k);
                u.push_back(k);
            } else {
                v.push_back(k);
                v.push_back(k);
            }
        }
    }

    set<ll> used;

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if ((i + j) % 2 == 0) {
                a[i][j] = u[i] * v[j];
                if (i % 2 == 1 && j % 2 == 1) {
                    a[i][j] *= 2;
                }
                used.insert(a[i][j]);
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if ((i + j) % 2 == 1) {
                ll cur = 1;
                for (int k = 0; k < 4; ++k) {
                    int x = i + dx[k], y = j + dy[k];
                    if (x < 0 || x >= n || y < 0 || y >= n) {
                        continue;
                    }
                    cur = cur / gcd(cur, a[x][y]) * a[x][y];
                }

                ll add = cur;
                ++cur;
                while (used.count(cur)) {
                    cur += add;
                }
                assert(cur < 1e15);
                a[i][j] = cur;
                used.insert(cur);
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cout << a[i][j]  << " ";
        }
        cout << "\n";
    }

}

Measured memory_bytes: 16896
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int i,j,n,K;cin>>n;
	llint ma=0,mb=0,mc=0,xa,xb,xc;
	while(n--){
		cin>>xa>>xb>>xc;
		xa+=max(mb,mc);
		xb+=max(mc,ma);
		xc+=max(ma,mb);
		ma=xa;mb=xb;mc=xc;
	}
	cout<<max(ma,max(mb,mc))<<endl;
	return 0;
}


Measured memory_bytes: 888
#include <iostream>
using namespace std;
typedef long long ll;
ll h,w,ans;
int main(void){
    cin>>h>>w;
    if(h==1||w==1){
        cout<<1<<endl;
        return 0;
    }
    if(w%2==0){
        cout<<h*w/2<<endl;
    }
    else{
        if(h%2==0){
            cout<<w*h/2<<endl;
        }
        else{
            h-=1;
            cout<<w*h/2+(w+1)/2<<endl;
        }
    }
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
result = 0
num = 1
if A.count(1) == 1 and len(A) == 1:
    print(0)
elif A.count(1) > 0:
    for i in range(N):
        if A[i] != num:
            result += 1
        else:
            num += 1
    if result == 0:
        print(-1 if len(set(A)) != N else 0)
    else:
        print(result)
else:
    print(-1)


Measured memory_bytes: 24748
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
#include <iomanip>
using namespace std;
#define Would
#define you
const int INF = 999999999;
const int MOD = 1e9 + 7;
const double pi = 3.141592653589793238;

long long digits(long long n) {
	long long ans = 0;
	while (n) {
		ans += n % 10;
		n /= 10;
	}
	return ans;
}

int main() {
	long long a, b, c, ans = 0, d;
	cin >> a >> b >> c;
	for (int i = 1; i <= 72; ++i) {
		d = 1;
		for (int j = 1; j <= b; ++j) {
			d *= a + i;
		}
		if (d <= c && digits(d) == i) { ++ans; }
	}
	cout << ans << endl;
}


Measured memory_bytes: 3120
#pragma GCC optimize("O3") //コンパイラ最適化用

#define _GLIBCXX_DEBUG //配列に[]でアクセス時のエラー表示
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはメントされる
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--) //ループ変数は1ずつデクリ
#define FOR(i, a, b) for (ll i = a; i < ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i > ll(b); i--) //ループ変数は1ずつデクリ
// xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end() // sortなどの引数を省略したい
#define SIZE(x) ll(x.size())      // sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 // 10^12:極めて大きい値,∞
#define MOD 1000000007    // 10^9+7:合同式の法
#define MAXR 100000 // 10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back // vectorヘの挿入
#define MP make_pair // pairのコンストラクタ
#define F first      // pairの一つ目の要素
#define S second     // pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000

int main() {
    string S;
    cin >> S;
    ll cur = S.length();
    bool fl = true;

    while (true) {
        if (cur == 0) {
            break;
        } else if (cur >= 7) {
            if (S.substr(cur - 7, 7) == "dreamer") {
                cur -= 7;
            } else if (S.substr(cur - 6, 6) == "eraser") {
                cur -= 6;
            } else if (S.substr(cur - 5, 5) == "erase" ||
                       S.substr(cur - 5, 5) == "dream") {
                cur -= 5;
            } else {
                fl = false;
                break;
            }

        } else if (cur >= 6) {
            if (S.substr(cur - 6, 6) == "eraser") {
                cur -= 6;
            } else if (S.substr(cur - 5, 5) == "erase" ||
                       S.substr(cur - 5, 5) == "dream") {
                cur -= 5;
            } else {
                fl = false;
                break;
            }
        } else if (cur >= 5) {
            if (S.substr(cur - 5, 5) == "erase" ||
                S.substr(cur - 5, 5) == "dream") {
                cur -= 5;
            } else {
                fl = false;
                break;
            }
        }

        else {
            fl = false;
            break;
        }
    }
    fl ? cout << "YES" << endl : cout << "NO" << endl;
}


Measured memory_bytes: 3760
package main

import "fmt"

var n int
var a [21][21]int
var result [1 << 21]int
var CYCLE = 1000000007

func solve(i, mask int) int {
	// fmt.Printf("%d %b\n", i, mask)

	if result[mask] >= 0 {
		return result[mask]
	}

	r := 0
	for j, m := 0, 1; j < n; j, m = j+1, m<<1 {
		if mask&m == 0 && a[i][j] == 1 {
			r += solve(i+1, mask|m)
			r %= CYCLE
		}
	}
	result[mask] = r
	// fmt.Printf("-> %d\n", r)
	return r
}

func main() {
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			fmt.Scan(&a[i][j])
		}
	}

	m := 1 << uint(n)
	for i := 0; i < m; i++ {
		result[i] = -1
	}
	result[m-1] = 1

	fmt.Println(solve(0, 0))
}


Measured memory_bytes: 16896
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
    int N,M;
    cin >> N;
    vector<string> s(N);
    for(int i=0;i<N;i++){
        cin >> s[i];
    }
    cin >> M;
    vector<string> t(M);
    for(int i=0;i<M;i++){
        cin >> t[i];
    }
    int count[N+1] = {0};
    for(int i = 0;i<N;i++){
        for(int j = 0;j<N;j++){
            if(s[i]==s[j]){
                count[j] += 1;
                break;
            }
        }
    }
    for(int i = 0;i<M;i++){
        for(int j = 0;j<N;j++){
            if(t[i]==s[j]){
                count[j] -= 1;
                break;
            }
        }
    }

    int x = 0;
    for(int i =0;i<N;i++){
        if(count[i] > x){
            x = count[i];
        }
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int n,d[50],i,j,sum = 0;
    scanf("%d",&n);
    for(i = 0 ; i < n ; i++)
    {
        scanf("%d",&d[i]);
    }
    for(i = 0; i < n - 1 ; i++)
    {
        for(j = i + 1 ; j < n ; j++)
        {
            sum += d[i] * d[j];
        }
    }
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 1712
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = {False: 'No', True: 'Yes'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


show_flg = True
show_flg = False


def main():
    N, K = MI()
    h = LI()
    dp = [IINF] * N
    dp[0] = 0

    for i in range(N-1):
        for k in range(1, K+1):
            if i + k < N:
                dp[i+k] = min(dp[i] + abs(h[i+k] - h[i]), dp[i+k])

    print(dp[N-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 53540
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll a, b, p, q, r;
  cin >> a >> b >> p >> q >> r;

  double dis = p * b - (b-a)*q;
  cout << dis / (r+q) + b << endl;
}



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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

char c[10][10];

void solve(){
	int n, m;
	scanf("%d%d", &n, &m);
	int cnt = 0;
	REP(i, 0, n){
		scanf("%s", &c[i][0]);
		REP(j, 0, m){
			if (c[i][j] == '#'){
				cnt++;
			}
		}
	}
	int l = 0;
	REP(i, 0, n){
		if (c[i][l] != '#'){
			break;
		}
		for(; c[i][l] == '#'; l++){
			cnt--;
		}
		l--;
	}
	if (cnt > 0){
		printf("Impossible\n");
	} else {
		printf("Possible\n");
	}
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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 n;
  cin >> n;
  int a = n / 1000;
  int b = (n % 1000) / 100;
  int c = (n % 100) / 10;
  int d = n % 10;
  if (a == b && b == c) cout << "Yes" << endl;
  else if (b == c && c == d) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;

int N,M;
ll fac[110000],finv[110000]; // n! & (n!)^(-1)

// 繰り返し２乗法での逆元計算
// a^(MOD-2) => a^(-1) (mod MOD)なので、 a^(MOD-2)をO(logMOD)で計算
ll inv(int x){
    ll res = 1;
    ll k = MOD - 2;
    ll y = x;
    // x^(MOD-2) = x^2 * x^4 * x^8 ...
    // とすると、この計算はO(logMOD)で終わる。
    while(k) {
        if(k & 1) res = (res * y) % MOD;
        y = (y * y) % MOD;
        k >>= 1;
    }
    return res;
}

ll comb(int n, int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int main(){
    cin >> N >> M;
    // まず素因数分解をする。
    map<int,int> primeFactor;
    for(int i = 2; i * i <= M; ++i){
        if(M % i == 0)
            while(M % i == 0){
                ++primeFactor[i];
                M /= i;
            }
    }
    if(M != 1) ++primeFactor[M];
    //
    // 階乗のメモ化
    fac[0] = fac[1] = 1; finv[0] = finv[1] = 1;
    for(int i = 2; i < 110000; ++i){
        fac[i] = fac[i-1] * i % MOD;
        finv[i] = inv(fac[i]);
    }
    //

    ll ans = 1;
    // Mの各素因数をN個の箱に分配する -> 重複組合せ
    // 入らなかった箱には1が入ってると考える。
    // 全ての素因数で分配し、それらの重ね合わせが答え->積をとる。
    for(auto itr = primeFactor.begin(); itr!=primeFactor.end();++itr){
        ll k = itr->second;
        ans = (ans * comb(N+k-1,k)) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1920
import scala.io.StdIn._
object Main extends App {
  val Array(h, w) = readLine.split(" ").map{_.toInt}
  val board = Array.fill(h){readLine.split(" ").map{_.toInt}}
  val moves = scala.collection.mutable.ArrayBuffer[String]()

  def pos(i: Int): (Int, Int) = {
    val y = i / w
    val x = if ((y & 1) == 0) i % w else w - 1 - i % w
    (x, y)
  }

  for {
    i <- (0 until h * w - 1)
  } {
    val (x, y) = pos(i)
    if ((board(y)(x) & 1) == 1) {
      val (xx, yy) = pos(i + 1)
      board(yy)(xx) += 1
      moves += (s"${y + 1} ${x + 1} ${yy + 1} ${xx + 1}")
    }
  }
  println(moves.size)
  println(moves.mkString("\n"))
}

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

using namespace std;

int main(void)
{
	int n,x,t;
	cin>>n>>x>>t;
	int w;
	w = n / x;
	if(n%x == 0){
		cout<<t*w<<endl;
	}
	else {
		w++;
		cout<<t*w<<endl;
	}
	return 0;
}



Measured memory_bytes: 3612
# -*- coding: utf-8 -*-

def lower_bound(l,k):
    def isOk(i):
        return l[i]>k

    ok = len(l)
    ng = -1
    while abs(ok-ng) > 1:
        mid = (ok+ng)//2

        if isOk(mid):
            ok = mid
        else:
            ng = mid
    return ok

s = input()
n = len(s)
t = input()
m = len(t)

d = {}
for c in t:
    if c in d:
        continue
    else:
        d[c] = []
    for i in range(2*n):
        if s[i%n]==c:
            d[c].append(i)
res = -1
for i in range(m):
    c = t[i]
    if len(d[c])==0:
        print(-1)
        exit()

    j = lower_bound(d[c],res%n)
    res += d[c][j] - res%n

print(res+1)


Measured memory_bytes: 11356
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }




int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s, t;
    cin >> s >> t;
    
    rep(i, sz(s)) {
        rep(j, sz(t)) {
            if (s[i + j] != t[j]) break;
            if (j == sz(t) - 1) {
                cout << i << endl;
            }
        }
    }
}



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


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

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

int main() {
	
	int n, m;
	cin >> n >> m;
	
	auto d = divisor(m);
	int ans = *(upper_bound(all(d), m/n) - 1);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
S = input()
cnt = {}
for s in S:
    if s not in cnt.keys():
        cnt[s] = 1
    else:
        cnt[s] += 1
for s in cnt.values():
    if s != 2:
        print("No")
        exit()
if len(cnt) != 2:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<tuple<string, int, int>> data;
  for (int i = 0; i < N;i++){
    string str;
    int num;
    cin >> str>> num;
    data.push_back(make_tuple(str, num * (-1), i+1));
  }
  sort(data.begin(), data.end());
  
  for (tuple<string,int,int> t:data)
  {
    int x;
    tie(ignore, ignore, x) = t;
    cout << x << endl;
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <utility>
#include <queue>
#include <ios>
#include <iomanip>
#include <ctime>
#include <tuple>

#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; i++)
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 (a > b) {a = b; return 1;} return 0; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFF
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")

#define PInt pair<int, int>
#define PLL pair<long long, long long>
#define VInt vector<int>
#define VLL vector<long long>
#define MatrixInt vector<vector<int>>
#define MatrixLL vector<vector<long long>>

typedef long long ll;
using namespace std;

int main() {
    
    int a, b, k;
    cin >> a >> b >> k;
    for (int i = max(a, b); i; i--) {
        if (a % i == 0 && b % i == 0) {
            k--;
            if (k == 0) {
                cout << i << endl;
                break;
            }
        }
    }
    
}

Measured memory_bytes: 256
use std::cmp;

macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;$n:expr) => {
        (0..$n).map(|_| scan!()).collect::<Vec<_>>()
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (x, t) = scan!(i64, i64);
    println!("{}", cmp::max(x - t, 0))
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > piii;
#define pb push_back
#define debug(x) cout << x << endl
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
#define PI acos(-1)
#define all(c) c.begin(), c.end()
#define SET(x, y) memset((x), y, sizeof(x))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const LL INF64 = 1e18;

const int N = 1e5 + 5;

LL BIT[2 * N];
LL height[2 * N];
LL beauty[2 * N];

LL upd(LL x, LL val) {
	for(; x < 2 * N; x += x & (-x))
		BIT[x] = max(val, BIT[x]);
}

LL getMax(LL x) {
	LL ret = 0LL;
	for(; x > 0; x -= x & (-x))
		ret = max(BIT[x], ret);
	return ret;
}

int main() {
	SET(BIT, 0);
	int n;
	scanf("%d", &n);
	LL ans = 0LL;
	for (int i = 0; i < n; i++) 
		scanf("%lld", height + i);
	for (int i = 0; i < n; i++)
		scanf("%lld", beauty + i);
	for (int i = 0; i < n; i++) {
		LL mx = getMax(height[i] - 1);
		mx += beauty[i];
		upd(height[i], mx);
		ans = max(ans, mx);
	}
	printf("%lld\n", ans);
	return 0;
}
		

Measured memory_bytes: 4992
#include <iostream>
#include <string>
using namespace std;
#define REP(i,n)    for(int i = 0; i < (int)n; i++)
#define MAX_N   100000
typedef long long ll;

void solve(){
    int n;
    cin >> n;
    if(n % 2){
        int chi = n / 2 + 1;
        float ans = float(chi) / float(n);
        printf("%f\n", ans);
    }
    else
        printf("%f\n", 0.5000000000);      

}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a, b, c, t=0, i;
	cin >> a >> b;
	c=b;
	do
	{
		c/=10;
		t++;
	}while (c!=0);
	c=1;
	for (i=1; i<=t; i++) c*=10;
	a=a*c+b;
	if (int(sqrt(a))==sqrt(a)) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define XX first
#define YY second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=1e9+7;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

int N;
int M;

signed main(){
  using Event = pair<pll, LL>;
  priority_queue<Event, vector<Event>, greater<Event>> evs;
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  cin >> N >> M;
  rep(i, M) {
    LL l, r, c;
    cin >> l >> r >> c;
    --l;
    --r;
    evs.push(Event(pll(l, c), r));
  }

  const LL INF = 1LL << 61;
  set<pll> costs;
  costs.insert(pll(0, 0));
  costs.insert(pll(N+1, INF));
  while (!evs.empty()) {
    auto e = evs.top(); evs.pop();
    LL l, c, r;
    tie(l, c) = e.XX;
    r = e.YY;
    auto itr = costs.lower_bound(pll(l, -1));
    auto itr2 = costs.lower_bound(pll(r, -1));
    LL nc = itr->YY + c;
    if (itr2->YY > nc) {
      if (itr2->XX == r) {
        costs.erase(itr2);
      }
      auto itr3 = costs.insert(pll(r, nc)).XX;
      while (1) {
        itr3--;
        if (itr3->YY > nc) {
          itr3 = costs.erase(itr3);
        } else break;
        assert(itr3->XX == r);
        //cout << "a";
      }
    }
  }
  auto itr = costs.lower_bound(pll(N-1, -1));
  if (itr->YY == INF) cout << "-1" << endl;
  else cout << itr->YY << endl;
}


Measured memory_bytes: 8816
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;

int main(){
    ll n,m;cin>>n>>m;
    ll maxi=m;
    for(ll i=1;i*i<=m;i++){
	if(m%i==0&&i>=n){
	    maxi=min(maxi,i);
	}
	ll j=m/i;
	if(m%j==0&&j>=n){
	    maxi=min(maxi,j);
	}
    }
    cout<<m/maxi<<endl;
    return 0;
}


Measured memory_bytes: 256
use std::collections::HashMap;

macro_rules! get_one {
    ($t:ty) => {{
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse::<$t>().unwrap()
    }};

    ($t:ty; $n:expr) => {
        (0..$n).map(|_| get_one!($t)).collect::<Vec<_>>()
    };
}

fn main() {
    let n = get_one!(usize);


    let v: usize = (1..=n).into_iter().map(|m| sum_till_n(m, n)).sum();

    println!("{}", v);



}

fn sum_till_n(m: usize, n: usize) -> usize {
    let mut i = 0;
    let mut sum = 0;
    while i <= n {
        sum += i;
        i += m;
    }
    sum
}


Measured memory_bytes: 2152
#include <iostream>
#include <string>
#include <cmath>

using namespace std;
int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int x = c - a, y = d - b;
    cout << c - y << " " << d + x << " " << a - y << " " << b + x;

    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    string s; cin >> s;
    
    ll g = 0;
    ll p = 0;

    ll ans = 0;
    for(ll i = 0; i < s.length(); i++){
        if(s[i] == 'g'){
            //パーを出したいが
            if(p + 1 <= g){
                p++;
                ans++;
            }else{
                g++;
            }
        }else{
            //パーを出してアイコにしたいが
            if(p + 1 <= g){
                p++;
            }else{
                g++;
                ans--;
            }
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std ;
const int N = 2e5 + 10 ;
int a[N] , b[N] , c[N] , d[N] ;
int n , m ;
int h[N * 2] , ne[N * 2] , e[N * 2] , w[N * 2] , vis[N * 2] ;
int idx , use[N] ;
int get(int x)
{
  return lower_bound(d + 1 , d + n + 1 , x) - d ;
}
void add(int a , int b , int c)
{
  e[idx] = b , ne[idx] = h[a] , w[idx] = c ,  h[a] = idx ++ ;
}
int dfs(int u)
{
  vis[u] = 1 ;
  int x = c[u] ;
  for(int i = h[u] ; ~i ; i = ne[i])
   {
     int v = e[i] ;
     if(!vis[v] && dfs(v))
      x ^= 1 , use[w[i]] = 1 ;
   }
  return x ;
}
int main()
{
  for(int i = 0 ;i < N ;i ++) h[i] = -1 ;
  ios::sync_with_stdio(false) ;
  cin.tie(0) , cout.tie(0) ;
  cin >> n >> m ;
  for(int i = 1; i <= n ; i ++) cin >> a[i] >> b[i] , d[i] = a[i] ;
  sort(d + 1 , d + n + 1) ;
  for(int i = 1; i <= n ;i ++)
   c[get(a[i])] = b[i] ;
  for(int i = n + 1; i >= 1 ;i --) c[i] ^= c[i - 1] ;
  for(int i = 1; i <= m ;i ++)
   {
     int l , r ;
     cin >> l >> r ;
     l = get(l) , r = upper_bound(d + 1 , d + n + 1 , r) - d - 1 ;
     if(l <= r)
     add(l , r + 1 , i) , add(r + 1 , l , i) ;
   }
   for(int i = 1; i <= n + 1 ;i ++)
    if(!vis[i] && dfs(i))
     {
       cout << -1 << endl ;
       return 0 ;
     }
     int ans =  0 ;
     for(int i = 1; i <= m ;i ++)
      if(use[i]) ans ++ ;
    cout << ans << endl ;
    for(int i = 1;i <= m ;i ++)
     if(use[i])
      cout << i << " " ;
  //  puts("") ;

}


Measured memory_bytes: 12544
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
import java.awt.Point;

public class Main {
    // static int INF = (1 << 30) - 1;
    // static long L_INF = (1L << 62) - 1;
    // static long MOD = (long) 1e9 + 7;

    static class Solver {
        int N, K;
        int[] p;

        // write your code
        void solve(InputReader in, PrintWriter out) {
            N = in.nextInt();
            K = in.nextInt();
            p = new int[N];
            for (int i = 0; i < N; i++) {
                p[i] = in.nextInt();
            }
            Arrays.sort(p);

            int ans = 0;
            for (int i = 0; i < K; i++) {
                ans += p[i];
            }
            out.println(ans);
        }

        void debug(Object... os) {
            System.err.println(Arrays.deepToString(os));
        }
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

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


Measured memory_bytes: 33280
#include <iostream>
#include <algorithm>
#include <string>


using namespace std;









int main(){
  string str[100],strb[100];
  int num,mini,hantei=1;
  
  cin >>num;

  for(int i=0;i<num;i++){
    cin >>str[i];
  }

  for(int i=0;i<num;i++){
    strb[i]=str[i];
  }

  

  
  //bubble sort
for(int i=0;i<num-1;i++){

  for(int j=num-1;j>i;j--){

    if((str[j]).substr(1,1)<(str[j-1]).substr(1,1)){
      swap(str[j],str[j-1]);
      
    }
    
  }
 }


//selection sort
 for(int i=0 ; i<num-1;i++){
    mini=i;
    for(int j=i+1;j<num;j++){//num-1
      
      if((strb[j]).substr(1,1)<(strb[mini]).substr(1,1)){ mini=j;
      }
    
    

    }
    if(mini!=i){
    swap(strb[i],strb[mini]);
    if((strb[i]).substr(0,1)==(strb[mini]).substr(0,1)){
      hantei =0;
    }
    
    }

  }
  




 
// (str[i]).substr(1,1)

//bubble
 for(int i=0;i<num;i++){

   if(i!=num-1){ cout << str[i]<<" ";
   }else{

     cout <<str[i]<<endl;
     
   }

   
 }

 cout<<"Stable"<<endl;
 
 //selection
 for(int i=0;i<num;i++){

   if(i!=num-1){ cout << strb[i]<<" ";
   }else{
     
     cout <<strb[i]<<endl;
     
   }

   
 }
 if(hantei==1){
   
  cout<<"Stable"<<endl;
 }else {

cout<<"Not stable"<<endl;

 }


  
  
  
  

  
  
  
  return 0;
}



Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  string str[n];
  for(int i=0;i<n;i++)
  	cin>>str[i];
  set<string> s;
  for(int i=0;i<n;i++)
  {
  	s.insert(str[i]);
  }
  cout<<s.size();
}

Measured memory_bytes: 25372
using System;

namespace c
{
    class Program
    {
        static void Main(string[] args)
        {
            var NKQ = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var N = NKQ[0]; var K = NKQ[1]; var Q = NKQ[2];

            var correct = new int[N + 1];
            for (int i = 0; i < Q; i++)
            {
                var A = int.Parse(Console.ReadLine());
                correct[A]++;
            }
            for (int i = 1; i < N + 1; i++)
            {
                Console.WriteLine(Q - correct[i] < K ? "Yes" : "No");
            }
        }
    }
}


Measured memory_bytes: 17600
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  int N,M;
  cin >> N >> M;

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

  while(M--) {
    int a = A.top();
    A.pop();
    a /= 2;
    A.push(a);
  }

  long long sum = 0;
  while(!A.empty()) {
    int a = A.top();
    A.pop();
    sum += a;
  }

  cout << sum << endl;


}


Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    string s, t;
    cin >> s >> t;
    ll a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if (s == u)
    {
        cout << a - 1 << " " << b << endl;
    }
    else
    {
        cout << a << " " << b - 1 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<pair<long long, int>> x;
	vector<pair<long long, int>> y;
	for (auto i = 0; i < N; ++i)
	{
		auto tempX = 0ll;
		auto tempY = 0ll;
		cin >> tempX >> tempY;

		x.push_back(make_pair(tempX, i));
		y.push_back(make_pair(tempY, i));
	}

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

	vector<vector<pair<long long, int>>> g(N);
	for (auto i = 0; i < N - 1; ++i)
	{
		auto& prev = x[i];
		auto& next = x[i + 1];
		auto diff = next.first - prev.first;
		g[prev.second].push_back(make_pair(diff, next.second));
		g[next.second].push_back(make_pair(diff, prev.second));
	}
	for (auto i = 0; i < N - 1; ++i)
	{
		auto& prev = y[i];
		auto& next = y[i + 1];
		auto diff = next.first - prev.first;
		g[prev.second].push_back(make_pair(diff, next.second));
		g[next.second].push_back(make_pair(diff, prev.second));
	}

	priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> q;
	q.push(make_pair(0, 0));
	set<int> used;
	auto result = 0ll;
	while (!q.empty())
	{
		auto p = q.top();
		q.pop();

		if (used.find(p.second) != used.end())
		{
			continue;
		}

		result += p.first;
		used.insert(p.second);
		for (auto& e : g[p.second])
		{
			if (used.find(e.second) != used.end())
			{
				continue;
			}

			q.push(e);
		}
	}

	cout << result << endl;

	return 0;
}

Measured memory_bytes: 20324
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if(a>0) cout<<"Positive\n";
    else if(b>=0) cout<<"Zero\n";
    else if((abs(b)-abs(a)+1)%2==0) cout<<"Positive\n";
    else cout<<"Negative\n";
    return 0;
}

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

using namespace std;

typedef long long int lli;

#define fastio			ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto &i : c)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())

int main(){
  #ifndef ONLINE_JUDGE
		FILE* f = freopen("/home/sravan/Projects/CP/input.txt", "r", stdin);
	#endif
    fastio;

    string s;
    cin >> s;
    int len = (int)s.length();
    if(s[len-1] == 's') cout << s << "es"<<endl;
    else cout << s << 's'<<endl;


  #ifndef ONLINE_JUDGE
		fclose(f);
	#endif
    return 0;

}


Measured memory_bytes: 3660
N, K, C = map(int, input().split())
S = input()

s = []

count = 0
for i in range(N):
    if len(s) == K:
        break
    if count == 0:
        if S[i] == 'x':
            continue
        else:
            count = C
            s.append(i+1)
    else:
        count -= 1
s2 = []
count = 0
for i in range(N-1, -1, -1):
    if len(s2) == K:
        break
    if count == 0:
        if S[i] == 'x':
            continue
        else:
            s2.append(i+1)
            count = C
    else:
        count -= 1

for a, b in zip(s, s2[::-1]):
    if a == b:
        print(a)


Measured memory_bytes: 26692
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		String b = sc.next();
		
		if (b.length() <= a) {
			System.out.println(b);
		} else {
			System.out.println(b.substring(0, a) + "...");
		}
	}
}

Measured memory_bytes: 38628
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <limits>

int test1(const std::vector<int> &h, const int k) {
	const int n = static_cast<int>(h.size());
	if (k > n) {
		return -1;
	}
	auto sorted_h = h;
	std::sort(sorted_h.begin(), sorted_h.end(), std::greater<>());
	int min_diff = std::numeric_limits<int>::max();
	for (int i = 0; i < n - k + 1; ++i) {
		min_diff = std::min(min_diff, sorted_h.at(i) - sorted_h.at(i + k - 1));
	}
	return min_diff;
}

int main() {
	int n, k;
	std::cin >> n >> k;
	std::vector<int> h(n);
	for (int i = 0; i < n; ++i) {
		std::cin >> h.at(i);
	}
	std::cout << test1(h, k) << std::endl;
	return false;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#define inf 10e8
using namespace std;
 
 
 
int main(){
    long n,k,q;
    cin >> n >>k >> q;
    long a[n+10];
    for (long i=0;i<n+3;i++) a[i]=0;
    for (long i=1;i<=q;i++){
        long d;
        cin >> d;
        a[d]++;
    }
    long ans=n;
    for (long i=1;i<=n;i++){
        long point;
        point=k-q+a[i];
        if(point<=0) cout <<"No" << endl;
        else cout << "Yes" << endl;
    }
   
}

Measured memory_bytes: 1408
using System;
class C
{
    static void Main()
    {
        int S = int.Parse(Console.ReadLine());
        var h = S / 3600;
        S -= h * 3600;
        var m = S / 60;
        S -= m * 60;
        Console.WriteLine($"{h}:{m}:{S}");
    }
}



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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

vector<long long int> prime_factor(long long int n){
    vector<long long int> res;
    for(int i=2; i*i<=n; ++i){
        while(n%i==0){
            res.push_back(i);
            n/=i;
        }
    }
    if(n!=1) res.push_back(n);
    return res;
};

class segtree{
public:
    i64 n,size_;
    vector<vector<pair<int,int>>> segs;
    segtree()=default;
    segtree(i64 size){ init(size); }
    void init(i64 size){
        size_=size;
        n=1;
        while(n<size) n*=2;
        segs.resize(n*2-1);
    }
    void insert(int l_,int r_){ insert(0,n,0,l_,r_); }
    void insert(int a,int b,int index,int l_,int r_){
        if(b<=l_ or r_<=a) return;
        if(l_<=a and b<=r_){
            segs[index].push_back(make_pair(l_,r_));
            return;
        }
        insert(a,(a+b)/2,2*index+1,l_,r_);
        insert((a+b)/2,b,2*index+2,l_,r_);
    }
    int query(int lb,int x){ return query(0,n,0,lb,x); }
    int query(int a,int b,int index,int lb,int x){
        if(b<=lb or x<a or b<=x) return 0;
        int res=0;
        if(lb<a and a<=x and x<b) res+=segs[index].end()-upper_bound(segs[index].begin(),segs[index].end(),make_pair(lb,inf));
        if((a+b)/2<b) res+=query(a,(a+b)/2,index*2+1,lb,x);
        if(a<(a+b)/2) res+=query((a+b)/2,b,index*2+2,lb,x);
        return res;
    }
};

void solve(){
    int N,M;
    cin >> N >> M;

    vector<pair<int,int>> LR;
    rep(i,0,N){
        int L,R;
        cin >> L >> R;
        ++R;
        LR.push_back(make_pair(L,R));
    }
    sort(LR.begin(),LR.end());
    segtree seg(M+1);
    rep(i,0,N) seg.insert(LR[i].first,LR[i].second);

    rep(i,1,M+1){
        int ans=0;
        rep(j,1,M/i+1){
            int tmp=seg.query(i*(j-1),i*j);
            ans+=seg.query(i*(j-1),i*j);
        }
        cout << ans << endl;
    }
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


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


int sum(int n) {
  if (n == 0) {
    return 0;
  }
  int s = sum(n - 1);
  return s + n;
}
int main() {
   vector<int> S(999);
  for(int i = 0;i<=998;i++){
    S.at(i) = sum(i+1);
  }

 int a,b;
 cin >> a >> b;
 for(int i = 0;i<=998;i++){
 if(b-a == S.at(i+1) -S.at(i)){
   cout << S.at(i) - a << endl;
   break;
  }
 }
}


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

struct node{
  int key;
  struct node *parent,*left,*right;
};

struct node *root,*NIL;
void insert(int);
void Inorder(struct node*);
void Preorder(struct node*);

void insert(int);
int main(){
  int i,num,value;
  char command[10];
  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf("%s",command);
    if(command[0]=='i'){           /*mean insert*/
      scanf("%d",&value);
      insert(value);
    }
    else if(command[0]=='p'){      /*mean print*/
      Inorder(root);
      printf("\n");
      Preorder(root);
      printf("\n");
    }
  }
  return 0;
}
    
void insert(int k){
  struct node *x=root,*y=NIL,*z;
  z=(struct node*)malloc(sizeof(struct node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
  while(x!=NIL){
    y=x;
    if(z->key < x->key)x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL) root=z;
  else{
    if(z->key<y->key) y->left=z;
    else y->right=z;
  }
}

void Inorder(struct node *x){
  if(x==NIL) return;
  Inorder(x->left);
  printf(" %d",x->key);
  Inorder(x->right);
}



void Preorder(struct node *x){
  if(x==NIL) return ;
  printf(" %d",x->key);
  Preorder(x->left);
  Preorder(x->right);
}



Measured memory_bytes: 25208
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl;
#define pno cout << "no" << endl;
#define pYe cout << "Yes" << endl;
#define pNo cout << "No" << endl;
#define pYE cout << "YES" << endl;
#define pNO cout << "NO" << endl;;
#define prin(num) cout << num << endl;
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define mp make_pair
#define INF 100000000000
#define MOD 1000000007LL
#define MAX 200005
#define NIL -1
#define WHITE 0
#define BLACK 1
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;
 
ll memo_f[200000];
ll memo_revf[200000];
 
ll modPow(ll x, ll n);
 
ll f(ll x) {
    if(x==0) return memo_f[x]=1;
    if(memo_f[x]!=-1) return memo_f[x];
    memo_f[x]=x*f(x-1)%MOD;
    return memo_f[x];
}
 
ll revf(ll x) {
    if(x==0) return memo_revf[x]=1;
    if(memo_revf[x]!=-1) return memo_revf[x];
    revf(x-1);
    return memo_revf[x]=modPow(memo_f[x], MOD-2)%MOD;
}
 
ll comb(ll n, ll k) {
    return f(n)*revf(k)%MOD*revf(n-k)%MOD;
}
 
ll modPow(ll x, ll n) {
    ll res=1;
    while(n>0) {
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
 
int main(void) {
    ll H, W, A, B;
    cin >> H >> W >> A >> B;
    
    memset(memo_f, -1, sizeof(memo_f));
    memset(memo_revf, -1, sizeof(memo_revf));
    
    f(100000);
    f(200000);
    revf(200000);
    ll j;
    ll ans=0;
    for(j=B; j<W; j++) {
        ans+=comb(H-1-A+j, j)*comb(A+W-j-2, W-1-j)%MOD;
        ans%=MOD;
    }
    prin(ans);
}

Measured memory_bytes: 4992
import math

A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if W >= V:
    print("NO")
else:
    ans = math.ceil(abs(B-A)/(V-W))
    if ans <= T:
        print("YES")
    else:
        print("NO")

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

const static ll MOD = (1e+9)+7;

int main(){
    string S,T;cin>>S>>T;
    set<char> lst[26],lst2[26];
    rep(i,S.size()){
        int tmp_s = (int)S[i]-(int)'a';
        int tmp_t = (int)T[i]-(int)'a';
        lst[tmp_s].insert(tmp_t);
        lst2[tmp_t].insert(tmp_s);
    }
    rep(i,26){
        if(lst[i].size()>1 || lst2[i].size()>1){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 776
#include <iostream>

using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  string num_str;
  size_t size = 5;
  int ans = 0;
  for (int i = A; i <= B; i++) {
    num_str = to_string(i);

    for (int k = 0; k < size / 2; k++) {
      if (num_str[k] != num_str[5 - 1 - k]) {
        break;
      }
      if (k == size / 2 - 1) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256