akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

///nの約数を追加する(nを含む)
vl divisor_pick(ll n){
    vl a;
    for(ll i=1LL;i*i<=n;i++){
        if(n%i == 0){
            a.push_back(i);
            if(n/i != i)a.push_back(n/i);
        }
    }
    sort(all(a));
    return a;
}

signed main()
{   
    gearup;
    ll n; cin >> n;
    vl a(n);
    rep(i,n)cin>>a[i];
    sort(all(a));
    ll res = 0;
    
    map<int,int> mp;
    rep(i,n)mp[a[i]]++;
    rep(i,n){ //a[i]について任意のa[j]を見る
        bool check = true;
        ll num = a[i];
        //約数列挙
        auto ans = divisor_pick(num);
        ll num2 = ans[ans.size()-1];
        ans.pop_back();
        int m = ans.size();
        rep(j,m)if(mp[ans[j]])check = false;
        if(mp[num2] != 1)check = false;
        if(check)res++;
    }
    out(res);
}


Measured memory_bytes: 33828
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;


bool dec_sort(const int&a, const int&b){return a>b;}

int main()
{
	int N, A, B;
	cin >> N >> A >> B;
	vector <int> H;
	for (int i = 0; i < N; i++) {
		int h;
		cin >> h;
		H.push_back(h);
	}
	sort(H.begin(), H.end(), dec_sort);

	int max = (H[0]+(B-1))/B;
	int mid = 1;
	int min = 1;
	int dif = A-B;

	while (mid < max) {
		int cnt = mid;
		int wk_cnt = 0;
		int dec = cnt*B;
		for (int i = 0; i < N; i++) {
			int left = H[i]-dec;
			if (left <= 0) break;
			wk_cnt += (left+(dif-1))/dif;
			if (wk_cnt > cnt) break;
		}
		if (wk_cnt > cnt) {
			min = mid;
			mid = (max+mid+1)/2;
		} else {
			max = mid;
			mid = (min+mid)/2;
		}
	}

	cout << mid << endl;
	return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <limits>
#include <algorithm>

int main()
{
  unsigned long long A, B;
  std::cin >> A >> B;
  auto calc = [](unsigned long long x)->unsigned long long
  {
    unsigned long long ans = (x & (~3ULL));
    unsigned long long remain = x & 3ULL;
    if (remain == 0)
      return ans;
    else if (remain == 1)
      return 1;
    else if (remain == 2)
      return ans ^ 3ULL;
    else
      return 0;
  };
  if (A < 2)
    std::cout << calc(B) << std::endl;
  else
    std::cout << (calc(B) ^ calc(A - 1)) << std::endl;
  return 0;
}



Measured memory_bytes: 256
n = int(input())
xyh = []
inf = 10 ** 10
for _ in range(n):
    x, y, h = map(int, input().split())
    xyh.append((x, y, h))
xyh.sort(key=lambda x:x[2], reverse=True)

# 全ての中央座標の組み合わせを試す
for i in range(101):
    for j in range(101):
        x, y, h = xyh[0]
        H = h + abs(i-x) + abs(j-y)
        for x, y, h in xyh:
            if h != max(H - abs(i-x) - abs(j-y), 0):
                break
        else:
            ans = i, j, H
print(*ans)

Measured memory_bytes: 3064
n,t = map(int,input().split())
time = [0 for i in range(3000)]
now = 0
ans = 0
lis = [list(map(int,input().split())) for i in range(n)]
lis.sort(key=lambda x:x[0])
for i in range(n):
    for j in range(t-1,-1,-1):
        if lis[i][0] + j >= t:
            ans = max(ans,time[j]+lis[i][1])
        else:
            time[j+lis[i][0]] = max(time[j+lis[i][0]],time[j]+lis[i][1])
print(max(ans,max(time)))

Measured memory_bytes: 46440
#include <iostream>

void make(bool prime[])
{
	for (int i = 2; i <= 100000; ++i)
	{
		if (!prime[i])
		{
			for (int j = i + i; j <= 100000; j += i)
			{
				prime[j] = 1;
			}
		}
	}
}

int main()
{
	bool prime[100010] = { 0 };
	make(prime);
	
	int prefix[100010] = { 0 };
	for (int i = 2; i <= 100000; ++i)
	{
		prefix[i] = prefix[i - 1];
		
		if (i & 1)
		if (!prime[i] && !prime[(i + 1) / 2])
		{
			++prefix[i];
		}
	}
	
	int q;
	std::cin >> q;
	
	while (q--)
	{
		int l, r;
		std::cin >> l >> r;
		std::cout << prefix[r] - prefix[l - 1] << "\n";
	}
}

Measured memory_bytes: 1152
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long int, long long int> lp;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (ll i = ll(a); i <= ll(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end

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

    ll n;
    in >> n;
    ll a[n];
    ll b[n];
    REP(i, n){
        in >> a[i];
    }
    REP(i, n){
        in >> b[i];
    }
    priority_queue<pair<ll, ll> > q;
    ll cnt = 0;
    REP(i, n){
        q.push(lp(b[i], i));
    }

    ll idx, p_idx, n_idx;
    ll minus, times;
    ll pre_idx = -1;
    while(!q.empty()){
        idx = q.top().second;
        q.pop();

        if(b[idx] == a[idx]) continue;
        p_idx = idx - 1;
        n_idx = idx + 1;
        if(p_idx == -1) p_idx = n - 1;
        if(n_idx == n) n_idx = 0;

        times = 1;
        minus = b[p_idx] + b[n_idx];
        if(b[idx] - minus <= 0 or pre_idx == idx){
            out << "-1" << endl;
            return 0;
        }
        times = min((b[idx] - a[idx]) / minus, ll(ceil((b[idx] - minus) / double(minus))));

        b[idx] -= minus * times;
        // out << idx << " " << b[idx] << endl;
        cnt += times;
        pre_idx = idx;
        if(b[idx] == a[idx]){
            continue;
        }else{
            q.push(lp(b[idx], idx));
        }
    }
    out << cnt << endl;
}


Measured memory_bytes: 9584
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define pb(a) push_back(a)
using namespace std;
typedef long long ll;

int main()
{
    int N, K;
    cin >> N >> K;

    cout << N - K + 1;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
#include<deque>
 
using namespace std;
typedef long long ll;
 
int main(void)
{
    string S;
    cin >> S;

    map<char, int > char_map;
    for(char s : S)
    {
        if(char_map.count(s) == 0)
        {
            char_map.insert(make_pair(s, 1));
        }
        else
        {
            char_map[s]++;
        }
    }

    if(char_map.size() != 2)
    {
        cout << "No" << endl;
        return 0;
    }
    
    for(pair<char, int> pair : char_map)
    {
        if (pair.second != 2)
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

ll dp[111][111][333];

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n,t;
  cin>>n>>t;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  dp[0][0][0]=1;
  rep(i,n)rep(j,n+1)rep(k,256){
    (dp[i+1][j+1][k^a[i]]+=dp[i][j][k])%=MOD;
    (dp[i+1][j][k]+=dp[i][j][k])%=MOD;
  }
  //rep(k,n+1){rep(i,n+1){rep(j,16) cout<<dp[k][i][j]<<",";cout<<endl;}cout<<endl;}
  ll re=(t==0),f=1;
  reps(i,1,n+1){
    (f*=i)%=MOD;
    //cout<<dp[n][i][t]<<endl;
    (re+=dp[n][i][t]*f%MOD)%=MOD;
  }
  cout<<re<<endl;
  return 0;
}


Measured memory_bytes: 27136
number = input().split(" ")
A = int(number[0])
B = int(number[1])
if B == 1:
    print(0)
elif A >= B:
    print(1)
else:
    x = (B-A)//(A-1)
    y = (B-A)%(A-1)
    if y == 0:
        print(x+1)
    else:
        print(x+2)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    set<ll> s;
    ll n,res=0;
    cin>>n;
    for(ll i=0;i<n;i++){
        ll x;
        cin>>x;
        auto it=s.lower_bound(x);
        if(s.empty()||it==s.begin())
        res++;
        s.insert(x);
    }
    cout<<res;
} 


Measured memory_bytes: 9600
#include <string.h>
#include <stdio.h>
int main (){
     int k;
     int pan;
     char s[101];
     scanf("%d",&k);
     scanf("%s",&s);
     pan = strlen (s);

     if (pan <= k){
         printf("%s",s);
    }
    else if (pan> k ){
        for (int i=0; i <= k-1; i++){
            printf("%c",s[i]);
        }
        printf("...");
    }
return 0;
}

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

int main(void)
{
	int n, a[100], num = 0;
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for(int i = 0; i < n; i++) {
		int minj = i;
		for(int j = i; j < n; j++) {
			if(a[j] < a[minj]){
				minj = j;
			}
		}
		if(i != minj){
			num++;
			swap(a[i], a[minj]);
		}
		cout << a[i] << (i == n - 1 ? "\n" : " ");
	}
	cout << num << endl;
	return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef pair<int, int> P;
const int H = 10;
const int W = 10;

void disp(vector< vector<int> > &v){
  cout <<"----------" <<endl;
  REP(i, H){
    REP(j, W) cout <<v[i][j];
    cout <<endl;
  }
}

void shoot(int y, int x, vector< vector<int> > &v){
  v[y][x] = !v[y][x];
  if(y + 1 < H) v[y + 1][x] = !v[y + 1][x];
  if(y - 1 > -1) v[y - 1][x] = !v[y - 1][x];
  if(x + 1 < W) v[y][x + 1] = !v[y][x + 1];
  if(x - 1 > -1) v[y][x - 1] = !v[y][x - 1];
}

vector<P> change(vector< vector<int> > &v){
  vector<P> res;
  FOR(y, 1, v.size()){
    REP(x, v[y].size()){
      if(v[y - 1][x] == 1){
        shoot(y, x, v);
        res.push_back(P(y, x));
      }
    }
  }
  return res;
}

bool check(vector< vector<int> > &v){
  REP(i, v.size()) REP(j, v[i].size()) if(v[i][j] == 1) return false;
  return true;
}

vector<P> solve(){
  vector< vector<int> > v(H, vector<int>(W));
  REP(i, H) REP(j, W) cin >>v[i][j];
  vector<P> res;
  REP(b, (1 << W)){
    vector< vector<int> > vv = v;
    vector<P> tmp;
    REP(i, W){
      if(!(1 & (b >> i))) continue;
      shoot(0, i, vv);
      tmp.push_back(P(0, i));
    }
    vector<P> ans = change(vv);
    REP(i, tmp.size()) ans.push_back(tmp[i]);
    if(check(vv)){ res = ans; break; }
  }
  return res;
}

int main() {
  int N; cin >>N;
  while(N--){
    vector<P> r = solve();
    vector< vector<int> > ans(H, vector<int>(W, 0));
    REP(i, r.size()) ans[r[i].first][r[i].second] = 1;
    REP(i, H){
      REP(j, W) cout <<(j != 0 ? " ": "") <<ans[i][j];
      cout <<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1224
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        PriorityQueue<Double> pq = new PriorityQueue<>();

        for (int i = 0; i < N; i++) {
            pq.offer(sc.nextDouble());
        }

        while (pq.size() > 2) {
            double v1 = pq.poll();
            double v2 = pq.poll();

            pq.offer((v1 + v2)/2);
        }

        double v1 = pq.poll();
        double v2 = pq.poll();
        double value = (v1 + v2) / 2.0;
        System.out.println(value);

        return;
    }

}

Measured memory_bytes: 23252
/******************************************************************

	AOJ 0529　ダーツの問題

	矢を四本投げるので、2本投げたときの

*******************************************************************/

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#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>
#include <fstream>
#include <queue>

#pragma warning( disable: 4996 )

using namespace std;

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

#define INF 1000000000
#define EPS 1e-10

#define MAX_N 1001

int N, M;
int po[MAX_N];

vector<int> ans_list;

int main(){

	while (true){
		cin >> N >> M;
		if (N == 0 && M == 0)
			break;
		for (int i = 0; i < N; i++){
			cin >> po[i];
		}
		po[N] = 0;
		N++;
		vector<int> A;

		for (int i = 0; i < N; i++){
			for (int j = 0; j < N; j++){
				A.push_back(po[i] + po[j]);
			}
		}

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

		int ans = 0;
		for (int i = 0; i < A.size(); i++){
			int tmp = A[i];
			int max_tmp = M - tmp;
			if (max_tmp < 0)
				break;
			int lb = 0, ub = A.size();
			while (ub - lb > 1){
				int mid = (ub + lb) / 2;
				if (max_tmp < A[mid])
					ub = mid;
				else
					lb = mid;
			}
			ans = max(ans, M - (max_tmp - A[lb]));
		}

		ans_list.push_back(ans);

	}

	for (int i = 0; i < ans_list.size(); i++){
		cout << ans_list[i] << endl;
	}

}

Measured memory_bytes: 9136
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
const double eps=1e-10;
double adj[21][21];
double  cost[20][20];
const double INF = 10000000;
#define MAOU 20

bool backTrack(int last,double r,int now,int n,
	   bool *visited){
  rep(i,n){
    if ( visited[i]==false && adj[MAOU][i]<=r)return false;
    if (visited[i]==false &&  adj[MAOU][i]<=r+adj[last][i])return false;
  }
  if ( now == n)return true;
  
  //
  /*
  visited[last]=false;
  rep(i,n){
    if (visited[i]==true)cost[i][i]=INF;
    else cost[i][i]=0;
    REP(j,i+1,n){
      if (visited[i]==true ||visited[j]==true)cost[i][j]=cost[j][i]=INF;
      else cost[i][j]=cost[j][i]=adj[i][j];
    }
  }
  visited[last]=true;
  rep(k,n)rep(i,n)rep(j,n)cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);
  rep(i,n)if( visited[i]==false && r+cost[last][i] >=adj[MAOU][i])return false;
  */
  //

  
  rep(i,n){
    if ( visited[i]==true)continue;
    if ( r+adj[last][i] < adj[MAOU][i]){
      visited[i]=true;
      if ( backTrack(i,r+adj[last][i],now+1,n,visited))return true;
      visited[i]=false;
    }//else return false;
  }
  return false;
}

double dist(int x,int y){
  return sqrt(x*x+y*y);
}

int solve(int n,int *x,int *y,int rx,int ry,int mx,int my){
  rep(i,n){
    adj[i][i]=0;
    adj[MAOU][i]=adj[i][MAOU]=dist(x[i]-rx,y[i]-ry);
    REP(j,i+1,n){
      adj[i][j]=adj[j][i]=dist(x[i]-x[j],y[i]-y[j]);
    }
  }
  
  rep(i,n){
    if ( dist(mx-x[i],my-y[i])+eps>dist(rx-x[i],ry-y[i]))return false;
  }


  bool visited[20]={false};
  rep(i,n){
    if ( dist(mx-x[i],my-y[i]) < dist(rx-x[i],ry-y[i])){
      visited[i]=true;
      if ( backTrack(i,dist(mx-x[i],my-y[i]),1,n,visited))return true;
      visited[i]=false;
    }
  }
  return false;
}

main(){
  int n,mx,my,rx,ry;
  while(cin>>n>>mx>>my>>rx>>ry && n){
    int x[n],y[n];
    rep(i,n)cin>>x[i]>>y[i];
    if ( solve(n,x,y,rx,ry,mx,my))puts("YES");
    else puts("NO");
  }
}

Measured memory_bytes: 852
#include <iostream>
using namespace std;
int main() {
  string b;
  cin >> b;
  if(b=="A"){
    cout << "T" << endl;
  }
  if(b=="T"){
    cout << "A" << endl;
  }
  if(b=="C"){
    cout << "G" << endl;
  }
  if(b=="G"){
    cout << "C" << endl;
  }
}

Measured memory_bytes: 764
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve(k):
    W = int(readline())
    if W == 0:
        return False
    INF = 10**18
    dp = [-INF]*(W+1)
    dp[0] = 0
    N = int(readline())
    for i in range(N):
        v, w = map(int, readline().split(","))
        for j in range(W-w, -1, -1):
            dp[j+w] = max(dp[j+w], dp[j] + v)
    vm = max(dp)
    wm = dp.index(vm)
    write("Case %d:\n%d\n%d\n" % (k, vm, wm))
    return True
i = 1
while solve(i):
    i += 1


Measured memory_bytes: 5612
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<math.h>

int main(){
    int n, d;
    int i;
    int cn = 0;

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

    for(i = 0;i < n;i++){
        double x, y;
        scanf("%lf %lf", &x, &y);
        if(d >= sqrt((x * x) + (y * y))) cn++;
    }
    printf("%d", cn);

    return 0;
}

Measured memory_bytes: 2220
#include <stdio.h>
#define N 8
#define F -1
#define NF -2
#define fal 0
#define tru 1


int row[N],col[N],dial[2*N-1],diar[2*N-1];//行は英語でrow、列は英語でcolumn、対角線は英語でdiagonal
int X[N][N];

void board(int);
void printboard(void);

int main(){
  int i,j,k,r,c;
  for(i=0;i<N;i++){
    row[i]=F;
    col[i]=F;
  }
  for(i=0;i<2*N-1;i++){
    dial[i]=F;
    diar[i]=F;
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      X[i][j]=fal;
    }
  }
  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d %d",&r,&c);
    X[r][c]=tru;
  }
  board(0);
  return 0;
}

void board(int i){
  //iが行、jが列と見る
  int j;
  //クイーンの配置に成功
  if(i==N){
    printboard();
    return;
  }
  for(j=0;j<N;j++){
    //(i,j)が他のクイーンに襲撃されている場合は何もせずループを回す
    if((col[j]==NF)||(dial[i+j]==NF)||(diar[i-j+N-1]==NF)){
      continue;
    }
    //(i,j)にクイーンを配置
    row[i]=j;
    col[j]=dial[i+j]=diar[i-j+N-1]=NF;
    //次の行を試す
    board(i+1);
    //(i,j)に配置されているクイーンを取り除く。最初、i=7の時に出て来て、i=7の時にNFにしたエリアをFにする。
    row[i]=col[j]=dial[i+j]=diar[i-j+N-1]=F;
    //上のが終った後、board関数を抜け出し、前の board(i+1);に戻り、 i=6でrow[i]=col[j]=dial[i+j]=diar[i-j+N-1]=F;を実行する。
  }
  
}

void printboard(){
  int i,j;

  
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(X[i][j]==tru){
	//printf("%d %d %d %d %d\n",i,j,X[i][j],row[i],j);
	
	if(row[i]!=j){
	  return;
	}
      }
    }
  }
  
  // printf("wa-i\n");
  
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i]==j){
	printf("Q");
      }
      else{
	printf(".");
      }
    }
    printf("\n");
  }
  //printf("\n");
}



