akhauriyash/Code-Regression huggingface dataset:
//libraries
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//namespace
using namespace std;
using namespace __gnu_pbds;

//typedef
//typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

//define
#define i(X) cin>>X;
#define ol(X) cout<<X<<endl;
#define os(X) cout<<X<<" ";
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define line cout<<"\n";
#define pbp(a,b) push_back(make_pair(a,b));
#define vll(A) vector<ll> A;
#define ivt(A,n,p) vector<ll> A(n,p);
#define vst(A) sort(A.begin(),A.end());
#define rvst(A) sort(A.rbegin(),A.rend());
#define forin(i,a,b) for(ll i=a;i<=b;i++)
#define forde(i,a,b) for(ll i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const long long inf=(long long)1e18;
long long MOD=(long long)(1e9+7);

ll power(ll x,ll y)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2) % MOD;
    p = (p * p) % MOD;

    return (y%2 == 0)? p : (x * p) % MOD;
}
ll modInverse(ll a)
{
   return power(a,MOD-2);
}

int main() 
{
	// #ifndef ONLINE_JUDGE
    //    freopen ("input.txt" , "r" , stdin);
	// 	// freopen ("OUTPUT.txt" , "w" , stdout);
	// #endif
	fio;
	ll testcase=1;
	//cin>>testcase;
	while(testcase--)
	{
		ll n,d;
		ll ans=0;
		cin>>n>>d;
		forin(i,0,n-1)
		{
			ll x,y;
			cin>>x>>y;
			if(d*d>=(x*x+y*y))
			{
				ans++;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define sf scanf
#define pf printf
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

const int N = 1e3+50;
const int INF = 2e9;
const double PI = acos(-1);

int arr[2000][2000];

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

    memset(arr,0,sizeof(arr));

    int k=42;
    int n = n=k*k-k+1;
    // int n=21, k=5;
    int angka = 2;
    for(int i=0;i<k;++i){
        for(int j=0;j<k;++j){
            if(j == 0){
                arr[i][j] = 1;
            }else{
                arr[i][j] = angka;
                angka++;
            }
        }
    }

    angka = 2;
    int cnt = 0;
    for(int i=k;i<n;++i){
        arr[i][0] = angka;
        cnt++;
        if(cnt == k-1){
            cnt = 0;
            angka++;
        }
    }

    angka = arr[1][1];
    cnt = 0;
    int blok;
    for(int j = 1; j < k; ++j){
        for(int t=0;t<k-1;++t){
            blok = 2;
            for(int i = k+t; i <= n ;){
                int realpos;
                if(i == k+t) realpos = i;
                else realpos = i + cnt;
                if(realpos > blok*(k-1)){
                    realpos -= k-1;
                }
                arr[realpos][j] = angka;
                i = realpos + k-1;
                blok++;
            }
            angka++;
        }
        cnt++;
    }
    

    pf("%d %d\n",n,k);
    for(int i=0;i<n;++i){
        for(int j=0;j<k;++j){
            if(j) pf(" ");
            pf("%d",arr[i][j]);
        }
        pf("\n");
    }

    return 0;
}

Measured memory_bytes: 16128
#include<iostream>
#include<vector>
#include<string>
#include<set>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K;
    cin >> K;
    if (K % 2 == 0) {
        cout << -1 << endl;
        return 0;
    }
    ll now = 0;
    int ans = 0;
    set<ll> S;
    while (true) {
        now += 7;
        if (S.count(now)) {
            cout << -1 << endl;
            return 0;
        }
        S.insert(now);
        ++ans;
        now = (now % K) * 10;
        if (!now) {
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 50488
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

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); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main() {
    ll n;
    cin >> n;
    UnionFind uf(220000);
    ll sy = 110000;
    rep(i, 0, n) {
        ll x, y;
        cin >> x >> y;
        uf.merge(x, y + sy);
    }
    vector<ll> cntx(220000), cnty(220000);
    rep(i, 0, sy) {
        cntx[uf.root(i)]++;
        cnty[uf.root(i+sy)]++;
    }

    ll ans = - n;
    rep(i, 0, 2 * sy) {
        ans += cntx[i] * cnty[i];
    }
    cout << ans << endl;

}

Measured memory_bytes: 4608
#include <iostream>
using namespace std;
int main(void){
    int e,y;
    cin>>e>>y;
    if(e==0){
        if(y>=1989){
            cout<<'H'<<y-1989+1<<endl;
        }
        if(y<1989&&y>=1926){
            cout<<'S'<<y-1926+1<<endl;
        }
        if(y<1926&&y>=1912){
            cout<<'T'<<y-1912+1<<endl;
        }
        if(y<1912&&y>=1868){
            cout<<'M'<<y-1868+1<<endl;
        }
    }
    if(e==1){
        cout<<y+1868-1<<endl;
    }
    if(e==2){
        cout<<y+1912-1<<endl;
    }
    if(e==3){
        cout<<y+1926-1<<endl;
    }
    if(e==4){
        cout<<y+1989-1<<endl;
    }
    
}


Measured memory_bytes: 3096
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	h,w,k = readline() |> split |> parseMap
	s = String["" for i in 1:h]
	lc = 0
	for i in 1:h
		s[i] = readline() |> chomp
		for j in 1:w
			if s[i][j]=='#'
				lc = i
			end
		end
	end
	fc = h
	for i in h:-1:1
		for j in 1:w
			if s[i][j]=='#'
				fc = i
			end
		end
	end
	a = zeros(Int,h,w)
	ct = 1
	for i in fc:lc
		f = 0
		for j in 1:w
			if s[i][j]=='#'
				if f==0
					f = 1
				else
					ct += 1
				end
			end
			a[i,j] = ct
		end
		if f==0
			for j in 1:w
				a[i,j] = a[i-1,j]
			end
		else
			ct += 1
		end
	end
	for i in fc-1:-1:1
		for j in 1:w
			a[i,j] = a[i+1,j]
		end
	end
	for i in lc+1:h
		for j in 1:w
			a[i,j] = a[i-1,j]
		end
	end
	for i in 1:h
		for j in 1:w-1
			print(a[i,j]," ")
		end
		println(a[i,w])
	end
end

main()

Measured memory_bytes: 128816
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define pi 3.14159265358979323846264338327950L
using namespace std;

int main() {
  int64_t N, X, T, ans;
  cin >> N >> X >> T;
  ans=T*floor((N+X-1)/X);
  cout << ans << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(void) {
	int N; cin >> N;
	vector<int> a(N);
	rep(i, N) cin >> a[i];
	map<int, int> ma;
	rep(i, N) ma[a[i]]++;
	ll ans = 0;
	for(auto u : ma) {
		// printf("%d %d\n", u.fi, u.se);
		if(u.fi < u.se) ans += u.se - u.fi;
		else if(u.fi > u.se) ans += u.se;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max({a*c,a*d,b*c,b*d}) << endl;
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int a[15];
string s;

int main()
{
    _FastIO;
    int ans = 0;
    for(int i = 0; i < 5; i++){
        cin >> a[i];
        if(!a[i])
            ans = i + 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3580
#include <stdio.h>
int main(){
  long k,n,a0,a1,a2,a_all=0,a_max=0,i;
  
  scanf("%ld %ld",&k,&n);
  
  scanf("%ld",&a0);
  a_all+=a0;
  a1=a0;
  
  for(i=1;i<n;i++){
    scanf("%ld",&a2);
    if((a2-a1)>a_max){
      a_max=a2-a1;
    }
    a1=a2;
  }
  
  if((k-a2+a0)>a_max){
    a_max=k-a2+a0;
  }
  
  printf("%ld",k-a_max);
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type Item struct {
	priority float64
	index int
}

type PriorityQueue []*Item

func (pq PriorityQueue) Len() int { return len(pq) }

func (pq PriorityQueue) Less(i, j int) bool {
	return pq[i].priority < pq[j].priority
}

func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *PriorityQueue) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Item)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	v := make(PriorityQueue, n)

	for i := 0; i < n; i++ {
		v[i] = &Item{
			priority: float64(nextInt()),
		}
	}

	heap.Init(&v)

	for {
		if v.Len() == 1 {
			fmt.Printf("%f", v.Pop().(*Item).priority)
			return
		}
		w1 := heap.Pop(&v).(*Item).priority
		w2 := heap.Pop(&v).(*Item).priority

		heap.Push(&v, &Item{
			priority: (w1 + w2) / 2,
		})
	}
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Main mainObj = new Main();
		mainObj.solve();
	}
	
	public void solve() {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextInt();
		long b = sc.nextInt();
		sc.close();
		
		long gcdVal = gcd(a,b);
		System.out.println(a*b/gcdVal);
		
	}
	
	public long gcd(long a, long b) {

		if(a > b) {
			long tmp = a;
			a = b;
			b = tmp;
		}
		
		while(b % a != 0) {
			
			long tmp = a;
			a = b % a;
			b = tmp;
		}
		
		return a;
	}
}


Measured memory_bytes: 23764
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
using P=pair<int,int>;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int h,w,dx[4]={1,0,-1,0},dy[4]={0,1,0,-1},cnt=0,dist[55][55]={};
  char c[55][55]={};
  cin >> h >> w;
  for(int i=0; i<h; i++) {
    for(int j=0; j<w; j++) {
      dist[i][j]=inf;
    }
  }
  for(int i=0; i<h; i++) {
    for(int j=0; j<w; j++) {
      cin >> c[i][j];
      if(c[i][j]=='#') {
        cnt++;
      }
    }
  }
  queue<P> q;
  q.push(P(0,0));
  dist[0][0]=0;
  while(q.size()) {
    P p=q.front();
    q.pop();
    for(int i=0; i<4; i++) {
      int nx=p.second+dx[i],ny=p.first+dy[i];
      if(0<=nx&&nx<w&&0<=ny&&ny<h&&c[ny][nx]=='.'&&dist[ny][nx]==inf) {
        q.push(P(ny,nx));
        dist[ny][nx]=dist[p.first][p.second]+1;
      }
    }
  }
  if(dist[h-1][w-1]==inf) {
    cout << -1 << endl;
  }
  else {
    cout << h*w-cnt-dist[h-1][w-1]-1 << endl;
  }
}

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


int main()
{
	int count=0;
	string s1,s2;
	cin>>s1>>s2;
	for(int i=0;i<s1.size();i++)
	{
		if(s1[i]==s2[i])
			count++;
	}
	cout<<count;
}

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

int main() {
  int N,A,B; /* 1 <= N <= 20
  			    1 <= A <= 100 
  				1 <= B <= 2000   N,A,B はすべて整数 */
  
  cin >> N >> A >> B ;

  if((A * N) < B){
    cout << A * N << endl;
  }else if((A * N) >= B){
    cout << B << endl;
  }
  
}

Measured memory_bytes: 3600
num = int(input())
key = input()
count = 0
for i in range(10):
  if key.find(str(i)) == -1:
    continue;
  else:
    a = key.find(str(i))
    for j in range(10):
      if key.find(str(j), a+1) == -1:
        continue;
      else:
        b = key.find(str(j), a+1)
        for k in range(10):
          if key.find(str(k), b+1) == -1:
            continue;
          else:
            count += 1
    
print(count)
  

Measured memory_bytes: 3060
import math
#def main(S, b):
if __name__ == '__main__':
    #a, b, c, k = map(int, input().split())

    n = input()
    #print(n[-1])
    if (n[-1] == "3"):
        print("bon")
    elif (n[-1] == "0" or n[-1] == "1" or n[-1] == "6" or n[-1] == "8"):
        print("pon")
    else:
        print("hon")

    # if (s == t[:(len(s))] and len(t) == len(s) + 1):

    #     print("Yes")
    # else:
    #     print("No")
    # s = sum(a)


Measured memory_bytes: 9104
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
	int a[100];
	for(int i=0;i<100;i++) a[i] = 0;
	int b;
	while(cin >> b) {a[b]++;}
	int max = 0;
	for(int i=0;i<100;i++) if(max<a[i]) max = a[i];
	for(int i=0;i<100;i++) if(a[i]==max) cout << i << endl;
}

Measured memory_bytes: 1160
n = int(input())
p = list(map(int,input().split()))
c = 0
for i in range(n-1):
    if p[i] == i+1:
        p[i],p[i+1] = p[i+1],p[i]
        c += 1
if p[n-1] == n:
    c += 1
print(c)

Measured memory_bytes: 14008
#include <iostream>

using namespace std;

int main(){
    long long X;

    cin >> X;

    long long happy_500 = (X / 500) * 1000;

    long long happy_5 = ((X % 500) / 5) * 5;

    cout <<  happy_500 + happy_5 << endl;
    return 0;  
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            (long A, long B, long C) = Slice3<long>();
            for (var i = 1; i <= 100; ++i)
                if (i * A % B == C)
                {
                    WriteLine("YES");
                    return;
                }
            WriteLine("NO");
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 27564
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

int main() {
  int n; cin >> n;
  vector<long long> a(n);
  for(int i=0;i<n;i++){
      cin >> a.at(i);
      if(a.at(i)==0){
          cout << 0 << endl;
          return 0;
      }
  }
  boost::multiprecision::int128_t cur = 1;
  for(int i=0;i<n;i++){
      cur *= a.at(i);
      if(cur > 1000000000000000000){
          cout << -1 << endl;
          return 0;
      }
  }
  cout << cur << endl;
    return 0;
}

Measured memory_bytes: 4048
def main():
    n,m = map(int,input().split())
    a = []
    for i in range(n):
        tmp = [int(i) for i in input().split()]
        a.append(tmp)
    l = [0 for i in range(m)]
    for i in range(n):
        k = a[i][0]
        for j in range(1,k+1):
            l[a[i][j]-1] +=1
    ans = 0
    for i in range(m):
        if l[i] == n:
            ans += 1
    print(ans)

main()

Measured memory_bytes: 9200
N = int(input())
pt, px, py = 0, 0, 0
t,  x,  y  = 0, 0, 0
for i in range(N):
  pt, px, py = t, x, y
  t, x, y = map(int, input().split())
  T = t - pt
  X = abs(x - px)
  Y = abs(y - py)
  if T < X + Y or T % 2 != (X + Y) % 2:
    print('No')
    exit()
print('Yes')

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

L = [1]*(N+1)
for i in range(2, N+1):
    j = 1
    while i*j <= N:
        L[i*j] += 1
        j += 1

ans = 0
for i in range(1, N+1):
    ans += i*L[i]
print(ans)

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

using namespace std;
typedef long long in;

int main()
{
  in n,sum=0;
  cin>>n;
  vector<in>v(n+1,0);


    for(in i=1;i<=n;i++)
        {
            for(in j=0;j<=n;j+=i)
                {
                   v[j]++;

                }
        }
         for(in i=1;i<=n;i++)
        {

            sum+=i*v[i];

        }

    cout<<sum<<endl;

}





Measured memory_bytes: 81376
#include <iostream>
using namespace std;
int main()
{
 int i,a,b;
  cin >> a >> b;
 if(a<b)
 {
  for(i=1;i<=b;i++)
  cout << a;
 }
 else
 {
  for(i=1;i<=a;i++)
  cout << b;
 }
 return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main( void ) 
{
    int n,x;
    int i,j,k;
    int cnt,ave,ave2;
     
    while( 1 ) {
        scanf( "%d%d", &n, &x );
        if( 0==n && 0==x ) { break; }
 
        cnt=0;
        ave = x / 3;
        for( i=1; i<ave; i++ ) {
        	ave2 = ( x-i ) / 2;
            for( j=i+1; j<=ave2; j++ ) {
            	k = x - i - j;
                if( j < k && k <= n ) {
                    cnt++;
                }
            }
        }
        printf( "%d\n", cnt );
    }
 
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <algorithm>

using namespace std;

int main() {
  int N, a;
  std::unordered_set<int> A;
  std::cin >> N;
  for (int i = 0; i < N; ++i) {
    std::cin >> a;
    A.insert(a);
  }
  if (A.size() == static_cast<size_t>(N)) {
    std::cout << "YES" << std::endl;
  } else {
    std::cout << "NO" << std::endl;
  }
  return 0;
}

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

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

using namespace std;

int main(){
	int n; scanf("%d",&n);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]);

	int sum=0;
	rep(i,n) sum^=a[i];

	rep(i,n) printf("%d%c",sum^a[i],i<n-1?' ':'\n');

	return 0;
}


Measured memory_bytes: 4048
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    long long tmp,x[n],y[n],z[n],sum[n],ans=-10000000000;
    for(int i=0;i<n;i++)
    cin>>x[i]>>y[i]>>z[i];
    
    for(int i=0;i<8;i++)
    {
        tmp=0;
        for(int i=0;i<n;i++)
        sum[i]=0;
        if(i&1)
        {
            for(int k=0;k<n;k++)
            {
                sum[k]+=x[k];
            }
        }
        else
        {
            for(int d=0;d<n;d++)
            {
                sum[d]-=x[d];
            }
        }
        if(i&2)
        {
            for(int p=0;p<n;p++)
            {
                sum[p]+=y[p];
            }
        }
        else
        {
            for(int l=0;l<n;l++)
            {
                sum[l]-=y[l];
            }
        }
        if(i&4)
        {
            for(int t=0;t<n;t++)
            {
                sum[t]+=z[t];
            }
        }
        else
        {
            for(int s=0;s<n;s++)
            {
                sum[s]-=z[s];
            }
        }
        sort(sum,sum+n);

        for(int k=n-1;k>=n-m;k--)
        tmp+=sum[k];
        ans=max(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(_) for _ in input().split()]
B = [int(_) for _ in input().split()]
ans = 0

for i in range(N):
    if B[i] < A[i]:
        ans += B[i]
    else:
        ans += A[i]
        tmp = min(A[i+1], B[i] - A[i])
        ans += tmp
        A[i+1] -= tmp

print(ans)

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

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

    double a,b,h,m;
    cin >> a >> b >> h >> m;

    double ax,ay,bx,by;
    double ans;

    ax = a*cos((60*h+m)*M_PI/360);
    ay = a*sin((60*h+m)*M_PI/360);
    bx = b*cos(M_PI*m/30);
    by = b*sin(M_PI*m/30);

    ans = sqrt(pow(ax-bx,2.0)+pow(ay-by,2.0));

    cout << fixed << setprecision(10) << ans << endl;
}

    

Measured memory_bytes: 4064
package main
import (
  "fmt"
)
func main() {
  var s string
  fmt.Scan(&s)
  strMap := make(map[rune]bool)
  result := "Yes"
  for _, char := range s {
    if strMap[char] {
      result = "No"
      break
    }
    strMap[char] = true
  }
  fmt.Println(result)
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
int cmp(int a,int b){
	return a>b;
}
using namespace std;
int main(){
	int n,m;
	int ar[100];
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>ar[i];
	}
	sort(ar+1,ar+n+1,cmp);
	int num=0;
	for(int i=1;i<=m;i++){
		num+=ar[i];
	}
	cout<<num<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <set>
using namespace std;
string palindrome(string s){
  for(int i=0;i<s.length()/2;i++) swap(s[i],s[s.length()-i-1]);
  return s;
}
int main(void){
  int n,i;
  string s,t1,t2,t3,t4;
  set<string> st;
  cin>>n;
  while(n--){
    cin>>s;
    st.clear();
    for(i=1;i<s.length();i++){
      t1=s.substr(0,i);
      t2=s.substr(i,s.length()-i);
      t3=palindrome(t1);
      t4=palindrome(t2);
      st.insert(t1+t2);
      st.insert(t1+t4);
      st.insert(t2+t1);
      st.insert(t4+t1);
      st.insert(t3+t2);
      st.insert(t3+t4);
      st.insert(t2+t3);
      st.insert(t4+t3);
    }
    cout<<st.size()<<endl;
  }
  return 0;
}

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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 59, M = 5e3 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;

int n, l, r;

ll a[N];

ll iterativeChoose(ll n, ll k){
    if(k > n)   return 0;
	ll ret = 1;
	for(ll i = k + 1;i <= n;i++){
		ll d = (i - k);
		ll q = i / d;
		ll r = i - q * d;
		ret = ret * q + ret * r / d;
	}
	return ret;
}

int main(){
    init();

    cin >> n >> l >> r;
    for(int i = 0;i < n;i++)    cin >> a[i];

    sort(a, a + n); reverse(a, a + n);

    long double sum = 0;

    int cnt1 = 0, cnt2 = 0;

    for(int i = 0;i < n;i++)    cnt1 += a[i] == a[l - 1];

    for(int i = 0;i < l;i++)    sum += a[i], cnt2 += a[i] == a[l - 1];;


    cout << fixed << setprecision(7) << 1.0 * sum / l << '\n';

    ll ans = 0;
    if(a[0] == a[l - 1]){
        for(int i = l;i <= r;i++)
            ans += iterativeChoose(cnt1, i);
        return cout << ans, 0;
    }
  
    cout << iterativeChoose(cnt1, cnt2);
}

Measured memory_bytes: 256
def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)
      
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        if isCLKWISE(phU) : continue
        while(True):
            del phU[-2]
            try:
                if isCLKWISE(phU) : break
            except IndexError : break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        if isCLKWISE(phL) : continue
        while(True):
            del phL[-2]
            try:
                if isCLKWISE(phL) : break
            except IndexError : break
      
    ph = phU + phL[1:-1]
    return ph
  
n = range(int(input()))
P = [[int(y) for y in input().split()] for _ in n]
Q = ConvexHullScan(P)
Q.reverse()
print(len(Q))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]
R = Q[idx:] + Q[:idx]
for r in R : print(r[0],r[1])

Measured memory_bytes: 33920
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
#define PI 3.14159265358979323846
using namespace std;
//
string S;
bool C,F;
int main(){
  cin>>S;
  FOR(i,0,(int)S.size()){
    if(S[i]=='C'){
      C=true;
    }else if(C&&S[i]=='F'){
      F=true;
    }
  }
  if(C&&F){
    Yes(1);
  }else{
    Yes(0);
  }
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws java.lang.Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int[] input = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();

        int count = 1;
        int tap = 0;


        while(count < input[1]) {
            count--;
            count+= input[0];
            tap++;
        }

        System.out.println(tap);
    }
}

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

int main(){
    ll n;
    cin>>n;
    ll ans=1LL<<60;
    ll tmp;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            tmp=i+n/i-2;
            ans=min(ans,tmp);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3644
// AOJ 0283
#include<cstdio>
#include<algorithm>
#include<set>
#include<vector>
#define rep(i,a) for( int i = 0; i != (a); ++i )

const int MAX_N = 1000000, INF = 1 << 30;

int N, Q;
int s[MAX_N], sorted[MAX_N];

std::multiset<int> ls;

int main()
{
	scanf( "%d%d", &N, &Q );
	rep( i, N )
	{
		scanf( "%d", s+i );
		sorted[i] = s[i];
	}

	std::sort( sorted, sorted+N );

	rep( i, Q )
	{
		char q[7];
		int x;
		scanf( "%s %d", q, &x );
		
		if( *q == 'A' )
			ls.insert( s[x-1] );
		else if( *q == 'R' )
			ls.erase( ls.lower_bound( s[x-1] ) );
		else
		{
			int lb = 0, ub = INF;
			while( ub - lb > 0 )
			{
				int mid = (lb + ub)>>1;
				int prv = 0, loss = 0;

				for( auto it = ls.begin(); it != ls.end(); ++it )
				{
					int p = std::lower_bound( sorted, sorted+N, *it-mid ) - sorted;
					loss += std::max( p-1-prv+1, 0 );
					prv = std::upper_bound( sorted, sorted+N, *it ) - sorted;
				}

				loss += std::max( N-1-prv+1, 0 );

				if( loss <= x )
					ub = mid;
				else
					lb = mid+1;
			}
			if( lb != INF )
				printf( "%d\n", lb );
			else
				puts("NA");
		}
	}

	return 0;
}

Measured memory_bytes: 8860
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		// 計算
		int maxL = 0;
		int minR = Integer.MAX_VALUE;
		for(int i = 0; i < m; i++){
		    maxL = max(maxL, sc.nextInt());
		    minR = min(minR, sc.nextInt());
		}
		int result = max(0, minR - maxL + 1);

		// 出力
		System.out.println(result);
	}
}

Measured memory_bytes: 64932
#include<iostream>
using namespace std;
int main(){
    int s=0, m=0, h=0;
    cin >> s;
    h = s/3600;
    s = s%3600;
    m = s/60;
    s = s%60;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}


Measured memory_bytes: 3088
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        if (scanner.hasNextLine()) {
            String[] array = scanner.nextLine().split(" ");
            int N = Integer.parseInt(array[0]);
            int X = Integer.parseInt(array[1]);

            int min = Integer.MAX_VALUE;
            for (int i = 0; i < N; ++i) {
                int m = Integer.parseInt(scanner.nextLine());
                if (min > m) {
                    min = m;
                }
                X -= m;
            }

            System.out.println(N + (X / min));
        }
    }
}

Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <set>
#include <limits>

