akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;

int main()
{
  int a[] ={-1,-1};
  int i=1;
  while(true){
    scanf("%d %d", &a[0], &a[1]);
    if(a[0]==0 && a[1]==0)
      break;
    sort(a,a+2);
    cout << a[0] << " " << a[1] << endl;
    i++;
  }
}

Measured memory_bytes: 1224
#include <iostream>
#include <queue>
using namespace std;
typedef pair<int, int> P;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, -1, 0, 1};
int h, w;
int sy, sx;
char field[22][22];

int main(){
 
  while(cin >> w >> h && (h || w)){
    fill(&field[0][0], &field[21][21] + 1, '#');
    for(int i = 1; i <= h; i++){
      for(int j = 1 ; j <= w; j++){
	cin >> field[i][j];
	if(field[i][j] == '@'){
	  sy = i;
	  sx = j;
	  field[i][j] = '#';
	}
      }
    }
    queue<P> que;
    que.push(P(sy, sx));
    int res = 1;
    while(!que.empty()){
      P p = que.front();
      que.pop();
      int y = p.first;
      int x = p.second;
      for(int i = 0; i < 4; i++){
	int y2 = y + dy[i];
	int x2 = x + dx[i];
	if(field[y2][x2] == '.'){
	  res++;
	  field[y2][x2] = '#';
	  que.push(P(y2, x2));
	}
      }
    }
    cout << res << endl;
  }
  return 0;
}

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

int n;
string s = "abcdefghijklmnopqrstuvwxyz";
int ch(char a){
	return a - 'a';
}
vector<pair<string,int>> ve[11];
int main(){
	cin >> n;
	ve[0].push_back({"a",0});
	for(int i = 0; i < 10; i++){
		for(auto j : ve[i]){
			for(int x = 0; x <= j.second+1; x++){
				ve[i+1].push_back({j.first+s[x], max(x,j.second)});
			}
		}
	}
	sort(ve[n-1].begin(), ve[n-1].end());
	for(auto u : ve[n-1]) cout << u.first << "\n";
}


Measured memory_bytes: 64100
#include <iostream>
// #include <vector>
// #include <cstdlib>
using namespace std;

int main()
{
    int N;
    cin >> N;
    int W;
    cin >> W;
    long long dp[110][100010];
    int w[110];
    int v[110];

    memset(dp, 0, sizeof(dp));

    for (int i = 1; i <= N; i++)
    {
        cin >> w[i] >> v[i];
    }

    for (int j = 1; j <= N; j++)
    {
        for (int i = 0; i <= W; i++)
        {
            if (i - w[j] >= 0)
                dp[j][i] = max(dp[j][i], dp[j - 1][i - w[j]] + v[j]);
            dp[j][i] = max(dp[j][i], dp[j - 1][i]);
        }
    }

    cout << dp[N][W] << endl;

    return 0;
}

Measured memory_bytes: 86144
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

#define REP(i,x) for(int i=0 ; i<(int)(x) ; i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

bool ok(string &s, int i, const string &T){
    REP(j, T.size()){
        if(s[i+j]=='?')s[i+j] = T[j];
        if(s[i+j]!=T[j])return false;
    }
    REP(j, s.size()){
        if(s[j]=='?')s[j] = 'a';
    }
    return true;
}

int main(){
    string S, T;
    cin >> S >> T;
    vector<string> res;
    REP(i, S.size()){
        if(i+T.size()>S.size())continue;
        string s = S;
        if(ok(s, i, T))res.push_back(s);
    }
    sort(ALL(res));
    cout << (res.size()==0 ? "UNRESTORABLE" : res[0]) << endl;
    return 0;
}


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

