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

int main(){
  long long m=1000000007,
  ans=0;
  int x,y,a,b;
  cin >> x >> y;
  if((x+y)%3==0){ 
    a=(2*y-x)/3;
    b=(2*x-y)/3;
    if(a>=0&&b>=0){
      long long p=1,q=1;
      for(int i=a+b;i>a;i--){
        p*=i;
        p=p%m;
        q*=i-a;
        q=q%m;
      }
      for(int i=0;i<m;i++){
        if(i*q%m==p){
          ans=i;
          break;
        }
      }
    }
  }
  cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector<ll> p(A), q(B), r(C);
  cin >> p;
  cin >> q;
  cin >> r;
  sort(all(p));
  reverse(all(p));
  sort(all(q));
  reverse(all(q));
  sort(all(r));
  reverse(all(r));
  ll res = 0ll;
  priority_queue<ll, vector<ll>, greater<ll>> que;
  for (int i = 0; i < X; i++) {
    res += p[i];
    que.push(p[i]);
  }
  for (int i = 0; i < Y; i++) {
    res += q[i];
    que.push(q[i]);
  }
  ll ans = res;
  for (int i = 0; i < C; i++) {
    if (que.empty()) break;
    res += r[i];
    res -= que.top();
    que.pop();
    chmax(ans, res);
  }
  cout << ans << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


Measured memory_bytes: 4852
//https://atcoder.jp/contests/dp/tasks/dp_r
//shauryakr
#include<bits/stdc++.h>
using namespace std;

int n;
long long int k;
const long long int mod = 1e9 + 7;

void add_self(int &a, int b)
{
    a += b;
    if(a >= mod)
    {
        a -= mod;
    }
}

int mul(int a, int b)
{
    return (long long int)a * b % mod;
}

struct M
{
    vector<vector<int> > t;
    M()
    {
        t.resize(n, vector<int>(n));
    }

    M operator* (const M& b) const
    {
        M c = M();
        for(int i=0; i<n; i++)
        {
            for(int j=0; j<n; j++)
            {
                for(int k=0; k<n; k++)
                {
                    add_self(c.t[i][k], mul(t[i][j], b.t[j][k]));
                }
            }
        }
        return c;
    }
};

int main()
{
    cin >> n >> k;
    vector<vector<int> > mat(n, vector<int>(n));
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            cin >> mat[i][j];
        }
    }

    // Identity matrix
    M answer = M();
    for(int i=0; i<n; i++)
    {
        answer.t[i][i] = 1;
    }

    M m = M();
    m.t = mat;

    while(k)
    {
        if(k&1)
        {
            answer = answer * m;
        }
        m = m * m;
        k = k / 2;
    }

    int total = 0;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            add_self(total, answer.t[i][j]);
        }
    }

    cout << total << endl;
    return 0;
}

Measured memory_bytes: 764
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


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


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    n, k = MAP()
    print(min(n % k, k - n % k))


if __name__ == '__main__':
    main()


Measured memory_bytes: 5784
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;