int64_t expr(int &pos);
int64_t term1(int &pos);
int64_t term2(int &pos);
int64_t term3(int &pos);
int64_t number(int &pos);

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
string s;
set<char> op1, op2, op3; // 優先度 op1 < op2 < op3

void debug(int pos) {
  cerr << "read string: " << s.substr(0, pos) << endl;
  cerr << "s[pos] = '" << s[pos] << "'" << endl;
}

int64_t expr(int &pos) {
  // debug(pos);
  auto res = term1(pos);
  // debug(pos);
  while (pos < s.size() and op1.count(s[pos])) {
    auto op = s[pos++];
    if (op == '+') {
      res += term1(pos);
    } else if(op == '-') {
      res -= term1(pos);
    } else {
      res *= term1(pos);
    }
  }
  return res;
}

int64_t term1(int &pos) {
  auto res = term2(pos);
  while (pos < s.size() and op2.count(s[pos])) {
    auto op = s[pos++];
    if (op == '+') {
      res += term2(pos);
    } else if(op == '-') {
      res -= term2(pos);
    } else {
      res *= term2(pos);
    }
  }
  return res;
}

int64_t term2(int &pos) {
  auto res = term3(pos);
  while (pos < s.size() and op3.count(s[pos])) {
    auto op = s[pos++];
    if (op == '+') {
      res += term3(pos);
    } else if(op == '-') {
      res -= term3(pos);
    } else {
      res *= term3(pos);
    }
  }
  return res;
}

