akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647 >> 1); // 10^9 + 5000
static const ll LLINF = (9223372036854775807 >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Kunitaka{
    template<
        typename TYPE,
        std::size_t SIZE
    >
    std::size_t array_length(const TYPE (&array)[SIZE])
    {
        return SIZE;
    }
}
using namespace Kunitaka;
namespace Printer{
    void br(){
        cout << endl;
    }

    void loop_cnt(int i){
        cout << "i = " << i << endl;
    }

    void loop_cnt(int i, int j){
        cout << "i = " << i << ", " << "j = " << j << endl;
    }

    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T, class S>
    void print(T x, S y){
        cout << x << "," << y << endl;
    }

    template<class T, class S, class U>
    void print(T x, S y, U z){
        cout << x << "," << y << "," << z << endl;
    }

    template<class T, class S>
    void print(pair<T, S> p){
        cout << p.first << ", " << p.second << endl;
    }

    template<
        typename TYPE,
        std::size_t SIZE
    >
    void print(const TYPE (&array)[SIZE]){
        int lim = array_length(array);
        for(int i=0; i<lim; i++){
            if(i) cout << " ";
            cout << array[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<S> v){
        for(int i=0; i<v.size(); i++){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<vector<S> > vv){
        for(int i=0; i<vv.size(); i++){
            for(int j=0; j<vv[i].size(); j++){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void yesno(bool x){
        if(x) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
};
using namespace Printer;

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    // variable
    ll ans = 0;

    // input
    cout << fixed << setprecision(10);
    string S; cin >> S;

    // solve
    rep(i, S.size()){
        cout << "x";
    }
    cout << endl;
    
    return 0;
}


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

string s;
string solve() {
    for (int i = 0; i < s.length(); i++) {
        // 奇数
        if (i % 2 == 0) {
            if (s[i] == 'L') return "No";
        } else {
            if (s[i] == 'R') return "No";
        }
    }
    return "Yes";
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    cout << solve() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    int n, p;
    cin >> n >> p;
    string s;
    cin >> s;


    if (10 % p == 0) {
        ll ans = 0;
        rep(r, n) {
            if ((s[r] - '0') % p == 0) ans += r + 1;
        }

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

    vector<int> d(n + 1);
    int ten = 1;
    for (int i = n - 1; i >= 0; i--) {
        int a = (s[i] - '0') * ten % p;
        d[i] += (d[i + 1] + a) % p;
        ten *= 10;
        ten %= p;
    }

    vector<int> cnt(p);
    ll ans = 0;
    for (int i = n; i >= 0; i--) {
        ans += cnt[d[i]];
        cnt[d[i]]++;
    }
    cout << ans << endl;

}


Measured memory_bytes: 1412
program grid_game
  implicit none
  integer :: h, w, n, p(200000,2) = 0, i, j = 1, x = 1, d
  read(*,*) h, w, n
  do i = 1, n
    read(*,*) p(i,:)
  end do
  call merge_sort(p(1:n,:))
  do i = 1, h
    do while (j <= n .and. p(j,1) < i+1)
      j = j+1
    end do
    d = 1
    do while (j <= n .and. p(j,1) == i+1)
      if (p(j,2) <= x) then
        write(*,'(i0)') i
        stop
      else if (p(j,2) == x+1) then
        d = 0
      end if
      j = j+1
    end do
    x = x+d
  end do
  write(*,'(i0)') h
contains
  subroutine merge_sort(a)
    integer, intent(inout) :: a(:,:)
    integer :: n, m, l, i, u
    n = size(a,1)
    m = n
    l = 1
    do while (m > 1)
      do i = 1, m/2
        u = min(2*i*l,n)
        call merger(a(2*(i-1)*l+1:(2*i-1)*l,:),a((2*i-1)*l+1:u,:))
      end do
      l = 2*l
      m = (m+1)/2
    end do
  end
  subroutine merger(a1,a2)
    integer, intent(inout) :: a1(:,:), a2(:,:)
    integer :: a(size(a1,1)+size(a2,1),size(a1,2))
    integer :: i1, i2, n1, n2
    i1 = 1
    i2 = 1
    n1 = size(a1,1)
    n2 = size(a2,1)
    do while (i1 <= n1 .and. i2 <= n2)
      if (a1(i1,1) < a2(i2,1) .or. &
      & (a1(i1,1) == a2(i2,1) .and. a1(i1,2) < a2(i2,2))) then
        a(i1+i2-1,:) = a1(i1,:)
        i1 = i1+1
      else
        a(i1+i2-1,:) = a2(i2,:)
        i2 = i2+1
       end if
    end do
    if (i1 <= n1) then
      a(i1+i2-1:n1+n2,:) = a1(i1:n1,:)
    else
      a(i1+i2-1:n1+n2,:) = a2(i2:n2,:)
    end if
    a1 = a(1:n1,:)
    a2 = a(n1+1:n1+n2,:)
  end
end program grid_game

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using P = pair<int,int>;
constexpr long long MOD = 998244353;
int n, x, d, l[200005];
long long dp[200005], ac[200005], ans;
P p[200005];
struct SegTree{
	int sz;
	int ide = -1;
	vector<int> dat;
	SegTree(int n){
		for(sz = 2; sz < n; sz *= 2);
		dat.assign(sz*2, ide);
		for(int i=sz; i<sz*2; i++) dat[i] = i-sz+1;
		for(int i=sz-1; i>=0; i--) dat[i] = max(dat[i*2],dat[i*2+1]);
	}
	void set(int x, int n){
		dat[x += sz] = n;
		while(x /= 2) dat[x] = max(dat[x*2], dat[x*2+1]);
	}
	int query(int a, int b, int k = 1, int l = 0, int r = -1){
		if(r == -1) r = sz;
		if(r <= a || b <= l) return ide;
		if(a <= l && r <= b) return dat[k];
		return max(query(a, b, k*2, l, (l+r)/2), query(a, b, k*2+1, (l+r)/2, r));
	}
} sg(200005);
int main(){
	scanf("%d", &n);
	rep(i,n){
		scanf("%d%d", &x, &d);
		p[i] = P{x,d};
	}
	sort(p,p+n);
	ans = dp[n] = ac[n] = 1;
	for(int i=n-1; i>=0; i--){
		int t = sg.query(i,upper_bound(p,p+n,P{p[i].first+p[i].second,0})-p);
		sg.set(i,t);
		dp[i] = ac[t]; 
		(ac[i] = dp[i] + ac[i+1]) %= MOD;
		(ans += dp[i]) %= MOD;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
#define int long long
int m = 1000000007;
 main() {
    int h, w;
    cin >> h >> w;
    char grid[h][w];
    int i, j;
    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
            cin >> grid[i][j];
        }
    }
    int dp[h][w];
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    for (i = 1; i < h; i++) {
        if (grid[i][0] == '#')
            dp[i][0] = 0;
        else
            dp[i][0] = dp[i - 1][0];
    }
    for (i = 1; i < w; i++) {
        if (grid[0][i] == '#')
            dp[0][i] = 0;
        else
            dp[0][i] = dp[0][i - 1];
    }
    for (i = 1; i < h; i++) {
        for (j = 1; j < w; j++) {
            if (grid[i][j] == '#') {
                dp[i][j] = 0;
                continue;
            }
            dp[i][j] = (dp[i - 1][j]%m + dp[i][j - 1]%m)%m;
        }
    }
    // for (i = 0; i < h; i++) {
    //     for (j = 0; j < w; j++) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    cout << dp[h - 1][w - 1];
   
}

Measured memory_bytes: 9088
n = int(input())
a_list = [int(i) for i in input().split()]

a = 0
ans = [str(i) for i in a_list]

for i in a_list:
    a += 1
    ax = str(a)
    ans[i-1] = ax

answer = ''
for i in ans:
    answer += i
    answer += ' '

print(answer)


Measured memory_bytes: 15584
N = int(input())
hhh = list(map(int, input().split()))
m = 0
ans = 0
for i in range(N - 1):
    if hhh[i] >= hhh[i + 1]:
        m += 1
        ans = max(ans, m)
    else:
        m = 0
print(ans)


Measured memory_bytes: 20316
n,a,*x=map(int,open(0).read().split())
x=[0]+x
dp=[[[0]*(50*n+1)for j in range(n+1)]for i in range(n+1)]
dp[0][0][0]=1
for i in range(1,n+1):
  dp[i][0]=dp[i-1][0]
  for j in range(1,n+1):
    for k in range(1,50*n+1):
      dp[i][j][k]=dp[i-1][j][k]
      if k-x[i]>=0:
        dp[i][j][k]+=dp[i-1][j-1][k-x[i]]
ans=0
for i in range(1,n+1):
  j=i*a
  if j<50*n+2:
    ans+=dp[-1][i][j]
print(ans)

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

vector<bool> seen;  // 訪問済みの点
Edge I;

// BFSのための再帰関数
void bfs(const Graph &G, int v, int color, int k) {
    seen[v] = true;
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue;
        I[make_pair(v, next_v)] = color;
        I[make_pair(next_v, v)] = color;
        color = (color + 1) % k;
        bfs(G, next_v, color, k);
    }
}

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

    // グラフ
    Graph G(N);

    vector<int> A(N-1);
    vector<int> B(N-1);

    seen.assign(N, false);

    vector<pair<int,int>> vp;

    REP(i, N-1){
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
        A[i] = a-1;
        B[i] = b-1;
        vp.emplace_back(a-1,b-1);
    }
    int K = 0;
    int index = 0;

    // 次数が最も高い頂点を探索
    REP(i, N){
        int size;
        size = G[i].size();
        if(size >= K){
            K = size;
            index = i;
        }
    }

    bfs(G, index, 0, K);

    cout << K << endl;
    for(auto p:vp) cout << I[p]+1 << endl;
    return 0;
}

Measured memory_bytes: 20856
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 

//prefix sums
void solve(){
	int n,q; string s; cin >> n >> q >> s;
	int pref[n];
	pref[0] = 0;
	FOR(i,1,n){
		pref[i] = pref[i-1];
		if(s.substr(i-1,2) == "AC") pref[i] += 1;
	}
	FOR(q){
		int l,r; cin >> l >> r;
		--l,--r;
		cout << pref[r] - pref[l] << '\n';
	}
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


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

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int N = int.Parse(input);
            string[] s_array = Console.ReadLine().Split(' ');
            var A_array = new List<int>();
            for (int i = 0; i < N; i++)
            {
                A_array.Add(int.Parse(s_array[i]));
            }
            int max = A_array.Max();
            int min = A_array.Min();
            Console.WriteLine(max - min);
        }
    }
}


Measured memory_bytes: 13268
ss,t = list(input()),input()

flag = False
for i in range(len(ss)):
    if ss[i] == '?' or ss[i] == t[0]:
        for j in range(len(t)):
            if i+j >= len(ss):                
                break
            elif ss[i+j] == t[j] or ss[i+j] == '?':
                if j == len(t)-1:
                    flag = True
                    start_t = i
                continue
            else:
                break
        
ans = 'UNRESTORABLE'
if flag:
    ss[start_t:start_t+len(t)] = t
    ans = ''.join(ss).replace('?','a')

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define repeat(i,a,b) for(int i=(a),i##__end=(b);i<i##__end;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,i##__end=(a);i>=i##__end;i--)
#define mst(a,x) memset((a),(x),sizeof(a))
#define pii pair<int,int>
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string s;
	int n,ans=0;
	cin>>n;
	cin>>s;
	repeat(i,0,n-1)
	if(s[i]!=s[i+1])ans++;
	cout<<ans+1<<endl;
	return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
const int INF = 0x3f3f3f3f;

ll f(ll N) {
    ll ret = 0;
    while (N) {
        ret += N % 10;
        N /= 10;
    }
    return ret;
}

int main() {
    ll N;
    cin >> N;
    if (N % f(N) == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(void)
{
    string S, ans;
    int al[26], i, j, n, x;

    cin >> S;

    n = S.size();

    for(i=0; i<26; i++){
        al[i] = 0;
    }

    for(i=0; i<n; i++){
        for(j=0; j<26; j++){
            if(S[i] == 'a'+j){
                al[j]++;
            }
        }
    }

    for(i=0; i<26; i++){
        if(al[i] == 0){
            ans = 'a'+i;
            cout << ans << endl;
            break;
        }

        if(i == 25){
            cout << "None" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int a,c,b,d;
cin>>a>>b>>c>>d;
if(abs(a-c)<=d)
    cout<<"Yes";
else
{
    if(abs(a-b)<=d&&abs(b-c)<=d)
        cout<<"Yes";
    else
        cout<<"No";
}
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b,c,d,e;
	while(scanf("%d",&e)!=EOF){
	a=e/1000;
	b=(e/100)%10;
	c=(e/10)%10;
	d=e%10;
	if((a+b+c+d)==7){printf("%d+%d+%d+%d=7\n",a,b,c,d);
	}
	else if((a+b+c-d)==7){printf("%d+%d+%d-%d=7\n",a,b,c,d);break;
	}
	else if((a+b-c+d)==7){printf("%d+%d-%d+%d=7\n",a,b,c,d);break;
	}
	else if((a+b-c-d)==7){printf("%d+%d-%d-%d=7\n",a,b,c,d);break;
	}
	else if((a-b+c+d)==7){printf("%d-%d+%d+%d=7\n",a,b,c,d);break;
	}
	else if((a-b+c-d)==7){printf("%d-%d+%d-%d=7\n",a,b,c,d);break;
	}
	else if((a-b-c-d)==7){printf("%d-%d-%d-%d=7\n",a,b,c,d);break;
	}
	else if((a-b-c+d)==7){printf("%d-%d-%d+%d=7\n",a,b,c,d);break;
	}
	}
	return 0; 
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define cs const
#define pb push_back
using namespace std;
typedef long long ll;
cs int N = 2e5 + 50;
int n, a[N], lp[N]; ll k;
int main(){
	#ifdef FSYolanda
	freopen("1.in","r",stdin);
	#endif
	scanf("%d%lld",&n,&k);
	for(int i=1; i<=n; i++) 
	scanf("%d",&a[i]);
	static int la[N];
	for(int i=1; i<=n; i++)
	if(!la[a[i]]) la[a[i]] = n+i;
	for(int i=n; i>=1; i--)
	lp[i]=la[a[i]], la[a[i]]=i;
	static int r[N];
	for(int i=1,x=1,c=1;;i++){
		if(i>1 && x==1){
			k = k % c ? k % c : c;
			break;
		} r[x] = c;
		if(lp[x] > n) ++c;
		x = lp[x] % n + 1;
	}
	for(int i=n; i>=1; i--) if(r[i] == k){
		static bool ex[N];
		memset(ex, 0 , sizeof(ex));
		static int stk[N]; int top = 0;
		for(int j = i; j <= n; j++){
			if(ex[a[j]]){
				while(stk[top] != a[j]) 
				ex[stk[top]] = false, --top;
				ex[a[j]] = false, --top;
			} else stk[++top] = a[j], ex[a[j]] = true;
		} for(int j = 1; j <= top; j++) cout << stk[j] << " ";
		return 0;
	}
	return 0;
}

Measured memory_bytes: 7688
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;

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

        while(true){
            int n = sc.nextInt();
            if(n == 0) break;

            int ave = 0;
            int[] s = new int[n];
            for(int i = 0; i < n; i++){
                s[i] = sc.nextInt();
            }

            Arrays.sort(s);
            for(int i = 1; i < n - 1; i++){
                ave += s[i];
            }
            ave /= (n - 2);

            result.add(ave);
        }

        for(int i : result){
            System.out.println(i);
        }
        sc.close();
    }
}


Measured memory_bytes: 28872
PROGRAM ATCODER

implicit none
integer :: a,b,k,i,c

read(*,*) a,b,k    !ここが入力欄

c = 0
do i = 100, 1, -1
	if(mod(a,i) == 0 .and. mod(b,i) == 0)then
		c = c + 1
	end if
    if(c == k)then
    	write(*,'(I0)') i
        stop
    end if
end do


END PROGRAM ATCODER

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

const int MAX = 200001;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    int H,W,A,B;cin >> H >> W >> A >> B;
    // 前処理
    COMinit();

    LL ans = 0;
    rep(i,W-B){
        LL tmp = 1;
        tmp = tmp * COM(H-A-1+B,B+i) % MOD;
        if(A+i < H)tmp = tmp * COM(A+W-1-B,A+i) % MOD;

        ans += tmp;
        ans %= MOD;

    //    cout << COM(H-A-1+B+i,B+i) << " " << COM(A+W-B-1-i,A) << endl;
    //    cout << ans << "# " << endl;
    }

    cout << ans << endl;

}

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

int top, S[100];
 
void push(int x){
	top++;
	S[top]=x;
}
 
int pop(){
	top--;
	return S[top+1];
}
 
int main(void){
	int a,b;
	char s[100];
	top=0;
   
	while(scanf("%s",s)!=EOF){
		if(s[0]=='+'){
			b=pop();
			a=pop();
			push(a+b);
		}else if(s[0]=='-'){
			b=pop();
			a=pop();
			push(a-b);
		}else if(s[0]=='*'){
			b=pop();
			a=pop();
			push(a*b);
		}else{
			push(atoi(s));
		}
	}
	
	printf("%d\n",pop());
	
	return 0;
}

Measured memory_bytes: 548
#pragma GCC optimize("Ofast")
#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;
using ll = long long;
using u64 = uint_fast64_t;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll A,B; cin >> A >> B;

    auto dfs=[](auto&& self, ll x, ll y)->ll {
        if (x==y) return 1;
        ll ma = -1, mb = -1;
        rep(i,60) if (x&(1LL<<i)) ma = i;
        rep(i,60) if (y&(1LL<<i)) mb = i;
        if (ma==mb) {
            x -= 1LL<<ma;
            y -= 1LL<<mb;
            return self(self,x,y);
        }
        // if (ma+2<=mb) {
        //     return (1LL<<(mb+1)) - x;
        // }
        ll val1 = (1LL<<mb) - x;
        ll val2 = self(self,0,y-(1LL<<mb));
        return min(val1+val2,1LL<<mb) + val1;
    };

    cout << dfs(dfs,A,B) << ln;
}

Measured memory_bytes: 3692
#include<stdio.h>

int main(void)
{
  int x,y,c1,c2;
  scanf("%d%d",&x,&y);
  if((x==4||x==6)||(x==9||x==11))
    c1=2;
  else if(x==2)
    c1=3;
  else
    c1=1;
  if((y==4||y==6)||(y==9||y==11))
    c2=2;
  else if(y==2)
    c2=3;
  else
    c2=1;
  if(c1==c2)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}


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

using namespace std;

int main() {
	int n;
	int count = 1;

	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}

	std::sort(v.begin(), v.end(), greater<int>());

	for (int i = 1; i < n; i++) {
		if (v[i] < v[i-1]) {
			count++;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
*/public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
static class TaskD   {
int N;
long X;
long sum = 0;

public void solve(int testNumber, Scanner in, PrintWriter out) {
        N = in.nextInt();
        X = in.nextLong();
        long max = 1;
        for(int i=0; i<=N-1; i++){
            max = max*2 + 3;
        }
        dfs(1, max, N);
        out.println(sum);
    }

void dfs(long i1, long i2, int d) {
        if (d == 0) {
            if(i1 <= X){
                sum++;
            }
            return;
        }
        long mid = (i1 + i2)/2;
        if (mid <= X) {
            sum++;
            dfs(mid+1, i2-1, d-1);
            for(int i=0; i<=d-1; i++){
                sum+=pow(2, i);
            }
        } else {
            dfs(i1+1, mid-1, d-1);
        }
    }

public   static long pow(long x, long n) {
        long sum = 1;
        while (n > 0) {
            if ((n & 1) == 1) {
                sum *= x;
            }
            x *= x;
            n >>= 1;
        }
        return sum;
    }

}
}



Measured memory_bytes: 23764
sx, sy, ex, ey = (int(n) for n in input().split(" "))
trial = int(input())
for _ in range(trial):
    x, y = (int(n) for n in input().split(" "))
    if sx == ex:
        print(sx, y)
    elif sy == ey:
        print(x, sy)
    else:
        grad = (ey - sy) / (ex - sx)
        y_seg = sy - (grad * sx)
        per_grad = -1 / grad
        per_y_seg = y - (per_grad * x)
        ans_x = (y_seg - per_y_seg) / (-1 * (grad - per_grad))
        ans_y = per_grad * ans_x + per_y_seg
        print(ans_x, ans_y)



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

int main() {
  string s;
  cin >> s;
  if(s[0] == s[1]){
    cout << "Bad";
    return 0;
  }
  if(s[2] == s[1]){
    cout << "Bad";
    return 0;
  }
  if(s[2] == s[3]){
    cout << "Bad";
    return 0;
  }
  cout << "Good";
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

ll sum(ll l, ll r) {
   return (l + r) * (r - l + 1) / 2;
}

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

   int n, k;
   cin >> n >> k;
   ll ans = 0;
   rep(i, k, n + 2) {
      ll l = sum(0, i - 1), r = sum(n - i + 1, n);
      (ans += r - l + 1) %= MOD;
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 3652
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
	    Scanner s=new Scanner(System.in);
	    long n=s.nextLong();
	    int k=s.nextInt();
	    long a[]=new long[k];
	    long sum=0;
	    for(int i=0;i<k;i++)
	    {a[i]=s.nextLong();sum+=a[i];}
	    if(sum>=n)
	    System.out.println("Yes");
	    else
	    System.out.println("No");
	}}
	    

Measured memory_bytes: 50356
#include <bits/stdc++.h>
using namespace std;
int a,b,n,k=1,divisor;
int main()
{
  cin >> a>>b>>n;
  divisor=max(a,b);
  while(true)
  {
    if(a%divisor==0&&b%divisor==0)
    {
      if(k==n)
      {
        cout <<divisor<<endl;
        exit(0);
      }
        k++;
    }
    divisor--;
  }
  return 0;
}

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

bool isKaibun(string s)
{
    int k=(s.size()-1)/2;
    string sub=s;
    reverse(s.begin(),s.end());
    if(s==sub)return true;
    return false;
}

bool is1(string s)
{
    int k=(s.size()-1)/2;
    string a=s.substr(0,k);
    if(isKaibun(a))return true;

    return false;
}

bool is2(string s)
{
    int k=(s.size()+3)/2;
    string a=s.substr(k-1);
    if(isKaibun(a))return true;

    return false;
}

int main()
{
    string s;
    cin>>s;
    if(isKaibun(s) && is1(s) && is2(s))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
 
int main(){
  std::string a, b;
  std::cin >> a >> b;
  int L = a.size();
  for(int i=0;i<L;i++){
    bool matched = true;
    for(int j=0;j<L;j++){
        if( a[j] != b[(i+j)%L]){
            std::cerr << i <<',' << j<<','<<a[i]<<','<<b[(i+j)%L]<<std::endl;
            matched = false;
            break;
        }
    }
    if(matched){
       std::cout << "Yes";
      return 0;
    }
   }
       std::cout << "No";
 
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  int ans = 0;
  FOR(i,1,N+1) {
    if(i%2==0) continue;
    int cnt = 0;
    FOR(j,1,i+1) {
      if(i % j == 0) {
        cnt++;
      }
    }
    if(cnt == 8) ans++;
  }
  cout << ans << endl;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> H(N);
    for (int i = 0; i < N; i++){
        cin >> H.at(i);
    }
    bool possible = true;
    int max_H = 0;
    for (int i = 0; i < N; i++){
        if (max_H - H.at(i) >= 2){
            possible = false;
            break;
        }
        max_H = max(max_H, H.at(i));
    }
    if (possible){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll H, W, N;
    cin >> H;
    cin >> W;
    cin >> N;

    cout << (N-1)/max(H,W) + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n+1];
	unsigned long long sum=0;
	for(int i=1;i<=n;i++){
		if(i%3!=0&&i%5!=0){
			sum+=i;
		}
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 3636
/// @file

#include <algorithm>
#include <iostream>
#include <vector>

namespace {

bool run(std::istream& is, std::ostream& os);
}  // unnamed namespace

/// @brief エントリポイント
#ifdef _TEST
static int run()
#else
int main()
#endif
{
  try {
    if (run(std::cin, std::cout) == false) {
      std::cerr << "main funciton error.\n";
      return EXIT_FAILURE;
    }
  } catch (const std::exception& e) {
    std::cerr << "catch exception\n";
    std::cerr << e.what() << "\n";
    return EXIT_FAILURE;
  }

  return EXIT_SUCCESS;
}

namespace {

using val_t = long;
using arr_t = std::vector<val_t>;

/// @brief 実行処理
bool run(std::istream& is, std::ostream& os)
{
  // 入力データの読み込み
  long n;
  is >> n;

  arr_t arr(n);
  for(auto& v: arr) is >> v;

  // 昇順ソート
  std::sort(arr.begin(), arr.end());

  val_t leftValue = arr.front();
  val_t rightValue = arr.back();
  val_t diffSum = rightValue - leftValue;
  for (std::size_t first = 1, last = arr.size() - 2; first <= last;) {
    const val_t ARR_FIRST = arr[first];
    const val_t ARR_LAST = arr[last];

    const val_t LEFT_FIRST = std::abs(leftValue - ARR_FIRST);
    const val_t LEFT_LAST = std::abs(leftValue - ARR_LAST);
    const val_t RIGHT_FIRST = std::abs(rightValue - ARR_FIRST);
    const val_t RIGHT_LAST = std::abs(rightValue - ARR_LAST);

    const val_t LEFT_MAX = std::max(LEFT_FIRST, LEFT_LAST);
    const val_t RIGHT_MAX = std::max(RIGHT_FIRST, RIGHT_LAST);
    if (LEFT_MAX > RIGHT_MAX) {
      diffSum += LEFT_MAX;
      if (LEFT_FIRST > LEFT_LAST) {
        leftValue = ARR_FIRST;
        ++first;
        continue;
      }

      leftValue = ARR_LAST;
      --last;
      continue;
    }

    diffSum += RIGHT_MAX;
    if (RIGHT_FIRST > RIGHT_LAST) {
      rightValue = ARR_FIRST;
      ++first;
      continue;
    }

    rightValue = ARR_LAST;
    --last;
  }

  os << diffSum << "\n";

  return true;
}
}  // unnamed namespace


Measured memory_bytes: 1024
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

P ab[2000001];

int
main(void){  
  ios_base::sync_with_stdio(false);

  int n, m;
  cin >> n >> m;
  
  REP(i, m){
    int a, b;
    cin >> a >> b;
    ab[i].first = a;
    ab[i].second = b;
  }
  bool f = false;
  sort(ab, ab+m);

  set<int> s;
  
  REP(i, m) if(ab[i].first == 1) s.insert(ab[i].second);
  REP(i, m) if(ab[i].second == n){
    auto src = s.find(ab[i].first);
    if(src != s.end()) f = true;
  }
  
  cout << (f ? "POSSIBLE" : "IMPOSSIBLE") << endl;
  
  return 0;
}


Measured memory_bytes: 6528
#include <stdio.h>
#include <string.h>
#include <math.h>

int main() {

    int n, d, x, a;
    scanf("%d %d %d", &n, &d, &x);

    int mysum = 0;
    for (int i = 0; i < n; i++) {
        scanf("%d", &a);
        int cnt = 1;
        while (1) {

            if (cnt * a + 1 <= d) {
                mysum += 1;
                cnt++;
                
            }else{
                break;
            }
        }
        mysum+=1;
    }
    printf("%d\n", mysum+x);

    


    return 0;
} 

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

int selectionSort(int A[],int n){
    int count = 0;
    rep(i,n){      
        int minj = i;
        for(int j=i;j<n;j++){
            if(A[j]<A[minj]) minj = j;
        }
        if(minj != i) {
            swap(A[i],A[minj]);
            count++;
        }
    }
    return count;
}

int main(){
    int N,count,A[100];
    cin >> N;
    rep(i,N) cin >> A[i];
    count = selectionSort(A,N);
    rep(i,N){
        if(i>0) cout << ' ';
        cout << A[i];
    }
    cout << endl << count << endl;
    return 0;
}


Measured memory_bytes: 3080
main = do
    k <- readInt <$> getLine
    [a, b] <- map readInt . words <$> getLine
    putStr $ solve k a b

readInt :: String -> Int
readInt = read

solve k a b
    | a `mod` k == 0 = "OK"
    | b `mod` k == 0 = "OK"
    | a `div` k /= b `div` k = "OK"
    | otherwise = "NG"

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

using namespace std;

template <typename T>
class dinic{
private:
	unordered_map<int,unordered_map<int,T>> mp;
	unordered_map<int,int> level;
	unordered_set<string> visited;
public:
	void add_edge(int from, int to, T cap){
		mp[from][to] = cap;
		mp[to][from] = 0;
	}

	void bfs(int s){
		level.clear();
		queue<int> q;
		level[s] = 0;
		q.push(s);
		while(!q.empty()){
			int v = q.front();q.pop();
			for(auto x:mp[v]){
				if(x.second > 0 && !level.count(x.first)){
					level[x.first] = level[v] + 1;
					q.push(x.first);
				}
			}
		}
	}

	T dfs(int v, int t, T f){
		if(v == t){
			return f;
		}
		for(auto x:mp[v]){
			if(visited.count(to_string(v) + ":" + to_string(x.first))) continue;
			visited.insert(to_string(v) + ":" + to_string(x.first));
			if(x.second > 0 && level.count(x.first) && level[v] < level[x.first]){
				T d = dfs(x.first, t, min(f, x.second));
				if(d > 0){
					mp[v][x.first] -= d;
					mp[x.first][v] += d;
					return d;
				}
			}
		}
		return 0;
	}

	T max_flow(int s, int t){
		T flow = 0;
		while(1){
			bfs(s);
			if(!level.count(t)) return flow;
			visited.clear();
			T f;
			while((f = dfs(s, t, 10000000)) > 0){
				flow += f;
			}
		}
	}
};

int main(){
	dinic<int> g;
	int x,y,e;
	cin >> x >> y >> e;
	for(int i=0;i<e;i++){
		int x,y;
		cin >> x >> y;
		g.add_edge(-1,x,1);
		g.add_edge(x,y+100,1);
		g.add_edge(y+100,-2,1);
	}
	cout << g.max_flow(-1,-2) << endl;
	return 0;
}


Measured memory_bytes: 5540
from collections import Counter

n = int(input())
s = [input() for i in range(n)]
march = ['M', 'A', 'R', 'C', 'H']
s = [v[0] for v in s if v[0] in march]

ans = 0
cnt = [v for v in Counter(s).values()]
if len(cnt) == 3:
    ans = cnt[0] * cnt[1] * cnt[2]
elif len(cnt) == 4:
    for i in range(4):
        ans += cnt[0] * cnt[1] * cnt[2] * cnt[3] // cnt[i]
elif len(cnt) == 5:
    for i in range(4):
        for j in range(i+1, 5):
            ans += cnt[0] * cnt[1] * cnt[2] * cnt[3] * cnt[4] // (cnt[i] * cnt[j])

print(ans)

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

int main(){
  long long L,R;
  cin>>L>>R;
  if((R-L)>2020){
    cout<<0<<endl;
    return 0;
  }
  long long res=2018;
  for (int i=L;i<R+1;i++){
    for (int j=i+1;j<R+1;j++){
      long long temp=((i%2019)*(j%2019))%2019;
      res=min(res,temp);
    }
  }
  cout<<res<<endl;
  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 rep2(i,n) for(int i=1;i<(n);i++)
typedef long long ll;

int main(){
    ll n,t; cin >> n >> t;
    vector<ll> s(n),u(n);
    rep(i,n){
       cin >> s[i]; 
    }
    u[0]=0;
    rep2(i,n){
        u[i]=s[i]-s[i-1];
        if(u[i]>t) u[i]=t;
    }
    ll ans=t;
    rep(i,n) ans+=u[i];
    cout << ans << endl;

}

Measured memory_bytes: 3328
import java.util.*;

public class Main {

    private static final int MOD = 1_000_000_007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        
        long ans = 0;
        long pow = 1;
        int i = 0;
        while (H > 0) {
            H /= 2;
            i++;

            ans += pow;

            pow *= 2;
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 22740
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
	int n; cin >> n;
	cout << (n >= 1000 ? "ABD": "ABC") << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  int n,s,max,f=0;
  cin>>n>>s;
  max=s;
  while(n--){
    int a,b;
    cin>>a>>b;
    s+=a-b;
    if(max<s)max=s;
    if(s<0)f=1;
  }
  cout<<((f)?0:max)<<endl;
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair

using namespace std;

ll get(ll n)
{
    return n*n*n;
}

int main()
{
   FAST/**/
   
   ll n,k;
   cin>>n>>k;
   
   ll ans = 0;
   
   if(k%2 == 0)
   {
       ll lim = (n/(k/2));
       ll n1 = (lim+1)/2;
       ans+=get(n1);
   }
   //cout<<"ans = "<<ans<<"\n";
   
   ll lim = n/k;
   ans+=get(lim);
   
   cout<<ans;
   
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
#define INF 10000000000

int main() {
	string ans;
	int n;
	cin >> n;

	if (n % 10 == 3) ans = "bon";
	else if (n % 10 == 0 || 
			 n % 10 == 1 || 
			 n % 10 == 6 || 
			 n % 10 == 8) ans = "pon";
	else ans = "hon";

	cout << ans;
	return 0;
}

Measured memory_bytes: 3600
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>
 
using namespace std;
 
#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

int main(){
	
	int a,b,c;
	while(cin>>a>>b>>c){
		if(a==-1)break;
		
		int sum = 120*60-((a*60+b)*60+c);
		int sum2 = sum*3;
		
		vector<int> s;
		rep(i,3){
			s.push_back(sum%60);
			sum/=60;
		}
		
		vector<int> s2;
		rep(i,3){
			s2.push_back(sum2%60);
			sum2/=60;
		}
		
		printf("%02d:%02d:%02d\n",s[2],s[1],s[0]);
		printf("%02d:%02d:%02d\n",s2[2],s2[1],s2[0]);
	}
	
}

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

vector<int>adj[100005];
bool visited[100005];
int dp[100005];

void visit(int vertex)
{
    visited[vertex]=1;
    dp[vertex]=0;
    for(int child:adj[vertex])
    {
        if(!visited[child])
        {
            visit(child);
        }
        dp[vertex]=max(dp[vertex],1+dp[child]);
    }
}

int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        adj[x].push_back(y);
    }

    for(int i=1;i<=n;i++)
    {
        if(!visited[i])
        {
            visit(i);
        }
    }

    int ans=0;
    for(int i=1;i<=n;i++)
    {
        ans=max(ans,dp[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12100
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int r, g, b;
  cin >>r >>g >>b;
  
  int a = r*100 + g*10 + b;
  
  if (a%4 == 0)
    cout << "YES";
  else
    cout << "NO";
}

Measured memory_bytes: 3600
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define _GLIBCXX_DEBUG
int INF = 1e9+7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
unsigned day;
if(dow < dow1) dow += 7;
day = dow - dow1;
day += 7 * n - 6;
return day;
}
unsigned DayToWeekNumber(unsigned day)
{
  return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
  return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main(){
  string S; cin>>S;
  int a=int(S.at(0)-48)*10+int(S.at(1)-48);
  int b=int(S.at(2)-48)*10+int(S.at(3)-48);
  if(a<13&&a>0&&b<13&&b>0)cout<<"AMBIGUOUS"<<endl;
  else if(a<13&&a>0)cout<<"MMYY"<<endl;
  else if(b<13&&b>0)cout<<"YYMM"<<endl;
  else cout<<"NA"<<endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;
typedef long long ll;  /* 10^18 くらいまでいける */

int naturelNum(int a){
  if (a<0)
    return 0;
  return a;
}

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

  cout << naturelNum(c - (a - b)) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

struct edge{
private:
public:
    edge(){}
    edge(uint to_in, uint cost_in): to(to_in), cost(cost_in) {}
    ~edge(){}
    uint to;
    uint cost;
};

int invColor(int c){
    if(c==0){ return 1;
    } else  { return 0; }
}
void dfs(vector<int>& vecColor, vector<vector<edge>>& graph, int v, int c){
    if(vecColor[v]!=-1){ return; }
    vecColor[v] = c;
    for(uint i=0; i<graph[v].size(); ++i){
        uint i_next = graph[v][i].to;
        uint w_next = graph[v][i].cost;
        if(w_next % 2 == 0){ dfs(vecColor, graph, i_next,          c );
        }       else       { dfs(vecColor, graph, i_next, invColor(c)); }
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    uint N; cin >> N;
    vector<vector<edge>> graph(N);
    for(uint i=0; i<N-1; ++i){
        uint u, v, w; cin >> u >> v >> w;
        --u; --v;
        graph[u].push_back( edge(v, w) );
        graph[v].push_back( edge(u, w) );
    }
    
    vector<int> vecColor(N, -1); // not used: -1,  white: 0,  black: 1
    dfs(vecColor, graph, 0, 0);
    
    for(uint i=0; i<N; ++i){
        cout << vecColor[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
using vvll = vector<vector<long long>>;
using pii = pair<int, int>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define rreps(i,n) for(int i = (int)(n); i > 0; i--)
#define FOR(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define RFOR(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define call(x) (x).cbegin(), (x).cend()
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) {if (b<a) {a=b; return 1;} return 0;}
const int INF = INT_MAX;
const int MOD = 1000000007;
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};

int main() {
    int N;
    cin >> N;
    vi a(N+1), b(N+1);
    reps(i, N) cin >> a[i];
    b = vi(N+1, 0);
    rreps(i, N) {
        int cur = 0;
        for (int j = 1; i * j <= N; ++j) {
            cur += b[i * j];
        }
        cur %= 2;
        if (cur != a[i]) b[i] = 1;
    }

    cout << accumulate(all(b), 0) << endl;
    reps(i, N) {
        if (b[i] == 1) printf("%d%c", i, (i == N) ? '\n' : ' ');
    }
}

Measured memory_bytes: 2560