int main(){
  int n;cin>>n;
  int ans=0;
  vector<int> no_zero;
  for(int i=0;i<n;i++){
    int s;cin>>s;
    ans+=s;
    if(s%10!=0)no_zero.push_back(s);
  }
  if(ans%10==0){
    if(no_zero.size()==0)cout<<0<<endl;
    else{
      int m=INF;
      for(int i=0;i<(int)no_zero.size();i++){
        m=min(m, no_zero[i]);
      }
      cout<<ans-m<<endl;
    }
  }else{
    cout<<ans<<endl;
  }
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;


void solve() {
	int i,j,k,l,r,x,y; string s;
	vector<int> V;
	int num=0;
	cin>>N>>K;
	
	
	if(N==1&&K==1) {
		cout<<-1<<endl;
		return;
	}
	if(N==1&&K==0) {
		cout<<"0 0 1 1"<<endl;
		return;
	}
	if(K>=1<<N) {
		cout<<-1<<endl;
		return;
	}
	
	FOR(i,1<<N) if(i!=K) cout<<i<<" ";
	cout<<K<<" ";
	for(i=(1<<N)-1;i>=0;i--) if(i!=K) cout<<i<<" ";
	cout<<K;
	cout<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S, T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>N;
    ll sum = 0;
    reps(i,1,N+1){
        sum += i;
        if(sum >= N){
            cout<<i<<endl;
            return 0;
        }
    }
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

int T;
ll A, B, C, D;

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> T;
    FOR(i,0,T-1){
        cin >> A >> B >> C >> D;

        if (A < B || D < B) cout << "No" << '\n';
        else {
            ll x = __gcd(B,D);
            ll y = C-B+1 + A%x - ((C-B+1)%x + x)%x;
            if (y < C-B+1) y += x;
            cout << (y >= 0 ? "Yes" : "No") << '\n';
        }
    }
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE long long
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}

// konoshita kara kaku

int main(void){
	long long n=llin(),m=llin();
	if(n==1&&m==1)llprint(1);
	else if(n==1)llprint(m-2);
	else if(m==1)llprint(n-2);
	else llprint((n-2)*(m-2));
	return 0;
}

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

#define dbg if(0)
using namespace std;
#define ll long long

int main(){
    ll n;
    string nums;
    cin >>nums;
    cin >>n;
    int cn1=0;
    char othernum;
    for(int i=0;i<nums.length();i++){
        if (nums[i]=='1')cn1++;
        else{
            othernum=nums[i];
            break;
        }
    }
    if (n<=cn1)cout<<"1"<<endl;
    else cout << othernum<<endl;



    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,start,end) for(int i=start;i<(int)(end);i++)
#define FORE(i,start,end) for(int i=start;i<=(int)end;i++)
#define RFORE(i,start,end) for(int i = start; i>=end; i--)
#define all(a) a.begin(), a.end()
#define v vector
#define mp make_pair
typedef long long ll;
typedef pair<int, int > pii;
template<class T> void minn(T &a, T b) { a = min(a, b); }
template<class T> void maxx(T &a, T b) { a = max(a, b); }
// F
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int m, k;
	cin >> m >> k;
	if(m==0){
		if(k==0){
			cout << "0 0\n";
		} else{
			cout << "-1\n";
		}
	} else if (m==1){
		if(k==0){
			cout << "1 0 0 1\n";
		} else {
			cout << "-1\n";
		}
	} else{
		if(k<(1<<m)){
			FOR(i,0,1<<m) if(i!=k) cout << i << " ";
			cout << k << " ";
			RFORE(i,(1<<m)-1,0) if(i!=k) cout << i << " ";
			cout << k << "\n";
		} else{
			cout << "-1\n";
		}
	}
}



Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		String input = sc.next();
		String[] inputS = input.split("");
		for (String string : inputS) {
			if (string.equals("a")) {
				if (A + B > 0) {
					A--;
					System.out.println("Yes");
				} else {
					System.out.println("No");
				}
				continue;
			}
			if (string.equals("b")) {
				if (A + B > 0 && B > 0) {
					B--;
					System.out.println("Yes");
				} else {
					System.out.println("No");
				}
				continue;
			}
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 61228
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
const bool debug=false;
// const bool debug=true;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    ll n,m;
    cin >> n >> m;
    ll s[n],t[m];
    ll dp[n+1][m+1]={},sum[n+1][m+1]={};
    rep(i,n){
        cin>>s[i];
    }
    rep(i,m){
        cin>>t[i];
    }
    rep(i,n)rep(j,m){
        if(s[i]==t[j]){
            dp[i+1][j+1]=(sum[i][j]+1+MOD)%MOD;
        }
        sum[i+1][j+1]=(sum[i][j+1]+sum[i+1][j]-sum[i][j]+dp[i+1][j+1]+MOD)%MOD;
    }
    cout << (sum[n][m]+MOD+1)%MOD << endl;
    return 0;
}


Measured memory_bytes: 62848
a = int(input())
ans_list = []
result = 0
ans_list = input().split()
ans_list2 = ans_list.copy()
for i in range(a-2):
    ans_list2.pop(0)
    for p in range(a-1 -i):
        result += int(ans_list[i]) * int(ans_list2[p])
    
result += int(ans_list[a-1]) * int(ans_list[a-2])
print(result)

Measured memory_bytes: 3064
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())printf("%d ",v[_]);cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};//RDLU
#define yes puts("YES")
#define no puts("NO")


int n,now;
vvi G;
vi in,out;
void dfs(int a,int p){
  rep(i,G[a].size())if(G[a][i]-p)
    dfs(G[a][i],a);
  out[a]=in[now++];
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

  cin>>n;
  G=vvi(n);
  rep(i,n-1){
    int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].pb(b);
    G[b].pb(a);
  }
  in=out=vi(n);
  rep(i,n)cin>>in[i];
  sort(all(in));

  dfs(0,-1);
  int sum=0;
  rep(i,n-1)sum+=in[i];
  cout<<sum<<endl;
  rep(i,out.size())cout<<out[i]<<" ";cout<<endl;
}


Measured memory_bytes: 1536
n, q = map(int, input().split())
s = input()

