akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int B[10][10];
int F[10][10];
int E[10];

signed main(){
	cin>>N;
	for(int i=1;i<=N;i++){
		string s=to_string(i);
		int R=s[0]-'0';
		int Q=s.back()-'0';
		B[R][Q]++;
	}
	int ans=0;
	for(int i=1;i<=9;i++){
		for(int j=1;j<=9;j++){
			ans+=B[i][j]*B[j][i];
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
/*ALDS1_1_A 挿入ソート*/
#include <stdio.h>

/*配列の要素を順番に出力*/
void trace(int A[], int N){
   int i;
   for(i = 0 ; i < N ; i++){
      if(i > 0 ) printf(" ");
      printf("%d", A[i]);
   }
   printf("\n");
}

/*挿入ソート*/
void InsertionSort(int A[], int N){
   int i, j, v;
   for(i = 1 ; i < N ; i++){
      v = A[i];
      j = i - 1;

      while(j >= 0 && A[j] > v){
         A[j + 1] = A[j];
         j--;
      }
      A[j + 1] = v;
      
      trace(A, N);
   }
}

int main(){
   int N, i, j;
   int A[100];

   scanf("%d", &N);
   for(i = 0 ; i < N ; i++) scanf("%d", &A[i]);

   trace(A, N);
   InsertionSort(A, N);

   return 0;
}



Measured memory_bytes: 2736
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
 
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
 
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
 
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
#define eb emplace_back
#define m_p make_pair
#define T int t = 0; cin >> t; while(t--)
#define pr(a) for(int i = 0; i < (int)a.size(); ++i)cout << a[i] << " ";cout << endl;
#define b_e(a) a.begin(), a.end()
typedef long long ll;
typedef long double lld;
const ll mod = 1e15;
const ll mx = 1e3 + 1;
const ll inf = (1LL << 62LL);
const int sz = 256;
const int max_k = 20;
typedef long long ll;

void input(){
    IOS;
    ll n, k;
    cin >> n >> k;
    vector<ll>p(n), c(n);
    f(i, n)cin >> p[i], --p[i];
    f(i, n)cin >> c[i];
    ll ans = -inf;
    f(i, n){
        ll start = p[i];
        vector<ll>temp;
        temp.push_back(c[start]);
        while(i != start){
            start = p[start];
            temp.push_back(c[start]);
        }
        ll t = (int)temp.size();
        vector<ll>pre(t);
        pre[0] = temp[0];
        for(int i = 1; i < t; ++i)pre[i] += pre[i - 1] + temp[i];
        for(ll r : {0LL, 1LL, k / t, k / t - 1}){
            if(t * r > k || r < 0)continue;
            if(t * r == k){
                ans = max(ans, pre[t - 1] * r);
            }else{
                ll y = k - r * t;
                ll as = -inf;
                f(j, min(t, y))as = max(as, pre[j]);
                ans = max(ans, pre[t - 1] * r + as);
            }
        }
    }
    cout << ans << endl;
    
}

int main(){
    input();
    return 0;
} 
/*
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
*/


Measured memory_bytes: 3848
S = input()

a_cnt = 0
b_cnt = 0
c_cnt = 0

for s in S:
    if s == 'a':
        a_cnt += 1
    elif s == 'b':
        b_cnt += 1
    elif s == 'c':
        c_cnt += 1

if a_cnt == 1 and b_cnt == 1 and c_cnt == 1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]


X,t = map(int, input().split())

print(max(0, X-t))



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

int main()
{
	int k,a,b;
	cin>>k>>a>>b;
	for(int i=a;i<=b;i++)
	{
		if(i%k==0)
		{
			cout<<"OK"<<endl;
			return 0;
		}
	 } 
	 
			cout<<"NG"<<endl;
			return 0;
 } 

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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

class UnionFind{
	private:
		vector<int> parent;
		vector<int> rank;
	public:
		UnionFind(int n)
			:parent(n + 1),rank(n + 1,1){
			for(int i = 1;i <= n;i++) parent [i] = i;
		}
		int find(int x){
			if(parent [x] == x) return x;
			return parent [x] = find(parent [x]);
		}
		bool connect(int x,int y){
			x = find(x),y = find(y);
			if(x == y) return false;
			if(rank [x] < rank [y]) swap(x,y);
			if(rank [x] == rank [y]) rank [x]++;
			parent [y] = x;
			return true;
		}
		bool same(int x,int y){
			return find(x) == find(y);
		}
};

int N,M,Q;
list< pair<int,ll> > edge [4001],used_edge [4001];
struct st{
	int a,b;
	ll c;
	bool operator<(const st& other){
		return this->c < other.c;
	}
};
ll max_edge [4001] [4001];

ll dfs(int curr,int prev,int s,ll mx)
{
	max_edge [s] [curr] = mx;
	max_edge [curr] [s] = mx;
	for(auto&& it : used_edge [curr]) if(it.first != prev){
		dfs(it.first,curr,s,max(mx,it.second));
	}
}

int main()
{
	scanf("%d%d",&N,&M);
	vector<st> A(M);
	FOR(i,0,M){
		scanf("%d%d%lld",&A [i].a,&A [i].b,&A [i].c);
		edge [A [i].a].push_back({A [i].b,A [i].c});
		edge [A [i].b].push_back({A [i].a,A [i].c});
	}
	sort(ALL(A));

	scanf("%d",&Q);
	vector< pair<int,int> > query(Q);
	FOR(i,0,Q){
		scanf("%d%d",&query [i].first,&query [i].second);
	}

	ll ans = 0;
	UnionFind uf(N);
	FOR(i,0,M){
		if(uf.same(A [i].a,A [i].b) == false){
			uf.connect(A [i].a,A [i].b);
			used_edge [A [i].a].push_back({A [i].b,A [i].c});
			used_edge [A [i].b].push_back({A [i].a,A [i].c});
			ans += A [i].c;
		}
	}

	for(int i = 1;i <= N;i++){
		dfs(i,-1,i,0);
	}

	FOR(i,0,Q){
		printf("%lld\n",ans - max_edge [query [i].first] [query [i].second]);
	}

	return 0;
}


Measured memory_bytes: 171648
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  def next(): String = sc.next()
  def nextInt(): Int = Integer.parseInt(next())

  def taskA(): Unit = {
    val n = next()
    println(n.count(_ == '2'))
  }

  def taskB(): Unit = {
    val n, h, w = nextInt()
    val ans = 1.to(n).count { _ =>
      val a, b = nextInt()
      a >= h && b >= w
    }
    println(ans)
  }

  taskB()
}


Measured memory_bytes: 30604
using System;

namespace Atcoder
{
    class ABC122_A
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            char b = str[0];
            switch (b)
            {
                case 'A':
                    Console.Write('T');
                    break;
                case 'T':
                    Console.Write('A');
                    break;
                case 'C':
                    Console.Write('G');
                    break;
                case 'G':
                    Console.Write('C');
                    break;
            }
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int n, s, cnt;

void dfs(int depth, int sum, int num) {
  if (depth == 0 && sum == s) {
    cnt++;
    return;
  }
  if (num == 10 || depth == 0) return;
  dfs(depth - 1, sum + num, num + 1);
  dfs(depth, sum, num + 1);
}

int main() {
  while (cin >> n >> s, n | s) {
    cnt = 0;
    dfs(n, 0, 0);
    cout << cnt << "\n";
  }
}


Measured memory_bytes: 3044
/* https://codeforces.com/contest/1360/problem/H */
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using vs = vector<string>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pair<ll, ll>>;
using ld = double;

#define f first
#define s second 
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define pb push_back
#define	lb lower_bound
#define	ub upper_bound
#define	sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define ins insert

const int MAX = INT_MAX;

int main() {
	
	string s;
	cin>>s;
	ll sum = 0;
	for (int i = 0;i < s.length();++i) {
		sum += s[i] - '0';
	}

	if (sum%9 == 0) {
		cout<<"Yes"<<endl;
	}
	else {
		cout<<"No"<<endl;
	}

	return 0;
}


Measured memory_bytes: 3720
from collections import Counter
from itertools import permutations

def main():
    N, C = map(int, input().split())
    D = [list(map(int, input().split())) for _ in range(C)]

    cnt = [Counter() for _ in range(3)]

    for i in range(N):
        c = [int(x)-1 for x in input().split()]
        for j in range(3):
            cnt[j].update(c[(3-(i+2)+j)%3::3])

    ans = 1000*500*500+5
    for p in permutations(range(C), 3):
        s = 0
        for j in range(3):
            s += sum(D[k][p[j]] * v for k, v in cnt[j].items())
        if s < ans: ans = s
    print(ans)

main()


Measured memory_bytes: 3436
#include <bits/stdc++.h>
typedef int ll;
//#define int long long 
using namespace std;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#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--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size()) 
#define MAX(x) *max_element(ALL(x)) 
#define MAX(x) *max_element(ALL(x)) 
#define INF 1000000000000 
#define MOD 10000007 
#define MAXR 100000 
#define PB push_back 
#define PI 3.14159265358979323846

using namespace std;

int main(){
    int H,W;
    cin >> H>>W;
    do
    {
        

        REP(i,W){
            cout << "#"  ;
        }
        cout << "" <<endl ;

        REP(i,H-2){
            cout << "#" ;
            REP(j,W-2){
                cout << ".";
            }
            cout << "#" <<endl ;
        }


        REP(i,W){
            cout << "#" ;
        }
        cout <<endl<<endl ;
        cin >> H>>W;
    } while (H!=0 || W!=0);
    
    


return 0 ;
}


Measured memory_bytes: 3092
#include<stdio.h>
main(){
  int n,i,sum;
  while(scanf("%d",&n)!=EOF){
    int l=2,a[1000001]={0};
    sum=0;
    while(n>=l*l){
      if(a[l]==0){
	for(i=l+l;i<=n;i+=l){
	  a[i]=1;
	}
      }
      l++;
    }
    for(i=2;i<=n;i++){
      if(a[i]==0){
	sum++;
      }
    }
    printf("%d\n",sum);
  }
  return 0;
}


Measured memory_bytes: 5636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;
//#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}
//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

int strsum(const int n){
    string s = to_string(n);
    int b(0);
    rep(i,s.size()){
        b += s[i]-'0';
    }
    return b;
}

int main(){
    int n,m;
    ll ans(0);
    cin >> n >> m;
    vector<int> x(m);
    vector<int>  d(m-1);
    rep(i,m){
        cin >> x[i];
    }
    if(n>=m){
        puts("0");
        return 0;
    }
    sort(x.begin(),x.end());
    ans = x[m-1]-x[0];

    rep(i,m-1){
        d[i] = x[i+1]-x[i];
    }
    sort(d.begin(), d.end(), greater<int>());

    rep(i,n-1){
        ans -= d[i];
    }
    put(ans);

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
#define MAX 100100
inline ll read()
{
	ll x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int n,Q,tot;
ll q[MAX],ans[MAX],s[MAX];
int Binary(int l,int r,ll k)
{
	int ret=0;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(k>=q[mid])l=mid+1,ret=mid;
		else r=mid-1;
	}
	return ret;
}
int main()
{
	n=read();Q=read();q[tot=1]=n;
	for(int i=1;i<=Q;++i)
	{
		ll x=read();
		while(tot&&q[tot]>=x)--tot;
		q[++tot]=x;
	}
	Q=tot;s[Q]=1;
	for(int i=Q;i;--i)
	{
		ll l=q[i];int p=Binary(1,i-1,l);
		while(p)s[p]+=l/q[p]*s[i],l%=q[p],p=Binary(1,p-1,l);
		ans[l]+=s[i];
	}
	for(int i=n;i;--i)ans[i]+=ans[i+1];
	for(int i=1;i<=n;++i)printf("%lld\n",ans[i]);
	return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

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


int main(){
	int a,b;
	cin>>a>>b;
	cout<<lcm(a,b)<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;
const long double PI = (acos(-1));
const long long MOD = 1000000007;
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)

///////////////////////////////////////////////////
// -------------------- I/O -------------------- //
///////////////////////////////////////////////////
// https://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords
template<typename T> void outputVec(const std::vector<T>& vec, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	for (auto it = vec.begin(); it != vec.end() - 1; ++it) { std::cout << *it << " "; }
	std::cout << *(vec.end() - 1) << "\n";
}
template<typename T> void outputVal(const T& res, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	std::cout << res << "\n";
}
template<typename T> T inputVal() { T a; std::cin >> a; return a; }
template<typename T> std::vector<T> inputVec(int N) {
	std::vector<T> vec(N);
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
	return vec;
}
template<typename T> void inputVec(std::vector<T>& vec) {
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
}

///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
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; }

///////////////////////////////////////////////////
// ------------------- main -------------------- //
///////////////////////////////////////////////////
void Main() {
	const int N = inputVal<int>();
	std::vector<string> s(N);
	rep(i, N) {
		string sline = inputVal<string>();
		sort(sline.begin(), sline.end());
		s[i] = sline;
	}
	sort(s.begin(), s.end());

	ll cnt = 0;
	ll cmb = 0;
	REP(i, 1, N) {
		if (s[i] == s[i - 1]) ++cnt;
		else if (cnt == 0) continue;
		else {
			cmb += (cnt +1) * cnt / 2;
			cnt = 0;
		}
	}
	if (cnt != 0) {
		cmb += (cnt + 1) * cnt / 2;
	}
	outputVal(cmb);
}

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

	return 0;
}


Measured memory_bytes: 5760
n = int(input())

i = 2
memo = []
while( i*i <= n ):
    x = 0
    while(n % i == 0):
        #print("n % i == 0 =",n,i,"n/i=",n/i,x+1)
        n = int(n / i);
        x = x + 1
    memo.append([i,x])
    i = i + 1

if not (n == 1):
    memo.append([n,1])

ans = 0
for i in memo:
    x = i[1]
    b = 1
    while b <= x:
        x = x - b
        b = b + 1
        ans = ans + 1

print(ans)


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

char a[101],b[101];
int main(){
	scanf("%s",a);
	scanf("%s",b);
	int len=strlen(a);
	if(len!=strlen(b)){
		puts("No");
		return 0;
	}
	for(int i=0;i<len;++i){
		for(int j=0;j<len;++j){
			if(a[(i+j)%len]!=b[j])break;
			if(j==len-1){
				puts("Yes");
				return 0;
			}
		}
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 256
use proconio::input;
use std::cmp::min;

fn main() {
    input! {
        n: u64,
        a: u64,
        b: u64,
    }

    solve(n, a, b);
}

fn solve(n: u64, a: u64, b: u64) {
    let cnt = n / (a + b);
    let m = n - cnt * (a + b);
    println!("{}", cnt * a + min(a, m));
}


Measured memory_bytes: 2144
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	while(true){
		int a,b,c,n;
		int x[1000],y[1000],z[1000],w[1000];
		int d[300];
		for(int i=0;i<300;i++)d[i]=2;
		scanf("%d%d%d",&a,&b,&c);
		if(a==0&&b==0&&c==0)return 0;
		scanf("%d",&n);
		for(int i=0;i<n;i++)scanf("%d%d%d%d",&x[i],&y[i],&z[i],&w[i]);

		for(int i=0;i<n;i++){
			if(w[i]==1)d[x[i]-1]=d[y[i]-1]=d[z[i]-1]=1;
		}
		for(int k=0;k<a+b+c;k++){
		for(int i=0;i<n;i++){
			if(w[i]==0){
				if(d[x[i]-1]==1&&d[y[i]-1]==1&&d[z[i]-1]==2)d[z[i]-1]=0;
				if(d[x[i]-1]==1&&d[y[i]-1]==2&&d[z[i]-1]==1)d[y[i]-1]=0;
				if(d[x[i]-1]==2&&d[y[i]-1]==1&&d[z[i]-1]==1)d[x[i]-1]=0;
			}
		}
		}
		for(int i=0;i<a+b+c;i++)printf("%d\n",d[i]);
		
	}
}

Measured memory_bytes: 1204
#include "bits/stdc++.h"
// #include <unordered_map>
using namespace std;
typedef long long int lli;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define ff first
#define ss second
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5 + 5;
lli a[N],b[N],lst[N];
int main() {
	IOS
	int T = 1;
	// cin>>T;
	lli ans = 0;
	while(T--) {
		int a,b;
      cin>>a>>b;
      cout<<max(0,a - b -b);
	}
	return 0;	
}

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

using namespace std;

string a,b;
int i;

int main(){
    cin>>a;
    b=a;
    reverse(a.begin(),a.end());
    for(i=0;i<a.size();++i)
    {
        if(a[i]=='b')a[i]='d';
        else if(a[i]=='d')a[i]='b';
        else if(a[i]=='p')a[i]='q';
        else if(a[i]=='q')a[i]='p';
    }
    if(a==b)cout<<"Yes\n";
    else cout<<"No\n";
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <boost/functional/hash.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
  int n, a;
  cin >> n >> a;
  
  vector<int> x(n);
  for (auto&& xx : x) {
    cin >> xx;
  }
  
  using Map = unordered_map<pair<int, int>, int64_t, boost::hash<pair<int, int>>>;
  Map m;
  for (auto xx : x) {
    Map next;
    for (const auto& entry : m) {
      auto key = entry.first;
      next[key] += entry.second;
      key.first += xx;
      key.second += 1;
      next[key] += entry.second;
    }
    
    next[make_pair(xx, 1)] += 1;
    m.swap(next);
  }

  int64_t ans = 0;
  for (const auto& entry : m) {
    auto key = entry.first;
    if (key.first == a * key.second) {
      ans += entry.second;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 2768
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <map>
using namespace std;


#define prec(i) cout << fixed << setprecision(i)

void outPut_YN(bool isYes) {
	if(isYes)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

const long long MOD = 1000000007;

long long fact(long long k) {
	long long sum = 1;
	for (long long i = 2; i <= k; i++)
		sum *= i;

	return sum;
}

long long fact_mod(long long k) {
	long long sum = 1;
	for (long long i = 2; i <= k; i++)
		sum = (sum * i) % MOD;

	return sum;
}

int ctoi(char c) {
	if (c >= '0' && c <= '9')
		return c - '0';
	else
		return -1;
}

long long pow_mod(int a, int b) {
	long long ans = 1;
	for (int i = 0; i < b; i++)
		ans = (ans * a) % MOD;

	return ans;
}

long long powll(long long a, long long  b) {
	long long ans = 1;
	for (long long i = 0; i < b; i++)
		ans = ans * a;

	return ans;
}

long long modinv(long long a) {

	long long b = MOD, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= MOD;
	if (u < 0) u += MOD;

	return u;
}

long long _gcd(long long a, long long b)
{
	if (a < b)
		swap(a, b);

	if (a % b == 0)
		return b;
	else
		return _gcd(b, a % b);
}

int main()
{
	long long n, k, sum = 0;

	cin >> n >> k;

	vector<long long> h(n);

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

	sort(h.begin(), h.end());

	for (int i = 0; i < n - k; i++)
		sum += h[i];

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 1792
N = int(input())

def get_parent(node):
    parent = -1
    if "parent" in node:
        parent = node["parent"]
    return parent

def get_depth(node):
    depth = 0
    while "parent" in node:
        depth += 1
        parent = node["parent"]
        node = rooted_tree[parent]
    return depth

def get_node_type(node):
    if "parent" not in node:
        return "root"
    if "left" not in node:
        return "leaf"
    return "internal node"

def get_children(node):
    if "left" not in node:
        return "[]"
    left = node["left"]
    siblings = []
    siblings.append(str(left))
    while rooted_tree[left]["right"] > -1:
        right = rooted_tree[left]["right"]
        siblings.append(str(right))
        left = right
    return "[{}]".format(", ".join(siblings))

rooted_tree = [{} for i in range(N)]
for _ in range(N):
    row = input()
    id, degree, *children = list(map(int, row.split()))
    if degree > 0:
        rooted_tree[id]["left"] = children[0]
        for i in range(len(children)):
            child_id = children[i]
            right = -1
            if i < len(children)-1:
                right = children[i+1]
            rooted_tree[child_id]["right"] = right
            rooted_tree[child_id]["parent"] = id

for id in range(N):
    node = rooted_tree[id]
    parent = get_parent(node)
    depth = get_depth(node)
    node_type = get_node_type(node)
    children = get_children(node)
    print("node {}: parent = {}, depth = {}, {}, {}".format(id, parent, depth, node_type, children))


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

    for(i=1;i<=3;i++){
        if((a*b*i)%2 != 0)
            c++;
    }
    if(c>0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
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; }
const ll INF = 1e9;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
int main(){
    string s;
    cin >> s;
    string ans = "";
    rep(i,s.length()) ans += "x";
    PRINT(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
ll mod =  1000000007;
ll maxn = 1000000000;
 
//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------
 
int main(){
   double w,h,x,y;
   cin>>w>>h>>x>>y;
   cout<<(w*h)/2<<" ";
   if(x==w/2&&y==h/2)cout<<1<<endl;
   else cout<<0<<endl;
   
   
   
}
   



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
#include <time.h> 
 
using namespace std;
long long mod = 1e9 + 7;
long long INF = 1e7;
double EPS = 1e-12;
typedef long long int lld;
long double tick(){static clock_t oldt; clock_t newt=clock();
    long double diff=1.0L*(newt-oldt)/CLOCKS_PER_SEC; oldt = newt; return diff; }
#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define repI(i,a,n) for(int i = (a); i <= (n); ++i)
#define repD(i,a,n) for(long long int i = (a); i >= (n); --i)
#define repDI(i,a,n) for(int i = (a); i >= (n); --i)
inline lld sc() { lld a; scanf("%lld", &a); return a; }
inline int scd() { int a; scanf("%d", &a); return a; }
inline double scf() { double a; scanf("%lf",&a); return a; }
#define prL(a) printf("%lld\n",a)
#define prS(a) printf("%lld ",a)
#define prdL(a) printf("%d\n",a)
#define prdS(a) printf("%d ",a)
#define all(c) (c).begin(), (c).end()
#define sz(a) ((int)a.size())
#define Error(x...) { cout << "(" << #x << ")" << " = ( "; printIt(x); }
template <typename T1> void printIt(T1 t1) { cout << t1 << " )" << endl; }
template <typename T1, typename... T2>
void printIt(T1 t1, T2... t2) { cout << t1 << " , "; printIt(t2...); }
#define errorpair(a) cout<<#a<<" = ( "<<((a).first)<<" , "<<((a).second)<<" )\n";
#define mset(a, v) memset(a, v, sizeof(a))
#define popcount __builtin_popcountll

typedef pair<lld,lld> PA;

lld powP(lld x, lld y) {
    lld ans = 1, po = x % mod;
    while(y > 0) {
        if(y & 1) ans = ans * po % mod;
        y >>= 1; po = po * po % mod;
    }
    return ans;
}
 
bool bitSet(lld n, lld bit){
    if((n & (1LL << bit)) != 0) return true;
    else return false;
}
 
lld findGcd(lld a, lld b){
    while(a != 0) { lld temp = b % a; b = a; a = temp; }
    return b;
}

#define lim 300010
#define lim2 200010
#define qqqqqq 210
// Ab :)
// inline lld sqr(lld x) { return x * x; }
// unordered_map<lld,lld>::iterator it;
// std::ios::sync_with_stdio(false);
// priority_queue<PA> Q;
// lld dp[1<<18];

// vector<lld> G[lim];
// string S[lim];
// lld A[lim];

int main(){
    string S;
    cin >> S;
    for(auto& c : S) if(c == '?') c = 'D';
    cout << S;
    // int d = 0;
    // for(auto c : S) d += (c == 'D');
    // for(int i = 1; i < S.size(); i++) {
    //     if(S[i - 1] == 'P' and S[i] == 'D') d++;
    // }
    // prL(d);
    return 0;
}


Measured memory_bytes: 3752
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    ll x, y, z, K;
    cin >> x >> y >> z >> K;
    ll ones[x] = {};
    ll twos[y] = {};
    ll threes[z] = {};
    for(int i=0;i<x;++i)
    {
        cin >> ones[i];
    }

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

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

    sort(ones, ones + x, greater<ll>());
    sort(twos, twos + y, greater<ll>());
    sort(threes, threes + z, greater<ll>());

    vector<ll> candidates;
    for(int i=0;i<x;++i)
    {
        for(int j=0;j<y;++j)
        {
            for(int k=0;k<z;++k)
            {
                if((ll)(i+1) * (j+1) * (k+1) > K) break;
                candidates.PB(ones[i] + twos[j] + threes[k]);
            }
        }
    }
    sort(candidates.rbegin(), candidates.rend());

    for(int i=0;i<K;++i)
    {
        cout << candidates[i] << endl;
    }
}

Measured memory_bytes: 1400
/*************
 *
 *ALDS1-9_A
 *Binary Search Tree
 *
 *2020/07/20
 *
 *************/
#include<stdio.h>
#include<stdlib.h>

typedef struct node{
  long long key;
  struct node* left;
  struct node* right;
} Node;

const int max_buffer = 32;

Node* createdNode(long long key){
  Node *new_node;
  new_node = (Node*)(calloc(1,sizeof(Node)));

  new_node->key = key;
  new_node->left = NULL;
  new_node->right = NULL;

  return new_node;
}

Node* insert(Node *T,Node *z){

  Node* current_node = T;

  if(current_node == NULL){
    T = z;
  }
  else{
    while(1){
      if(z->key < current_node->key){
	if(current_node->left != NULL) {
	  current_node = current_node->left;
	}
	else {
	  current_node->left = z;
	  break;
	}
      }
      else {
	if(current_node->right != NULL) {
	  current_node = current_node->right;
	}
	else {
	  current_node->right = z;
	  break;
	}
      }
    }
  }
  return T;
}

void print_inorder(Node *node){

  if(node->left != NULL) print_inorder(node->left);

  printf(" %lld",node->key);
  
  if(node->right != NULL) print_inorder(node->right);
}

void print_preorder(Node *node){

  
  printf(" %lld",node->key);
  
  if(node->left != NULL) print_preorder(node->left);
  if(node->right != NULL) print_preorder(node->right);

  return;
}

int main(void){
  int n;
  char string[max_buffer];
  char order[8];//最長命令数(=6)と'\0'
  long long key=0;
  Node *root = NULL;
  Node *input_node =NULL;
  
  fgets(string,sizeof(string),stdin);
  sscanf(string,"%d",&n);
  
  for(int i=0;i<n;i++){
    
    fgets(string,sizeof(string),stdin);
    sscanf(string,"%s %lld",order,&key);

    switch(string[0]){
    case 'i':
      input_node = createdNode(key);
      root = insert(root,input_node);
      break;
    case 'p':
      if(root != NULL){
	print_inorder(root);
	printf("\n");
	print_preorder(root);
	printf("\n");
      }
      break;
    default:
      printf("\"%s\" is error.",string);
      break;
    }
  }
  return 0;
}



Measured memory_bytes: 18192
#include <iostream>
#include <iomanip>

using namespace std;

int main(){
	int n, k, i, j, v[1000], aux, s = 0;
	cin >> n >> k;
	
	for(i = 0; i < n; i++){
		cin >> v[i];
	}
	
	for(i = 0; i < n; i++){
		for(j = i+1; j < n; j++){
			if(v[i] > v[j]){
				aux = v[i];
				v[i] = v[j];
				v[j] = aux;
			}
		}
	}
	
	for(i = 0; i < k; i++){
		s = s + v[i];
	}
	
	cout << s << endl;
	
	return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

int main() {
  int N;
  cin >> N;
  map<long long, long long, greater<int> > m;
  for (int i = 0; i < N; ++i) {
    long long a;
    cin >> a;
    m[a]++;
  }
  long long first = 0;
  for (auto const& e: m) {
    if (e.second > 1) {
      if (first == 0) {
	if (e.second > 3) {
	  cout << e.first * e.first << endl;
	  return 0;
	}
	first = e.first;
      } else {
	cout << first * e.first << endl;
	return 0;
      }
    }
  }
  cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 6528
abcd = input()
n = len(abcd)

for bit in range(1<<n-1):
    t = ""
    for i in range(n-1):
        if bit & (1<<i):
            t += "+"
        else:
            t += "-"
        t += abcd[i+1]
    t = abcd[0] + t

    ans = 0
    if t[1] == "+":
        ans = int(t[0]) + int(t[2])
    else:
        ans = int(t[0]) - int(t[2])
    for j in range(3,len(t),2):
        if t[j] == "+":
            ans += int(t[j+1])
        else:
            ans -= int(t[j+1])
    if ans == 7:
        print(t+"=7")
        exit()


Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
//		int[] a = new int[n];
//		int[] b = new int[n];
//		int[] c = new int[n];
		int a,b;
		ArrayList<Ab> ablist = new ArrayList<>(n);
		for(i=0;i<n;i++) {
			a = Integer.parseInt(sc.next());
			b = Integer.parseInt(sc.next());
//			c[i] = b[i] - a[i];
			ablist.add(new Ab(a, b));
		}
		sc.close();
		ablist.sort((x, y) -> x.b-y.b);
		String ans = "Yes";
		long asum = 0;
		long bsum = 0;
		for(i=0;i<ablist.size();i++) {
			asum += ablist.get(i).a;
			bsum = ablist.get(i).b;
//			System.out.printf("a,b=%d,%d",asum,bsum);
			if(asum > bsum) {
				ans = "No";
				break;
			}
		}
		System.out.println(ans);
	}
}
class Ab {
	int a;
	int b;
//	int c;
	public Ab(int a, int b) {
		this.a = a;
		this.b = b;
//		this.c = b-a;
	}
}


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

using namespace std;

int main()
{
    #ifdef DEBUG
    freopen("input.txt", "r", stdin);
    #endif
    int a, b;
    cin >> a >> b;
    if (a == 1) a += 13;
    if (b == 1) b += 13;
    if (a == b){
        cout << "Draw";
    }
    else if (a < b){
        cout << "Bob";
    }
    else{
        cout << "Alice";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <sstream>
using namespace std;
int main(){
	int N;
	cin >> N;
	for(int i=0;i<N;i++){
		string key[]={".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
		string input;
		cin>>input;
		stringstream b(input);
		int num=0,count=0;
		while(1){
			char c;
			if(!(b>>c))break;
			int input=c-'0';
			if(input!=0){
				count++;
				num=input;
			}
			else {
				if(count!=0)
					cout<<key[num-1][(count-1)%key[num-1].size()];
				num=0;count=0;
			}
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long x,k,d;
    long ans;
    cin >> x >> k >> d;
    x = abs(x);
    long a = x/d;
    if(k <= a)cout << abs(x-k*d) <<  endl;
    else{
        ans = abs(x-a*d);
        k -= a;
        if(k%2 == 0)cout << ans << endl;
        else cout << abs(ans - d) << endl;
    }
}

Measured memory_bytes: 3624
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int T = sc.nextInt();
		int A = sc.nextInt();
		
		float[] map = new float[N];
		for (int i = 0; i < N; i++) {
			map[i] = sc.nextFloat();
			map[i] = T - map[i] * 0.006F;
		}
		
		int ans = -1;
		float min = Float.MAX_VALUE;
		for (int i = 0; i < map.length; i++) {
			if (min > Math.abs(map[i] - A)) {
				min = Math.abs(map[i] - A);
				ans = i;
			}
		}
		
		System.out.println(ans+1);
	}
}

Measured memory_bytes: 28500
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<memory.h>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

struct UnionFind{
   vector<int> par;
   UnionFind(int n):par(n,-1){}
   int find(int x){
       if(par[x]<0)return x;
       return par[x]=find(par[x]);
   }
   bool unite(int x,int y){
       x=find(x);
       y=find(y);
       if(x==y)return false;
       if(par[x]>par[y]){
           par[y]+=par[x];
           par[x]=y;
       }
       else{
           par[x]+=par[y];
           par[y]=x;
       }
       return true;
   }
 
   bool same(int x,int y){
       return find(x)==find(y);
   }
   int size(int x){
       return -par[find(x)];
   }
};

int main(){
  int h,w;
  cin >> h >> w;
  UnionFind uf(h*w);
  char c[h][w];
  int d[5]={0,1,0,-1,0};
  rep(i,h){
    rep(j,w){
      cin >> c[i][j];
    }
  }
  rep(i,h){
    rep(j,w){
      for(int k=0;k<4;k++){
        int nx=i+d[k];
        int ny=j+d[k+1];
        if(nx>=0 && nx<h && ny>=0 && ny<w){
          if(c[i][j]!=c[nx][ny]){
            uf.unite(i*w+j,nx*w+ny);
          }
        }
      }
    }
  }
  ll ans=0;
  ll black[h*w]={},white[h*w]={};
  rep(i,h){
    rep(j,w){
      if(c[i][j]=='.')white[uf.find(i*w+j)]++;
      else black[uf.find(i*w+j)]++;
    }
  }
  rep(i,h*w){
    if(uf.find(i)==i){
      ans+=black[i]*white[i];
    }
  }
  cout << ans << endl;
return 0;}

Measured memory_bytes: 3584
import scala.io.{StdIn => in}
import scala.collection.{mutable => mu}

object Main extends App {
  val n = in.readInt
  val a = in.readLine.split(" ").map(_.toInt)

  val c = a.zipWithIndex.map { case (a, i) => a - (i+1) }.sorted
  val b = c(n/2)

  val ans = a./:(0L, 1L){ case ((acc, idx), ai) =>
    (acc + (ai - (b + idx)).abs, idx + 1L)
  }._1

  println(ans)
}

Measured memory_bytes: 85960
var
  s:string;
  i:longint;
  b:boolean;
begin
  readln(s);
  b:=false;
  for i:=1 to length(s) do
    if s[i]='9' then
                  begin
                    b:=true;
                    break;
                  end;
  if b then write('Yes')
       else write('No');
end.

Measured memory_bytes: 128
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n; cin >> n;
	int res = 0;
	for (int i = 1; i <= n; i += 2)
	{
		int cnt = 0;
		for (int j = 1; j <= i; j += 2)
		{
			if (i%j == 0)++cnt;
		}
		if (cnt == 8)++res;
	}
	cout << res << endl;
}

Measured memory_bytes: 3596
#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(auto i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const long double EPS = 1e-8;
using vi = vector <int>;
using vvi = vector <vi>;

signed main() {
	int n;
	while (cin >> n) {
		vi ab(2001, 0);
		// a + b となる組み合わせの数
		rep (a, 1001) rep (b, 1001) {
			ab[a + b]++;
		}
		vi cd(2001, 0);
		// c + d となる組み合わせの数
		rep (c, 1001) rep (d, 1001) {
			cd[c + d]++;
		}

		int ans = 0;
		rep (i, 2001) {
			if (0 <= n - i && n - i <= 2000) {
				ans += (ab[i] * cd[n - i]);
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3104
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#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 SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int q;
    ll a[110], b[110];

    cin >> q;

    REP(i, q)
    cin >> a[i] >> b[i];

    REP(i, q)
    {
        ll t = a[i] * b[i];
        t--;

        ll l = 0;
        ll r = LLONG_MAX;

        while (r - l > 1)
        {
            ll mid = (l + r) / 2;

            if (t / mid >= mid)
                l = mid;
            else
                r = mid;
        }

        if (l == 0)
        {
            cout << 0 << endl;
            continue;
        }

        ll res = l * 2;

        if (t / l == l)
            res--;

        if (a[i] <= l)
            res--;

        if (b[i] <= l)
            res--;

        cout << res << endl;
    }

    return 0;
}

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

public class CSharp{
    public static void Main(){
        Kyopuro chokudai = new Kyopuro();
	    chokudai.AtCoder();
	}
}

public class Kyopuro{
    
    int n, a, b, c, d;
    int[] fac, inv;
    int[][] invpow;
    
    public void AtCoder(){
        const int p = 1000000007;
        long tmp = 0;
        string[] s = Console.ReadLine().Split(' ');
        n = int.Parse(s[0]);
        a = int.Parse(s[1]);
        b = int.Parse(s[2]);
        c = int.Parse(s[3]);
        d = int.Parse(s[4]);
        fac = new int[n+1];
        inv = new int[n+1];
        invpow = new int[n+1][];
        for(int i=0; i<=n; i++) invpow[i] = new int[n+1];
        
        fac[0] = 1;
        for(int i=1; i<=n; i++){
            tmp = fac[i-1];
            tmp *= i;
            tmp %= p;
            fac[i] = (int)tmp;
        }
        for(int i=0; i<=n; i++){
            inv[i] = Mod.Pow(fac[i], p-2);
        }
        for(int i=1; i<=n; i++){
            for(int j=0; j<=n; j++){
                invpow[i][j] = Mod.Pow(inv[i], j);
            }
        }
        
        int[][] dp = new int[n+1][];
        for(int i=0; i<=n; i++) dp[i] = new int[n+1];
        for(int i=0; i<=n; i++) dp[i][0] = 1;
        for(int i=a; i<=b; i++){
            for(int j=1; j<=n; j++){
                dp[i][j] += dp[i-1][j];
                dp[i][j] %= p;
                for(int k=c; k<=d; k++){
                    if(j-i*k<0) break;
                    tmp = dp[i-1][j-i*k];
                    tmp = tmp * fac[j] % p;
                    tmp = tmp * inv[j-i*k] % p;
                    tmp = tmp * invpow[i][k] % p;
                    tmp = tmp * inv[k] % p;
                    dp[i][j] += (int)tmp;
                    dp[i][j] %= p;
                }
            }
        }
        long ans = 0;
        for(int i=c; i<=d; i++){
            ans += dp[i][n];
            ans %= p;
        }
        Console.WriteLine(dp[b][n]);
    }
    
    public static void DebugWL(object x){ System.Diagnostics.Debug.WriteLine(x); }
}

// Mod(int n)
// int[] fac: factors (1-indexed)
// int n: the length of fac

// int .Ncr(n,r): nCr
// int .Fac(n): n!%p
// int .Pow(n,m): n^m%p

public class Mod{
	const int p = 1000000007;

	public static int Pow(int n, int m){
		if(m==0) return 1;
		if(m==1) return n;
		long a = 1;
		if(m%2 == 0){
			a = Pow(n,m/2);
			a = a * a % p;
		}else{
			a = Pow(n,m/2);
			a = a * a % p;
			a = a * n % p;
		}
		return (int)a;
	}
}

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

const int N = 100005;

int n, m;
bool vis[N];

vector<int> adj[N], p1, p2;

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++) {
		int A, B;
		scanf("%d%d",&A,&B);
		adj[A].push_back(B);
		adj[B].push_back(A);
	}
	p1.push_back(1);
	vis[1] = true;
	for(int i=1;;) {
		bool F = false;
		for(auto &T : adj[i]) {
			if(!vis[T]) {
				p1.push_back(T);
				vis[T] = true;
				F = true;
				i = T;
				break;
			}
		}
		if(!F) break;
	}
	for(int i=1;;) {
		bool F = false;
		for(auto &T : adj[i]) {
			if(!vis[T]) {
				p2.push_back(T);
				vis[T] = true;
				F = true;
				i = T;
				break;
			}
		}
		if(!F) break;
	}
	printf("%d\n",(int)(p1.size()+p2.size()));
	for(int i=p1.size();i--;) {
		printf("%d ",p1[i]);
	}
	for(int i=0;i<p2.size();i++) {
		printf("%d ",p2[i]);
	}
}


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

int main(){
    int n,ball,fb;
    cin >> n;
    for(int i = 0 ; i < n ; i++){
        int x[11] = {0} , y[11] = {0};
        int flg = 0;
        
        cin >> fb;
        x[0] = fb;
        for(int j = 1 ; j < 10 ; j++){
            cin >> ball;
            if(x[j-1] < ball){
                x[j] = ball;
                y[j] = y[j-1];
            }
            else if(y[j-1] < ball){
                y[j] = ball;
                x[j] = x[j-1];
            }
            else flg = 1;
        }
    
        if(flg==0) cout << "YES" << endl;
        else cout << "NO" << endl;
        
    }


    return 0;
}

Measured memory_bytes: 1148
n, y = map(int, input().split())
a = 0
b = 0
c = 0
for i in range(n + 1):
    if a + b + c > 0:
        break
    else:    
        for j in range(n - i + 1):
            if 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
                a = i
                b = j
                c = n - i - j
                break
            else:
                pass
if a + b + c > 0:
    print(str(a), ' ', str(b), ' ', str(c))
else:
    print("-1 -1 -1")


Measured memory_bytes: 3064