Measured memory_bytes: 2084
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <limits.h>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <string>
#define ll long long
#define ull unsigned long long
#define ms(a) memset(a,0,sizeof(a))
#define pi acos(-1.0)
#define INF 0x7f7f7f7f
#define lson o<<1
#define rson o<<1|1
const double E=exp(1);
const int maxn=1e6+10;
const int mod=1e9+7;
using namespace std;
int a[maxn];
int vis[maxn];
bool check(int n)
{
	while(n)
	{
		if(vis[n%10])
			return false;
		n/=10;
	}
	return true;
}
int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	int n,k;
	int x;
	cin>>n>>k;
	for(int i=0;i<k;i++)
	{
		cin>>x;
		vis[x]=1;
	}
	for(int i=n;;i++)
	{
		if(check(i))
		{
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
n,k,q = [int(i) for i in input().split()]
a = [int(input())-1 for i in range(q)]
point = [k-q]*n
for i in range(q):
  point[a[i]] += 1
for i in point:
  if i > 0:
    print('Yes')
  else:
    print('No')


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

// UnionFind
struct UnionFind {
    vector<int> d;
    UnionFind(int n=0) : d(n, -1) {} // 各ルートノードはサイズのマイナスを値にもつ
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (-d[x] < -d[y]) swap(x,y); // Xの方がサイズが大きくなるように
        d[x] += d[y];                   // サイズを更新
        d[y] = x;                       // 大きいツリーに小さいツリーを足す
        return true;
    }
    bool same(int x, int y) {return find(x) == find(y);}
    int size(int x) {return -d[find(x)];}
    int component() {
        set<int> S;
        rep(x,d.size()) S.insert(find(x));
        return S.size();
    }
};

int main()
{
    int n, m;
    cin >> n >> m;
    UnionFind U(n);
    set<int> S;
    rep(i,m) {
        int x, y, z;
        cin >> x >> y >> z;
        x--;y--;
        U.unite(x, y);
        S.insert(x);
        S.insert(y);
    }

    int ans = 0;
    ans += U.component();

    cout << ans << endl;




    return 0;
}


Measured memory_bytes: 5632
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

const int N=1e5;
ll n,m;
vector<int> g[N+1];
int color[N+1];

bool dfs(int u,int c){
  color[u]=c;
  for(int i=0;i<g[u].size();i++){
    if(color[g[u][i]]==c) return false;
    if(color[g[u][i]]==0&&!dfs(g[u][i],-c)) return false;
  }
  return true;
}

int main(){
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  if(dfs(1,1)){
    ll b=0,w=0;
    for(int i=1;i<=n;i++){
      if(color[i]==1) w++;
      else b++;
    }
    cout<<b*w-m<<endl;
  }else{
    cout<<n*(n-1)/2-m<<endl;
  }

  return 0;
}


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

struct Edge{
	int src,dst,cost;
};
typedef vector< vector<Edge> > G;
G g;

vector<int> tmp;
int dfs(int x,int p,int c){
	tmp.push_back(c);
	int ans = 0;
	for( auto e : g[x] ){
		if( e.dst == p ) continue;
		if( g[e.dst].size() == 1 ){
			ans += e.cost;
		}else{
			ans += 3*e.cost;
			ans += dfs(e.dst,x,c+e.cost);
		}
	}
	return ans;
}
int main(){
	int N;
	while(cin >> N && N){
		g = G(N);
		vector<int> p(N);
		vector<int> c(N);
		for(int i = 0 ; i < N-1 ; i++) cin >> p[i];
		for(int i = 0 ; i < N-1 ; i++) cin >> c[i];
		for(int i = 0 ; i < N-1 ; i++){
			p[i]--;
			g[i+1].push_back({i+1,p[i],c[i]});
			g[p[i]].push_back({p[i],i+1,c[i]});
		}
		int ans = 2e9;
		for(int st = 0 ; st < N ; st++){
			tmp.clear();
			int subans = dfs(st,-1,0);
			for(int j = 0 ; j < tmp.size() ; j++){
				ans = min(ans,subans-tmp[j]);
			}
			
		}
		cout << ans << endl;
	}
	
	
}

Measured memory_bytes: 1376
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> A >> B >> M;
    vi a(A), b(B);
    cin >> a >> b;
    ans = *min_element(ALL(a)) + *min_element(ALL(b));
    REP(i, M) {
        int x, y, c;
        cin >> x >> y >> c;
        x--, y--;
        ans = min(int(ans), a[x] + b[y] - c);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
import sys
n,m = map(int, input().split())
SCs = [list(map(int, input().split())) for _ in range(m)]
for i in range(10**n):
  X=str(i)
  tf=True
  if len(X)==n:
    for j in SCs:
      if X[j[0]-1]!=str(j[1]):
        tf=False
        break
    if tf:#全ループ終わって条件を満たしていれば
      print(i)
      sys.exit()
print(-1)

Measured memory_bytes: 38256
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

long long dp[50];

int main() {
    int n, t, ans = 0, i, j;
    vector <pair<int, int>> v, w;
    
    scanf("%d %d", &n, &t);
    
    for (i = 0; i < n; i++) {
        int a, b;
        
        scanf("%d %d", &a, &b);
        
        if (a > 0) {
            v.push_back(make_pair(a, b));
        } else {
            w.push_back(make_pair(a, b));
        }
    }
    
    sort(v.begin(), v.end(), [](pair <int, int>& p1, pair <int, int>& p2) { return (long long)p2.first * (p1.second + 1) < (long long)p1.first * (p2.second + 1); });
    sort(w.begin(), w.end());
    
    for (i = 1; i < 50; i++) dp[i] = 1e18;
    dp[0] = 1;
    
    for (i = 0; i < v.size(); i++) {
        int a = v[i].first;
        int b = v[i].second;
        
        for (j = 49; j >= 0; j--) {
            long long nt;
            
            if (dp[j] == 1e18) continue;
            
            nt = dp[j] + a * dp[j] + b;
            if (nt > t) continue;
            
            dp[j + 1] = min(dp[j + 1], nt + 1);
        }
    }
    
    for (i = 0; i < 50; i++) {
        int c = i;
        long long nt = dp[i];
        
        if (nt == 1e18) continue;
        
        for (j = 0; j < w.size(); j++) {
            int a = w[j].first;
            int b = w[j].second;
            long long nnt = nt + a * nt + b;
            
            if (nnt > t) break;
            
            nt = nnt + 1;
            c++;
        }
        
        ans = max(ans, c);
    }
    
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 2420
inf = 10**18
N = int(input())
balls = []
m, M = inf, -1
mp, Mp = -1, -1
for i in range(N):
    x, y = map(int, input().split())
    if x>y:
        x, y = y, x
    balls.append((x, y))
    if m>x:
        mp = i
        m = x
    if M<y:
        Mp = i
        M = y
a = max(x[0] for x in balls)
b = min(x[1] for x in balls)
ans = (a-m)*(M-b)
if mp == Mp:
    print(ans)
    exit()
balls.sort()
a, b = balls[0][0], balls[-1][0]
ans = min(ans, (M-m)*(b-a))
k = inf
for i in range(N-1):
    a = balls[i+1][0]
    b = max(b, balls[i][1])
    k = min(k, balls[i][1])
    if a>k:
        ans = min(ans, (M-m)*(b-k))
        break
    ans = min(ans, (M-m)*(b-a))
b = max(b, balls[i][1])
k = min(k, balls[-1][1])
ans = min(ans, (M-m)*(b-k))
print(ans)







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

int main(){
    ll n, tmp;
    cin >> n;

    set<ll> a;
    rep(i, n){
        cin >> tmp;
        a.insert(tmp);
    }

    string ans = "NO";
    if(a.size()==n) ans= "YES";
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int64_t sum = 0;
  int dist[N][N];
  int war[N][N];
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      cin >> dist[i][j];
      sum += dist[i][j];
      war[i][j] = dist[i][j];
    }
  }
  
  for(int k=0; k<N; k++){
    for(int i=0; i<N; i++){
      for(int j=0; j<N; j++){
        war[i][j] = min(war[i][j], war[i][k] + war[k][j]);
      }
    }
  }
  
  bool flag = true;
  
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      if(dist[i][j] > war[i][j]){
        flag = false;
      }
    }
  }
  

  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      for(int k=0; k<N; k++){
        if(i == k || j == k){
          continue;
        }
        if(dist[i][j] == dist[i][k] + dist[k][j]){
          sum -= dist[i][j];
          break;
        }
      }
    }
  }
  
  if(flag){
    cout << sum/2 << endl;
  }
  else{
    cout << -1 << endl;
  }

}