int main() {
  int N,K,j;
  cin >> N >> K;
  for (int i = N;i <= K; i++){
    if(i / 10000 == i % 10){
      if(i / 1000 % 10 == i % 100 / 10){
        j++;
      }
      else{
        continue;
      }
    }
    else{
      continue;    
    }  
  }
  cout << j << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;
int INF = 1000000000;
int main(){
    int n;
    cin >> n;
    vector<int> w(n);
    for (int i=0;i<n;i++) cin >> w[i];
    int min_abs = INF;
    for (int i=0;i<n;i++){
        int first_sum = 0;
        int second_sum = 0;
        for (int j=0;j<=i;j++) first_sum += w[j];
        for (int k=i+1;k<n;k++) second_sum += w[k];
        int sa = abs(first_sum-second_sum);
        if (sa <= min_abs) min_abs = sa;
    }
    cout << min_abs << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


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


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(A, B, C, K):
    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)

    def s(i, j, k):
        return A[i] + B[j] + C[k]
    used = set()
    
    cand = []
    heapq.heappush(cand, (-s(0, 0, 0), (0, 0, 0)))
    for _ in range(K):
        v, i = heapq.heappop(cand)
        print(-v)
        
        ti = (i[0]+1, i[1], i[2])
        if ti[0] < len(A) and ti not in used:
            heapq.heappush(cand, (-s(*ti), ti))
            used.add(ti)
        
        ti = (i[0], i[1]+1, i[2])
        if ti[1] < len(B) and ti not in used:
            heapq.heappush(cand, (-s(*ti), ti))
            used.add(ti)
        
        ti = (i[0], i[1], i[2]+1)
        if ti[2] < len(C) and ti not in used:
            heapq.heappush(cand, (-s(*ti), ti))
            used.add(ti)



def main():
    # for _ in range(1000):
    #     K = 3000
    #     A = [random.randint(1, 10000000000) for _ in range(random.randint(1, 1000))]
    #     B = [random.randint(1, 10000000000) for _ in range(random.randint(1, 1000))]
    #     C = [random.randint(1, 10000000000) for _ in range(random.randint(1, 1000))]
    #     K = min(K, len(A) + len(B) + len(C))
    #     slv(A,B,C,K)
    # N = read_int()
    X, Y, Z, K = read_int_n()
    A = read_int_n()
    B = read_int_n()
    C = read_int_n()
    (slv(A, B, C, K))


if __name__ == '__main__':
    main()


Measured memory_bytes: 7236
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main() {
    int n;cin >> n;
    vector<int>a(n);
    rep(i,n)cin >> a[i];
    vector<int> st;
    int k = 1;
    st.push_back(-a[0]);
    for(int i = 1;i<n;i++){
        // for(auto l:st)
        //cerr <<  l << " ";
        auto s =upper_bound(st.begin(),st.end(), -a[i]);
        if(s==st.end()){
            st.push_back(-a[i]);
         //   cerr << a[i] << "NEW"<<endl;
        }else{
          //  cerr << a[i] << "idex"<<endl;
            *s= -a[i];
        }
        
    }
    cout << st.size() << endl;

}


Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define int long long
#define rep(a,b) for(int (a)=0; (a)<(int)(b); ++(a))
#define all(a) (a).begin(),(a).end()
#define sel(a,b,c) (a).begin()+(b),(a).begin()+(b)+(c)
#define prec(a) fixed<<setprecision(a)
using namespace std;

constexpr int MOD=1000000007;
using ull=unsigned long long;
template<typename T>
using vec=vector<T>;
template<typename T>
using dvec=vector<vec<T>>;
using pint=pair<int,int>;

void print(void){cout<<"\n";}

template<class HEAD,class... TAIL>
void print(HEAD&& head,TAIL&&... tail){
  cout<<head<<" ";
  print(forward<TAIL>(tail)...);
}

template<typename T,typename U,class... TAIL>
void print(pair<T,U> p,TAIL&&... tail){
  cout<<p.first<<" "<<p.second<<" ";
  print(forward<TAIL>(tail)...);
}

signed main(void){
  int N,K; cin>>N;
  vector<int> a(N);
  rep(i,N) cin>>a[i];
  
  int ans=0;
  int r=0;
  int sum=0;
  rep(l,N){
    while(r<N&&(sum^a[r])==(sum+a[r]))
      sum+=a[r],++r;
    ans+=r-l;
    if(l==r) ++r;
    else sum-=a[l];
  }
  cout<<ans;
}


Measured memory_bytes: 1792
#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;

int main()
{
	int N, M;
	cin >> N >> M;
	int K[N];
	vector<vector<int>> v(N, vector<int>(M, 0));
	REP(i, N){
		cin >> K[i];
		REP(j, K[i]) cin >> v[i][j];
	}

	REP(i, N){
		v[i].erase(remove(v[i].begin(), v[i].end(), 0), v[i].end());
		sort(v[i].begin(), v[i].end());
	}
	vector<vector<int>> intersection(N, vector<int>(M, 0));
	intersection[0] = v[0];
	REP(i, N - 1){
		set_intersection(intersection[i].begin(), intersection[i].end(), 
		v[i + 1].begin(), v[i + 1].end(),
		inserter(intersection[i + 1], intersection[i + 1].end()));
	}
	intersection[N - 1].erase(remove(intersection[N - 1].begin(), 
		intersection[N - 1].end(), 0), intersection[N - 1].end());
	cout << intersection[N - 1].size() << endl;
}

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  int A,B,X;
  cin>>A>>B>>X;
  if(A<=X&&A+B>=X){
    cout<<"YES"<<endl;
  }
  else cout<<"NO"<<endl;
}


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

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

