akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
pair<double , double> tab[10];
bool dejaVu[10];
double total = 0;
int N;

void recursion(int actu , int nbFaits ,double tActu)
{
	if (nbFaits== N)
	{
		total += tActu;
		return;
	}
	for (int i = 0 ; i < N ; i++)
	{
		if (!dejaVu[i])
		{
			double au = tActu + sqrt((tab[actu].first - tab[i].first) * (tab[actu].first - tab[i].first) + (tab[actu].second - tab[i].second) * (tab[actu].second - tab[i].second));
			dejaVu[i] = true;
			recursion(i , nbFaits + 1 ,  au);
			dejaVu[i] = false;
		}
	}
}
int main()
{
	cin>>N;
	int f = 1;
	for (int i = 1 ; i <= N ; i++)
	{
		f*=i;
	}
	for (int i = 0 ; i < N ; i++)
	{
		cin>>tab[i].first>>tab[i].second;
	}
	for (int i = 0 ; i < N ; i ++)
	{
		dejaVu[i] = true;
		recursion(i , 1 , 0);
		dejaVu[i] = false;
	}
	cout.precision(15);
	cout<<total / f;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


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


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

class Program
{
    static void Main(string[] args)
    {
        var line = Console.ReadLine().Split(' ');
        var personNumber = int.Parse(line[0]);
        var friendNumber = int.Parse(line[1]);
        var blockNumber = int.Parse(line[2]);

        var unionFind = new UnionFind(personNumber);

        var list = new List<int[]>();

        var result = new int[personNumber];

        for (var i = 0; i < friendNumber; i++)
        {
            var l = Console.ReadLine().Split(' ');
            unionFind.UniteMembers(int.Parse(l[0]) - 1, int.Parse(l[1]) - 1);

            list.Add(new int[2] { int.Parse(l[0]) - 1, int.Parse(l[1]) - 1 });

        }

        for (var i = 0; i < blockNumber; i++)
        {
            var l = Console.ReadLine().Split(' ');
            list.Add(new int[2] { int.Parse(l[0]) - 1, int.Parse(l[1]) - 1 });
        }


        for (var i = 0; i < personNumber; i++)
        {
            result[i] = unionFind.GetMenberSize(i) - 1;
        }


        foreach (var item in list)
        {
            if (unionFind.CheckSameGroup(item[0], item[1]))
            {
                result[item[0]] -= 1;
                result[item[1]] -= 1;
            }        }
        Console.WriteLine(string.Join(" ", result));
    }
}

class UnionFind
{
    public int[] ParentId { get; set; }

    public UnionFind(int nodeNumber)
    {
        this.ParentId = new int[nodeNumber];
        for (var i = 0; i < nodeNumber; i++)
        {
            this.ParentId[i] = -1;
        }
    }

    public int FindParentId(int id)
    {
        if (this.ParentId[id] < 0)
        {
            return id;
        }

        this.ParentId[id] = this.FindParentId(this.ParentId[id]);
        return this.ParentId[id];
    }

    public int GetMenberSize(int id)
    {
        var parentId = this.FindParentId(id);
        return -this.ParentId[parentId];
    }

    public bool CheckSameGroup(int x, int y)
    {
        return this.FindParentId(x) == this.FindParentId(y);
    }

    public void UniteMembers(int x, int y)
    {
        var xParentId = this.FindParentId(x);
        var yParentId = this.FindParentId(y);

        if (xParentId == yParentId)
        {
            return;
        }


        if (this.ParentId[xParentId] < this.ParentId[xParentId])
        {
            var tmp = xParentId;
            xParentId = yParentId;
            yParentId = tmp;
        }

        this.ParentId[xParentId] += this.ParentId[yParentId];
        this.ParentId[yParentId] = xParentId;
    }

}

Measured memory_bytes: 32928
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n, a[100];
    cin>>n;
    for (int i=0; i<n; i++) cin>>a[i];
    for (int i=0; i<n; i++)
    {
        for (int j=i; a[j-1]>a[j] && j>0; j--)
        {
            swap(a[j-1], a[j]);
        }
        for (int j=0; j<n; j++)
        {
            if (j!=n-1) cout<<a[j]<<' ';
            else cout<<a[j]<<'\n';
        }
    }
    return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    bool ans = false;
    for(int i=1;i<10;i++) for(int j=1;j<10;j++) if(i * j == N) ans = true;
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
n, a, b = [int(i) for i in input().split()]

# 勝ち負けが決まるのはAB######か#######ABのようになる時
# 勝負はAとBの距離、そして背後の余白マスのみに依存
# どっちに動こうが関係ない
if (a - b) % 2 == 0:
    print("Alice")
else:
    print("Borys")


Measured memory_bytes: 2940
#include <stdio.h>

int x,box[50];

int hattuken(int y,int z) {
  int retan;
  if(z==0) return 1;
  if(y>=x) return 0;
  retan=hattuken(y+1,z)|| hattuken(y+1,z-box[y]);
  return retan;
}


int main()
{
  int i,j,comp;

  scanf("%d",&x);
  for(i=0;i<x;i++){
    scanf("%d",&box[i]);
  }

  scanf("%d",&j);
  for(i=0;i<j;i++){
    scanf("%d",&comp);
    if(hattuken(0,comp)){
      printf("yes\n");
    }
    else printf("no\n");
  }

  return 0;
}



Measured memory_bytes: 2140
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int x,y,s;
  int a,b,maxSum;
  while(true){
    cin >> x >> y >> s;
    if(x == 0 && y == 0 && s == 0) break;
    maxSum = -1;
    for(int i = 1; i <= s; i++){
      for(int j = 1; j <= s; j++){
        if((i*(100+x)/100)+ (j*(100+x)/100) != s) continue;
        else maxSum = max(maxSum,( (i*(100+y)/100) + j*(100+y)/100 ) );
      }
    }
    cout << maxSum << endl;
  }
}



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