a = [0, 0]
for i in range(2, n + 1):
    a.append(a[i - 1] + (s[i - 2:i] == 'AC'))


for _ in range(q):
    li, ri = map(int, input().split())
    print(a[ri] - a[li])

Measured memory_bytes: 7812
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i=0; i<(n); ++i)
inline void chmin(int &a, int b) {
    if (a > b) a = b;
}
const int MAX_V = 1e5 + 10;
const int INF = 1e9 + 10;

int main() {
    int n, w;
    cin >> n >> w;
    vector<int> we(n), va(n);
    rep(i, n) cin >> we[i] >> va[i];
    vector<vector<int>> dp(n+1, vector<int>(MAX_V, INF));
    dp[0][0] = 0;
    rep(i, n) {
        rep(j, MAX_V) {
            chmin(dp[i+1][j], dp[i][j]);
            if (j >= va[i]) {
                chmin(dp[i+1][j], dp[i][j-va[i]] + we[i]);
            }
        }
    }
    int ans = 0;
    rep(i, MAX_V) {
        if (dp[n][i] <= w) ans = i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 40192
#include <cstdio>
#include <algorithm> 
using namespace std;
const int M = 32;
const int N = 51200;
const int INF = 0x3f3f3f3f;

int a[M], dp[N];

int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; ++i)
		scanf("%d", a+i);
	
	for (int i = 0; i <= n; ++i)
		dp[i] = INF;
	
	dp[0] = 0;
	for (int i = 0; i < m; ++i)
	{
		for (int j = a[i]; j <= n; ++j)
		{
			dp[j] = min(dp[j], dp[j-a[i]]+1);
		}
	}
	
	printf("%d\n", dp[n]);
	return 0;
}


Measured memory_bytes: 2912
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N = int(readline())
A = list(map(int, readline().split()))

counts = [0] * (N + 1)
for a in A:
    counts[a] += 1

for c in counts[1:]:
    print(c)