Measured memory_bytes: 896
#include<iostream>
#include<string>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)

int main(){
    string n,ans;
	int cnt=0;
    cin>>n;
  //cout<<n.size()<<endl;
    r(i,n.size()-1){
        if(n.at(i)==n.at(i+1)){
            cnt++;
          //cout<<cnt<<endl;
            if(cnt==2){ans="Yes";break;}
        }else cnt=0;
        ans="No";
    }
    cout<<ans<<endl;

    return 0;
}



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

int compare(const void *a, const void *b) {
    return strcmp((char *)a, (char *)b);
}

int main(void) {
    int n;
    unsigned long long count = 0;
    unsigned long long count_tmp = 0;

    scanf("%d", &n);
    char s[n][11];

    for (int i = 0; i < n; i++) {
        scanf("%s", s[i]);
        qsort((void *)s[i], 10, sizeof(char), compare);
    }

    qsort((void *)s, n, sizeof(s[0]), compare);

    for (int i = 1; i < n; i++) {
        if (strcmp(s[i - 1], s[i]) == 0) {
            count_tmp++;
            if (i == n - 1) {
                count += count_tmp * (count_tmp + 1) / 2;
            }
        } else {
            count += count_tmp * (count_tmp + 1) / 2;
            count_tmp = 0;
        }
    }


    printf("%llu\n", count);

    return 0;
}