int main() {
  int h, w;
  cin >> h >> w;
  
  vector<string> a(h);
  for (int i = 0; i < h; i++) {
    cin >> a.at(i);
  }
  
  vector<bool> row(h, false);
  vector<bool> col(w, false);
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (a.at(i).at(j) == '#') {
        row.at(i) = true;
        col.at(j) = true;
      }
    }
  }
  
  for (int i = 0; i < h; i++) {
    if (row.at(i)) {
      for (int j = 0; j < w; j++) {
        if (col.at(j)) {
          cout << a.at(i).at(j);
        }
      }
      cout << endl;
    }
  }
}

Measured memory_bytes: 256
function Main(input){
	input = input.split("\n");
	var mem = input[0].split(" ").map(Number);
	var arr = input[1].split(" ").map(Number);
	var sum = arrsum(arr);
	var n = sum/4/mem[1];
	var ans = 0
	for(var i=0;i<arr.length;i++){
		if(arr[i]>=n) ans++;
	}
	console.log(ans>=mem[1]?"Yes":"No")
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
function arrsum(arr){
    var sum = 0;
    for (var i=0,len=arr.length; i<len; ++i) {
        sum += arr[i]-0;
    }
    return sum;
}

Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

using int128 = __int128_t;
using uint128 = __uint128_t;
ostream &operator<<(ostream &os, int128 value) {
    ostream::sentry s(os);
    if (s) {
        uint128 tmp = value < 0 ? -value : value;
        char buffer[128];
        char *d = end(buffer);
        do {
            --d;
            *d = "0123456789"[tmp % 10];
            tmp /= 10;
        } while (tmp != 0);
        if (value < 0) --d, *d = '-';
        int len = end(buffer) - d;
        if (os.rdbuf()->sputn(d, len) != len) {
            os.setstate(ios_base::badbit);
        }
    }
    return os;
}

ll f(ll b, ll n) {
    if(n < b) return n;
    return f(b, n/b) + n%b;
}

int main(void) {
    ll n, s;
    cin >> n >> s;

    int128 t = n-s;
    vector<int128> v;
    for(int128 i=1; i*i<=t; ++i) {
        if(t%i == 0) {
            v.push_back(i);
            if(t/i != i) v.push_back((n-s)/i);
        }        
    }
    v.push_back(1);
    v.push_back(s);
    sort(ALL(v));
    dump(v);

    int128 ans = INF;
    for(auto i: v) if(f(i+1, n) == s) chmin(ans, i+1);
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int N;
vector<int> G[100000];

int d[100000];
int pre[100000];
void solve(){
	queue<int> q;
	q.push(0);
	reps(i, N - 1){
		d[i] = INF;
	}
	while(!q.empty()){
		int n = q.front(); q.pop();
		rep(i, G[n].size()){
			int to = G[n][i];
			if(d[to] > d[n] + 1){
				d[to] = d[n] + 1;
				pre[to] = n;
				q.push(to);
			}
		}
	}
	int cost = (d[N - 1] - 1) / 2;
	int lim = N - 1;
	while(cost--){
		lim = pre[lim];
	}
	q.push(0);
	reps(i, N - 1){
		d[i] = INF;
	}
	int cnt = 1;
	while(!q.empty()){
		int n = q.front(); q.pop();
		rep(i, G[n].size()){
			int to = G[n][i];
			if(to == lim) continue;
			if(d[to] > d[n] + 1){
				d[to] = d[n] + 1;
				cnt++;
				q.push(to);
			}
		}
	}
	if(2 * cnt > N)
		cout<<"Fennec"<<endl;
	else
		cout<<"Snuke"<<endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin>>N;
	rep(i, N - 1) {
		int a, b;
		cin >> a >> b;
		a--;b--;
		G[a].pub(b);
		G[b].pub(a);
	}
	solve();
	return 0;
}


Measured memory_bytes: 6656
unittest
{
	assert( [ "6 5", "4 7 10 6 5" ].parse.expand.solve == 8 );
	assert( [ "10 5", "4 7 10 6 5" ].parse.expand.solve == 9 );
	assert( [ "100 0", "" ].parse.expand.solve == 100 );
	
	assert( [ "1 2", "1 2" ].parse.expand.solve == 0 );		// 追加ケース
	assert( [ "100 2", "99 100" ].parse.expand.solve == 101 );		// 追加ケース
}



import std.algorithm;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto xn = input.front.split.to!( long[] );
	input.popFront;
	auto ps = input.front.split.to!( long[] );
	return tuple( xn[ 0 ], ps );
}

auto solve( long x, long[] ps )
{
	auto ans = 0L;
	auto d = x;
	auto ps_s = ps.sort();
	foreach( i; 1L .. 102L )
	{
		if( !ps_s.equalRange( i ).empty ) continue;
		auto dd = abs( x - i );
		if( dd < d )
		{
			d = dd;
			ans = i;
		}
	}
	return ans;
}


Measured memory_bytes: 2788
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;


int main(){
   int sx,sy,tx,ty;
   char sw,sh,tw,th;
   cin>>sx>>sy>>tx>>ty;
   if(tx-sx>=0){
       sw='R';
       tw='L';
   }
   else {
       sw='L';
       tw='R';
   }
   if(ty-sy>=0){
       sh='U';
       th='D';
   }
   else {
       sh='D';
       th='U';
   }
   for(int i=0;i<abs(tx-sx);i++)cout<<sw;
   for(int i=0;i<abs(ty-sy);i++)cout<<sh;

   for(int i=0;i<abs(tx-sx);i++)cout<<tw;
   for(int i=0;i<abs(ty-sy);i++)cout<<th;
   
   cout<<tw;
   for(int i=0;i<abs(ty-sy)+1;i++)cout<<sh;
   for(int i=0;i<abs(tx-sx)+1;i++)cout<<sw;
   cout<<th;

   cout<<sw;
   for(int i=0;i<abs(ty-sy)+1;i++)cout<<th;
   for(int i=0;i<abs(tx-sx)+1;i++)cout<<tw;
   cout<<sh<<endl;
}
   


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

namespace Program {
    class Program {
        static void Main(string[] args) {
            var cr = new CR();
            var N = cr.i;
            var Z = cr.i;
            var W = cr.i;

            int a0 = -1, a1 = 0;
            for (int i = 0; i < N - 1; i++)a0 = cr.i;
            a1 = cr.i;

            int ans;
            if (N == 1) {
                ans = Math.Abs(a1 - W);
            } else {
                var case1 = Math.Abs(a0 - a1);
                var case2 = Math.Abs(a1 - W);
                ans = Math.Max(case1, case2);
            }
            Console.WriteLine(ans);
        }

        private class CR {
            System.IO.TextReader _r;
            Queue<string> _d;
            public CR() { _r = Console.In; _d = new Queue<string>(); }
            string Read() {
                while (_d.Count == 0)
                    foreach (var v in _r.ReadLine().Split(' '))
                        if (v != "")_d.Enqueue(v);
                return _d.Dequeue();
            }
            public int i { get { return int.Parse(Read()); } }
            public string s { get { return Read(); } }
        }
    }
}

Measured memory_bytes: 13304
#include <bits/stdc++.h>
#define N 500003
#define MOD 1000000007
#define int long long
using namespace std;


signed main()
{
    int n;
    cin>>n;
    int k;
    cin>>k;
    int w[n],v[n];
    for(int i=0;i<n;i++){
        cin>>w[i];
       // cout<<w[i]<<endl;
        cin>>v[i];
    }
    int dp[n+1][k+1];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=k;j++){
            if(i==0 || j==0)dp[i][j]=0;
            else{
                if(w[i-1]>j){
                    dp[i][j]=dp[i-1][j];
                }
                else{
                    dp[i][j]=max(dp[i-1][j],v[i-1]+dp[i-1][j-w[i-1]]);

                }
            }

        }
     //   cout<<endl;
    }
    cout<<dp[n][k];

}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N, M, K;
string S, T;
vector<int> A;
int a,b;
//=============================
void input()
{
    cin>>N;
}
//=============================
void func() {}
//=============================
void solve()
{
    cout<<(N<=999 ? "ABC" : "ABD")<<endl;
}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

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

