akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
/*
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};
*/
const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

//デバッグ
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};


ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}


//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

ll H, W;
char mp[410][410];
ll po[410][410];
ll now;

void dfs(ll y, ll x){
  ll p = 1;
  if(mp[y][x] == '#') p -= 2;
  po[y][x] = now * p;
  rep(i, 4){
    ll ny = y + dy[i];
    ll nx = x + dx[i];
    if(ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
    if(po[ny][nx] != 0) continue;
    if(mp[ny][nx] == mp[y][x]) continue;
    dfs(ny, nx);
  }
}

void solve(){
  now = 1;
  rep(i, H)rep(j, W)if(po[i][j] == 0){
    dfs(i, j);
    now++;
  }
  ll ans = 0;
  map<ll, ll> cnt;
  rep(i, H)rep(j, W) cnt[po[i][j]]++;
  rep(i, now+1){
    ans += cnt[i] * cnt[-i];
  }
  cout << ans << endl;
}

int main(){
  cin >> H >> W;
  rep(i, H)rep(j, W) cin >> mp[i][j];
  solve();
}


Measured memory_bytes: 19072
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
typedef long long ll;
int n;
ll x, a[100000];
void solve(){
    ll ans=0;
    for(int i=0;i<n-1;i++){
       if(a[i]+a[i+1]>x){
        ans+=a[i]+a[i+1]-x;
        a[i+1]-=a[i]+a[i+1]-x;
        if(a[i+1]<0){
            a[i]+=-a[i+1];
            a[i+1]=0;
        }
       }
    }
    cout<<ans<<"\n";
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> x;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    solve();
}

Measured memory_bytes: 1024
N = int(input())
A = list(map(int, input().split()))

ans = 0

xor = A[0]
now = A[0]
right = 1
for left in range(N):
    while right < N and xor ^ A[right] == now + A[right]:
        xor ^= A[right]
        now += A[right]
        right += 1
    ans += right - left
    now -= A[left]
    xor ^= A[left]

print(ans)

Measured memory_bytes: 24840
#include <stdio.h>

int main(){
  int a=0,i,j;
  char d[101];
  while(scanf("%s",d)!=EOF){
    a++;
    for(i=0;d[i]!=0;i++);i--;
    for(j=0;j<=i/2;j++) if(d[j]!=d[i-j]){a--;break;}
  }
  printf("%d\n",a);
  return 0;
}

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

using namespace std;

int main(){
    long long n;
    cin>>n;
    vector<long long> hoge(n);
    
    for(int i=0;i<n;i++) cin>>hoge.at(i);
    
    long long sum=0;
    
    hoge.insert(hoge.begin(),0);
    hoge.push_back(0);
    
    for(int i=0;i<n+1;i++){
        sum+=abs(hoge.at(i+1)-hoge.at(i));
    }
    
    
    
    for(int i=1;i<n+1;i++){
        long long a=hoge.at(i-1);
        long long b=hoge.at(i);
        long long c=hoge.at(i+1);
        if(a>c) swap(a,c);
        
        if(a<=b && b<=c) cout<<sum<<endl;
        else if(a<=b && c<=b) cout<<sum-abs(b-c)*2<<endl;
        else if(b<=a && b<=c) cout<<sum-abs(a-b)*2<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 2032
#include <stdio.h>
int main(void) {
	int a, b;
	char op;
	while (scanf("%d %c %d", &a, &op, &b) == 3 && op != '?') {
		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);
	}
	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#include<bitset>
#include<map>
#include<set>
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define dbg(a) cout<<"* "<< #a <<" : "<<a<<endl
#define fr first
#define se second
//#define ls x<<1
//#define rs x<<1|1
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define lowbit(x) x&(-x)
#define ac cout<<ans<<endl
//#define DEBUG 0
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-10;
const ull hashp=131;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn=2e5+100;
int qpow(int a,int b){
	int ret=1;
	while(b){
		if(b&1)ret=1ll*ret*a%mod;
		b>>=1;
		a=1ll*a*a%mod;
	}
	return ret;
}
int a[maxn],n;
int jc[maxn]={1},inv[maxn];
void init(){
	rep1(i,n){
		jc[i]=1ll*jc[i-1]*i%mod;
		inv[i]=qpow(i,mod-2);
	}
	rep1(i,n)inv[i]=(inv[i]+inv[i-1])%mod;
}
void solve(){
	scd(n);init();
	rep1(i,n)scd(a[i]);
	int ans=0;
	rep1(i,n)
		ans=(ans+1ll*a[i]*((inv[i]+inv[n-i+1]-1)%mod)%mod)%mod;
	ans=1ll*ans*jc[n]%mod;ans=(ans+mod)%mod;ac;
}
int main(){
    //IOS;
    //freopen("D:\\data.txt","r",stdin);
    //freopen("D:\\out.txt","w",stdout);
    solve();
 
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;                                             ;;
    ;;         ;;            ;;;;;;;;;       ;;    ;;
    ;;        ;; ;;        ;;                ;;    ;;
    ;;       ;;   ;;       ;;                ;;    ;;
    ;;      ;;;;;;;;;      ;;                ;;    ;;
    ;;     ;;       ;;     ;;                      ;;
    ;;    ;;         ;;      ;;;;;;;;;       ;;    ;;
    ;;                                             ;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
    return 0;
}


Measured memory_bytes: 4800
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];

    int ans = -1;
    int val = 1e9;
    rep(i,101) {
        int cnt = 0;
        rep(j,N) {
            cnt += (A[j]-i)*(A[j]-i);
        }
        chmin(val,cnt);
    }

    cout << val << ln;
}

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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, k;
  cin >> n >> k;
  ll ans = k;
  rep(i, n - 1) ans *= k - 1;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
        int k;
        long long int a,b,c;

        scanf("%lld%lld%lld%d",&a,&b,&c,&k);
        if(k-a<=0) printf("%lld\n",k);
        else {
                if(k-a-b<=0) printf("%lld\n",a);
                else printf("%lld\n",a-(k-a-b));
        }

        return 0;
}


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