Measured memory_bytes: 2300
//DavitMarg//
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <iterator>
#include <ctype.h>
#include <bitset>
#include <cassert>
#include <unordered_map>
#include <time.h>
#include <fstream>
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(),v.end()
using namespace std;

int n,used[100005],e[100005];
LL ans,dp[100005][2];
vector<int> g[100005];

void dfs(int v)
{
	used[v] = 1;
	dp[v][0] = dp[v][1] = 1;
	vector<pair<LL, LL>> d;
	for (int i = 0; i < g[v].size(); i++)
	{
		int to = g[v][i];
		if (used[to])
			continue;
		dfs(to);

		dp[v][1] *= dp[to][0];
		dp[v][1] %= mod;
		d.PB(MP(dp[to][0], dp[to][1]));
	}

	if (!d.empty())
	{
		for (int i = 0; i < d.size(); i++)
		{
			LL s = dp[v][0];
			dp[v][0] = (s*d[i].first) % mod;
			dp[v][0] %= mod;
			dp[v][0] += (s*d[i].second) % mod;
			dp[v][0] %= mod;
		}
	}
}

int main()
{
	cin >> n;
	e[0] = 1;
	for (int i = 1; i <= n; i++)
		e[i] = (e[i - 1] * 2) % mod;
	for (int i = 1; i <= n-1; i++)
	{
		int y, x;
		scanf("%d%d",&x,&y);
		g[x].PB(y);
		g[y].PB(x);
	}
	dfs(1);
	cout << (dp[1][0] + dp[1][1]) % mod << endl;
	return 0;
}