int main()
{
	int n,m,inp,div,taro_sum,hanako_sum,flag=0;
	while(cin>>n>>m, n!=0 && m!=0)
	{
		taro_sum=0;
		hanako_sum=0;
		flag=0;
		vector<int> taro,hanako;
		for(int i=0;i<n;i++)
		{
			cin>>inp;
			taro.push_back(inp);
		}
		for(int i=0;i<m;i++)
		{
			cin>>inp;
			hanako.push_back(inp);
		}

		sort(taro.begin(),taro.end());
		sort(hanako.begin(),hanako.end());
		for(int i=0;i<n;i++)
			taro_sum+=taro[i];
		for(int i=0;i<m;i++)
			hanako_sum+=hanako[i];

		div=taro_sum-hanako_sum;
		if(div%2==0)
		{
			if(div>=0)//太郎の和のが大きいor等しい
			{
				for(int i=0;i<m;i++)
				{
					for(int j=0;j<n;j++)
						if(hanako[i]+div/2==taro[j])
						{
							cout<<taro[j]<<" "<<hanako[i]<<endl;
							flag=1;
							break;
						}
					if(flag==1)
						break;
				}
			}
			else
			{
				div=hanako_sum-taro_sum;
				for(int i=0;i<n;i++)
				{
					for(int j=0;j<m;j++)
						if(taro[i]+div/2==hanako[j])
						{
							cout<<taro[i]<<" "<<hanako[j]<<endl;
							flag=1;
							break;
						}
					if(flag==1)
						break;
				}
			}
		}
		if(flag==0)
			cout<<-1<<endl;
	}
}

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

int dp[105][4][2];

int main(){
  	string s;
  	int K;
  	cin >> s >> K;
  	
  	int n = s.size();
  	dp[0][0][0] = 1;
  	
  	rep(i, n)rep(j, 4)rep(k, 2){
    	int nd = s[i]-'0';
      	rep(d, 10){
        	int ni = i+1, nj = j, nk = k;
          	if(d != 0) nj++;
          	if(nj > K) continue;
          	if(k == 0){
            	if(d > nd) continue;
              	if(d < nd) nk = 1;
            }
          	dp[ni][nj][nk] += dp[i][j][k];
        }
    }
  	int ans = dp[n][K][0] + dp[n][K][1];
  	cout << ans << endl;
}

Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var nums = new long[S.Length+1];
            for (var i = 0; i < S.Length; i++)
            {
                if (S[i] == '<')
                {
                    nums[i + 1] = Math.Max(nums[i + 1], nums[i] + 1);
                }
            }
            for (var i = S.Length-1; 0<=i; i--)
            {
                if (S[i] == '>')
                {
                    nums[i] = Math.Max(nums[i], nums[i+1] + 1);
                }
            }
            Console.WriteLine(nums.Sum());
        }
    }
}