bool is_digit(char ch) {
  return '0' <= ch and ch <= '9';
}

int64_t term3(int &pos) {
  if (is_digit(s[pos])) {
    return number(pos);
  }
  assert(s[pos++] == '(');
  auto res = expr(pos);
  assert(s[pos++] == ')');
  return res;
}

int64_t number(int &pos) {
  int64_t res = 0;
  while (pos < s.size() and is_digit(s[pos])) {
    res = res * 10 + (s[pos++] - '0');
  }
  return res;
}

int main() {
  cin >> s;
  vector<char> ops = {'+', '-', '*'};
  int64_t ans = numeric_limits<int64_t>::min();
  rep(b1, 1 << 3) {
    if (b1 == 0) continue;
    rep(b2, 1 << 3) {
      if (b1 != (1 << 3) - 1 and b2 == 0) continue;
      if (b1 & b2) continue;
      rep(b3, 1 << 3) {
        if (b1 & b3) continue;
        if (b2 & b3) continue;
        if ((b1 | b2 | b3) != (1 << 3) - 1) continue;
        op1.clear();
        op2.clear();
        op3.clear();
        rep(i, 3) {
          if (b1 >> i & 1) op1.insert(ops[i]);
          if (b2 >> i & 1) op2.insert(ops[i]);
          if (b3 >> i & 1) op3.insert(ops[i]);
        }
        // for (auto it: op1) cerr << it << ","; cerr << "|";
        // for (auto it: op2) cerr << it << ","; cerr << "|";
        // for (auto it: op3) cerr << it << ",";
        // cerr << endl;
        // <expr> ::= <term1> [('+'|'-'|'*') <term1>]*
        // <term1> ::= <term2> [('+'|'-'|'*') <term2>]*
        // <term2> ::= <term3> [('+'|'-'|'*') <term3>]*
        // <term3> ::= <number> | '(' <expr> ')'
        // <number> ::= 123 など
        int pos = 0;
        auto res = expr(pos);
        // cerr << res << endl;
        ans = max(ans, res);
      }
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3228
import heapq as h
n,m,s,t = map(int,input().split())
g = [dict() for _ in range(n+1)]
for _  in range(m):
  u,v,a,b = map(int,input().split())
  g[u][v] = (a,b)
  g[v][u] = (a,b)

def dijkstra(s,g,mode):
  dist = [10**15]*(n+1)
  seen = [False]*(n+1)
  dist[s] = 0
  q = [(0,s)]
  while q:
    d,v = h.heappop(q)
    if seen[v]:
      continue
    seen[v] = True
    dist[v] = d
    for x in g[v]:
      if not seen[x]:
        h.heappush(q,(dist[v]+g[v][x][mode],x))
  return dist

ou = dijkstra(s,g,0)
fuku = dijkstra(t,g,1)
rot = [(ou[i] + fuku[i],i) for i in range(n+1)]
h.heapify(rot)
for i in range(1,n+1):
  if rot[0][1] < i:
    while rot[0][1] < i:
      h.heappop(rot)
  print(10**15 - rot[0][0])

Measured memory_bytes: 129828
#include<stdio.h>
int hantei(int ,int);
int A[2000],n;
int main(){
  int q,i,m;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if( hantei(0,m)){printf("yes\n");}
    else printf("no\n");
  }
  return 0;
}

int hantei(int i,int m){
  int a;
  if(m==0)return 1;
  if(i>=n)return 0;
  a=hantei(i+1,m-A[i])||hantei(i+1,m);
  return a;
  
  
}



Measured memory_bytes: 2144
#include <stdio.h>

int main(void)          
{
	int a, b, c;
	int queue;
	int i;
	scanf("%d %d %d", &a, &b, &c);

	for (i = 0; i < 2; i++) 
	{
		if(a > b)
		{
			queue = a;
			a = b;
			b = queue;
		}
		if (b > c)
		{
			queue = b;
			b = c;
			c = queue;
		}
	}
	printf("%d %d %d\n", a, b, c);
	

	return 0;
}

Measured memory_bytes: 596
// AOJ 1028 - ICPC: Ideal Coin Payment and Change (ツ妥ヲ5ツ嘉アツ療サツ習ツ嘉ッJ)

#include <iostream>
#include <algorithm>

using namespace std;

int c[6] = {1, 5, 10, 50, 100, 500};

int getNum(int t){
	int res = 0;
	for(int i=5;i>=0;i--){
		res += t/c[i];
		t %= c[i];
	}
	return res;
}

int main(){
	int P, N[6];
	while(cin >> P, P){
		int end = 0;
		for(int i=0;i<6;i++){
			cin >> N[i];
			end += c[i]*N[i];
		}
		int ans = 10000000;
		for(int i=P;i<=min(P+500,end);i++){
			int cur = getNum(i-P);
			int l = i;
			for(int j=5;j>=0;j--){
				int tmp = l/c[j];
				cur += min(N[j], tmp);
				l -= min(N[j], tmp)*c[j];
			}
			if(l != 0) continue;
			ans = min(ans, cur); 
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
#include <stdio.h>

int main(){
int input[4];
for (int i = 0; i<4; i++) scanf("%d", &input[i]);
printf("%d\n", (input[0] > input[1] ? input[1] : input[0]) + (input[2] > input[3] ? input[3] : input[2]));
return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout(a) cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ll MOD2   = 998244353;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define reps(i, n)      for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define repbit(bit, n)  for(int bit = 0; (bit) < (1 << (n)); ++(bit))
#define ifbit(bit, i)   if((bit) & (1 << (i)))
#define CtoI(c)         int((c)) - int('0')
#define ItoC(c)         char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n; cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d[i];

    ll ans = 0;
    for(int i = 0; i < n-1; ++i){
        for(int j = i + 1; j < n; ++j){
            ans += d[i] * d[j];
        }
    }

    cout << ans << endl;

return 0;
}

Measured memory_bytes: 3652
# -*- coding: utf-8 -*-
# C - management
# 標準入力の取得
N = int(input())
A = list(map(int, input().split()))

# 求解処理
result = [0 for n in range(N)]
for a in A:
    result[a-1] += 1

for r in result:
    print(r)

Measured memory_bytes: 32312
#include<cstdio>
#include<algorithm>
#define MM 0x7fffffff
using namespace std;
typedef pair<int,int> P;
P ppp[500000];
int main(void)
{
	int i,j,n,mn,x1,x2,y1,y2;

	scanf("%d",&n);
	for(i=0;i<n;i++)	{
		scanf("%d %d",&ppp[i].first,&ppp[i].second);
	}
	sort(ppp,ppp+n);
	mn=MM;
	for(i=0;i<n-1;i++)	{
		for(j=i+1;j<n;j++)	{
			x1=ppp[i].first;	x2=ppp[j].first;
			y1=ppp[i].second;	y2=ppp[j].second;
			if((x1-x2)*(x1-x2)>=mn)	break;
			if((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)<mn)	mn=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
		}
	}
	printf("%d\n",mn);
	return 0;
}


Measured memory_bytes: 4932
class Modulo
  attr_accessor :num, :mod

  def initialize(mod, init = 0)
    @mod = mod
    @num = init % @mod
    @com_init_max = 0
  end

  def mod_inv(num)
    num2 = @mod
    u = 1
    v = 0
    while num2 > 0
      t = num / num2
      num, num2 = num2, num - t * num2
      u, v = v, u - t * v
    end
    u % @mod
  end

  def +(other)
    @num = (@num + other) % @mod
    self
  end

  def -(other)
    @num = (@num - other) % @mod
    self
  end

  def *(other)
    @num = (@num * other) % @mod
    self
  end

  def /(other)
    @num = (@num * mod_inv(other)) % @mod
    self
  end

  def **(other)
    ret = 1
    multi = @num
    other.to_s(2).chars.reverse.each do |b|
      ret = (ret * multi) % @mod if b == '1'
      multi = (multi**2) % @mod
    end
    @num = ret
    self
  end

  def com(n, k, max = nil)
    max = n if max.nil?
    com_init(max) if @com_init_max < max
    return 0 if n < k
    return 0 if n < 0 || k < 0
    @fac[n] * (@finv[k] * @finv[n - k] % @mod) % @mod
  end

  def to_s
    @num.to_s
  end

  def to_i
    @num.to_i
  end

  private

  def com_init(max)
    @com_init_max = max
    @fac = [0] * (max + 1)
    @finv = [0] * (max + 1)
    inv = [0] * (max + 1)
    @fac[0] = 1
    @fac[1] = 1
    @finv[0] = 1
    @finv[1] = 1
    inv[1] = 1;
    2.upto(max) do |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
    end
  end
end

def get(x, y)
  go21 = 0
  while x >= 0
    return [go21, x] if y == x * 2
    go21 += 1
    x -= 2
    y -= 1
  end
  nil
  

end


X, Y = gets.chomp.split.map(&:to_i)
a = get(X, Y)
if a.nil?
  puts "0"
  exit
end

mod = Modulo.new(10**9 + 7)
puts mod.com(a[0] + a[1], a[0])


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

using namespace std;

typedef long long ll;
typedef vector<int> vi; 
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ini(a, i) memset(a, i, sizeof(a))
#define present(i, c) ((c).find(i) != (c).end())

#define for0(i, n) for(int i = 0; i < n; i++)
#define for1(i, n) for(int i = 1; i <= n; i++)
#define fora(i, a, b) for(int i = (a); i < (b); i++)
#define ford(i, n) for(int i = (n)-1; i >= 0; i--)

#define TRACE(x...) x
#define watch(x) TRACE(cerr << #x" = " << x << endl)
#define watch_all(x) TRACE(cerr << #x" = "; for(auto __i : x) cerr << __i << " "; cerr << endl)
	
#define INF 0x3F3F3F3F

//=========================

int N, _W;
int W[101], V[101];
ll dp[100001];

void run_test() {
	cin >> N >> _W;
    for1(i, N) cin >> W[i] >> V[i];

    ini(dp, 0x3F);
    dp[0] = 0;
    for1(i, N) 
        for(int v = 1e5; v >= V[i]; v--) 
            dp[v] = min(dp[v], dp[v - V[i]] + W[i]);
    
    int ans = 0;
    for0(v, 100001) if(dp[v] <= _W) ans = v;
    cout << ans << endl;
}

//=========================

ifstream infile;
clock_t start__;
void open_func();
void close_func();

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	open_func();
	//int t; cin >> t; while(t--) run_test();
	run_test();
	close_func();
	return 0;	
}

void open_func() {
	//infile = ifstream("input.in"); if(infile.good()) cin.rdbuf(infile.rdbuf());
	start__ = clock();
	cerr << "---" << endl;
}

void close_func() {
	clock_t elapsed = clock()-start__;
	cerr << "---" << endl << "(time " << fixed << setprecision(2) << elapsed * (1.0/CLOCKS_PER_SEC) << "s)" << endl;	
	//if(infile.good()) infile.close();
}


Measured memory_bytes: 4576
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        if(A<=8 && B<=8){
            System.out.println("Yay!");
        }
        else{
            System.out.println(":(");
        }
    }
}

Measured memory_bytes: 23252
/* D-"Median of Medians" */
/*  */
//include <bits/stdc++.h>
#include <iostream>
#include <deque>
#include <vector>
#include <math.h>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++) 
using namespace std;

int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    ll ans = c-a-b;
    if(ans > 0 && ans*ans > 4*a*b) cout << "Yes";
    else cout << "No";

    return 0;
}
    

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

using namespace std;
using LL = long long;
using P = pair<int,int>;

int main(){
	bool x;
	cin >> x;
	cout << !x << endl;

	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
typedef long long int LL;
using namespace std;

const int N = 5e5+6;
const int MOD = 1e9+7;
const int INF = 1e9+7;
const double eps = 1e-6;

inline int read() {
    int x=0,f=1;char c=getchar();
    for(; c<'0'||'9'<c; c=getchar())if(c=='-')f=-1;
    for(; '0'<=c&&c<='9'; c=getchar())x=(x<<3)+(x<<1)+c-'0';
    return x*f;
}

#define lal puts(" ***  ");
#define pii pair<int,int>
#define mp  make_pair
#define pb  push_back
#define x   first
#define y   second

/********************************************/
int a025,a05,a1,a2,n;
int main(){
    scanf("%d%d%d%d%d",&a025,&a05,&a1,&a2,&n);
    LL ans ;
    if(n&1){
        ans = min(min(a025*4,a05*2),a1);n--;
    }
    if(n==0) printf("%lld\n",ans);
    else {
        n>>=1;
        ans+=(LL)min(min(a025*8,a05*4),min(a1*2,a2))*n;
        printf("%lld\n",ans );
    }
    return 0;
}

Measured memory_bytes: 256
//by The_One_Solver
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
double r,m,d,c;
int n;
int main()
{
    cin>>n;
    if(n%3==0)
    {
        r=n/3;
        m=n/3;
        d=n/3;
    }
    else
    {
        c=n%3;
        n-=c;
        r+=(n/3)+(c/3);
        m+=(n/3)+(c/3);
        d+=(n/3)+(c/3);
    }
  cout<<fixed<<setprecision(12)<<(r*m*d);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <typename T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> bool chmin(T &a, const T &b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const long long INFLL = 1LL << 60;
const long long MOD = 1e9 + 7;

int main() {
    string S, T;
    cin >> S >> T;
    int min = 1e6, count = 0;
    rep(i, S.size() - T.size() + 1) {
        count = 0;
        rep(j, T.size()) {
            if(S.at(i + j) != T.at(j)) count++;
        }
        chmin(min, count);
    }
    cout << min << endl;
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
typedef complex<ld> Point;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int main() {
    string s;
    cin >> s;
    int n = s.length();
    string goal_1 = "";
    string goal_2 = "";
    rep(i, n) {
        if (i % 2 == 0) {
            goal_1 += '0';
            goal_2 += '1';
        } else {
            goal_1 += '1';
            goal_2 += '0';
        }
    }
    int haming_1 = 0;
    int haming_2 = 0;
    rep(i, n) {
        if (s[i] != goal_1[i]) haming_1++;
        if (s[i] != goal_2[i]) haming_2++;
    }
    out(min(haming_1, haming_2));
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define lli long long int
using namespace std;

int a, b;

int main()
{
  scanf("%d %d", &a, &b);
  int got = 1, p = 0;
  while (got < b)
    got += a - 1, p ++;
  printf("%d\n", p);

  return(0);
}

Measured memory_bytes: 256