const int MOD = 1000000007;
struct modint {
  long long val;
  modint(long long val=0) : val((val % MOD + MOD) % MOD){}
  modint operator-() const { return modint(-val); }
  modint& operator+=(const modint a) { if ((val += a.val)     >= MOD) val -= MOD; return *this; }
  modint& operator-=(const modint a) { if ((val += MOD-a.val) >= MOD) val -= MOD; return *this; }
  modint& operator*=(const modint a) { (val *= a.val) %= MOD; return *this; }
  modint operator+(const modint a) const { return (modint)*this += a; }
  modint operator-(const modint a) const { return (modint)*this -= a; }
  modint operator*(const modint a) const { return (modint)*this *= a; }
  modint pow(long long n) const { modint r(1), m(val); while (n > 0) { if (n & 1) {r *= m;} m *= m; n >>= 1; } return r; }
  modint inv() const { return pow(MOD-2); }
  modint& operator/=(const modint a) { return (*this) *= a.inv(); }
  modint operator/(const modint a) const { return (modint)*this /= a; }
  bool operator==(const modint &p) const { return val == p.val; }
  bool operator!=(const modint &p) const { return val != p.val; }
  friend ostream &operator<<(ostream &os, const modint &p) { return os << p.val; }
  friend istream &operator>>(istream &is, modint &a) { long long t; is >> t; a = modint(t); return (is); }
};

struct mod_combination {
  /* initialize: O(n) */
  /* choose    : O(1) */
  vector<modint> fact, fact_inv, inv;
  mod_combination(int n) : fact(n+1, 1), fact_inv(n+1, 1), inv(n+1, 1) {
    for (int i = 2; i <= n; i++) {
      fact[i] = fact[i - 1] * i;
      inv[i] = -inv[MOD % i] * (MOD / i);
      fact_inv[i] = fact_inv[i - 1] * inv[i];
    }
  }
  modint choose(int n, int k) { return fact[n] * fact_inv[k] * fact_inv[n - k]; }
};

modint choose(modint n, int k) {
  /* O(k) */
  modint c = 1;
  for(int i=1; i<=k; i++) c *= (n-i+1) / i;
  return c;
}