Measured memory_bytes: 16864
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

//A[N - M]を青木がとれるか
bool is_aoki_get(vll& A, ll x, int N, int M) {
    ll y = A[M];
    if (A[N - 1] <= x) return false;
    if (y < x) return true;
    //lower_bound(A.begin(), A.end(), x);
    auto it = lower_bound(A.begin(), A.end(), x - abs(x - y));
    auto t = distance(A.begin(), it);
    if (abs(M - t) + 1 < N - M ) return true;
    return false;
}

//aokiがとれる最大位置
int binsearch(vll& A, int N, ll x) {
    int l = -1, r = N;
    while (r - l > 1) {
        int m = (l + r) / 2;
        if (is_aoki_get(A, x, N, m) == true) 
            l = m;
        else
            r = m;
        
    }
    return l;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N, Q;
    cin >> N >> Q;
    vll A(N);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end());
    vll X(Q);
    rep(i, Q) cin >> X[i];
    vll S(N + 1);
    vll S_even(N + 1);
    vll S_odd(N + 1);
    rep(i, N) {
        S[i + 1] = S[i] + A[i];
        if ((i + 1) % 2 == 0) {
            S_even[(i + 1) / 2] = S_even[(i + 1) / 2 - 1] + A[i];
        }
        else {
            S_odd[(i + 1) / 2 + 1] = S_odd[(i + 1) / 2] + A[i];
        }
    }
    rep(i, Q) {
        int M = binsearch(A, N, X[i]);
        ll ans;
        if (M < 0) {
            if (N % 2 == 0) {
                ans = S_even[N / 2];
            }
            else {
                ans = S_odd[N / 2 + 1];
            }
        }
        else {
            ans = S[N] - S[M + 1];
            int alt_start = max(0LL, M - (N - 1 - M) + 1);
            if (alt_start % 2 == 0) {
                ans += S_even[alt_start / 2];
            }
            else {
                ans += S_odd[alt_start / 2 + 1];
            }
        }
        cout << ans << endl;
    }
   
    return 0;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 924844033
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
int a[114][114];
int b[114][114];
int c[114][114];
priority_queue<int> c1[114][114];

struct BipartiteMatching {
  vector< vector< int > > graph;
  vector< int > match, alive, used;
  int timestamp;

  BipartiteMatching(int n) : graph(n), alive(n, 1), used(n, 0), match(n, -1), timestamp(0) {}

  void add_edge(int u, int v) {
    graph[u].push_back(v);
    graph[v].push_back(u);
  }

  bool dfs(int idx) {
    used[idx] = timestamp;
    for(auto &to : graph[idx]) {
      int to_match = match[to];
      if(alive[to] == 0) continue;
      if(to_match == -1 || (used[to_match] != timestamp && dfs(to_match))) {
        match[idx] = to;
        match[to] = idx;
        return true;
      }
    }
    return false;
  }

  int bipartite_matching() {
    int ret = 0;
    for(int i = 0; i < graph.size(); i++) {
      if(alive[i] == 0) continue;
      if(match[i] == -1) {
        ++timestamp;
        ret += dfs(i);
      }
    }
    return ret;
  }

  void output() {
    for(int i = 0; i < graph.size(); i++) {
      if(i < match[i]) {
        cout << i << "-" << match[i] << endl;
      }
    }
  }
};

signed main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>a[i][j];
			a[i][j]--;
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			int k = a[i][j] / m;
			c1[i][k].push(a[i][j]);
		}
	}
	for(int tim = 0; tim < m; tim++){
		BipartiteMatching bm(2*n);
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if( !c1[i][j].empty() )bm.add_edge(i,j+n);
			}
		}
		bm.bipartite_matching();
		for(int i = 0; i < bm.graph.size(); i++) {
			if(i < bm.match[i]) {
				int num=-1;
				if(!c1[i][bm.match[i]-n].empty())num = c1[i][bm.match[i]-n].top(); c1[i][bm.match[i]-n].pop(); 
				b[i][tim] = num;
			}
		}
    }
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cout<<b[i][j]+1<<" ";
		}
		cout<<endl;
	}
	for(int i=0;i<m;i++){
		vector<int> vec;
		for(int j=0;j<n;j++){
			vec.pb(b[j][i]);
		}
		sort(vec.begin(),vec.end());
		for(int j=0;j<n;j++){
			c[j][i]=vec[j];
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cout<<c[i][j]+1<<" ";
		}
		cout<<endl;
	}
	return 0;
}

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

ll n, ans;

bool cmp (ll a, ll b) {
	return (a>b);
}

int main() {
	cin>>n;
	ll a[n];
	for (int i=0; i<n; i++) {
		cin>>a[i];
	}
	sort(a, a+n, cmp);
	ans=a[0];
	ll sisa=(n-2)/2;
	for (int i=1; i<=sisa; i++) {
		ans+=2*a[i];
	}
	if (n%2==1) ans+=a[sisa+1];
	cout<<ans<<endl;
}