Measured memory_bytes: 27960
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yes(ans) if(ans)printf("yes\n");else printf("no\n")
#define Yes(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YES(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
const int MOD2=998244353;
const int INF=1<<30;
const ll INF2=(ll)1<<60;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T,class L>void scan(pair<T, L>& p){scan(p.first);scan(p.second);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T,class L>void print(const pair<T, L>& p){print(p.first);putchar(' ');print(p.second);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    INT(h,w,a,b);
    vector2d(char,mat,h,w,'0');
    rep(y,b){
        rep(x,a){
            mat[y][x]='1';
        }
    }
    for(int y=b;y<h;y++){
        for(int x=a;x<w;x++){
            mat[y][x]='1';
        }
    }
    for(int y=0;y<h;y++){
        for(int x=0;x<w;x++){
            cout<<mat[y][x];
        }
        cout<<endl;
    }
}

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

int main(){
  int N,d = 1,di,n;
  cin >> N;
  
  for(int i = 10; N%i != N; i *= 10){
    d++;
  }
  n = N;
  for(int i = 0; i < d; i++){
    di += n%10;
    n = n/10;
  }
  if(N%di == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;

int main()
{
	int h = 0;
	int w = 0;
	int n = 0;
	int p[100][100];
	while (cin >> h >> w >> n)
	{
		memset(p, 0, sizeof(p));
		int *q = new int[n];
		for (int i = 0; i < n; i++)
		{
			cin >> q[i];
		}
		int i = 0, j = 0;
		int biaoji = 0;//0表示正向
		for (int h1 = 0; h1 < n; h1++)
		{
			for (int g = 0; g < q[h1]; g++)
			{
				p[i][j] = h1 + 1;
				if (biaoji == 0)
				{
					j++;
				}
				else
				{
					j--;
				}
				if (biaoji == 0 && j == w)
				{
					i++;
					j = w - 1;
					biaoji = 1;
				}
				else if (biaoji == 1 && j == -1)
				{
					biaoji = 0;
					i++;
					j = 0;
				}
			}
		}
		for (int h1 = 0; h1 < h; h1++)
		{
			for (int w1 = 0; w1 < w; w1++)
			{
				cout << p[h1][w1];
				if (w1 != w - 1)
				{
					cout << " ";
				}
				else
				{
					cout << endl;
				}
			}
		}
		delete q;
	}
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b;
    while (1) {
        cin >> a >> b;
        if (a == 0 && b == 0) {
            break;
        }
        if (a < b) {
            cout << a << " " << b << "\n";
        } else {
            cout << b << " " << a << "\n";
        }
    }

    return 0;
}

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

int main()
{
    bool flag = 1 ;
    int H , W ;
    cin >> H >> W ;
    string Pic[H+2];
    string frame;
    for(int i = 0 ; i < H+2 ; i++)
        frame += "." ;
    Pic[0] = frame ;
    Pic[H+1] = frame ;

    for(int i = 1 ; i <= H ; i++)
    {
        cin >> Pic[i] ;
        Pic[i] = "." + Pic[i] + "." ;
    }

    for(int i = 1 ; i <= H ; i++)
    {
        for(int j = 1 ; j <= W ; j++)
        {
            if(Pic[i][j] == '#')
            {
                if(Pic[i+1][j] == '#' || Pic[i-1][j] == '#' || Pic[i][j+1] == '#' || Pic[i][j-1] == '#')
                {
                    flag = 1 ;
                }
                else
                {
                cout << "No" << endl ;
                return 0;
                }
            }
        }
    }
    if(flag == 1)
    cout << "Yes" << endl ;
    else
    cout << "No" << endl ;

    return 0 ;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<list>
#include<algorithm>
#include<cstring>
#include<string>
#include<queue>
#include<cmath>
#include<set>
using namespace std;
#define LL long long
int main()
{
	int a,b;
	int ca,cb;
	ca=cb=0;
	cin>>a>>b;
	if(a>=2)
		ca=a*(a-1)/2;
	if(b>=2)
		cb=b*(b-1)/2;
	cout<<ca+cb<<endl;
}

Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <algorithm>

bool isContaned(std::vector<int>& S, int x){
    int b = 0;
    int e = S.size()-1;
    for(;;){
	int pt = (e - b) / 2 + b;
	int s = S.at(pt);
	if(s == x){
	    return true;
	}else if(s < x){
	    if(pt == e){
		return false;
	    }else{
		b = pt + 1;
	    }
	}else{
	    if(pt == b){
		return false;
	    }else{
		e = pt - 1;
	    }
	}
    }
}

int main(int argc, char **argv){

    int N;
    std::cin >> N;
    std::vector<int> S(N);
    for(int i = 0; i < N; i++){
	std::cin >> S.at(i);
    }

    int Q;
    std::cin >> Q;
    std::vector<int> T(Q);
    for(int i = 0; i < Q; i++){
	std::cin >> T.at(i);
    }

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

    int sum = 0;
    for(int i = 0; i < Q; i++){
	if(isContaned(S, T.at(i))){
	    sum++;
	}
    }
    std::cout << sum << std::endl;
    
}



Measured memory_bytes: 3416
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n, k; readV(n, k);
  int[] h; readA(n, h);

  auto dp = new int[](n); dp[] = 10^^9;
  dp[0] = 0;
  foreach (i; 1..n)
    foreach (j; 1..k+1)
      if (i-j >= 0) dp[i] = min(dp[i], dp[i-j] + (h[i]-h[i-j]).abs);

  writeln(dp[$-1]);
}


Measured memory_bytes: 3964
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define si(x)     scanf("%d", &x)
#define sll(x)    scanf("%lld", &x)
#define ssll(x,y)    scanf("%lld %lld", &x ,&y)
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define vll(a)	  vector<ll>a
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "



int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		ll n;
		sll(n);
		ll a[maxn];
		for (int i=0 ; i<n ; i++) sll(a[i]); 
		sort(a,a+n);
		ll sum = 0;
		for (int i=0 ; i<=n-2 ; i++) sum+=a[i];
	//	cerr << imie(sum) imie(a[n-1]);
		if(a[n-1]<sum) cout << "Yes" << endl;
		else cout << "No" << endl;
		return 0;
}



Measured memory_bytes: 3700
// This template is based on Mr. tonymontaro's template (https://atcoder.jp/users/tonymontaro).
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    static PrintWriter out;
    static CF_Reader in;

    public static void main(String[] args) throws IOException {
        out = new PrintWriter(new OutputStreamWriter(System.out));
        in = new CF_Reader();
        StringBuilder result = new StringBuilder();

        // Start: int型の整数n mを取得する
        // // N M 形式
        int A = in.intNext();
        int B = in.intNext();
        int H = in.intNext();
        int M = in.intNext();
        // End: int型の整数n mを取得する

        double alpha = 6 * M - (30 * H + 0.5 * M);
        double alphaRad = Math.toRadians(alpha);
        double c2 = A*A + B*B - 2 * A * B * Math.cos(alphaRad);
        double c = Math.sqrt(c2);

        result.append(c);

        // Start: int型の整数Nと配列Aを取得する
        // // N
        // // A1 A2 A3... AN 形式
        // int n = in.intNext();
        // int[] A = in.nextIntArray(n);
        // End: int型の整数Nと配列Aを取得する

        // Start: Char型の文字をInt型に変換する
        // Integer.parseInt(String.valueOf(charText))
        // End: Char型の文字をInt型に変換する

        // Start: 文字列を1文字ずつ出力する
        // String text = in.next();
        // char[] work = new char[text.length()];
        // for(int i = 0; i < text.length(); i++){
        //   work[i] = text.charAt(i); // Char型の文字
        //   out.println(work[i]);
        // }
        // End: 文字列を1文字ずつ出力する

        out.println(result);

        out.close();
    }

    static class CF_Reader {
        BufferedReader br;
        StringTokenizer st;

        public CF_Reader() throws IOException {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine().trim());
            return st.nextToken();
        }

        long longNext() throws IOException {
            return Long.parseLong(next());
        }

        int intNext() throws IOException {
            return Integer.parseInt(next());
        }

        double doubleNext() throws IOException {
            return Double.parseDouble(next());
        }

        char charNext() throws IOException {
            return next().charAt(0);
        }

        public int[] nextIntArray(final int n) throws IOException {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = intNext();
            return a;
        }

        public long[] nextLongArray(final int n) throws IOException {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = longNext();
            return a;
        }

        String line() throws IOException {
            return br.readLine().trim();
        }
    }
}

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