#define fast() {ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
#define o(a) { cout << #a << ":" << (a) <<" ";}
#define ov(a) { cout << "["; \
	for(int i = 0; i < (a).size(); ++i){ \
		cout << i <<":" << a[i] <<" "; \
		if(i % 10 == 9) cout <<"\n"; \
		} \
	cout << "]"; \
}
#define ovv(a) { cout << "["; \
	for(int i = 0; i < a.size(); ++i){ \
		for(int j = 0; j < a[i].size(); ++j){ \
			cout << "(" << i <<"," <<j <<")" <<":" << a[i][j] <<" "; \
		} \
		cout << "\n"; \
	} \
	cout << "]"; \
}
#define op(a) { cout <<"[" << #a << ".fi:"<<a.first; \
					cout << " "<< #a << ".se:" << a.second <<"]"; }

#define ll long long
const int mod = 1e9 + 7;
const int nax = 1e5 + 5;

void solve(ll &ans, string &s, char R, char B, char G){
	int n = s.length();
	for(int pos = 1; pos < n - 1; ++pos){
		if(s[pos] == B){
			// R B G
			int minus = 0;
			int nl = 0, nr = 0;
			int l, r;
			for(l = pos - 1, r = pos + 1; l >= 0 && r < n; l--, r++){
				if(s[l] == R && s[r] == G){
					minus ++;
				}
				if(s[l] == R) nl ++;
				if(s[r] == G) nr ++;
			}
			while(l >= 0){
				if(s[l] == R) nl++;
				l--;
			}
			while(r < n){
				if(s[r] == G) nr++;
				r++;
			}
			ans += (ll) (nl * nr - minus);
			nl = nr = 0;
			minus = 0;
			// G B R
			for(l = pos - 1, r = pos + 1; l >= 0 && r < n; l--, r++){
				if(s[l] == G && s[r] == R){
					minus ++;
				}
				if(s[l] == G) nl ++;
				if(s[r] == R) nr ++;
			}
			while(l >= 0){
				if(s[l] == G) nl++;
				l--;
			}
			while(r < n){
				if(s[r] == R) nr++;
				r++;
			}
			ans += (ll) (nl * nr - minus);
		}
	}
}
int main()
{
	fast();
	int n;
	string s;
	cin >> n >> s;
	vector<int> R, B, G;
	// for(int i = 0; i < n; ++i){
	// 	if(s[i] == 'R') R.push_back(i);
	// 	if(s[i] == 'B') B.push_back(i);
	// 	if(s[i] == 'G') G.push_back(i);
	// }
	// R B G or G B R
	ll ans = 0;
	solve(ans, s, 'R', 'B', 'G');
	solve(ans, s, 'B', 'R', 'G');
	solve(ans, s, 'R', 'G', 'B');
	cout << ans;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For(i, 0, n)
#define rrep(i, n) rFor(i, n, 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

lint pow10(int n){
    if(n < 0) return 0;
    lint ret = 1, x = 10;
    while(n){
        if(n & 1) ret *= x, --n;
        else x *= x, n >>= 1;
    }
    return ret;
}

int K, n;

void solve(){
    auto f = [&](int k){return pow10(k - 1) * 9 * k;};
    auto g = [&](int k){
        lint ret = 0;
        rep(i, k + 1) ret += f(i);
        return ret;
    };
    int low = 0, high = 10;
    while(high - low > 1){
        int mid = (high + low) / 2;
        (g(mid) < K ? low : high) = mid;
    }
    int k = low;
    K -= g(k);
    ++k;
    int start = pow10(k - 1) + div_ceil(K, k) - 1;
    K -= k * (start - pow10(k - 1));
    string s;
    rep(i, 120) s += to_string(start + i);
    cout << s.substr(K - 1, n) << "\n";
}

int main(){
    while(scanf("%d%d", &K, &n) && K){
        solve();
    }
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

typedef struct {
	vector <int> to;
	int cost;
	bool is_visited;
} edge;

int main( void ){
	int H, W; cin >> H >> W;
	vector <vector <int> > mine( H, vector <int>( W ));
	rep( i, 0, H ){
		rep( j, 0, W ){
			char c; cin >> c;
			if (c == '#')
				mine[ i ][ j ] = -1;
			else
				mine[ i ][ j ] = 0;
		}
	}
	int dir[ 8 ][ 2 ] = {{1, 0}, {1, -1}, {0, -1}, {-1, -1}, {-1, 0}, {-1, 1}, {0, 1}, {1, 1}};
	rep( i, 0, H ){
		rep( j, 0, W ){
			if (mine[ i ][ j ] == -1){
				rep( d, 0, 8 ){
					int y = i + dir[ d ][ 1 ], x = j + dir[ d ][ 0 ];
					if (y < 0 || y >= H || x < 0 || x >= W || mine[ y ][ x ] == -1)
						continue;
					mine[ y ][ x ]++;
				}
			}
		}
	}
	rep( i, 0, H ){
		rep( j, 0, W ){
			if (mine[ i ][ j ] == -1)
				cout << "#";
			else
				cout << mine[ i ][ j ];
		}
		cout << endl;
	}

}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 256
n, l = map(int, input().split())
# 等差数列の和の公式
# S = 1/2n(2a + (n-1)d)
a = l
if l >= 0:
    total = 1/2 * n * (2 * a + (n - 1) * 1) - l
elif l < 0 and abs(n) > abs(l):
    total = 1/2 * n * (2 * a + (n - 1) * 1)
elif l < 0:
    total = 1/2 * n * (2 * a + (n - 1) * 1) - (l + n - 1)
print(int(total))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

int main(){
    string s;cin>>s;
    ll cnt=0; rep(i,0,3) if(s[i] == 'o') cnt++;
    cout << 700+cnt*100 << endl;
}


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

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (b / a > c) cout << c << endl;
	else cout << b / a << endl;
}

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

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

using namespace std;

int main()
{
    int n;
    while (cin >> n, n) {
        int w, h;
        cin >> w >> h;
        vector<vector<bool> > board(w+1, vector<bool>(h+1, false));
        rep(i, n) {
            int a, b;
            cin >> a >> b;
            board[a][b] = true;
        }
        int a, b, ans = 0;
        cin >> a >> b;
        rep(i, w+2-a) {
            rep(j, h+2-b) {
                int cnt = 0;
                rep(k, a) {
                    rep(l, b) {
                        if (board[k+i][l+j]) {
                            cnt++;
                        }
                    }
                }
                ans = max(ans, cnt);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3072
using System;

class Cybeans {
   static void Main() {
       string[] str = Console.ReadLine().Split(' ');

       long d = long.Parse(str[0]);
       long a = long.Parse(str[1]);
       long b = long.Parse(str[2]);

       if(a >= b){
           Console.WriteLine("delicious");
       }else if(b - a <= d){
           Console.WriteLine("safe");
       }else{
           Console.WriteLine("dangerous");
       }
   }
}

Measured memory_bytes: 11092
using System;

class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            string[] datas = input.Split(' ');

            int number = int.Parse(datas[0] + datas[1]);

            if ((int)Math.Sqrt(number) == Math.Sqrt(number))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }

Measured memory_bytes: 11092
results = Hash.new
N, K = gets.split.map(&:to_i)
numbers = gets.split.map(&:to_i)
kinds = numbers.uniq.length - K
numbers.each do |number|
  results[number].nil? ? results[number] = 1 : results[number] += 1
end
if kinds <= 0
  puts 0
else
  result = 0 
  results.min_by(kinds) { |k, v| v }.each do |num|
    result += num[1]
  end
  puts result
end

Measured memory_bytes: 42248
(defun coins (a b c x)
  (let ((res 0)
        (total 0))
    (dotimes (i (+ a 1))
      (dotimes (j (+ b 1))
        (dotimes (k (+ c 1))
          (setf total (+ (* 500 i) (* 100 j) (* 50 k)))
          (if (= total x) (incf res)))))
    res))

(format t "~A~%" (coins (read) (read) (read) (read)))

Measured memory_bytes: 12768
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

a,b,c,k = inpl()
if k <= a:
    print(k)
elif k <= a+b:
    print(a)
else:
    print(a-(k-a-b))



Measured memory_bytes: 10404
#include<stdio.h>//３つの整数を読み込み、それらを値が小さい順に並べて出力するプログラム

void temp(int *,int *);
int main(void){

	int a,b,c;
	
	scanf("%d%d%d",&a,&b,&c);

	if(a>b)
		temp(&a,&b);
	if(b>c)
		temp(&b,&c);
	if(a>b)
		temp(&a,&b);

	printf("%d %d %d\n",a,b,c);
	
	return 0;
}

void temp(int *a,int *b){
	int temp;

	temp=*a;
	*a=*b;
	*b=temp;
}

Measured memory_bytes: 596
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>

using namespace std;
typedef long long ll;

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

int main() {

    ll N,A;
    cin >> N;
    double out = 0;
    rep(i,N){
        cin >> A;
        out += (double)1/A;
    }
    cout << fixed << setprecision(5) << 1/out << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
  #include <string>
  #include <vector>
  #include <algorithm>
  using namespace std;
  typedef long long ll;
  #define rep(i,n) for (int i=0;i < (int)(n);i++)

  
  int main(){
    int a,b;
    string s;
    cin >> a >> b;
    if (a==b) cout << "Draw" << endl;   
    else if (a == 1) cout <<"Alice" << endl;
    else if (b==1) cout << "Bob" << endl;
    else if (a > b) cout << "Alice" << endl;
    else cout << "Bob" << endl;
    return 0;
  }


Measured memory_bytes: 256
# div2019C - AB Substrings
def main():
    N, *S = open(0).read().split()
    ans, ab, start_b, end_a = 0, 0, 0, 0
    for s in S:
        if s[0] == "B" and s[-1] == "A":
            ab += 1
        elif s[0] == "B":
            start_b += 1
        elif s[-1] == "A":
            end_a += 1
        ans += s.count("AB")
    if start_b + end_a == 0:
        ans += max(0, ab - 1)
    else:
        ans += ab + min(start_b, end_a)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3700
// finish date: 2018/01/15
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int i=a;i<b;i++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define bigmod 1000000007
#define INF 500000000

int mul(int a, int b) {
    return (int) (((ll) (a % bigmod) * (b % bigmod)) % bigmod);
}

int main() {
    const int maxa = 401;
    int N, Ma, Mb;
    cin >> N >> Ma >> Mb;
    vector<vector<vector<int>>> DP(N + 1, vector<vector<int>>(maxa + 1, vector<int>(maxa + 1, INF)));
    DP[0][0][0] = 0;
    int a, b, c;
    rep(k, N) {
        cin >> a >> b >> c;
        rep(i, k * 10 + 1) {
            rep(j, k * 10 + 1) {
                if (DP[k][i][j] != INF) {
                    DP[k + 1][i][j] = min(DP[k + 1][i][j], DP[k][i][j]);
                    DP[k + 1][i + a][j + b] = min(DP[k + 1][i + a][j + b], DP[k][i][j] + c);
                }
            }
        }
    }
    int mi = INF;
    rep(i, maxa) {
        rep(j, maxa) {
            if (i == 0 && j == 0) continue;
            if (i % Ma == 0 && j % Mb == 0 && i / Ma == j / Mb) {
                mi = min(mi, DP[N][i][j]);
            }
        }
    }
    if (mi == INF) cout << -1 << endl;
    else cout << mi << endl;

    return 0;
}


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

struct xy
{
	double x;
	double y;
};
int main()
{
	double a, b, c, d, e, f,x,y;
	vector<xy> dst;
	while (cin>> a >> b >> c >> d >> e >> f) {
		y = (f - d / a * c) / (e - d / a * b);
		x = (c - b * y) / a;
		dst.push_back({ x,y });
	}
	for (vector<xy>::iterator it = dst.begin(); it < dst.end(); it++) {
		cout.setf(ios::fixed);
		cout << fixed << setprecision(3) << (*it).x<<" "<<(*it).y << endl;
	}
	return 0;
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int index=1;
    int num=0;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]==index){
            index++;
        }else{
            num++;
        }
    }

    cout << ((num==n)?-1:num) <<endl;


    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#define mm(a,x) memset(a,x,sizeof(a))
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0)
#define ll long long
using namespace std;
const int MAXN=2e5+10;
const ll mod=1e9+7;
ll a[MAXN];
int main(void)
{
    sync;
    int n,k;
    cin>>n>>k;
    for(ll i=1;i<=n;++i)
        a[i]=a[i-1]+i;
    ll res=0;
    for(int i=k;i<=n+1;++i)
    {
        ll pre=a[i-1]%mod;
        ll suf=(a[n]-a[n-i])%mod;
        res=(res%mod+(suf-pre+1+mod)%mod)%mod;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 5168
#include <bits/stdc++.h>
using namespace std;
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;
typedef unsigned long long int ull;
#define vi vector<ll>
#define pii pair<ll,ll>
#define vii vector<pii>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define mod 998244353
#define MAX 1000000001

vector<vector<int>>g(100001);
bool vis[100001]={};

void dfs(int u){
    vis[u]=1;
    for(auto &i:g[u]){
        if(!vis[i]){
            dfs(i);
        }
    }
}

int main(){
	fast;
	int test=1;
	//cin >> test;
	while(test--){
	    int n,m;
	    cin >> n >> m;
	    int cnt=0;
	    for(int i=1 ; i<=m ; i++){
	        int u,v;
	        cin >> u >> v;
	        g[u].pb(v);
	        g[v].pb(u);
	    }
	    for(int i=1 ; i<=n ; i++){
	        if(!vis[i]){
	            dfs(i);
	            cnt++;
	        }
	    }
	    cout << cnt-1 << endl;
	}
	return 0;
}

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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr ll mod = static_cast<ll>(1e9 + 7);

int n, m, s[2005], t[2005];
ll dp[2005][2005];
ll sum[2005][2005];
int main() {
	std::cin >> n >> m;

	for (int i = 1; i <= n; ++i)
		std::cin >> s[i];
	for (int i = 1; i <= m; ++i)
		std::cin >> t[i];

	dp[0][0] = 1LL;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			if (s[i] == t[j])
				dp[i][j] = sum[i - 1][j - 1] + 1LL;
			else
				dp[i][j] = 0LL;
			sum[i][j] = (sum[i][j - 1] + sum[i - 1][j] - sum[i - 1][j - 1] + dp[i][j] + mod) % mod;
		}
	}

	std::cout << (sum[n][m] + 1LL) % mod << std::endl;
	return 0;
}


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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

const ll N = 1e5 + 5;
vector<pii>adj[N];
ll ans[N];

void dfs(ll n, ll p, ll c){
	ans[n] = c;
	for(auto x : adj[n]){
		if(x.ff != p){
			dfs(x.ff,n,c ^ (x.ss&1));
		}
	}
}

void doit(){
	ll n, i, x, y, d;
	cin >> n;
	rep(i,0,n - 1){
		cin >> x >> y >> d;
		adj[x - 1].pb({y - 1, d});
		adj[y - 1].pb({x - 1, d});
	}
	dfs(0,-1, 0);
	rep(i,0,n)cout << ans[i] << nl;
}

int main() {
#ifndef ONLINE_JUDGE
//    freopen("input1.txt","r",stdin);
//    freopen("output1.txt","w",stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll t = 1;
//	 cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}


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

int main(){
	string is, os;
	while ( cin >> is ){
		os = "";
		for ( unsigned i = 0; i < is.size(); ++i ){
			if ( is[ i ] == '@' ){
				++i;
				int n = static_cast< int >( is[ i ] - '0' );
				++i;
				for ( int j = 0; j < n; ++j ){
					os += is[ i ];
				}
			}else{
				os += is[ i ];
			}
		}

		cout << os << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main { 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
      	
      	int ret = n;
      	for (int i = 0; i <= n; i += 9){
        	int tmp = 0;
          	int itmp = i;
          	while (itmp > 0){
            	tmp += itmp % 9;
              	itmp /= 9;
            }
          	itmp = n - i;
            while (itmp > 0){
            	tmp += itmp % 6;
              	itmp /= 6;
            }
          	if (ret > tmp) ret = tmp;
        }
      	System.out.println(ret);
    }
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    string s;
    cin >> s;
    int ans = 0;
    for(char c : s) if(c == '1') ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
d={};an=0
for i in l:
  d[i]=d.get(i,0)+1
for i in d.values():
  an+=i*(i-1)//2
for j in l:
  i=d[j];print(an+(i-1)*(i-2)//2-i*(i-1)//2)

Measured memory_bytes: 24872
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>

int main (void)
{
    intmax_t X, Y;
    intmax_t ans = 0;

    scanf("%jd%jd", &X, &Y);

    if (X == 1)
        ans += 300000;
    else if (X == 2)
        ans += 200000;
    else if (X == 3)
        ans += 100000;

    if (Y == 1)
        ans += 300000;
    else if (Y == 2)
        ans += 200000;
    else if (Y == 3)
        ans += 100000;

    if ((X == 1) && (Y == 1))
        ans += 400000;

    printf("%jd\n", ans);

    return 0;
}


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

using namespace std;

#define int long long

signed main(){
    int n, k;
    cin >> n >> k;
    
    set<pair<int, pair<int, int> > > s;
    vector<int > a(n), f(n);
    for(int i = 0; i < n; ++i){
    	cin >> a[i];
    }
    for(int i = 0; i < n; ++i){
    	cin >> f[i];
    }
    
    sort(a.begin(), a.end());
    sort(f.rbegin(), f.rend());
    
    int l = 0, r = 1e12;
    while(l < r){
    	int m = (l+r)/2;
    	int need = 0;
    	for(int i = 0; i < n; i++){
    		need += max(0LL, a[i]-m/f[i]);
    	}
    	if(need <= k){
    		r = m;
    	}else{
    		l = m+1;
    	}
    }
    cout<< r;
	return 0;
}

Measured memory_bytes: 3328
#include<stdio.h>

int main(){
	int mount[10]={0},i,j,high;
	
	
	for(i=0;i<10;i++){
	scanf("%d",&mount[i]);
	}
	
	for(i=0;i<10;i++){
		for(j=i+1;j<10;j++){
			if(mount[i]<mount[j]){
				high=mount[i];
				mount[i]=mount[j];
				mount[j]=high;
			}
		}
	}
	
	for(i=0;i<3;i++){
		printf("%d\n",mount[i]);
	}
	
	return 0;
	
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
int main() {
	int n, k; cin>>n>>k;
	vector<pair<int, int>> a(k);
	for(int i = 0; i < n; i++){
		cin>>a[i].first>>a[i].second;
	}
	vector<int> dp(n), pref(n);
	dp[0] = pref[0] = 1;
	for(int i = 1; i < n; i++){
		for(pair<int, int> p: a){
			int l = max(0, i - p.second);
			int r = i - p.first;
			if(l <= r){
				dp[i] += pref[r];
				if(l >= 1) dp[i] -= pref[l-1];
				dp[i] %= mod;
				if(dp[i] < 0) dp[i] += mod;
			}
		}
		pref[i] = (pref[i - 1] + dp[i]) % mod;
	}
	cout<<dp[n - 1]<<endl;
}

Measured memory_bytes: 4748
#include <iostream>

int getMinIteration(const int& a, const int& b, const int& c) {
	int ret = 0;
	int temp_total = 0;

	if (a <1 || b < 0|| c < 1) {
		std::cout <<"a or b or c exceed min"<< std::endl;
		return ret;
	}
	if ( 1000 < a || 1000 < b || 1000000 < c ) {
		std::cout<< "a or b or c exceed max"<< std::endl;
		return ret;
	}

	do {
		ret += 1;
		temp_total += a;
		if (ret%7 == 0) { temp_total += b; }
	} while (temp_total<c);
	return ret;
}


int main() {

	int i_a, i_b, i_c;
	std::cin >> i_a;
	std::cin >> i_b;
	std::cin >> i_c;

	auto min = getMinIteration(i_a, i_b, i_c);
	std::cout << min<<std::endl;

	return 0;
}


Measured memory_bytes: 3132
//Digit Number
#include<bits/stdc++.h>

int digit(long long x){
  int i=1;
  while(true){
    x/=10;
    if(x==0)break;
    i++;
  }
  return i;
}

int main(){
  long long  a, b;
  while(scanf("%lld %lld", &a, &b)!=EOF){
    printf("%d\n", digit(a+b));
  }
  return 0;
}

Measured memory_bytes: 1188
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

        int total = 0;
        for (int i = 0; i <= N; i++) {
            int four = i / 10000;
            int three = (i - 10000 * four) / 1000;
            int two = (i - 10000 * four - three * 1000) / 100;
            int one = (i - 10000 * four - three * 1000 - 100 * two) / 10;
            int zero = i - 10000 * four - three * 1000 - 100 * two - 10 * one;
            int add = four + three + two + one + zero;
            if (add >= A && add <= B) {
                total += i;
            }

        }
        System.out.println(total);
        sc.close();
    }

}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define rep(i,l,r) for (int i=l;i<=r;i++)
#define per(i,l,r) for (int i=l;i>=r;i--)
using namespace std;
typedef long long ll;
int n,x,ans;
int a[400500],st[400500];
map<int,int> c;
bool jud(int mid){
    int now=mid;
    c.clear();
    int tot=0;
    rep(i,2,n){
        if (a[i]>a[i-1]) continue;
        while (tot&&st[tot]>a[i]){
            c[st[tot]]=0;
            tot--;
        }
        st[++tot]=a[i];
        int x=a[i];
        c[x]++;
        if (mid==1) return 0;
        while (c[x]>=mid) c[x]=0,c[--x]++;
        if (x<=0) return 0;
    }
    return 1;
}
int main(){
    scanf("%d",&n);
    rep(i,1,n) scanf("%d",&a[i]);
    int l=1,r=n,ans=n;
    while (l<=r){
        int mid=(l+r)/2;
        if (jud(mid)) ans=mid,r=mid-1;
        else l=mid+1;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
  int M,N,L;
  int ans;
  
  while(1){
    cin>>L;
    ans=1;
    if(L==0)break;
    for(int i=0;i<12;i++){
      cin>>M>>N;
      L=L-(M-N);
      if(L>0) ans++;
    }
    if(L>0)cout<<"NA"<<endl;
    else cout<<ans<<endl;
  }
  
  return 0;
}

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

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

int gcd(int a,int b)
{
	if (a%b==0)
	{
		return(b);
    }
	else
	{
		return(gcd(b,a%b));
    }
}

int main() {
  int p, q;
  cin>>p>>q;

	q = q/gcd(p,q);  /*??????????´??????????????????????*/

	//int qq = q/gcd(p,q);
	int qq = q;
	long long ans = 1;
	for(int j=2; j*j<=qq; j++){
		if(qq % j == 0){
			ans *= j;
			while(qq % j == 0){
				qq /= j;
			}
		}
	}
	if(qq != 1) ans *= qq;

	cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define CLEAR(a) memset(a,0,sizeof a)
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define fr freopen("input.txt", "r", stdin);
#define fw freopen("output.txt", "w", stdout);
typedef long long LL;
typedef pair<int,int> pii;
const int MOD = 1e9 + 7;
const int MAX = 1e6 + 5;
vector<pair<int, pii> > v;
int n,m, t[MAX];
    

void update(int l, int r, int value) {
  for (l += m+1, r += m+1; l < r; l >>= 1, r >>= 1) {
    if (l&1) t[l++] += value;
    if (r&1) t[--r] += value;
  }
}

int query(int p) {
  int res = 0;
  for (p += m+1; p > 0; p >>= 1) res += t[p];
  return res;
}


int main() {
     cin >> n >> m;
    REP(i, n){
      int l, r;
      cin >> l >> r;
      l--;r--;
      v.pb(mp(r-l+1, mp(l, r)));
    }
    
    sort(v.begin(), v.end());

    int j = 0;
    
    FOR(i,1,m){
      
      while(j < n && v[j].F < i){
        update(v[j].S.F, v[j].S.S+1, 1);
        j++;
      }

      int ans = n - j;
     
      for(int k=i-1;k<=m;k+=i){
        ans += query(k);
      }
      cout << ans <<"\n";
    }
    return 0;
}

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

int main(){
    vector<vector<int>> data(3,vector<int>(3));
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin>>data.at(i).at(j);
        }
    }

    bool ans=false;
    int p=data.at(0).at(0);
    int q=data.at(1).at(1);
    int r=data.at(2).at(2);

    for(int i=0;i<=100;i++){
        for(int j=0;j<=100;j++){
            for(int k=0;k<=100;k++){
                if(data[0][1]==p-i+j&&data[0][2]==p-i+k&&data[1][0]==q-j+i&&data[1][2]==q-j+k&&data[2][0]==r-k+i&&data[2][1]==r-k+j)ans=true;
            }
        }
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
    


Measured memory_bytes: 256
a,b,c,d = map(int, input().split())

player= [[a,b],[c,d]]

turn = 0

while player[0][0] > 0 and player[1][0] > 0:
    opp = 1-turn
    player[opp][0] -= player[turn][1]
    turn = opp

if player[0][0] <= 0:
    print("No")
else:
    print("Yes")
    


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


typedef long long LL;
LL b[100005];
LL l[100005]; 
LL u[100005];

LL totals[100005];

typedef pair<LL, int> score;

int main(){
	LL n, x; cin >> n >> x;
	for (int i = 0; i < n; i++){
		cin >> b[i] >> l[i] >> u[i];
		totals[i] = l[i] * b[i] + (x - b[i]) * u[i];
	}
	LL target = 0;
	for (int i = 0; i < n; i++){
		target += l[i] * b[i];
	}
	
	//how many exams
	vector<score> scores;
	for (int i = 0; i < n; i++){
		scores.push_back(make_pair(totals[i], i));
	}
	sort(scores.begin(), scores.end());
	reverse(scores.begin(), scores.end());
	LL running_tot = 0;
	LL how_many = 0; 
	int cnt = 0;
	for (int i = 0; i < scores.size(); i++){
		running_tot += scores[i].first;
		if (running_tot > target){
			running_tot -= scores[i].first;
			break;
		}
		how_many += x;
		++cnt;
	}
	LL finres;
	LL resid = target - running_tot;
	if (resid == 0){
		cout << how_many << endl;
		return 0;
	}
	LL leftover = (x + 1);
	for (int i = cnt; i < n; i++){
		//how many do I need to get over resid
		if (totals[scores[i].second] < resid){
			continue;
		}
		else{
			if (resid <= l[scores[i].second] * b[scores[i].second]){
				LL needed = (resid - 1) / l[scores[i].second] + 1;
				leftover = min(leftover, needed);
			}
			else{
				LL needed = b[scores[i].second] + 1 + (resid - (l[scores[i].second] * b[scores[i].second]) - 1) / (u[scores[i].second]);
				leftover = min(leftover, needed);
			}
		}
	}
	finres = leftover + how_many;
	
	running_tot += scores[cnt].first;
	assert(running_tot > target);
	//what's the most you can remove and keep it above x, so you want it low
	resid = running_tot - target;
	LL rem = 0;
	for (int i = 0; i <= cnt; i++){
		if (resid <= (x - b[scores[i].second]) * u[scores[i].second]){
			rem = max(rem, resid / u[scores[i].second]);
		}
		else{
			rem = max(rem, (resid - (x - b[scores[i].second]) * u[scores[i].second]) / l[scores[i].second] + (x - b[scores[i].second]));
		}
	}

	cout << min(finres, how_many + x - rem) << endl;


	//Case 1: be greedy, but get on the departing train
	
	//Case 2: only the largest k + 1 totals. 
	

}


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

int main() {
  string S;
  cin >> S;
  
  int count = 0;
  for(int i = 0; i < 3; i++){
    if(S.at(i) == 'R'){
      count++;
    }
  }
  
  if(count == 2 && S.at(1) == 'S') count = 1;
  //if(count == 1) count = 0;
  cout << count << endl;
}

Measured memory_bytes: 3544
N, K = map(int, input().split())
A = list(map(int, input().split()))


def int2bin(n):
    return '{:040b}'.format(n)
B = list(map(int2bin, A))

Kbin = int2bin(K)
res = 0
flag = False
for i in range(40):
    cnt1 = 0
    for elem in B:
        if elem[i] == '1':
            cnt1 += 1
    if flag:
        if cnt1 <= N//2:
            res += 2**(39-i)
        continue
    if cnt1 <= N//2 and Kbin[i] == '1':
        res += 2**(39-i)
    else:
        if Kbin[i] == '1':
            flag = True

ans = 0
for elem in A:
    ans += res ^ elem
print(ans)


Measured memory_bytes: 18340
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1
#define INF 1000000000 //1e9

int main(){
    int n,m;
    cin >> n >> m;
    if(n == m) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    from sys import stdin
    input = lambda : stdin.readline().rstrip()
    N = int(input())
    diff = [0] * N
    A = map(int,input().split())
    for a in A:
        diff[a] += 1

    r = N % 2
    if r == 1 and diff[0] != 1:
        print(0)
        return


    for i in range(r,N,2):
        if not diff[i] == 0:
            print(0)
            return

    ans = 1
    for i in range(r+1,N,2):
        if diff[i] == 2:
            ans = ans * 2 % (10**9+7)
        else:
            print(0)
            return
    print(ans)

main()

Measured memory_bytes: 52080
def DFS(num):
    global time
    time +=1
    color[num]="gray"
    D[num][0]=time
    for i in M[num]:
        if color[i]=="white":
            DFS(i)
    color[num]="black"
    time +=1
    D[num][1]=time


n=int(input())
M=[[] for _ in range(n+1)]
for i in range(n):
    for j in list(map(int,input().split()))[2:]:
        M[i+1].append(j)
color=["white" for _ in range(n+1)]
D=[[0,0] for _ in range(n+1)]
time=0
for i in range(n):
    if color[i+1]=="white":
        DFS(i+1)

for i in range(n):
    print(i+1,*D[i+1])


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

int main()
{
  int height[10];
  
  for(int i = 0 ; i < 10 ; i++)
    {
      cin >> height[i];
    }

  for(int i = 0 ; i < 10 ; i++)
    {
      for(int j = i + 1 ; j < 10 ; j++)
	{
	  if(height[i] < height[j])
	    {
	      int dumy = height[i];
	      height[i] = height[j];
	      height[j] = dumy;
	    }
	}
    }
  for(int i = 0 ; i < 3 ; i++)
    {
      cout << height[i] << endl;
    }
  return 0;
}



Measured memory_bytes: 3092
n=int(input())
i=0
s=[]
a=[]
d=[]
while i!=n:
    a=list(map(int,input().split()))
    d.append(a[1])
    d.append(a[0])

    s.append(d)
    d=[]
    i+=1

s.sort()
#print(s)

ans=0
i=0
x=0
while i!=n:
    ans+=s[i][1]
    if ans>s[i][0]:
        x=1
        break
    i+=1
if x==1:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 51792
q=int(input())
max=100001
is_prime =[1]*max
is_prime[0] = 0
is_prime[1] = 0
for i in range(2,max):
    if not is_prime[i]:
        continue
    for j in range(i*2,max,i):
        is_prime[j] = 0

a=[0]*(max+1)
for i in range(max):
    if i%2==0:
        continue
    if is_prime[i]==1 and is_prime[(i+1)//2]:
        a[i]=1

s=[0]*(max+1)
for i in range(max):
    s[i+1]=s[i]+a[i]

for i in range(q):
    l,r=map(int,input().split())
    print(s[r+1]-s[l])


Measured memory_bytes: 53208
using System;
using System.Collections.Generic;

class Program
{
  static void Main(string[] args)
  {
    string[] l1 = Console.ReadLine().Split(' ');
    int n = int.Parse(l1[0]);
    int k = int.Parse(l1[1]);

    int[] d = new int[k];
    string[] l2 = Console.ReadLine().Split(' ');
    for (int i=0; i<k; i++) {
      d[i] = int.Parse(l2[i]);
    }

    for (int i=n; ; i++) {
      bool ok = true;
      var ret = ParseInt(i);
      for (int j=0; j<ret.Count; j++) {
        for (int l=0; l<k; l++) {
          if (ret[j] == d[l]) {
            ok = false;
            break;
          }
        }
        if (ok == false) {
          break;
        }
      }

      if (ok == true) {
        Console.Write(i + "\n");
        return;
      }
    }
  }

  static List<int> ParseInt(int i) {
    var ret = new List<int>();
    for (; i>=10; i/=10) {
      ret.Add(i%10);
    }
    ret.Add(i);
    return ret;
  }
}


Measured memory_bytes: 15308
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

vector<int> g[200000];
vector<ll> cnt(200000);

void dfs(int v, int p, int c) {
  cnt[v] += c;
  for (auto u : g[v]) {
    if (u == p) continue;
    dfs(u, v, cnt[v]);
  }
}

int main() {
  int n, q;
  cin >> n >> q;
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vector<int> p(q), x(q);
  for (int i = 0; i < q; ++i) {
    cin >> p[i] >> x[i];
    p[i]--;
    cnt[p[i]] += x[i];
  }
  dfs(0, -1, 0);
  for (int i = 0; i < n; ++i) {
    cout << cnt[i] << (i == n - 1 ? '\n' : ' ');
  }
  return 0;
}

Measured memory_bytes: 25856