/**/

Measured memory_bytes: 16384
from bisect import bisect_left,bisect

n=int(input())
l=list(map(int,input().split()))
l.sort()

#n=7
#l=[218, 233, 389, 645, 704, 728, 786]

#print(l)
icnt=0
for a in range(n-2):
    for b in range(a+1,n-1):
        nc=bisect(l,l[a]+l[b]-1)
        if nc>b+1:
            icnt+=nc-(b+1)
#            print(a,b,nc,l[a],l[b],l[a]+l[b])
        
print(icnt)
        

Measured memory_bytes: 9356
#include <bits/stdc++.h>
 
#define int long long
 
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 999999999999
 
using namespace std;

int32_t main(){
    string str;
    cin >> str;

    int n=str.length();
    int m=26;

    vector<int> memo(m, 0);
    REP(i, m){
        vector<int> v(1, -1);
        REP(j, n){
            if((char)('a'+i) == str[j]){
                v.pb(j);
            }
        }
        v.pb(n);

        REP(j, v.size()-1){
            memo[i]=max(memo[i], v[j+1]-v[j]);
        }
    }   

    SORT(memo);
    cout << memo[0]-1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない


int main() {

	int e[10];
	int me = 0;
	int n;
	int se = 0;
	cin >> n;
	rep(i, 0, n) {
		cin >> e[i];
		se += e[i];
		me = max(e[i], me);
	}

	if (me < se - me) {
		Yes;
	}
	else {
		No;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
	char c;
	cin >> c;
	if(c == 'A') cout << "T" << endl;
	if(c == 'T') cout << "A" << endl;
	if(c == 'C') cout << "G" << endl;
	if(c == 'G') cout << "C" << endl;
	
	return 0;
}

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

#define pb push_back
#define eb emplace_back
#define rep(i,a,b) for(auto i=(a);i!=(b);++i)
#define all(v) (v).begin(), (v).end()
#define rs resize
#define x first
#define y second

using namespace std;

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

ostream& operator<<(ostream &out, const pii &a) { return out << '(' << a.x << ", " << a.y << ')'; }
istream& operator>>(istream &in, pii &a) { return in >> a.x >> a.y; }

const int INF = 2147483647;
const ll LLINF = 9223372036854775807LL;

// lambda-expression: [] (args) -> retType { body }

const int maxn = 5e5 + 10;

int N;
char S[maxn];

int run()
{
	scanf("%d%s", &N, S + 1);
	vi dp(N + 1, 0);
	int last = 0;
	for (int i = 3; i <= N; i++) {
		dp[i] = dp[i - 1];
		if (S[i] == '1' && S[i - 1] == '0' && S[i - 2] == '1') {
			last = i;
			for (int j = i - 2; j >= 0 && S[j] == '1'; j--) {
				dp[i] = max(dp[i], dp[j - 1] + i - 1 - j);
			}
		} else if (S[i] == '0') last = 0;

		if (last > 0) {
			dp[i] = max(dp[i], dp[last - 3] + i - last + 1);
		}
	}
	return dp[N];
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	// cerr << boolalpha;
	(cout << fixed).precision(10);

	int ans = run();
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define pr_arr(name, a, b) \
  for (int i = (a); i < (b); i++) { \
    for (int j = (a); j < (b); j++) {\
      if (j > (a)) printf(" "); \
      printf("%lld", name[i][j]); \
    }\
    printf("\n");\
  }\

#define YES puts("YES")
#define NO  puts("NO")
#define Yes puts("Yes")
#define No  puts("No")

using namespace std;

typedef long long ll;

static const int MAX = 1000005;
static const int MOD = 1000000007;

ll ans;
ll X, Y;

long long fac[MAX],   // i!    mod p iの階乗
          finv[MAX],  // i!^-1 mod p iの階乗の逆元
          inv[MAX];   // i^-1  mod p iの逆元 inverse

/* 
   逆元漸化式によるnCk mod pを求めるための前準備
　　n! mod p
   (k!)^-1 mod p
   を予め求めておく
   使用可能場面
   ・1 <= k <= n <= 10^7
   ・p が素数
   ・n < p
   pが素数でないとMOD%iで0になってしまう
   n < pでないとMOD%iで0になってしまう
*/
void comb_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}
/*
    nCk = n! / ((k!)^-1 * ((n-k)!)^-1) であることを利用し、
    予め求めたn!と(k!)^-1 mod p からO(1)でnCk mod pを返す
*/

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

int main(void) {
    scanf("%lld %lld", &X, &Y);
    comb_init();

    // 2m+ n = X 
    //  m+2n = Y
    // 3n = 2Y - X -> n = (2Y-X)/3
    //                m = (2X-Y)/3

    if ((X+Y)%3 != 0) {
        puts("0");
        return 0;
    }

    ll m = (2*X-Y)/3;
    ll n = (2*Y-X)/3;

    printf("%lld\n", combination(n+m, m));

	return 0;
}


Measured memory_bytes: 23680
N,M=map(int,input().split())
N=list(range(1,N+1))
for i in range(M):
    N[int(input())-1]=0
m=10**9+7
ans=[0,1]
for i in N:
    if i==0 and i+1==0:
        print(0)
        exit()
    if i==0:
        ans.append(0)
    else:
        ans.append(ans[-1]+ans[-2])

print(ans[-1] % m)

Measured memory_bytes: 463988
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N, K, cnt = 0; cin >> N >> K;
    for (int i = 0; i < N; ++i) {
        int a; cin >> a;
        if (a >= K) cnt++;
    }
    printf("%d\n", cnt);
}


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

#define vl vector<ll>
#define vs vector<string>
#define vll vector< vector<ll> >
#define pll pair<ll,ll>
#define pls pair<ll,string>
#define psl pair<string,ll>
#define tll tuple<ll, ll, ll>
#define vp vector< pair<ll,ll> >
#define vt vector< tuple<ll, ll, ll> >
#define all(c) c.begin(),c.end()

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
 
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;

//command
//c++ atcoder.cpp -std=c++14
//./a.out

//cout << setprecision(12) << ans << endl;

#define NN 2020202

int main(){
  ll n;
  cin >> n;
  ll A[n];
  ll vmax = -INF;
  for (int i=0;i<n;i++){
    cin >> A[i];
    if (vmax < A[i]) vmax = A[i];
  }

  ll center1;
  ll center2;
  if (vmax%2 == 0){
    center1 = vmax/2;
    center2 = vmax/2;
  }
  else{
    center1 = (vmax-1)/2;
    center2 = (vmax+1)/2;
  }

  ll vmin = INF;
  ll dis = INF;
  for (int i=0;i<n;i++){
    if (A[i] == vmax) continue;
    if (abs(A[i] - center1) < dis || abs(A[i] - center2) < dis){
      vmin = A[i];
      dis = min(abs(A[i] - center1), abs(A[i] - center2));
    }
  }
  
  cout << vmax << " " << vmin << endl;
  //cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n,k;
    cin>>n>>k;
    //vi d(n);
    vi a(n);
    REP(i,k){
        int d;
        cin>>d;
        REP(j,d){
            int tmp;
            cin>>tmp;
            a[tmp-1]++;
        }
    }

    //DEBUG_VEC(a);

    int ans=0;
    REP(i,n){
        if(a[i]==0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int e, t;
  cin >> e >> t;
  int i = 0;
  while(true){
   if(i*8/100 == e && i*10/100 == t){
    cout << i << endl;
     break;
   }
    if(i > 1008){
     cout << -1 << endl;
      break;
    }
    i++;
    
  }
  
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
using namespace std;
using ll = long long;
const ll mod =  998244353;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (int i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent, ll module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ ll root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2, mod);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

ll dp[10010] = {-1, -1, -1, -1, -1, -1, -1, -1};

signed main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  ll ans = a[0];
  REP(i, n) ans = gcd(ans, a[i]);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>

int main(void)
{
  int k;
  char s[256];

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

  if (strlen(s) > k) {
    s[k] = '\0';
    strcat(s, "...");
  }

  puts(s);
}


Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
int main(){
	string S;
	bool al[26];
	for(int i = 0; i < 26; i++) al[i] = false;
	cin >> S;
	for(int i = 0; i < S.size(); i++){
		al[S[i] - 'a'] = true;
	}
	int ans = -1;
	for(int i = 0; i < 26; i++){
		if(al[i] == false){
			ans = i;
			break;
		}
	}
	if(ans == -1) cout << "None" << endl;
	else cout << (char)('a' + ans) << endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}

int pch(ll H) {
	ll i = 2;
	while (i * i <= H) {
		if (H % i == 0) {
			return -1;
		}
		i++;
	}
	return H;
}



int main() {
	ll X;
	cin >> X;
	if (X >= 10500) {
		cout << 1 << endl;
		return 0;
	}
	else if ((X / 100) * 5 >= X % 100) {
		cout << 1 << endl;
		return 0;
	}
	else {
		cout << 0 << endl;
	}
	
}





Measured memory_bytes: 256
N,M,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
x=sorted(x)
y=sorted(y)
flag=0 
for Z in range(X+1,Y+1):
    if x[N-1]<Z and y[0]>=Z:
        flag=1
print('No War' if flag==1 else 'War')

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	int n,a, b;
	cin >>n>> a >> b;
	if (abs(n - a) > abs(n - b) ){
		cout << "B";
	}
	else {
		cout << "A";
	}
	return 0;
}

//Ctrl+Aを使わない

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int arr[200000] = {};
    int pos = -1;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        int v1, v2;
        cin >> v1;
        if (v1==0)
        {
            cin >> v2;
            arr[++pos] = v2;
        }
        else if (v1 == 1)
        {
            cin >> v2;
            cout << arr[v2] << endl;
        }
        else if (v1 == 2)
            --pos;
    }
    return EXIT_SUCCESS;
}



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

int main() {
  int N;
  cin >> N;
  vector<int> button(N);
  for(int i = 0; i < N; i++){
    cin >> button.at(i);
  }
  int a = 1;
  for(int t = 0; t < N; t++){
    if(a == 2){
      cout << t << endl;
      break;
    }
    a = button.at(a - 1);
  }
  
  if(a != 2)
    cout << -1 << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int i=1;
        int x;
        while(i <= n){
            x = i;
            if(x%3 == 0){
                System.out.print(" "+i);
                i++;
                continue;
            }
            do{
                if(x%10 == 3){
                System.out.print(" "+i);
                break;
                }
            }while((x /= 10) != 0);
            i++;
        }
        System.out.println("");
    }
}

Measured memory_bytes: 28816
#include<bits/stdc++.h>
#define INF 1000000007
#define inf 10000000
#define mod 1000000007
using namespace std;
template <typename T> T Max(T X,T Y){return X>Y?X:Y;}
template <typename T> T Min(T X,T Y){return X<Y?X:Y;}

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

Measured memory_bytes: 3616