int mark[200004], cnt[200004];
vector<int>adj[200004];

void solve(int u, int p, int d)
{
	d += mark[u];
	cnt[u] = d;
	for (int v : adj[u])if (v != p)solve(v, u, d);
}

int main()
{
	int n, m, x, y;
	cin >> n >> m;
	for (int i = 0; i < n - 1; i++)
	{
		cin >> x >> y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	for (int i = 0; i < m; i++)
	{
		cin >> x >> y;
		mark[x] += y;
	}
	solve(1, -1, 0);
	for (int i = 1; i <= n; i++)cout << cnt[i] << " ";
	cout << endl;

	return 0;

}

Measured memory_bytes: 24192
#include<stdio.h>
int seg[(1<<20)];
void init(int n){
  int b=1;
  while(b < n*2) b *= 2;
  for(int i=0;i<b;i++) seg[i] = 0;
}
void add(int i,int x,int ban,int l,int r){
  if(l == i && r == i) seg[ban] += x;
  else {
    int mid = (l+r)/2;
    if(l <= i && i <= mid) add(i,x,ban*2+1,l,mid);
    if(mid < i && i <= r) add(i,x,ban*2+2,mid+1,r);
    seg[ban] = seg[ban*2+1] + seg[ban*2+2];
  }
}
int getsum(int s,int t,int ban,int l,int r){
 
  if(s <= l && r <= t) return seg[ban];
  if(t < l || r < s) return 0;

  int mid = (l+r)/2;
  return getsum(s,t,ban*2+1,l,mid) + getsum(s,t,ban*2+2,mid+1,r);
}
int main(){
  int n,q,c,x,y;
  scanf("%d %d",&n,&q);
  init(n);
  for(int i=0;i<q;i++){
    scanf("%d %d %d",&c,&x,&y);
    if(c == 0) add(x,y,0,1,n);
    if(c == 1) printf("%d\n",getsum(x,y,0,1,n));
  }
  return(0);
}



Measured memory_bytes: 3704
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;

  for (char c : s)
  {
    if (c == '1')
    {
      cout << 9;
    }
    else if (c == '9')
    {
      cout << 1;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
void func() {
    int N ;
    cin  >> N;
    int sum = 0;
    int temp = N;
    while (temp > 0) {
        sum += temp % 10;
        temp /= 10;
    }
    cout << (N % sum == 0 ? "Yes" : "No") << endl;
}

int main() {
    func();
    return 0;
}

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

const int MAXN = 2e5 + 10;

int n, a[MAXN], h[MAXN];
ll f[MAXN];

#define mid ((l + r) >> 1)
#define ls k << 1, l, mid
#define rs k << 1 | 1, mid + 1, r

struct Segmenttree {
    ll data;
} t[MAXN << 2];

void pushup(int k) { t[k].data = max(t[k << 1].data, t[k << 1 | 1].data); }
void modify(int k, int l, int r, int pos, ll val) {
    if (l == r) { t[k].data = val; return ; }
    if (pos <= mid) modify(ls, pos, val);
    else modify(rs, pos, val);
    pushup(k);
}
ll query(int k, int l, int r, int ql, int qr) {
    if (qr < ql) return 0;
    //printf("%d %d\n", l, r);
    if (ql <= l && r <= qr) { return t[k].data; }
    ll res = 0;
    if (ql <= mid) res = max(res, query(ls, ql, qr));
    if (qr > mid) res = max(res, query(rs, ql, qr));
    return res;
}

int main() {
    scanf("%d", &n);
    int maxh = 0;
    for (int i = 1; i <= n; ++i) scanf("%d", &h[i]), maxh = max(maxh, h[i]);
    for (int i = 1; i <= n; ++i) scanf("%d", &a[i]), f[i] = a[i];
    for (int i = 1; i <= n; ++i) {
        ll tmp = query(1, 1, maxh, 1, h[i] - 1);
        f[i] = tmp + a[i];
        modify(1, 1, maxh, h[i], f[i]);
    }
    ll fans = 0;
    for (int i = 1; i <= n; ++i) fans = max(fans, f[i]);
    printf("%lld\n", fans);
    return 0;
}

Measured memory_bytes: 9600
#include <cstdio>
int main()
{
	int a =0,b =0,h =0,s =0;
	
	scanf ("%d",&a);
	scanf ("%d",&b);
	scanf ("%d",&h);
	s =(a+b)*h/2;
	printf ("%d",s);
	return 0;
	}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <ctime>
#include <stack>
#include <map>
#include <set>
#define MEM(x,y) memset ( x , y , sizeof ( x ) )
#define rep(i,a,b) for (int i = a ; i <= b ; ++ i)
#define per(i,a,b) for (int i = a ; i >= b ; -- i)
#define pii pair < int , int >
#define X first
#define Y second
#define rint read<int>
#define int long long
#define pb push_back

using std::set ;
using std::pair ;
using std::max ;
using std::min ;
using std::priority_queue ;
using std::vector ;
using std::stack ;

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

const int N = 1e5 + 100 ;

int n , v[N] , f[N] , ans ;

signed main (int argc , char * argv[] ) {
    n = rint () ; f[1] = 0 ;
    rep ( i , 1 , n ) v[i] = rint () ;
    rep ( i , 2 , n ) {
        if ( v[i] <= v[i-1] ) f[i] = f[i-1] + 1 ;
        else f[i] = 0 ;
    }
    rep ( i , 1 , n ) ans = max ( f[i] , ans ) ;
    printf ("%lld\n" , ans ) ;
    return 0 ;
}

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

int main()
{
	string s;
	cin >> s;
	vector<int> cnt(26);
	ll ans =0;
	for(auto c:s)
	{
		for(int i =0 ;i<26;i++)
		{
			if(i+'a'==c)continue;
			ans+=cnt[i];
		}
		cnt[c-'a']++;
	}
	cout<<ans+1<<endl;
}

Measured memory_bytes: 640
//==========================================c#
using System; //Console, IComparable
using System.IO; //StreamWriter 
using System.Linq; //Select(), Where(), OrderBy(), Count()
using System.Collections.Generic; //List<T>

public static class Run{
    private static class gv{
        public static int K = 0;
        public static int N = 0;
        public static List<int> A;
        public static int max_interval = 0;
    }
    
    public static void build(){
        string[] input;
        
        input = IOC._stringa;
        gv.K = int.Parse(input[0]);
        gv.N = int.Parse(input[1]);
        
        input = IOC._stringa;
        gv.A = input.Select(int.Parse).ToList();
        for (int i = 1; i < gv.N; i++) {
            gv.max_interval = Math.Max(gv.max_interval, gv.A[i] - gv.A[i -1] );
        }
    }
    
    public static void solve(){
        StreamWriter so = new StreamWriter(Console.OpenStandardOutput());
        
        var ans = 0;
        ans = Math.Min( gv.A[gv.N -1] - gv.A[0],
                        gv.K - gv.max_interval );
        
        Console.WriteLine(ans);
    }
}

class Program { 
    static void Main() { 
        Run.build();
        Run.solve();
    } 
}

public static class IOC{
    public static int _int{get{return int.Parse(Console.ReadLine());}}
    public static int[] _inta{get{return Array.ConvertAll(Console.ReadLine().Split(), int.Parse);}}
    public static long _long{get{return long.Parse(Console.ReadLine());}}
    public static long[] _longa{get{return Array.ConvertAll(Console.ReadLine().Split(), long.Parse);}}
    public static string _string{get{return Console.ReadLine();}}
    public static string[] _stringa{get{return (Console.ReadLine().Split());}}
    public static double _double{get{return double.Parse(Console.ReadLine());}}
    public static double[] _doublea{get{return Array.ConvertAll(Console.ReadLine().Split(), double.Parse);}}
}

Measured memory_bytes: 34396
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n' 
#define   sz(x)  (int)x.size() 
#define   all(a) (a.begin(),a.end()) 
#define   ff   first 
#define   ss   second 
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std; 

inline void solve(){ 
    int  l, r ; 
    cin >> l >> r ; 
    if (r-l>=673) cout << 0 << endl;
    else {
        int ans=2018;
        for (int i=l;i<r;i++){
            for (int j=i+1;j<=r;j++){
                ans = min(ans,(i*j)%2019);
            }
        }
        cout << ans << endl;
    }

     
} 

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	string s;
	cin >> s;
	int a = (s[5] - '0');
	a *= 10;
	a += (s[6] - '0');
	int b = (s[8] - '0');
	b *= 10;
	b += (s[9] - '0');
	if (a >= 5) {
		cout << "TBD" << endl;
	}
	else if (a == 4 && b >= 31) {
		cout << "Why?" << endl;
		return 0;
	}
	else {
		cout << "Heisei" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(){

  string s;
  cin>>s;
  for(int i=0;i<s.size()-1;i++) if(s[i]==s[i+1]){
      cout<<i+1<<" "<<i+2<<endl;
      return 0;
    }
  for(int i=0;i<s.size()-2;i++) if(s[i]==s[i+2]){
      cout<<i+1<<" "<<i+3<<endl;
      return 0;
    }
  cout<<"-1 -1"<<endl;
  return 0;
}



Measured memory_bytes: 512
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int a = stdIn.nextInt();
        String s = stdIn.next();
        if(a>=3200) {
            System.out.println(s);
        } else {
            System.out.println("red");
        }
    }
}

Measured memory_bytes: 23764
# encoding:utf-8

while True:
    a,op,b = map(str, input().split())
    c = int(a)
    d = int(b)
    if op == '+': result = c + d
    if op == '-': result = c - d
    if op == '*': result = c * d
    if op == '/': result = int(c / d)
    if op == '?': break
    print("{0}".format(result))

Measured memory_bytes: 7676
n, a, b, c = map(int, input().split())
s = []
for i in range(n):
    s.append(input())
temp = []
flag = True
for i in range(n):
    if s[i] == "AB":
        if a == 0 and b == 0:
            flag = False
            break
        elif a == 0:
            a += 1
            b -= 1
            temp.append("A")
        elif b == 0:
            b += 1
            a -= 1
            temp.append("B")
        else:
            if i == n - 1:
                temp.append("A")
            else:
                if s[i + 1] == "BC":
                    b += 1
                    a -= 1
                    temp.append("B")
                elif s[i + 1] == "AC":
                    a += 1
                    b -= 1
                    temp.append("A")
                else:
                    if a > b:
                        a -= 1
                        b += 1
                        temp.append("B")
                    else:
                        a += 1
                        b -= 1
                        temp.append("A")
    elif s[i] == "BC":
        if c == 0 and b == 0:
            flag = False
            break
        elif c == 0:
            c += 1
            b -= 1
            temp.append("C")
        elif b == 0:
            b += 1
            c -= 1
            temp.append("B")
        else:
            if i == n - 1:
                temp.append("C")
            else:
                if s[i + 1] == "AB":
                    b += 1
                    c -= 1
                    temp.append("B")
                elif s[i + 1] == "AC":
                    c += 1
                    b -= 1
                    temp.append("C")
                else:
                    if c > b:
                        c -= 1
                        b += 1
                        temp.append("B")
                    else:
                        c += 1
                        b -= 1
                        temp.append("C")
    elif s[i] == "AC":
        if a == 0 and c == 0:
            flag = False
            break
        elif a == 0:
            a += 1
            c -= 1
            temp.append("A")
        elif c == 0:
            c += 1
            a -= 1
            temp.append("C")
        else:
            if i == n - 1:
                temp.append("A")
            else:
                if s[i + 1] == "BC":
                    c += 1
                    a -= 1
                    temp.append("C")
                elif s[i + 1] == "AB":
                    a += 1
                    c -= 1
                    temp.append("A")
                else:
                    if a > c:
                        a -= 1
                        c += 1
                        temp.append("C")
                    else:
                        a += 1
                        c -= 1
                        temp.append("A")
if flag == False:
    print("No")
else:
    print("Yes")
    for i in temp:
        print(i)

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

int main()
{
    string s;
    cin >> s;
    int n = 0;
    for (int i = 0; i < s.length(); ++i)
    {
        if (s[i] == '1')
            ++n;
    }
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<climits>
#include<cmath>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

typedef unsigned int uint;
typedef long long ll;

using namespace std;

int main(){
  int c1,c2,c3;
  int sum;
  while(cin>>c1>>c2>>c3){
    vector<bool> flag(10,true);
    flag[c1-1] = flag[c2-1] = flag[c3-1] = false;
    sum = c1 + c2;
    int cnt = 0;
    REP(i,10){
      int card = i + 1;
      if(flag[i] && sum + card <= 20)
        cnt++;
    }
    if(cnt > 3)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] pqr = new int[3];
		for (int i = 0; i < 3 ; i++) {
			pqr[i] = sc.nextInt();
		}
		Arrays.sort(pqr);
		System.out.println(pqr[0] + pqr[1]);
	}
}

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

long N;
long B[110];
long A[110];

int main()
{
  cin >> N;
  if (N%2==0){
    cout << N*(N-1)/2-(N/2) << endl;
    for (int i=1; i<=N; i++){
      for (int j=i+1; j<=N; j++){
        if (i+j!=N+1){
          cout << i << " " << j << endl;
        }
      }
    }
  }else{
    cout << (N-1)*(N-2)/2-((N-1)/2)+(N-1) << endl;
    for (int i=1; i<=N-1; i++){
      for (int j=i+1; j<=N-1; j++){
        if (i+j!=N){
          cout << i << " " << j << endl;
        }
      }
    }
    for (int i=1; i<=N-1; i++){
      cout << i << " " << N << endl;
    }
  }
}


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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] b = Console.ReadLine().Split();
            int[] c = new int[3];
            for (int i = 0; i < 3; i++) { c[i] = int.Parse(b[i]); }
            int an;
            an = c.Max() * 9 + c[0] + c[1] + c[2];
            Console.Write(an);
        }
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<bits/stdc++.h>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<bitset>
#include<unordered_map>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #include "boost/algorithm/string.hpp"
#define fio ios_base::sync_with_stdio(false)
#define mod 998244353
#define mod1 mod
#define mod2 1000000007
#define li long long int
#define ll li
#define readi(x) scanf("%d",&x)
#define  reads(x)  scanf("%s", x)
#define readl(x) scanf("%I64d",&x)
#define rep(i,n) for(i=0;i<n;i++)
#define revp(i,n) for(i=(n-1);i>=0;i--)
#define myrep1(i,a,b) for(i=a;i<=b;i++)
#define myrep2(i,a,b) for(i=b;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define MAXN 1000000000010000005
#define MINN -1000000000000000000
#define INTMAX 1000001000
#define pii pair<ll,ll>
#define pdd pair<double,double>
#define pic pair<int,char>
#define N 3000105
#define lgn 20
#define ddouble long double
#define minus minu
#define PI 2*acos(0)
#define lgn 20
 
 
// #define INTMAX 200000000
 