Measured memory_bytes: 5144
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
int main(){
  int n;cin>>n;
  vector<pii> a(n),b(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i).first>>a.at(i).second;
  }
  for(int i=0;i<n;i++){
    cin>>b.at(i).first>>b.at(i).second;
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  int count=0;
  for(int i=0;i<n;i++){
    int j=0,k=-1,ma=-1;
    while(j<n){
      if(a.at(j).first<0){
        j++;
        continue;
      }
      if(b.at(i).first>a.at(j).first&&b.at(i).second>a.at(j).second){
        if(ma<=a.at(j).second){
          ma=a.at(j).second;
          k=j;
        }
      }
      j++;
    }
    if(k>=0){
      a.at(k).first=-1;
      count++;
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
   int n,a[100000],i,j,m,z;
    
   scanf("%d",&n);
   m=1;
   for (i=0;i<n;i++) {
      scanf("%d",&a[i]);
      while (m<a[i]) m*=2;
   }
   for (i=1;i<m;i*=2) {
       for (z=j=0;j<n;j++)
          if ((a[j]&i)==0) z++;
       if (z!=n && 3*z!=n) {
          puts("No");
          return 0;
       }
   }
   puts("Yes");
   return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
string s;
int n;
int main()
{
	cin>>n>>s;
	int pos=s.find("ABC");
	int nc=0;
	while(pos!=string::npos){
		nc++;
		pos=s.find("ABC",pos+3);
	}
	cout<<nc<<endl; 
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	ll S;
	ll X1, Y1, X2, Y2, X3, Y3;

	cin >> S;
	X1 = 0;
	Y1 = 0;
	X2 = (ll)1e9;
	Y2 = 1;
	X3 = (ll)1e9 - (S + (ll)1e9 - 1) % (ll)1e9 - 1;
	Y3 = (S + (ll)1e9 - 1) / (ll)1e9;

	printf("%lld %lld %lld %lld %lld %lld\n", X1, Y1, X2, Y2, X3, Y3);

	return 0;
}


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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

ll gcd(ll x, ll y)
{
	return y==0 ? x:gcd(y,x % y);
}

ll lcm(ll number1,ll number2){
	return number1 * number2 / gcd(number1,number2);	
}

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

    vector<int> a(N);
    ll ans = 0;
    rep(i,N)
    {
        cin >> a[i];
        ans += a[i]-1;
    }
    cout << ans << endl;


}


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

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}

//v.erase(unique(v.begin(),v.end()),v.end());


int main(){
	int ans=0;
	rep(i,5){
		int t;
		cin>>t;
		if(t<40) t=40;
		ans+=t;
	}
	cout<<ans/5<<endl;
}

Measured memory_bytes: 1160
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

struct restaurant_t {
    int num = 0;
    int score;
};

struct city_t {
    vector<restaurant_t>  restaurants;
};

bool restaurantComparer(restaurant_t a, restaurant_t b)
{
    return (a.score > b.score);
}

int main(int argc, const char * argv[]) {
    int N = 0;
    cin >> N;
    //vector<city_t> cities;
    map<string, city_t> city_map;
    
    for(int i = 0; i < N; i++) {
        string name;
        int score;
        cin >> name >> score;
        //city_t city = {i+1, name, score};
        restaurant_t restaurant = {i+1, score};
        city_map[name].restaurants.push_back(restaurant);
    }
    
    for(auto p : city_map) {
        sort(p.second.restaurants.begin(), p.second.restaurants.end(), restaurantComparer);
        for(auto r : p.second.restaurants) {
            cout << r.num << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import math
import numpy as np
from functools import reduce


def spaceinput():
    return list(map(int,input().split(" ")))


def _gcd(*numbers):
    return reduce(math.gcd, numbers)

#def gcd(numbers):
#    return reduce(np.gcd, numbers)

def gcd(a, b):
    if not b:
        return a
    else:
        return gcd(b, a % b)


def gcd_n(numbers):
  '''Returns GCD of given n numbers.
  Argument: numbers - List of given numbers
  '''
  return reduce(lambda x, y: gcd(x, y), numbers)



N,X=spaceinput()

x=spaceinput()

x.append(X)
x=sorted(x)
d=[]
for i,xx in enumerate(x[:-1]):
    d.append(x[i+1]-x[i])

#print(d)

#print( np.gcd(12, 20))
print(gcd_n(d))

Measured memory_bytes: 23128
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    if (n < 1000)
        cout << "ABC";
    else
        cout << "ABD";
}


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

namespace codeTester.contest190622
{
    class ProblemA
    {
        static string value = "";
        static string answer = "";

        public static void Main(string[] args)
        {
            Input();
            Logic();
            Output();
        }

        static void Input()
        {
            value = Console.ReadLine();
        }

        static void Logic()
        {
            for (int i = 0; i < 3; i++)
            {
                if (value[i] == value[i + 1])
                {
                    answer = "Bad";
                    return;
                }
            }
            answer = "Good";
        }

        static void Output()
        {
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>
#include <string>
#include <set>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int> ;
using vl = vector<ll>;

class unionfind{
    public:
    vector<int> par,rank;

    unionfind(int n){
        par.resize(n);
        rank.resize(n);

        rep(i,n){
            par[i] = i;
            rank[i] = 0;
        }
    }

    int find(int x){
        if(par[x] == x) return x;
        else return par[x] = find(par[x]);
    }

    void unite(int x,int y){
        x = find(x);
        y = find(y);
        if(x == y) return;

        if(rank[x] < rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
    }

    bool same(int x,int y){
        return find(x) == find(y);
    }
};

int main(){
    int n,m;
    cin >> n >> m;
    unionfind uf(n+10);
    int a,b;
    rep(i,m){
        cin >> a >> b;
        a--; b--;
        uf.unite(a,b);
    }

    rep(i,n){
        uf.find(i);
    }

    map<int,int> mp;
    rep(i,n){
        //cout << i << " " << uf.par[i] << endl;
        mp[uf.par[i]]++;
    }
    int ans = 0;
    for(auto e: mp){
        //cout << e.first << " " << e.second << endl;
        ans = max(ans,e.second);
    }

    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 14268
from heapq import heappush, heappop

def dijkstra(graph:list, node:int, start:int) -> list:
    # 未探索のノードは距離INF
    INF = float("inf")
    dist = [INF]*node
    
    # 始点ノードの距離を0とし、dfsのためのpriority queを作成
    dist[start] = 0
    heap = [(0,start)]
    
    # 未探索のノードをpriority queueに入れる
    while heap:
        cost, cur_node = heappop(heap)
        
        for nex_cost, nex_node in graph[cur_node]:
            dist_cand = dist[cur_node] + nex_cost
            if dist_cand < dist[nex_node]:
                dist[nex_node] = dist_cand
                heappush(heap, (dist[nex_node], nex_node))
    
    return dist

# 全体のグラフ作成
N,M = map(int, input().split())
adj_list = [[] for _ in range(N)]
AB = [tuple(map(int, input().split())) for _ in range(M)]

for a,b in AB:
    a -= 1
    b -= 1
    adj_list[a].append((1,b))
    adj_list[b].append((1,a))

INF = float("inf")
ans = 0

# 1辺を除いてダイクストラ
for a,b in AB:
    a -= 1
    b -= 1
    
    adj_list[a].remove((1,b))
    adj_list[b].remove((1,a))
    
    dist = dijkstra(adj_list, N, 0)
    
    if INF in dist:
        ans += 1
        
    adj_list[a].append((1,b))
    adj_list[b].append((1,a))
    

print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main() {
	long long N,M,X,num1,num2,ans;
	cin>>N>>M>>X;
  num1=0;
	num2=0;
	rep(i,M){
	  long long A;
		cin>>A;
		if(A<X)num1++;
		else num2++;
	}
	ans=min(num1,num2);
	cout<<ans<<endl;
}

Measured memory_bytes: 3624
// Best practice

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <functional> // for less 

#define int         long long
#define pb          emplace_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

#define fbo find_by_order
#define ook order_of_key

signed main() {
   tezz
   
  int n,m;
  cin >> n >> m;
  int x=n*500;
  if(x>=m){
      cout << "Yes";
  }
  else{
      cout << "No";
  }
   return 0;
}

//()()()))


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  string S;
  cin >> S;

  bool result = true;
  rep (i, S.size()) {
    if (i % 2 == 0 and S[i] == 'L') result = false;
    if (i % 2 == 1 and S[i] == 'R') result = false;
  }

  cout << (result ? "Yes" : "No") << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

int main() {
    long long int W, H, x, y;
    cin >> W >> H >> x >> y;
    if(x*2==W && y*2==H){
        cout << W*H/2.0 << " " << 1 << endl;
    }
    else{
        cout << W*H/2.0 << " " << 0 << endl;
    }

}

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

int n,h;
int arr[200005];
int dp[200005];

int main() {
    cin >> n;
    for (int i=1;i<=n;i++) {
        cin >> arr[i];
    }

    dp[2]=dp[1]+abs(arr[2]-arr[1]);
    for (int i=3;i<=n;i++) {
        dp[i]=min(dp[i-2]+abs(arr[i]-arr[i-2]),dp[i-1]+abs(arr[i]-arr[i-1]));
    }
    cout << dp[n];

}




Measured memory_bytes: 4396
#include <bits/stdc++.h>
    using namespace std;
    typedef long long int  ll;
    const int mod=1e9+7;
    
     ll fp(ll b,ll p){ 
	if(p==0) return 1;
	if(p&1) return (b*fp(b,p-1))%mod;
	return fp((b*b)%mod,p/2);
}

    ll  inv(ll a){ 
          return fp(a,mod-2);
    } 
    
   
 
    int main()
    {
        int n,a[10005];
        ll lcm=1,ans=0;
        map<int,int>cnt,freq;
        cin>>n;
        for(int i=0;i<n;i++){ 
            cin>>a[i];
            int x=a[i];
            cnt.clear();
            for(int j=2;j*j<=x;j++){ 
                while(x%j==0){ 
                    cnt[j]++;
                    x=x/j;
                } 
            }
            if(x!=1)cnt[x]++; 
            for(auto j:cnt){ 
             freq[j.first]=max(freq[j.first],j.second);
            } 
        } 
        for(auto i:freq){ 
            for(int j=1;j<=i.second;j++) lcm=(lcm*i.first)%mod;
        } 
        
        //cout<<lcm<<'\n';
        //ans+=(lcm/a[i]);
        for(int i=0;i<n;i++){
           ll add=(lcm*inv(a[i]))%mod;
           ans=(ans+add)%mod;
        } 
        cout<<ans<<'\n';
            
     
        return 0;
    }

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>void add(T &a, const T &b){a += b; a %= mod;}

int m, k;
int x, l;
void rec(vi a, int i){
  if(i == l){
    map<int,set<int>> mp;
    rep(j,l) mp[a[j]].insert(j);
    bool f = true;
    for(auto p : mp){
      if(p.second.size() != 2) f = false;
    }
    if(f){
      bool g = true;
      for(auto p : mp){
	int b = -1, c;
	for(auto ss : p.second){
	  if(b == -1) b = ss;
	  else c = ss;
	}
	int tmp = 0;
	FOR(j,b,c+1) tmp^=a[j];
	if(tmp != k) g = false;
      }
      if(g){
	dump(a);
      }
    }
  }else{
    rep(j,x){
      a[i] = j;
      rec(a,i+1);
    }
  }
}

template<typename T>
T mypow(T a, ll n){
  bool f = (n < 0);
  n = abs(n);
  
  T ans(1);
  while(n){
    if(n&1) ans *= a;
    a *= a;
    n = n >> 1;
  }

  if(f) ans = T(1) / ans;
  return ans;
}

signed main(){
  cin >> m >> k;
  x = mypow(2ll,m); l = mypow(2ll,m+1);
  // vi a(l);
  //rec(a,0);
  if(k == 0){
    rep(i,l){
      if(i == 0) cout << i;
      else cout << " " << i/2;
    }
    cout << endl;
  }else if(x <= k or (m == 1 and k == 1)){
    cout << -1 << endl;
  }else{
    rep(i,x){
      if(i != k) cout << i << " ";
    }
    cout << k << " ";
    ROF(i,x,0){
      if(i != k) cout << i << " ";
    }
    cout << k << endl;
  }
}


Measured memory_bytes: 1792
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int a[100010];

int main(void){
	int i;

	cin.tie(0);
	ios_base::sync_with_stdio(false);

	int N;
	cin >> N;
	for(i=1;i<=N;i++) cin >> a[i];
	int ans=0;
	for(i=1;i<=N;i++){
		if(a[i]!=0 && a[a[i]]==i){
			ans++;
			a[i]=0;
			a[a[i]]=0;
		}
	}

	cout << ans << endl;



	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int ace[222222],n;
priority_queue<pair<int,pair<int,int> > > q;
int ancestor(int x){
	return x-ace[x]?ace[x]=ancestor(ace[x]):x;
}
int main(){
	int m;
	scanf("%d%d",&n,&m);
	for(int i=0; i<n; i++)
		ace[i] = i;
	while(m--){
		int A,B,C;
		scanf("%d%d%d",&A,&B,&C);
		q.push(make_pair(-C,make_pair(A,B)));
		q.push(make_pair(-(C+1),make_pair(B,(A+1)%n)));
	}
	long long int res = 0;
	while(!q.empty()){
		pair<int,pair<int,int> > pr = q.top();
		q.pop();
		int C = -pr.first, A = pr.second.first, B = pr.second.second;
		if(ancestor(A) == ancestor(B))
			continue;
		res += C;
		q.push(make_pair(-(C+2),make_pair((A+1)%n,(B+1)%n)));
		ace[ancestor(A)] = ancestor(B);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 9580
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};



signed main(){
  int N;
  cin>>N;
  if(N>=1000){
    cout<<"ABD";
  }else{
    cout<<"ABC";
  }

  return 0;
}


Measured memory_bytes: 256
n, m = map(int, raw_input().split())
#print n, m

ans_x, ans_y, ans_z = -1, -1, -1
for x in range(0, n+1):
  for y in range(0, n+1-x):
    #print x, y
    sum = x*10000 + y*5000 + (n-x-y)*1000
    if sum == m:
      ans_x, ans_y, ans_z = x, y, n-x-y
      break
  else:
    continue
  break
print ans_x, ans_y, ans_z


"""
for x in range(0, n+1):
  for y in range(0, n+1-x):
    #print x, y
    sum = x*10000 + y*5000 + (n-x-y)*1000
    if sum == m:
      ans_x, ans_y, ans_z = x, y, n-x-y
      break
    else:
    continue
  break
"""

Measured memory_bytes: 2692
/* ex5_3
   YSK722 */

#include <stdio.h>

int main(void){
    int height, width;
    char box[100][100][3];
    scanf("%d %d", &height, &width);
    // 白黒を読み取る
    for (int i = 0; i < height; i++){
        for (int j = 0; j < width; j++){
            scanf(" %c", &box[i][j][0]);
        }
    }
    /* i行の要素が全て白のとき、2つめのboxのi行目の
    要素をすべて"n"にし、それ以外の時はすべて"y"にする */
    for (int i = 0; i < height; i++){
        for (int j = 0; j < width; j++){
            if (box[i][j][0] == '#'){
                for (int k = 0; k < width; k++){
                    box[i][k][1] = 'y';
                }
                break;
            }
            box[i][j][1] = 'n';
        }
    }
    /* j列の要素が全て白のとき、3つめのboxのj列目の
    要素をすべて"n"にし、それ以外の時はすべて"y"にする */
    for (int j = 0; j < width; j++){
        for (int i = 0; i < height; i++){
            if (box[i][j][0] == '#'){
                for (int k = 0; k < height; k++){
                    box[k][j][2] = 'y';
                }
                break;
            }
            box[i][j][2] = 'n';
        }
    }
    /* 2つめ、3つめのboxの対応する要素がどちらとも"y"のときだけ
       boxの要素を出力する */
    for (int i = 0; i < height; i++){
        for (int j = 0; j < width; j++){
            if (box[i][j][1] == 'y' && box[i][j][2] == 'y'){
                printf("%c", box[i][j][0]);
            }
        }
        printf("\n");
    }
    return 0;
}

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

    int main() {
    	int N;
    	cin>>N;
    	
    	vector<int> vec(N+1);
    	for (int i = 0 ;i<N;i++){
    		cin >> vec.at(i); 
    	}
    	sort(vec.begin(), vec.end()); 
    	
    	int A=0;
    	int B=0;
    	
    	for (int i = N; i>0 ; i--){
    	  if (i%2 == N%2){
    	  	A += vec.at(i);
    	  }else{
    	  	B += vec.at(i);
    	  }
    	}
    	cout << A-B;
    }

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
class Program
    {
    	static void Main(string[] args)
    	{
    		long n = long.Parse(Console.ReadLine());
            if (n < 10)
            {
                Console.WriteLine(n);
                return;
            }
            bool allNine = true;
            int count = 0;
            for (count = 0;; count++)
            {
                if (n % 10 != 9) allNine = false;
                n = n / 10;
                if (n < 10) break;
            }
            if (allNine) Console.WriteLine(9 * count + n + 9);
            else Console.WriteLine(9 * count + n + 8);
            
        }
    }
    //mcs Main.cs
    //mono Main.exe

Measured memory_bytes: 11092
import java.io.*;

public class Main {
  public static void main(String... args) {
    BufferedReader br = new BufferedReader(
      new InputStreamReader(System.in));

    try {
      String[] line = br.readLine().split(" ");
      int n = Integer.parseInt(line[0]);
      int k = Integer.parseInt(line[1]);
      int q = Integer.parseInt(line[2]);
      int[] point = new int[n];

      for(int i = 0; i < q; i++) {
          point[Integer.parseInt(br.readLine()) - 1] += 1; 
      }

      for(int i =0; i < n; i++){
        point[i] += k - q;
      }

      for(int i = 0; i < point.length; i++) {
        if(point[i] <= 0) {
          System.out.println("No");
        } else {
          System.out.println("Yes");
        }
      }
      br.close();
    } catch(IOException e) {
      e.printStackTrace();
    }
  }
}

Measured memory_bytes: 55612
from bisect import bisect_right, bisect_left

n = int(input())
s = list(map(int, input().split()))
q = int(input())
t = list(map(int, input().split()))

cnt = 0
for num in t:
    if bisect_right(s, num) != bisect_left(s, num):
        cnt += 1
print(cnt)


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

const int INF = 1e9 + 7;

int main() {
  int n, m;
  cin >> n >> m;
  int yen[m], open_num[m];
  vector<int> opens[m];
  for ( int i = 0; i < m; i++ ) {
    cin >> yen[i] >> open_num[i];
    for ( int k = 0; k < open_num[i]; k++ ) {
      int box;
      cin >> box;
      box--;
      opens[i].push_back(box);
    }
  }

  vector<int> dp(4097, INF);
  dp[0] = 0;
  for ( int i = 0; i < m; i++ ) {
    int open_kind = 0;
    // 鍵iで開けられる宝箱のbit
    for ( int k = 0; k < open_num[i]; k++ ) {
      open_kind |= (1 << opens[i][k]);
    }
    // 鍵iを用いるべきか、各セットにおいて判定
    for ( int bit = 0; bit < (1 << n); bit++ ) {
      dp[bit | open_kind] = min(dp[bit | open_kind], dp[bit] + yen[i]);
    }
  }

  int ans = ( dp[(1 << n) - 1] != INF ) ? dp[(1 << n) - 1] : -1;
  cout << ans << endl;
  return 0;
}


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

#define N 8

void funk(int);

int row[N],col[N],A[2 * N - 1],B[2 * N - 1];

int main() {
  int i,x,a,b;

  scanf("%d",&x);
  for(i = 0; i < x; i++) {
    scanf("%d%d",&a,&b);
    row[a] = b + 1;
    col[b] = A[a + b] = B[a - b + 7] = 1;
  }

  funk(0);

  return 0;
}

void funk(int a) {
  int i,j;

  if(a == N) {
    for(i = 0; i < N; i++) {
      for(j = 0; j < N; j++) {
	printf("%c",(row[i] == j + 1) ? 'Q' : '.');
      }
      putchar('\n');
    }
    return;
  }

  if(row[a]) {
    funk(a + 1);
    return;
  }else{
    for(i = 0; i < N; i++) {
      if(col[i] || A[a + i] || B[a - i + N - 1]) {
	continue;
      }
      row[a] = i + 1;
      col[i] = A[a + i] = B[a - i + N - 1] = 1;
      funk(a + 1);
      row[a] = col[i] = A[a + i] = B[a - i + N - 1] = 0;
    }
  }
}



Measured memory_bytes: 2104
n,m = map(int, input().split())
t = [[] for i in range(n)]
near = [-1 for i in range(n)]
near[0] = 0
c = []
for i in range(m):
    a,b = map(int, input().split())
    t[a-1].append(b-1)
    t[b-1].append(a-1)
for i in range(len(t[0])):
    near[t[0][i]] = 0
    c.append(t[0][i])
while len(c) > 0:
    e = c[0]
    for j in range(len(t[e])):
      if near[t[e][j]] == -1:
        near[t[e][j]] = e
        c.append(t[e][j])
    del c[0]
print('Yes')
for i in range(1,len(near)):
    print(near[i]+1)

Measured memory_bytes: 33788
import bisect

def solve():
    n=int(raw_input())
    m=int(raw_input())
    dist=[0]+[int(raw_input()) for _ in xrange(n-1)]+[d]
    q=[int(raw_input()) for _ in xrange(m)]
    dist.sort();

    ans=0
    for i in q:
        if bisect.bisect_left(dist,i)==n:
            l=n-1
        else:
            l=bisect.bisect_left(dist,i)
            if dist[l]!=i:
                l-=1
        r=bisect.bisect_left(dist,i)
        ans+=min(i-dist[l],dist[r]-i)

    return ans

while 1:
    d=int(raw_input())
    if d==0:break
    ans=solve()
    print ans

Measured memory_bytes: 10288