akhauriyash/Code-Regression huggingface dataset:
//  Created by conan1024hao in 2020.
//  Copyright © 2020 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao Twitter/QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e17
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef long long int LL;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????统一类型        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    string s;cin>>s;
    ll n=0;
    ll B[200002];
    memset(B,0,sizeof(B));
    ll now=0;
    for(int i=0;i<s.length();i++){
        if(s[i]=='B')now++;
        else{
            n+=now;
        }
    }
    cout<<n<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------








Measured memory_bytes: 2196
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define Max(a,b) a=max(a,b);
typedef long long ll;

using namespace std;
#define N 200010
ll n,m,a[N],cnt[N],sum[N];
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>m;
    lol(i,N)cnt[i]=0,sum[i]=0;
    lol(i,n){
	cin>>a[i];
	if(a[i]<N)cnt[a[i]]++;
    }
    lol(i,N){
	for(ll j=i-cnt[i]+1;j<=i;j++)sum[j]++;
    }
    ll ans=0;
    for(int i=1;i<=n;i++)ans+=sum[i]==0;
    lol(i,m){
	ll x,y;cin>>x>>y; x--;
	if(a[x]<=n){
	    ll p=a[x]-cnt[a[x]]+1;
	    if(p>=1){
		sum[p]--;
		if(sum[p]==0)ans++;
	    }
	    cnt[a[x]]--;
	}
	a[x]=y;
	if(a[x]<=n){
	    ll p=a[x]-cnt[a[x]];
	    if(p>=1){
		if(sum[p]==0)ans--;
		sum[p]++;
	    }
	    cnt[a[x]]++;
	}
	cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 6272
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>
#include<list>


using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;



int main() {
	string x;
	cin >> x;

	stack<char> st;
	for (int i = 0; i < x.length();i++) {
		if (!st.empty() && st.top() == 'S' && x[i] == 'T') {
			st.pop();
		}
		else {
			st.push(x[i]);
		}
	}

	cout << st.size() << endl;
}



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

typedef long long LL;

const int N=3000;

int n,a[3];

void into(){
  scanf("%d%d%d%d",&a[0],&a[1],&a[2],&n);
}

LL dp[N+9];

void Get_dp(){
  dp[0]=1;
  for (int i=0;i<3;++i)
	for (int j=a[i];j<=n;++j) dp[j]+=dp[j-a[i]];
}

void work(){
  Get_dp();
}

void outo(){
  printf("%lld\n",dp[n]);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
signed main()
{
  int a1,a2,a3;
  cin>>a1>>a2>>a3;
  if(a1+a2+a3>=22)
    	cout<<"bust";
  else
    cout<<"win";
}

Measured memory_bytes: 256
n, x = map(int, input().split())
x -= 1

def main(n, x):
    if n == 0:
        if x >= 0:
            return 1
        else:
            return 0
    if x == 0:
        return 0
    if x == 2 ** (n + 1) - 2:
        return 2 ** n
    if x < 2 ** (n + 1) - 2:
        return main(n - 1, x - 1)
    if x > 2 ** (n + 1) - 2:
        return 2 ** n + main(n - 1, x - (2 ** (n + 1) - 1))
print(main(n, x))

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

using namespace std;

#define DIM 200009
#define INF ((long long)1e18+9ll)
#define pairll pair<long long,long long>
#define fi first
#define se second
#define ld long double
#define amen exit(0)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define endl '\n'
#define y1 trymax_lox
#define y2 sijgkvdfbo
#define eps 1000000

long long i,j,k,l,n,m;

long long dp[DIM];

pairll a[DIM];

inline bool cmp(pairll a,pairll b){
    if(a.se!=b.se)return a.se<b.se;
    return a.fi<b.fi;
}

long long f[DIM];

void add(long long x,long long d){
    for(int i=x;i<DIM;i+=i&-i)f[i]=max(f[i],d);
}

long long get(long long x){
    long long res=0;

    for(int i=x;i>0;i-=i&-i)res=max(res,f[i]);

    return res;
}

vector<long long>nums;

long long pos(long long x){
    return lower_bound(nums.begin(),nums.end(),x)-nums.begin();
}

int main(){

    //freopen("threesum.in","r",stdin);
    //freopen("threesum.out","w",stdout);

    fast;

    cin>>n>>k>>l;

    if(l!=1e9){
       for(i=1;i<=k;i++)cout<<l<<' ';
       for(i=1;i<=n-k;i++)cout<<l+1<<' ';
          cout<<endl;
    }
    else{
        for(i=1;i<=k;i++)cout<<l<<' ';
        for(i=1;i<=n-k;i++)cout<<l-1<<' ';
        cout<<endl;
    }

    amen;
}

Measured memory_bytes: 1280
import sys
input = lambda: sys.stdin.readline().rstrip()
n,m=map(int,input().split())
a=[]
for _ in range(n):
    a.append([int(i) for i in input().split()])
a.sort()
ans=0 ; ind=-1 ; p=0
while ans<m:
    ind+=1
    ans+=a[ind][1]
for i in range(ind):
     p+=a[i][1]*a[i][0]
p+=a[ind][0]*(a[ind][1]-(ans-m))
print(p)
    
    

Measured memory_bytes: 56668
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

set<int> s;
vector<int> spf(1e6 + 1);

void sieve()
{
    spf[1] = 1;
    for(int i = 2; i < 1e6 + 1; i++) spf[i] = i;
    for(int i = 4; i < 1e6 + 1; i += 2) spf[i] = 2; 
    for(int i = 3; i * i < 1e6 + 1; i++)
    {
        if(spf[i] == i) for(int j = i * i; j < 1e6 + 1; j += i) if(spf[j] == j)
        	spf[j] = i; 
    }
}

bool factorise(int x)
{
    while(x != 1)
    {
        int temp = spf[x];
       	if(!s.count(temp)) s.insert(temp);
       	else return 0;
        while(x != 1 && !(x % temp)) x /= temp;
    }
    return 1;
}

int main()
{
	#ifndef ONLINE_JUDGE
	freopen(".in.txt", "r", stdin);
	freopen(".out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	sieve();
	int n; cin >> n;
	bool ok = 1;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++)
	{
		ok = factorise(a[i]);
		if(!ok) break;
	}
	if(ok)
	{
		cout << "pairwise coprime";
		return 0;
	}
	int g = a[0];
	for(int i = 1; i < n; i++) g = __gcd(g, a[i]);
	cout << (g == 1 ? "setwise coprime" : "not coprime");

	return 0;
}

Measured memory_bytes: 11092
N,A,B = map(int,input().split())

ans = 0
for i in range(1,N+1):
	sum = 0
	n = i
	
	while(n > 0):
		sum += n % 10
		n = n // 10
		
	if A <= sum and sum <= B:
		ans = ans +i
	

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

long long int MOD = 1000000007;

long long int dp[100005];

int N, M, a[100005];

long long int p[100005];

int main(void) {

	cin >> N >> M;

	for (int i = 1; i <= M; i++) {
		cin >> a[i];
		p[a[i]] = -1;
	}

	dp[0] = 1;

	for (int i = 0; i <= N - 1; i++) {
		if (p[i] == -1) { continue; }

		if (p[i + 1] != -1) { dp[i + 1] += dp[i]; dp[i + 1] %= MOD; }
		if (p[i + 2] != -1) {
			dp[i + 2] += dp[i]; dp[i + 2] %= MOD;
		}
	}

	cout << dp[N] << endl;

	return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

vector<vector<int>> g(10);
vector<bool> visited(10, false);
int ans = 0;
int n, m;

void dfs(vector<int> ARR, int s, int cnt) {
	visited[s] = true;
	if (cnt + 1 == n) {
		bool ok = true;
		rep (i, n) if (!visited[i]) ok = false;
		if (ok) ans++;
		return;
	}
	for (auto to: g[s]) {
		if (visited[to]) continue;
		if (to == ARR[cnt]) {
			dfs(ARR, to, cnt + 1);
		}
	}
}

int main(void) {

	cin >> n >> m;
	rep (i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].pb(b);
		g[b].pb(a);
	}

	vector<int> arr(n - 1);
	rep (i, n - 1) arr[i] = i + 1;

	
	do {
		rep (i, n) visited[i] = false;
		dfs(arr, 0, 0);
	} while (next_permutation(rng(arr)));

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

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

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

  vector<ll> a(n);
  for (ll i = 0; i < n; i++)
    cin >> a[i];

  cin >> q;

  vector<ll> b, c;
  rep(i, q)
  {
    ll s, d;
    cin >> s >> d;
    b.push_back(s);
    c.push_back(d);
  }

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

  map<ll, ll> map;
  for (ll i = 0; i < n; i++)
  {
    auto itr = map.find(a[i]);
    if (itr != map.end())
      map[a[i]]++;
    else
      map[a[i]] = 1;
  }

  // for (auto x : map)
  //   cout << x.first << " " << x.second << endl;
  ll sum = accumulate(a.begin(), a.end(), 0LL);
  // cout << sum << endl;

  vector<ll> s;
  for (ll i = 0; i < q; i++)
  {
    sum += (c[i] - b[i]) * (map[b[i]]);
    s.push_back(sum);
    map[c[i]] += map[b[i]];
    map[b[i]] = 0;

    // for (auto x : map)
    //   cout << x.first << " " << x.second << endl;
  }

  for (auto ans : s)
    cout << ans << endl;
}


Measured memory_bytes: 12460
/*
 * =====================================================================================
 *
 *       Filename:  frog1.cpp
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  21/03/2019 20:17:37
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  YOUR NAME (), 
 *   Organization:  
 *
 * =====================================================================================
 */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1000000
int h[101000];
ll dp[101000];
 ll costTD(ll n){
    dp[0] = 0;
    dp[1] = abs(h[1] -h[0]);
    for(ll i =2;i<n;i++){
        dp[i] = min(abs(h[i]-h[i-1])+dp[i-1], abs(h[i]-h[i-2])+dp[i-2]);
    }
    return dp[n-1];
}

int main(){
    ll ans = 0;
    ll n;
    memset(dp, 0, sizeof dp);
    scanf("%lld", &n);
    for(ll i =0;i<n;i++)
        scanf("%d", &h[i]);
    ans = costTD(n);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int minCost(int index, int n, vector<int> &cost, vector<int> &res) {
    if (index == n-1)
        return 0;
    if (res[index] != -1)
        return res[index];
    int jump1 = abs(cost[index] - cost[index+1]) + minCost(index+1, n, cost, res);
    int jump2 = INT_MAX;
    if (index+2 < n) {
        jump2 = abs(cost[index] - cost[index+2]) + minCost(index+2, n, cost, res);
    }
    return res[index] = min(jump1, jump2);
}
int main() {
    int n;
    cin>>n;
    vector<int> cost(n);
    for (int i = 0; i < n; i++) {
        cin>>cost[i];
    }
    vector<int> res(n, -1);
    cout<<minCost(0, n, cost, res)<<"\n";
}


Measured memory_bytes: 10316
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>

#define ull unsigned long long
#define ul unsigned long
#define ll long long
#define size_t unsigned long long

using namespace std;

void printVec(std::vector<char> &vec) {
  std::cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    std::cout << *it << " ";
  }
  std::cout << std::endl;
}

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

  //sort(td.begin(), td.end(), [](auto& x, auto& y){return x[0] > y[0];});

  int n;
  string a,b,c;
  std::cin >> n;
  std::cin >> a;
  std::cin >> b;
  std::cin >> c;


  int ans = 0;
  for (size_t i = 0; i < n; i++) {
    vector<char> vec = {a[i], b[i],c[i]};
    std::sort(vec.begin(), vec.end());
    vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
    // printVec(vec);
    ans += vec.size() - 1;
  }

  std::cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 256
from collections import Counter
from itertools import groupby


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def ilen(ll):
    return sum(1 for _ in ll)


def solve():
    H, W, M = read_ints()
    hw = []
    for _ in range(M):
        hw.append(tuple(read_ints()))
    hw.sort()

    rows = set()
    max_count_row = 0
    for h, ws in groupby(hw, key=lambda pair: pair[0]):
        count = ilen(ws)
        if count == max_count_row:
            rows.add(h)
        elif count > max_count_row:
            rows = set([h])
            max_count_row = count

    hw.sort(key=lambda pair: pair[1])
    cols = set()
    max_count_col = 0
    for w, hs in groupby(hw, key=lambda pair: pair[1]):
        count = ilen(hs)
        if count == max_count_col:
            cols.add(w)
        elif count > max_count_col:
            cols = set([w])
            max_count_col = count

    hw = set(hw)
    for h in rows:
        for w in cols:
            if (h, w) not in hw:
                return max_count_row+max_count_col
    return max_count_row+max_count_col-1


if __name__ == '__main__':
    print(solve())


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

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
   
  string s;
  cin >> s;
  for(int bit=0;bit<(1<<3);bit++){
    int now = s[0]-'0';
    rep(i,3){
      if(bit&(1<<i)){
        now+=s[i+1]-'0';
      }
      else{
        now-=s[i+1]-'0';
      }
    }
    if(now == 7){
      vector<char>vec(3);
      rep(i,3){
        if(bit&(1<<i))vec[i]='+';
        else vec[i]='-';
      }
      cout << s[0]-'0';
      rep(i,3){
        cout << vec[i] << s[i+1]-'0';
      }
      cout << "=7" << endl;
      return 0;
    }
  }
  
  return 0;
}


Measured memory_bytes: 3596
{-# LANGUAGE BangPatterns #-}

import Control.Monad
import Data.List
import Data.Maybe
import qualified Data.ByteString.Char8 as C8

type Pair = (Int, Int)

main :: IO ()
main = do
  [n,m] <- readInts
  ps <- replicateM n readPair
  print $ solve m $ sortOn fst ps
 
solve :: Int -> [Pair] -> Int
solve m = fst . foldl' f e
  where
    e = (0,0)
    f (s,n) (a,b)
      | n == m = (s,n)
      | n+b > m = until ((m==).snd) (\(s,n) -> (s+a,n+1)) (s,n)
      | otherwise = (s+a*b, n+b)
      
-- utils
readInts :: IO [Int]
readInts = map (fst . fromJust . C8.readInt) . C8.words <$> C8.getLine

readPair :: IO Pair
readPair = do
  [x,y] <- readInts
  return (x,y)

Measured memory_bytes: 58748
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

ll f(ll s){
  if(s%2==0)return s/2;
  return 3*s+1;
}

int main() {
  ll s;
  cin >> s;
  vector<bool> al(1000001,false);
  vl ans(10000001);
  ans[1]=s;
  al[s]=true;
  rep2(i,1,1000001){
    ans[i+1]=f(ans[i]);
    if(al[ans[i+1]]){cout << i+1 << endl;return 0;}
    al[ans[i+1]]=true;
  }
}


Measured memory_bytes: 78464
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;

    ll prevH, curH;
    cin >> prevH;

    bool renzoku = false;
    FOR(i, 1, n)
    {
        cin >> curH;
        ll sa = curH - prevH;

        if (sa > 0)
            renzoku = false;
        if (sa <= -2)
        {
            cout << "No" << endl;
            return 0;
        }
        if (sa == -1)
        {
            if (!renzoku)
                renzoku = true;
            else
            {
                cout << "No" << endl;
                return 0;
            }
        }
        prevH = curH;
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Yes() std::cout << "Yes" << std::endl
#define No() std::cout << "No" << std::endl
#define Say(s) std::cout << s << std::endl
const ll MOD = 1000000007;
const ll INF = 1061109567;

std::vector<ll> fac(2001);   //n!(mod M)
std::vector<ll> ifac(2001);  //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n)
{  //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while (n != 0) {
        if (n & 1)
            ans = ans * x % MOD;
        x = x * x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b)
{  //aCbをmod計算
    if (a == 0 && b == 0)
        return 1;
    if (a < b || a < 0)
        return 0;
    ll tmp = ifac[a - b] * ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}
int main()
{
    fac[0] = 1;
    ifac[0] = 1;
    for (ll i = 0; i < 2000; i++) {
        fac[i + 1] = fac[i] * (i + 1) % MOD;                 // n!(mod M)
        ifac[i + 1] = ifac[i] * mpow(i + 1, MOD - 2) % MOD;  // k!^{M-2} (mod M) ←累乗にmpowを採用
    }
    ll n;
    std::cin >> n;
    ll bar = 0;
    ll ans = 0;
    while (n - 3 >= bar) {
        ll temp = comb(n - 3, bar);
        ans += temp;
        ans %= MOD;
        n -= 2;
        bar += 1;
    }
    while (ans < 0) {
        ans += MOD;
    }
    Say(ans);
    return 0;
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
#include<vector>
#include<map>
#include<set>
using namespace std;

#define mod 1000000007

#define ll long long
#define ff first
#define ss second
#define E endl;
#define PII pair<int, int>
#define PCI pair<char, int>
#define PLL pair<ll, ll>
#define O " "
#define ghur(i, n) for(int i = 0; i < n; i++)
#define pb(x) push_back(x);
#define i_n v.begin(), v.end()
#define dec_v(v) std::vector<int> v;
#define in(x) insert(x)
#define file()  freopen("input.text", "rt", stdin), freopen("out.txt", "wt", stdout);
#define inf INT_MAX
void cin_ar(int n, int ar[]) {for(int i = 0; i < n; i++) cin>>ar[i];}
void cin_ll(int n, ll ar[]) { for(int i = 0; i < n; i++) cin>>ar[i];}
void cin_v(int n, vector<int> v){int x; for(int i = 0; i < n; i++){cin>>x; v.pb(x);}}
bool cmp(int a, int b) {return a>b;}
bool cmp_pair(PII &a, PII &b){return a.ss<b.ss;}
int n, k;
int bs(int x1, int x2)
{
	return abs(2*x2 - x1) - k;
}

void solve()
{
  string s;
  int sum = 0;
  cin>>s;

  int n = s.size();

  for(int i = 0; i < n; i++) sum += s[i] - '0';

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

}


void solve_2() {int t; cin>>t; while(t--) solve();}

int main()
{   
 	//file();
    
    solve();
    //solve_2();



    return 0;
} 

Measured memory_bytes: 3736
def f(a):
    if a % 4 == 1:
        return 1
    elif a % 4 == 2:
        return a + 1
    elif a % 4 == 3 or a == 0:
        return 0
    else:
        return a


a, b = map(int, input().split())
print(f(b) ^ f(a - 1))

Measured memory_bytes: 2940
N,M = map(int, raw_input().split())
A = map(int, raw_input().split())

C = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

T = [(-10**8,0)]*(N+1)
T[0] = (0, 0)
for i in range(1, N+1):
  for a in A:
    if i-C[a]>=0:
      T[i] = max(T[i], (T[i-C[a]][0]+1, a))

ans = ""
p = N
while p>0:
  ans += str(T[p][1])
  p -= C[T[p][1]]
print ans


Measured memory_bytes: 3844
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int k;
    cin >> k;
    string s;
    cin >> s;
    if (s.size() <= k) {
        cout << s << "\n";
    } else {
        cout << s.substr(0, k) + "..."
             << "\n";
    }
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
 
//BIAR MANTAB LAH YA
#define Willy using
#define Indrayana namespace
#define Komara std
 
Willy Indrayana Komara;
 
//TIPE DATA BENTUKAN
typedef long l;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;


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

bool tupleSort(tuple<int, int, int> &a, tuple<int, int, int> &b)
{
    return get<2>(a) > get<2>(b);
}


int fact(int n)
{
    if (n <= 0) return 1;
    return n * fact(n-1);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    ll temp = 1;
    ll ans = 1;
    for (int i = n-1; i <= n; i++)
    {
        temp = temp * i;
    } 
    ans = temp / 2;
    temp = 1;
    for (int i = m-1; i <= m; i++)
    {
        temp = temp * i;
    } 
    ans += temp / 2;
    cout << ans << '\n';

    /*
    cout << fact(13) << endl;
    cout << (fact(n)/(fact(n-2)*fact(2))) << ' ' <<  (fact(m)/(fact(m-2)*fact(2))) << '\n';
    */
   return 0;
}

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

int main() {
  int w,a,b;cin>>w>>a>>b;
  if(a+w<b)cout<<b-(a+w)<<endl;
  else if(b+w<a)cout<<a-(b+w)<<endl;
  else cout<<0<<endl;
}

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

#define ll long long

int main() {
    int N;
    int K;

    cin >> N >> K;

    double sum = 0;
    for(int d = 1;d <= N;d++) {
        double k = K <= d ? 0 : ceil(log2((double)K/d));
        sum += pow(2, -k)/N;
    }
    cout << std::setprecision(14) << sum << endl;
    return 0;
}

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

static unsigned int K = 2019;
int R[2019] = {0};

int main(int argc, char* argv[]){
	char str[200000+1]={0};
	int L=0;

	scanf("%s", str);
	L = strlen(str);

	int u0 = atoi(&str[L-1]);
	R[u0]++;
	int r0=1, r1=1;
	int u1=0;
	for(int i=1; i<L; i++){
		char c[2]={0};
		c[0] = str[L-1-i];
		int a = atoi(c);
		//u1 = u0 + a*(10**i)i;
		r1 = (r0*10)%K;
		u1 = a*r1 + u0 ;
		u1 = u1%K;
		R[u1]++;
		r0 = r1;
		u0 = u1;
	}

	long long ans = R[0];
	for(int i=0; i<K; i++){
		int m = R[i];
		if( m>1 ){
			ans += (m*(m-1))/2; 
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1928
#include <iostream>
#include <vector>
#include <deque>
#include <map>
#include <algorithm>
#include <cmath>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include "iomanip"
#include <cstdio>
#include <cstring>
#include <set>
#include <vector>
#include <fstream>
#include <queue>
#include <cassert>
#include <stack>

using namespace std;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;

void print(const vi &a) {
    for (auto item : a) {
        cout << item << " ";
        flush(cout);
    }
}

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

    int n;
    cin >> n;
    vi a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int res = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            res += a[i] * a[j];
        }
    }
    cout << res;

    
    return 0;
}


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

int main() {
	int N;
	cin >> N;
	vector<int> A(N, 0);
	for (int i = 0; i < N; i++) cin >> A[i];
	
	int i = 0, j = N - 1;
	int dif = 0;
	while (i <= j) {
		if (dif > 0) {
			dif -= A[j];
			j--;
		}
		else {
			dif += A[i];
			i++;
		}
	}
	cout << abs(dif) << endl;
}

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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int N;
    cin >> N;
    vector<int> b(N);
    rep(i,N) {
        int tmp ;
        cin >> tmp;
        b[i] = tmp;
    }
    vector<int> ans,tmp;
    bool t;
    while(1) {
        t = true;
        tmp.assign(0,0);
        for (int i=b.size()-1; i>=0; i--) {
            if (i+1==b[i] && t) {
                ans.push_back(i+1);
                t = false;
            }
            else {
                tmp.push_back(b[i]);
            }
        }
        reverse(tmp.begin(),tmp.end());
        b = tmp;
        if (t) {
            break;
        }
        else if (tmp.size()==0) {
            break;
        }
    }

    if (t) {
        cout << -1 << endl;
    }
    else {
        rep(i,N) {
            cout << ans[N-1-i] << endl;
        }
    }
}


Measured memory_bytes: 256
mod=2019
l,r=map(int,input().split())
d={}
for i in range(l,min(r+1,l+2020)):
    w=i%2019
    if w in d:
        d[w]+=1
    else:
        d[w]=1
ans=2020
for i in d:
    for j in d:
        if i!=j:
            ans=min(ans,i*j%mod)
        elif i==j and d[i]>1:
            ans=min(ans,i*j%mod)
print(ans)

Measured memory_bytes: 42204
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <bitset>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)

using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

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

    ll i,j,h;
    ll N;
    ll temp;
    ll ans = 0;
    vector<int> aa;
    
   cin >> N;
    rep(i,N){
        cin >> temp;
        aa.push_back(temp);
    }

    
    sort(aa.begin(),aa.end(),greater<int>());
    // ll t=aa[0];
    // repr (i,1,N){
    //     ans+=t;
    //     if(aa[i]!=t){
    //         t = aa[]
    //     }
    // }
    ans +=aa[0];
    if((N-2)%2==0){
        repr(i,1,(N-2)/2+1){
        ans += aa[i]*2;
        }
    }else{
        repr(i,1,(N-1)/2){
        ans += aa[i]*2;
        }
        ans += aa[(N-1)/2];
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int main()
{
  long double hebe = 3305785;
  long double a,b;
  long double c;
  cin >> a >> b;
  c = (a*b*1000000)/(double)hebe;
  cout << setiosflags(ios::fixed) << setprecision(4) << c << endl;
}

Measured memory_bytes: 1288
import sys

def main():
    input = sys.stdin.readline
    MOD = 10**9 + 7
    N, M = map(int, input().split())
    S = [0] + list(map(int, input().split()))
    T = [0] + list(map(int, input().split()))

    dp = [[0] * (M+1) for _ in range(N+1)]
    for i in range(1, N+1):
        for j in range(1, M+1):
            dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]
            if S[i] == T[j]:
                dp[i][j] += dp[i-1][j-1] + 1
            dp[i][j] %= MOD

    return (dp[N][M] + 1) % MOD


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 72156
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let mut cards = vec![VecDeque::new(); 3];
    for i in 0..3 {
        cards[i] = read::<String>()
            .chars()
            .map(|x| x.to_digit(36).unwrap() as usize - 10)
            .collect::<VecDeque<_>>();
    }
    let mut cur_player = 0;
    while let Some(next) = cards[cur_player].pop_front() {
        cur_player = next;
    }
    match cur_player {
        0 => println!("A"),
        1 => println!("B"),
        _ => println!("C"),
    };
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

int main() {
  int M, D;
  cin >> M >> D;
  
  int ans = 0;
  
  int d_1, d_10;
  for (int d = 22; d <= D; d++) {
    d_1 = d % 10;
    d_10 = d / 10;
    if (d_1 >= 2 && d_1 * d_10 <= M) ans++;
  }
  
  cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,k;
	cin>>a>>b>>k;
	for(int i=0;i<k/2;i++)
	{
		if(a%2!=0) a--;
		a/=2;
		b+=a;
		if(b%2!=0) b;
		b/=2;
		a+=b;
	}
	if(k%2!=0)
	{
		if(a%2!=0) a--;
		a/=2;
		b+=a;
	}
	cout<<a<<" "<<b;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
5 6
0 1
1 0
1 2
2 4
4 3
3 2
4
0 1
0 3
2 3
3 4

output:
1
0
1
1
"""
import sys

sys.setrecursionlimit(int(1e6))


def generate_adj_table(_v_info):
    for v_detail in _v_info:
        v_from, v_to = map(int, v_detail)
        init_adj_table[v_from].append(v_to)
    return init_adj_table


def graph_dfs(current, low, disc, stack_member, st):
    global Time
    # Initialize discovery time and low value
    disc[current] = Time
    low[current] = Time
    Time += 1
    stack_member[current] = True
    st.append(current)
    scc_set = set()

    # Go through all vertices adjacent to this
    for adj in adj_table[current]:

        # If adj is not visited yet, then recur for it
        if disc[adj] == -1:

            graph_dfs(adj, low, disc, stack_member, st)

            # Check if the subtree rooted with adj has a connection to
            # one of the ancestors of current
            # Case 1 (per above discussion on Disc and Low value)
            low[current] = min(low[current], low[adj])

        elif stack_member[adj]:

            '''Update low value of 'current' only if 'adj' is still in stack
            (i.e. it's a back edge, not cross edge).
            Case 2 (per above discussion on Disc and Low value) '''
            low[current] = min(low[current], disc[adj])

    # head node found, pop the stack and print an SCC
    scc_candidate = -1  # To store stack extracted vertices
    if low[current] == disc[current]:
        while scc_candidate != current:
            scc_candidate = st.pop()
            scc_set.add(scc_candidate)
            stack_member[scc_candidate] = False
        ans.append(scc_set)

    return None


def scc():
    # Mark all the vertices as not visited
    # and Initialize parent and visited,
    # and ap(articulation point) arrays
    disc = [-1] * vertices
    low = [-1] * vertices
    stack_member = [False] * vertices
    st = []

    # Call the recursive helper function
    # to find articulation points
    # in DFS tree rooted with vertex 'i'
    for v in range(vertices):
        if disc[v] == -1:
            graph_dfs(v, low, disc, stack_member, st)

    return ans


def solve():
    for question in q_list:
        flag = False
        ele1, ele2 = map(int, question)
        for each in scc_sets:
            if (ele1 in each) and (ele2 in each):
                flag = True
                break
        if flag:
            print('1')
        else:
            print('0')
    return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices, edges = map(int, _input[0].split())
    v_info = map(lambda x: x.split(), _input[1:edges + 1])
    q_num = int(_input[edges + 1])
    q_list = map(lambda x: x.split(), _input[edges + 2:])

    init_adj_table = tuple([] for _ in range(vertices))
    adj_table = generate_adj_table(v_info)

    Time = 0
    ans = []
    scc_sets = scc()
    solve()

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

int main() {
  
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  
  if(A+B==C+D)
    cout<<"Balanced";
  
  else{
  	if(A+B<C+D)
  		cout<<"Right";
  	else
  		cout<<"Left";
  	   }
}

       

  
  



Measured memory_bytes: 256
import java.util.*;
 
public class Main{
	public static void main(String[] args){
	    Scanner sc = new Scanner(System.in);
    	int num = sc.nextInt();
        int t = sc.nextInt();
        int number[] = new int[num];
        number[0] = sc.nextInt();
        int sum = t;
        for(int i = 1; i < num; i++){
        	number[i] = sc.nextInt();
            if(number[i] - number[i - 1] < t){
            	sum += number[i] - number[i - 1];
            }else{
            	sum += t;
            }
        }
        System.out.println(sum);
	}
}

Measured memory_bytes: 58820
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
const long double pi = (acos(-1));
#define pb push_back

//最大最小の入れ替え
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;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる

//ここから
int main(){
    ll N;
    cin>>N;
    vector<pll> vec(N);
    rep(i,N) cin>>vec.at(i).first>>vec.at(i).second;
    sort(all(vec));
    ll count=0;
    long double sum=0;
    do{
        count++;
        rep(i,N-1){
            ll x1,x2,y1,y2;
            x1=vec.at(i).first;
            x2=vec.at(i+1).first;
            y1=vec.at(i).second;
            y2=vec.at(i+1).second;
            ll a=(x1-x2)*(x1-x2);
            ll b=(y1-y2)*(y1-y2);
            sum+=sqrt(a+b);
        }
    }while(next_permutation(all(vec)));
    cout<<fixed<<setprecision(8)<<sum/count<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++){
		if(s[i]=='7'){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll K, N; cin >> K >> N;
  ll x[N];
  ll d[N];
  for (ll i = 0; i < N; i++) {
    cin >> x[i];
  }
  for (ll i = 0; i < N-1; i++) {
    d[i] = x[i+1]-x[i];
  }
  d[N-1] = x[0]+K-x[N-1];
  ll res = 0;
  for (ll i = 0; i < N; i++) {
    res = max(res,d[i]);
  }
  cout << K-res << endl;
}

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

using namespace std;

using LL = long long;

LL a, b, c, d;

unordered_set<LL> vis;

int main() {
	int T; cin >> T;
	while (T--) {
		cin >> a >> b >> c >> d;
		
		if (a < b) puts("No");
		else if (b > d) puts("No");
		else if (b <= c) puts("Yes");
		else {
			LL gcd = __gcd(d % b, b);
			LL t = (b - a % b) / gcd - ((b - a % b) % gcd == 0);
			
			puts(a % b + t * gcd > c ? "No" : "Yes");
		}
		
		/* vis.clear();
		
		vis.insert(a);
		
		bool flag = 1;
		while (1) {
			LL t = max(1LL, (a - c + b - 1) / b);
			a -= b * t;
			if (a < 0) {
				flag = 0; break;
			}
			if (a <= c) a += d;
			if (vis.count(a)) break;
		}
		
		puts(flag ? "Yes" : "No"); */
	}
	
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

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

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      String[] lines = in.readLine().split(" ");
      int h = Integer.parseInt(lines[0]);
      int w = Integer.parseInt(lines[1]);
      boolean[][] mat = new boolean[h][w];

      String line;
      for(int y=0; y<h; y++) {
        line = in.readLine();
        for(int x=0; x<w; x++) {
          mat[y][x] = line.charAt(x) == '#' ? true : false;
        }
      }

      int[] rx = {0,0,-1,1};
      int[] ry = {-1,1,0,0};
      boolean result = true;
      boolean isPossible = false;
      for(int y=0; result && y<h; y++) {
        for(int x=0; result && x<w; x++) {
          if(mat[y][x]) {
            for(int i=0; !isPossible && i<4; i++) {
              if(y+ry[i] > -1 && y+ry[i] < h && x+rx[i] > -1 && x+rx[i] < w)
                if(mat[y+ry[i]][x+rx[i]]) isPossible = true;
            }
            if(isPossible) isPossible = false;
            else {
              result = false;
              // System.out.println( y + " " + x);
            }
          }
        }
      }

      String ans = result ? "Yes" : "No";
      System.out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

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

int main(){
	ll k, a, b, ef;
	ll ans;
	cin >> k >> a >> b;
	ef = b - a;
	if(ef <= 2 || a+1 > k){
		cout << 1+k << endl;
		return 0;
	}
	
	k -= a-1;
	ans = a;
	ans += ef*(k/2);
	if(k % 2 == 1){
		ans++;
	}
	
	cout << ans << endl;
	
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

template<typename T>
bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

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

	int N=in();
	if(N<1000) cout << "ABC" << endl;
	else cout << "ABD" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007

void solve()
{
	string s;
	cin>>s;
	ll n=s.size();
	reverse(s.begin(),s.end());
	for(ll i=0;i<n;)
	{
		if(n-i>=5)
		{
			if(s.substr(i,5)=="maerd" || s.substr(i,5)=="esare")
			{
				i+=5;
				continue;
			}
		}
		if(n-i>=6)
		{
			if(s.substr(i,6)=="resare")
			{
				i+=6;
				continue;
			}
		}
		if(n-i>=7)
		{
			if(s.substr(i,7)=="remaerd")
			{
				i+=7;
				continue;
			}
		}
		cout<<"NO";
		return;
	}
	cout<<"YES";
	return;
}

int main()
{
	fast;
	ll q=1;
	// cin>>q;
	while(q--)
		solve();
	return 0;
}



Measured memory_bytes: 3748
fun main(args: Array<String>) {
    val length = readLine()!!.toInt()
    val listB = readLine()!!.split(" ").map { it.toInt() }

    print(abc140c(length, listB))
}

fun abc140c(length: Int, listB: List<Int>): Int {

    val listA = mutableListOf(listB[0])

    when {
        length >= 3 -> {
            for (i in 1 until length - 1) {
                listA.add(listB[i].coerceAtMost(listB[i - 1]))
            }
            listA.add(listB[length - 2].coerceAtLeast(listB.last()))
        }
        else -> listA.add(listB.last())
    }

    return listA.sum()
}

Measured memory_bytes: 37912
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll gya[200010];
ll kai[200010];
ll beki(ll n,ll k){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=mod;
    }
    now*=now;
    now%=mod;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n){
  return beki(n,mod-2);
}
void nckinit(ll n){
  kai[0]=1;
  kai[1]=1;
  for(int i=2;i<=n;i++){
    kai[i]=kai[i-1]*i;
    kai[i]%=mod;
  }
  gya[n]=gyaku(kai[n]);
  for(int i=n-1;i>=1;i--){
    gya[i]=gya[i+1]*(i+1);
    gya[i]%=mod;
  }
  gya[0]=1;
}    
ll nck(ll n,ll k){
  if(k<0)return 0;
  if(k==0||n==k)return 1;
  ll ret=kai[n];
  ret*=gya[n-k];
  ret%=mod;
  ret*=gya[k];
  ret%=mod;
  return ret;
}
ll npk(ll n,ll k){
  if(k<0)return 0;
  if(k==0)return 1;
  ll ret=kai[n];
  ret*=gya[n-k];
  ret%=mod;
  return ret;
}


int main(){
  int n;cin>>n;
  string s;cin>>s;
  if(s[0]=='W'||s[2*n-1]=='W'){
    cout<<0<<endl;
    return 0;
  }
  int a[2*n];
  a[0]=0;
  rep(i,1,2*n){
    if(s[i]==s[i-1]){
      a[i]=a[i-1]+1;
      a[i]%=2;
      
     
    }
    else{
      a[i]=a[i-1];
    }
  }
 // rep(i,0,2*n)cout<<a[i]<<" ";
  int cnt=0;
  if(a[2*n-1]==0){
    cout<<0<<endl;
    return 0;
  }
  rep(i,0,2*n)if(a[i]==0)cnt++;
  if(cnt!=n){
    cout<<0<<endl;
    return 0;
  }
  ll ans=1;
  ll n0=0;
  rep(i,0,2*n){
    if(a[i]==0)n0++;
    else{
      ans*=n0;
      n0--;
      ans%=mod;
    }
  }
  nckinit(n+1);
  ans*=kai[n];
  ans%=mod;
  cout<<ans<<endl;
  
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

ll N, K;
vector<ll> H;
ll dp[MAX_N];

// 現在 i にいるときの最小コスト
ll dfs(ll i = 0) {
    if(i == N-1) { return 0; }

    ll& ret = dp[i];
    if(~ret) { return ret; }
    ret = LLINF;

    for(ll k = 1; k <= K; ++k) {
        if(i < N - k) { ret = min(ret, dfs(i + k) + abs(H[i] - H[i + k])); }
    }

    return ret;
}

signed main()
{
    cin >> N >> K;
    H.assign(N, 0);
    REP(i, N) { cin >> H[i]; }
    MINUS(dp);
    printf("%lld\n", dfs());
    return 0;
}


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

typedef long long ll;
typedef int64_t i6;
typedef std::vector<std::vector<int64_t> > Graph;

#define rep(i, n) for (int64_t i = 0; i < n; ++i)
#define rep2(i, n) for (int64_t i = 1; i <= n; ++i)
#define repb(i, l, n) for (int64_t i = l; i < n; ++i)
#define repb2(i, l, n) for (int64_t i = l; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))
#define Push_back(p, a, b) (p).push_back( make_pair( (a), (b) ) )

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<typename V,typename T> bool find_num(V v, T num) { if ( find(ALL(v), num) == v.end() ) { return false; } return true; }

int main() {
    int64_t a, b, c;
    cin >> a >> b >> c;
    int64_t k;
    cin >> k;

    int64_t ans = 0;
    int64_t bb = b;
    int64_t cc = c;

    rep(i, k) {
        if ( bb <= a ) {
            bb *= 2;
        } else {
            cc *= 2;
        }
    }

    if ( a < bb && bb < cc ) {
        ans = 1;
    }
    cout << ( ans ? "Yes" : "No" ) << endl;
    return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
int main(){int n,k,i,j,s;
cin>>n>>k;
int h[n+3],dp[n+3];
for(i=1;i<=n;i++){cin>>h[i];
    dp[i]=1000000000;
}
dp[1]=0;
for(i=2;i<=n;i++){
    s=max(1,i-k);
    for(j=s;j<i;j++){dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));}
}
cout<<dp[n];
    return 0;}

Measured memory_bytes: 1024