// using namespace boost;
// #define si short int
 
using namespace std;
using namespace __gnu_pbds;
typedef priority_queue<pii, vector<pii > > max_pq;
typedef priority_queue<pii, vector<pii> , greater<pii>  > min_pq;
ll toint(const string &s) {stringstream ss; ss << s; ll x; ss >> x; return x;}
string tostring ( ll number ){stringstream ss; ss<< number; return ss.str();}
 
// using namespace __gnu_pbds;
// typedef priority_queue<pair<ll,char> , vector<pair<ll , char> > > max_pq;
// typedef priority_queue<pii , vector<pii > ,greater<pii > > min_pq;
typedef tree<pair<string,string> , null_type, less<pair<string,string> >, rb_tree_tag, tree_order_statistics_node_update> OST;
// typedef priority_queue<pair < ll , pair < pii , ll > >  , vector<pair < ll , pair < pii , ll > >  > ,greater<pair < ll , pair < pii , ll > >  > > min_pq;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif
#define nn 2000005
ll ar[ N ];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    char c;
    cin >> c;
    if ( c >= 'A' and c <= 'Z' ){
        cout << 'A';
    }
    else{
        cout << 'a';
    }
    
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long
#define ld long double 
#define For(i, a, n) for(long long i = a; (a < n) ? (i < n) : (i > n); (a < n) ? (i++) : (i--))
#define ee 1000000007
#define pb push_back
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
 
using namespace std;

void solve() {
    string s;
    cin >> s;
    ll mx = 0;ll c = 0;
    For(i, 0, s.size()) {
        if(s[i] == 'S') {
            mx = max(mx, c);
            c = 0;
        }
        else
            c++;
    }
    cout << max(mx, c);
}

int main() {
    fio;
    ll t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
}

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

int main() {
  int count = 1;
  while (1) {
    int i;
    cin >> i;
    if (i == 0){
      return 0;
    } else {
      cout << "Case " << count << ": " << i << endl;
      count++;
    }
  }

  return 0;

}


Measured memory_bytes: 3076