signed main() {
  int N,K;
  cin >> N >> K;
  int blue = K, red = N-K;
  for(int i=1; i<=K; i++) 
    cout << choose(blue-1, i-1) * choose(red + 1, i-1+2-1) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

struct union_find {
    vector<int> data;
    int comp;
    union_find(int size) : data(size, -1), comp(size) {}
    void unite(int x, int y) {
        x = root(x); y = root(y);
        if(x != y) {
            if(data[y] < data[x]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
            comp--;
        }
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : (data[x] = root(data[x]));
    }
    int size(int x) {
        return -data[root(x)];
    }
    int components() { return comp; }
};

signed main() {
    string S;
    cin >> S;
    int N = sz(S);
    vector<int> ans(N);

    union_find uf(N);
    rep(i, 0, N) {
        if (S[i] == 'L') {
            uf.unite(i - 1, i);
        } else {
            uf.unite(i, i + 1);
        }
    }

    vector<int> black(N), white(N);
    rep(i, 0, N) {
        if (i % 2) {
            black[uf.root(i)]++;
        } else {
            white[uf.root(i)]++;
        }
    }
    dump(black);
    dump(white);

    rep(i, 0, N - 1) {
        if (S[i] == 'R' && S[i + 1] == 'L') {
            if (i % 2) {
                ans[i] = black[uf.root(i)];
                ans[i + 1] = white[uf.root(i + 1)];
            } else {
                ans[i] = white[uf.root(i)];
                ans[i + 1] = black[uf.root(i + 1)];
            }
        }
    }

    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 3792
#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>

int main(){
    using std::string;
    int a, b;
    string s, sa, sb;
    std::cin >> a >> b;
    std::cin >> s;
    if(s[a] == '-'){
        sa = s.substr(0, a-1);
        sb = s.substr(a+1, a+b);
        if(std::all_of(sa.cbegin(), sa.cend(), isdigit) && (std::all_of(sb.cbegin(), sb.cend(), isdigit))){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }
    else{
        printf("No\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 REP(i,a,b) for(int i=a; i<b; ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
//プロトタイプ宣言
int gcd(int , int);
void often(void);
int get_digent(int);


int main(){
  often();
  int n,cnt=0;
  cin >> n;
  vi p(n);
  rep(i,n) cin >> p[i];
  REP(i,1,n+1){
    if(p[i-1] != i) cnt++;
  }
  if(cnt == 2 || cnt == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}








































//以下、ライブラリ

int gcd(auto a, auto b) {
  return b ? gcd(b, a%b) : a;
}  //ユークリッドの互除法

void often(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int get_digent(int x){
  string s;
  s = to_string(x);
  int digent = s.size();
  return digent;
} 

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

const int MAX = 5050;
const llint inf = 1e18;

llint f[MAX][MAX];

int main(void) {
  int N;
  scanf("%d", &N);

  vector<pair<int, int>> a(N);
  REP(i, N) scanf("%d %d", &a[i].first, &a[i].second);

  sort(a.begin(), a.end(), [&] (const pair<int, int>& a, const pair<int, int>& b) {
      return a.first + a.second < b.first + b.second;
    }
  );


  REP(i, N+1) REP(j, N+1) f[i][j] = inf;
  f[0][0] = 0;
  REP(i, N) REP(j, i+1) {
    if (f[i][j] <= a[i].first) {
      f[i+1][j+1] = min(f[i+1][j+1], f[i][j] + a[i].second);
    }
    f[i+1][j] = min(f[i+1][j], f[i][j]);
  }

  int ret = 0;
  while (ret + 1 <= N && f[N][ret + 1] != inf) ret++;
  printf("%d\n", ret);
  return 0;
}


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

using namespace std;

int main(void){
    int n;
    long long min_=1000001,max_=-1000001,sum=0,newNum;
    std::cin >> n;
    for(int i=0;i<n;i++){
        std::cin >> newNum;
        
        sum+=newNum;
        max_=max(newNum,max_);
        min_=min(newNum,min_);
    }
    std::cout << min_<<" "<<max_<<" "<<sum << std::endl;
}



Measured memory_bytes: 3112
/*#include <iostream>

using namespace std;

int main() {
	int a = 0, b = 0, c = 0,count = 0;
	cin >> a >> b;
	c = a + b;
	while (c!=0) {
		c /= 10;
		count++;
	}
	cout << count << endl;


}*/
#include <iostream>
using namespace std;

int main() {
	int a, b, ans;
	while (cin >> a >> b) {
		a += b;
		ans = 0;
		while (a > 0, ans++, a /= 10);
		cout << ans << endl;
	}
}

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

int count_[50];

int main(void){
    int i, a, b, N, M;

    cin >> N >> M;

    for(i=0; i<M; i++){
        cin >> a >> b;
        count_[a-1] += 1;
        count_[b-1] += 1;
    }

    for (i = 0; i < N; i++)
    {
        cout << count_[i] << endl;
    }
    

    return 0;
}

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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n), w(n);
    REP(i, 0, n) {
        cin >> a[i];
    }
    REP (i, 0, n) {
        cin >> w[i];
    }
    vector<int> perm(n - 1);
    iota(perm.begin(), perm.end(), 1);
    ll ans = 1LL << 60;
    do {
        vector<int> p(n);
        p[0] = 0;
        REP (i, 1, n) {
            p[i] = perm[i - 1];
        }
        ll s = 0;
        REP (i, 0, n) {
            int j = (i + 1) % n;
            int k = (i - 1 + n) % n;
            if (a[p[i]] == 0 && a[p[j]] == 1) {
                s += w[p[i]];
            }
            if (a[p[i]] == 1 && a[p[k]] == 0) {
                s += w[p[i]];
            }
        }
        chmin(ans, s);
    } while (next_permutation(perm.begin(), perm.end()));
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3192
/*
	Name:
	Author: xiaruize
	Date:
*/
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
#define sz(a) int((a).size())

inline int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
}

int a[200005];
int cnt[1000005];

int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		cnt[a[i]]++;
	}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		bool flag=true;
		cnt[a[i]]--;
		for(int j=1;j*j<=a[i];j++)
		{
			if(a[i]%j==0)
			{
				if(cnt[j]||cnt[a[i]/j])
				{
					flag=false;
					break;
				}
			}
		}
		cnt[a[i]]++;
		ans+=flag;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8180
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

int main(){
  int n;
  while(true){
    cin >> n;
    if(n==0)
      break;

    vector<vector<int> > mop;
    vector<int> mup; 
    mup.resize(n+1);
    for(int i=0; i<n; i++){
      vector<int> mip;
      int k, l=0;
      for(int j=0; j<n; j++){
	cin >> k;
	mip.push_back(k);
	l+=k;
	mup[j]+=k;
      }
      mip.push_back(l);
      mop.push_back(mip);
    }
    for(int i=0; i<n; i++){
      mup[n]+=mup[i];
      for(int j=0; j<n+1; j++){
	printf("%5d", mop[i][j]);
      }
      cout << endl;
    }
    for(int i=0; i<=n; i++)
      printf("%5d", mup[i]);
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1244
n = int(input())
h = list(map(int, input().split()))
c = [0] * n
c[0] = 0
c[1] = abs(h[1] - h[0])
m = c[1]


for i in range(2, n):
    c[i] = min(c[i - 2] + abs(h[i] - h[i - 2]),
               c[i - 1] + abs(h[i] - h[i - 1]))

print(c[n - 1])


Measured memory_bytes: 13928
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n,tc,ts,tf,time;
  vector<int> c,s,f,ans;
  cin >> n;
  for(int i=0;i<n-1;i++){
    cin >> tc >> ts >> tf;
    c.push_back(tc);
    s.push_back(ts);
    f.push_back(tf);
  }
  for(int i=0;i<n;i++){
    time=0;
    for(int j=i;j<n-1;j++){
      if(time<=s[j]){
        time = s[j]+c[j];
      }else{
        while((time-s[j])%f[j]!=0) time++;
        time += c[j];
      }
    }
    cout << time<<endl;
  }
}


Measured memory_bytes: 256
//線形探索
//2018-12-17
//Ebitani Akira

#include <stdio.h>
#include <stdlib.h>

#define N1 10000
#define N2 500

int main (){
  int array1[N1];
  int array2[N2];
  int i, j, answer;
  int n1, n2;

  scanf( "%d", &n1 );
  if( n1 > 10000 || n1 < 1 ){
    printf("要素数が適当でありません。\n");
    exit(1);
  }
  for( i = 0 ; i < n1 ; i++ ){
    scanf( "%d", &array1[i] );
  }

  scanf( "%d", &n2 );
  if( n2 > 500 || n2 < 1 ){
    printf("要素数が適当でありません。\n");
    exit(2);
  }
  for( i = 0 ; i < n2 ; i++ ){
    scanf( "%d", &array2[i] );
  }

  answer = 0;
  
  for( i = 0 ; i < n2 ; i++ ){
    for( j = 0 ; j < n1 ; j++ ){
      if( array2[i] == array1[j] ){
	answer++;
	break;
      }
    }
  }

  printf("%d\n", answer);

  return 0;
}



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

using namespace std;
typedef long long int ll;

#define INF (1e9)

int main() {
    int D, G, p[12], c[12];
    cin >> D >> G;
    for (int i = 0; i < D; i++) {
        cin >> p[i] >> c[i];
    }

    int ans = INF;

    for (int mask = 0; mask < (1 << D); mask++) {
        int sum_score = 0, num_solved = 0, max_not_soleved = -1;

        for (int i = 0; i < D; i++) {
            if ((mask >> i) & 1) {  // all 100i plobrems are solved.
                num_solved += p[i];
                sum_score += p[i] * 100 * (i + 1) + c[i];
            } else {
                max_not_soleved = i;
            }
        }

        if (sum_score < G) {
            int score_need = G - sum_score;
            if (score_need > (p[max_not_soleved] - 1) * 100 * (max_not_soleved + 1)) {
                continue;
            }
            num_solved += (score_need + 100 * max_not_soleved) / (100 * (max_not_soleved + 1));
        }

        ans = min(ans, num_solved);
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <math.h>

typedef long long ll;
using namespace std;

int main() {
    int n, m;
    string s;
    cin >> n >> m;
    cout << (n*3 + m)/2 << endl;
    return 0;
}



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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 5010
#define MOD 1000000007
#define int ll
int N,M;
string S;

int num[maxn][maxn];
int dp[maxn][maxn];

int power(int a,int b,int M){ //returns a^b % M, O(logb)
  	 if (b==0) return 1;
    
   	int half = b/2;
   	int halfval;
    
   	halfval = (power(a,half,M))%M;
   	if (b%2 == 0) return (halfval * halfval) % M;
   	else return (((halfval * halfval) % M) * (a % M)) % M;
}

int modinv(int a,int b){
	return (a * power(b,MOD-2,MOD)) % MOD;
}
int dpf(int i,int j){
	if (dp[i][j] != -1) return dp[i][j];

	if (i == 0 && j == 0) return dp[i][j] = 1;
	if (i < j) return dp[i][j] = 0;
	
	dp[i][j] = dpf(i-1,j+1) + dpf(i-1,j+1);
	dp[i][j] %= MOD;
	
	dp[i][j] += dpf(i-1,max((ll)0,j-1));
	
	dp[i][j] %= MOD;
	
	return dp[i][j];
}

int32_t main(){
	fast;
	
	cin>>N>>S;
	
	M = S.size();
	mem(dp,-1);
	
	

	

	cout<<dpf(N,M);
	
	
	
	
	
}



Measured memory_bytes: 197120
using System;
using System.Collections.Generic;
class Program
{
    //static List<string> str = new List<string>();
    static void Main(string[] args)
    {
        // 入力
        string[] input = Console.ReadLine().Split(' ');
        int A = int.Parse(input[0]);
        int B = int.Parse(input[1]);
        int K = int.Parse(input[2]);

        int i = 0, d = Math.Min(A,B);
        while(true)
        {
            if(A%d == 0 && B%d == 0)
            {
                i++;
            }
            if(i==K)
            {
                Console.WriteLine(d);
                break;
            }
            d--;

            if (d <= 0)
                break;
        }
        //Console.WriteLine(walk);
    }
}

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

typedef long long ll;

using namespace std;

int main() {
	int k, n; cin >> k >> n;
	int d[n];
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	int ans = k-(d[0] + k - d[n-1]);
	for(int i = 1; i < n; i++) {
		ans = min(ans, k-(d[i] - d[i-1]));
	}
	cout << ans;
	
}



	


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int gcd(int,int);
void swap(int *,int *);

int main()
{
  int a,b,c;

  scanf("%d%d",&a,&b);

  c = gcd(a,b);

  printf("%d\n",c);

  return 0;
}

int gcd(int a,int b){
  int r;

  if(a < b)
    swap(&a,&b);

  while(b > 0){
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}

void swap(int *a,int *b){

  int x;
  x = *a;
  *a = *b;
  *b = x;
  }

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  auto f = [&](ll x){
    return (x/c) + (x/d) - (x/(c*d/__gcd(c,d)));
  };

  ll ans = b-a+1;
  ans -= f(b) - f(a-1);
  cout << ans << endl;
}

Measured memory_bytes: 3592
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = sum(b)
for i in range(n-1):
    if (a[i+1] - a[i])==1:
        ans += c[a[i]-1]

print(ans)


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

using namespace std;

int N, M, Q;
vector<int> a, b, c, d;
vector<int> A(1, 1);
int ans;
int sum;

void dfs(vector<int> A)
{
    if(A.size() == N + 1)
    {
        sum = 0;
        for (int i = 0; i < Q; i++)
        {
            if (A[b[i]] - A[a[i]] == c[i]) sum += d[i];
        }
        if(sum > ans) ans = sum;

    }else
    {
        A.emplace_back(A.back());
        while (A.back() <= M)
        {
            dfs(A);
            A.back()++;
        }
        
    }

}

int main(int argc, char const *argv[])
{
    cin >> N >> M >> Q;
    int ina, inb, inc, ind;
    for (int i = 0; i < Q; i++)
    {
        cin >> ina >> inb >> inc >> ind;
        a.emplace_back(ina);
        b.emplace_back(inb);
        c.emplace_back(inc);
        d.emplace_back(ind);
    }
    
    dfs(A);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3196
local mfl = math.floor
local n = io.read("*n")

local function getprimes(x)
  local primes = {}
  local allnums = {}
  for i = 1, x do allnums[i] = true end
  for i = 2, x do
    if allnums[i] then
      table.insert(primes, i)
      local lim = mfl(x / i)
      for j = 2, lim do
        allnums[j * i] = false
      end
    end
  end
  return primes
end

local t = getprimes(n * 2)
for i = 1, #t do
  if n <= t[i] then
    print(t[i])
    break
  end
end


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> k(m);
  int s[10][10] = {};
  rep(i, m){
    cin >> k[i];
    rep(j, k[i]){
      cin >> s[i][j];
    }
  }
  vector<int> p(m);
  rep(i, m) cin >> p[i];
  
  int ans = 0;
  rep(i, 1<<n){
    bool state = true;
    rep(j, m){
      int num = 0;
      rep(l, k[j]){
        if ( i / (1<<(s[j][l]-1)) % 2 == 1 )
          num = (num + 1) % 2;
      }
      if (num != p[j]){
        state = false;
        break;
      }
    }
    if (state) ans++;
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 384
/*input
AAAAABBBBAAABBBBAAAA
BBBBAAABBBBBBAAAAABB
10
2 15 2 13
2 13 6 16
1 13 2 20
4 20 3 20
1 18 9 19
2 14 1 11
3 20 3 15
6 16 1 17
4 18 8 20
7 20 3 14
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back

#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)

#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int raise(int a,int n,int m = MOD){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= raise(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

const int N = 1e5+1;
int pref[N];
int pref1[N];
string s,t;
int n,m,q;

void solve(){
  	cin >> s >> t >> q;
  	n = s.size();
  	m = t.size();
  	pref[0] = pref1[0] = 0;
  	RE(i,n){
  		pref[i] = pref[i-1]+(s[i-1] == 'A');
  	}
  	RE(i,m){
  		pref1[i] = pref1[i-1]+(t[i-1] == 'A');
  	}
  	while(q--){
  		int a,b,c,d;cin >> a >> b >> c >> d;
  		int a1 = pref[b]-pref[a-1];
  		int a2 = pref1[d]-pref1[c-1];
  		int b1 = (b-a+1)-a1;
  		int b2 = (d-c+1)-a2;
  		int one = a1-a2;
  		int two = b1-b2;
  		one %= 3;
  		two %= 3;
  		if(one < 0)one += 3;
  		if(two < 0)two += 3;
  		if(one == two){
  			cout << "YES";
  		}
  		else cout << "NO";
  		cout << endl;
  	}
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
  return 0;
}

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

int dfs(int n,int s,int i){
  if(n == 0){
    if(s == 0)return 1;
    else return 0;
  }
  if(s -i < 0)return 0;
  if(i > 9 || n <= 0)return 0;

  return dfs(n,s,i + 1) + dfs(n - 1,s - i,i + 1);
}

int main(){
  int n,s;
  
  while(cin >> n >> s,n|s){
    cout << dfs(n,s,0) << endl;
  }
}

Measured memory_bytes: 3084
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iomanip>
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;

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

 if(a==b && a!=c){
 cout << "Yes" <<endl;
 }else{
   if(a==c && a!=b){
     cout << "Yes" <<endl;
   }else{
     if(b==c && b!=a){
       cout << "Yes" <<endl;
     }else{
       cout << "No" <<endl;
     }
   }
  }

}

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

using namespace std;

int main() {
  int N, ans = 0;
  cin >> N;
  int mark[105] = {false};
  for (int i = 1; i <= N; ++i) { int x; cin >> x; mark[x] = 1; }
  for (int i = 1; i <= 100; ++i) if (mark[i]) ans++;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <deque>
#include <utility>
#include <algorithm>
using namespace std;

int main(void){

    string s, t;
    cin>>s>>t;
    
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());
    
    bool bb=true;
    bool bc=false;

    if(s<t){
        bb=true;
    }else{
        bb=false;
    }
  
    if(s.size()<t.size()){
        bc=true;
        for(int i=0; i<s.size(); i++){
            if(s[i]!=t[i]){
                bc=false;
                break;
            }
        }
    }
    
    
    if(bb||bc){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

}


Measured memory_bytes: 256
import itertools
import numpy as np
d_list = []
sum_d = 0
N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for i in range(Q)]
ans = 0
A = [1 for i in range(N)]
for A in itertools.combinations_with_replacement(range(1, M+1), N):
  for i in range(Q):
    if A[abcd[i][1]-1]-A[abcd[i][0]-1] == abcd[i][2]:
      d_list.append(abcd[i][3])
  if sum_d <= sum(d_list):
    sum_d = sum(d_list)
  d_list.clear()
print(sum_d)

Measured memory_bytes: 26956
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    if(n % 1000 == 0){
		cout << 0 << "\n";
	}else{
		cout << 1000 - n % 1000 << "\n";
	}
}
 


Measured memory_bytes: 3636
//Author : Prakhar Asaiya
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(ll i=a;i<b;++i)
#define REPN(i,a,b) for(ll i=a;i<=b;++i)
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define ll long long
const int M=1e9+7;


int main()
{/*
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#*/
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);

   ll a,b;
   cin>>a>>b;
   cout<<a*b<<'\n';

   return 0;
}

Measured memory_bytes: 3656
#include <iostream>
using namespace std;
int main(void){
  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;
  
  return 0;
}

Measured memory_bytes: 256
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from functools import *
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def Golf():
    *a,=map(int,open(0))
def S_():
    return input()
def IS():
    return input().split()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2)
    found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['YES','NO']

mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()
 
def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0

n=I()

if n<=999:
    ans='ABC'
else:
    ans='ABD'

print(ans)




Measured memory_bytes: 39020
import sys
input = sys.stdin.readline

S,K=input().split()
K=int(K)
mod=998244353

LEN=len(S)

ONES=[]
Z=0
for s in S:
    if s=="0":
        Z+=1
    else:
        ONES.append(Z)

if ONES==[]:
    print(1)
    sys.exit()

O=len(ONES)
Z=ONES[-1]

DP=[[0]*(O+1) for i in range(min(O,K)+1)]
DP[0][0]=1

# DP[i][j]で, i個石を動かし、j個石が残っているときの場合の数

from collections import Counter
C=Counter(ONES)

for numb in range(Z,-1,-1):
    #print(DP)
    c=C[numb]

    NDP=[[0]*(O+1) for i in range(min(O,K)+1)]

    for i in range(min(O,K)+1):        
        for j in range(O+1):
            if DP[i][j]==0:
                continue
            for oku in range(c+j+1):
                if i+max(0,oku-c)<=min(O,K) and 0<=c+j-oku<=O:
                    NDP[i+max(0,oku-c)][c+j-oku]=(NDP[i+max(0,oku-c)][c+j-oku]+DP[i][j])%mod
    DP=NDP

ANS=0
for i in range(min(O,K)+1):
    ANS+=DP[i][0]

print(ANS%mod)


Measured memory_bytes: 73068
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

ll fact[1000010];

ll power(ll a, ll b) {
	ll result = 1;
	while(b) {
		if(b % 2) result = (result * a) % P;
		a = (a * a) % P;
		b /= 2;
	}
	
	return result;
}

ll divide(ll a, ll b) {
	return a * power(b, P - 2) % P;
}

ll C(int n, int k) {
	ll ans = fact[n];
	ans = divide(ans, fact[k]);
	ans = divide(ans, fact[n - k]);
	
	return ans;
}

void solve() {
	int n;
	cin >> n;
	
	ll tot = power(10, n);
	for(int i = 1; i <= n; i++) {
		ll res = (((2 * C(n, i)) % P) * power(8, n - i)) % P;
		tot = (tot - res + P) % P;
	}
	
	tot = (tot - power(8, n) + P) % P;
	
	cout << tot << endl;
}

int main() {
	ios_base::sync_with_stdio(false);
	fact[0] = 1;
	for(int i = 1; i <= 1000000; i++) fact[i] = (fact[i - 1] * i) % P;
	
	solve();
    return 0;
}

Measured memory_bytes: 11460
// Problem : B - Making Triangle
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*

WINNERS NEVER QUIT AND QUITTERS NEVER WIN!!

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<long,long> pl;
typedef pair<ll,ll> pll;
typedef vector<long> vl;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef vector<vll> vvll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef unordered_map<ll,ll> umll;

#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define REV(i,a,b) for(long long i=a;i>=b;i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define tc ll tests;cin>>tests;while(tests--)
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define coutv(v) for(auto it: (v))cout<<it<<" ";newl;
#define cout2d(v) for(auto it: (v)) {for(auto j:it) cout<<j<<" ";newl;}
#define cinv(v,n) vll (v)(n);FOR(i,0,(n)){cin>>v[i];}
#define cinvg(v,n) (v).resize(n);FOR(i,0,(n)){cin>>v[i];}
#define cin2d(v,n,m) vvll (v)(n,vll(m,0));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define cin2dg(v,n,m) (v).resize(n,vll(m));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define newl cout<<"\n"
#define mod 1000000007
#define INF LLONG_MAX/2

int main()
{
    io;
    ll n,ans=0;
    cin>>n;
    cinv(l,n)
    sort(all(l));
    FOR(i,0,n-2)
    {
    	FOR(j,i+1,n-1)
    	{
    		FOR(k,j+1,n)
    		{
    			if(l[i]!=l[j] && l[j]!=l[k] &&l[i]+l[j]>l[k])
    			{
    				ans++;
    			}
    		}
    	}
    }
    cout<<ans;
    return 0;
}



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

int main(){
    int a;
    string s;
    cin >> a >> s;
    if(a>=3200) cout << s << endl;
    else puts("red");
    return 0;
}

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

int main() {
    ll a, b ;
    cin >> a >> b ;
    ll k = a + b;
    if(k % 2 == 1){
        cout << "IMPOSSIBLE" << endl ;
    }
    else {
        cout << k / 2 << endl ;
    }
}

Measured memory_bytes: 3632