akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
using namespace std;
int n,m;
int w[60][60];
int tw[60][60];
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};

int main()
{
    cin>>n>>m;
    for (int i=1; i<=n; ++i)
        for (int j=1; j<=m; ++j)
        {
            char c;
            scanf("%c",&c);
            while (c!='.' && c!='#') scanf("%c",&c);
            if (c=='.') w[i][j]=0; else w[i][j]=1;
        }
    for (int i=1; i<=n; ++i)
        for (int j=1; j<=m; ++j)
            if (w[i][j])
               for (int k=0; k<4; ++k)
                {
                    int nx,ny;
                    nx = i+dx[k];
                    ny = j+dy[k];
                    if (w[nx][ny])
                    {
                        tw[nx][ny]=1;
                        tw[i][j]=1;
                    }
                }
    bool flag=1;
    for (int i=1; i<=n; ++i)
        for (int j=1; j<=m; ++j)
            if (tw[i][j]!=w[i][j])
                flag=0;
    if (flag==1) cout<<"Yes"<<endl;else cout<<"No"<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream> 
using namespace std;
int main(){
	long long int k,a=0,c=0;
	long long int i=0;
	cin>>k;
	int flag=0;
	// if(k==999983){
	// 	printf("999982\n");
	// 	flag=1;
	// }
	// else{
	for(long long int i=1;i<=k;i++){
		a=(a%k*10)%k+7;
		if(a%k==0){
			printf("%lld\n",i);
			flag=1;
			break;
		}
	}
	if(flag!=1){
		printf("-1\n");
	}
}

Measured memory_bytes: 3724
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"4 4
##.#
....
##.#
.#.#"# => r#"###
###
.##"#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        h: usize, w: usize,
        a: [chars; h],
    }
    let mut ans = "".to_string();
    let mut ignore_list = vec![false; w];

    // println!("{:?}", a[1]);// y

    for x in 0..w {
        let mut cnt = 0;
        for y in 0..h {
            if a[y][x] != '.' {
                break;
            }
            cnt += 1;
        }
        if cnt == h {
            ignore_list[x] = true;
        }
    }

    for y in 0..h {
        if a[y].iter().filter(|&&c| c == '.').count() != w {
            for x in 0..w {
                if !ignore_list[x] {
                    ans.push_str(&a[y][x].to_string());
                }
            }
            if y != h - 1 {
                ans.push_str(&"\n");
            }
        }
    }

    ans.to_string()
}

Measured memory_bytes: 4352
#include <stdio.h>
#define DATALEN 200000

int main(void){
    int n;
    char s[DATALEN + 1];
    int a,b,c,d;
    int i,flag,max;
    int result = 1;//Yesなら1 Noなら0
    
    scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);
    scanf("%s", s);
    max = (c > d) ? c : d;
    //2連の石判定
    for(i = a; i < max; i++){
        if(s[i] == '#' && s[i-1] == '#'){
            result = 0;
            break;
        }
    }
    
    //追い越し判定
    if(c > d){
        flag = 0;
        for(i = b; i <= d; i++){
            if(s[i] == '.' && s[i-1] == '.' && s[i-2] == '.'){
                flag = 1;
                break;
            }
        }
        if(!flag){
            result = 0;
        }
    }
    
    if(!result){
        puts("No");
    }else{
        puts("Yes");
    }
    
    
    
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<functional>
#include<climits>

using namespace std;


template<class S=int, class T=std::less<S>, S nil=INT_MAX>
class RMQ2D{
	int h,w;
	S *datrmq;
	mutable int xs,xe;

	static int calcsize(int n){
		int res=1;
		while(res<n)res<<=1;
		return res;
	}
	void xbuild(int y,int n,const S a[]){
		S *dat=datrmq+y*(2*w-1);
		for(int i=0;i<n;i++)dat[w-1+i]=a[i];
		for(int i=n;i<w;i++)dat[w-1+i]=nil;
		for(int i=w-2;i>=0;i--){
			dat[i]=std::min(dat[i*2+1],dat[i*2+2],T());
		}
	}
	void xupdate(S *dat,int x,int a){
		x+=w-1;
		dat[x]=a;
		while(x>0){
			x=(x-1)/2;
			dat[x]=std::min(dat[x*2+1],dat[x*2+2],T());
		}
	}
	void yupdate(int y,int x,int a){
		y+=h-1;
		while(y>0){
			y=(y-1)/2;
			xupdate(datrmq+y*(2*w-1),x,a);
		}
	}
	S xquery(const S *dat,int k,int l,int r)const{
		if(r<=xs||xe<=l)return nil;
		if(xs<=l&&r<=xe)return dat[k];
		else{
			S vl=xquery(dat,k*2+1,l,(l+r)/2);
			S vr=xquery(dat,k*2+2,(l+r)/2,r);
			return std::min(vl,vr,T());
		}
	}
	S yquery(int ys,int ye,int k,int l,int r)const{
		if(r<=ys||ye<=l)return nil;
		if(ys<=l&&r<=ye)return xquery(datrmq+k*(2*w-1), 0,0,w);
		else{
			S vl=yquery(ys,ye,k*2+1,l,(l+r)/2);
			S vr=yquery(ys,ye,k*2+2,(l+r)/2,r);
			return std::min(vl,vr,T());
		}
	}
public:
	RMQ2D(int h,int w,const S a[]){
		S *dat;
		int n=h,m=w;
		h=this->h=calcsize(h);
		w=this->w=calcsize(w);
		datrmq=new S[(2*h-1)*(2*w-1)];
		dat=new S[2*w-1];
		for(int i=0;i<w;i++)dat[i]=nil;
		for(int i=0;i<n;i++)xbuild(h-1+i,m,a+i*m);
		for(int i=n;i<h;i++)xbuild(h-1+i,m,dat);
		for(int i=h-2;i>=0;i--){
			const S *a=datrmq+(i*2+1)*(2*w-1);
			const S *b=datrmq+(i*2+2)*(2*w-1);
			S *c=datrmq+i*(2*w-1);
			for(int j=0;j<2*w-1;j++){
				c[j]=std::min(a[j],b[j],T());
			}
		}
		delete[] dat;
	}
	~RMQ2D(){
		delete[] datrmq;
	}
	void update(int y,int x,int a){//(y,x)をaに変更
		yupdate(y,x,a);
	}
	S query(int ys,int ye,int xs,int xe)const{//[ys,ye)+[xs,xe)の最小(大)値
		this->xs=xs;
		this->xe=xe;
		return yquery(ys,ye,0,0,h);
	}
};



unsigned int g[1000000];
int main(){
	int r,c,q;
	while(cin>>r>>c>>q,r|c|q){
		for(int i=0;i<r*c;i++)cin>>g[i];
		RMQ2D<unsigned int,std::less<unsigned int>,~0u> rmq(r,c,g);
		for(int i=0;i<q;i++){
			int y1,x1,y2,x2;
			cin>>y1>>x1>>y2>>x2;
			cout<<rmq.query(y1,y2+1,x1,x2+1)<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 37668
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<pair<int, int> > VPII;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define INF 999999999999999997;
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	LL N;
	LL ans = 0;
	VL A;
	cin >> N;
	FOR(i, 0, N)
		A.push_back(IN<LL>());

	while (1) {
		FOR(i, 0, N) {
			if (A[i] % 2 == 0)
				A[i] /= 2;
			else {
				O(ans);
				return 0;
			}
		}
		ans++;

	}
	O(ans)
	return 0;
}

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

using namespace std;

bool is_room(int S){

  for(int i=1;i*i<=S;i++)
    if((S-i)%(2*i+1)==0)return true;
  return false;
}

int main(void){

  int n,S,cnt=0;

  cin >> n;
  while(n--){
    cin >> S;
    if(!is_room(S))cnt++;
  }
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<queue>

using namespace std;
static const int N = 100;
static const int INFTY = (1<<21);

int n, M[N][N];
int d[N];  // 距離で訪問状態（color）を管理する

void bfs(int s) {
  queue<int> q;  // 標準ライブラリの queue を使用
  q.push(s);
  for ( int i = 0; i < n; i++ ) d[i] = INFTY;
  d[s] = 0;
  int u;
  while ( !q.empty() ) {
    u = q.front(); q.pop();
    for ( int v = 0; v < n; v++ ) {
      if ( M[u][v] == 0 ) continue;
      if ( d[v] != INFTY ) continue;
      d[v] = d[u] + 1;
      q.push(v);
    }
  }
  for ( int i = 0; i < n; i++ )
    cout << i+1 << " " << ( (d[i] == INFTY) ? (-1) : d[i] ) << endl;
}

int main() {
  int u, k, v;

  cin >> n;
  for ( int i = 0; i < n; i++ )
    for ( int j = 0; j < n; j++ ) M[i][j] = 0;

  for ( int i = 0; i < n; i++ ) {
    cin >> u >> k;
    u--;
    for ( int j = 0; j < k; j++ ) {
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }

  bfs(0);

  return 0;
}


Measured memory_bytes: 3124
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)
const ll INF = 1LL << 60;


int main(){
    int n;
    char x;
    string s;
    cin >> x;
    if (x == 'A') cout << 'T' << endl;
    else if (x == 'T') cout << 'A' << endl;
    else if (x == 'C') cout << 'G' << endl;
    else cout << 'C' << endl; 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
#include <random>
using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  vector <int> A(N);
  for (int i = 0; i < N; i++) {
	  cin >> A[i];
	}
  cout << ceil((double) (N - 1) / (K - 1)) << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)cin>>a[i];
  int x=1,cnt=0;
  bool no=true;
  for(int i=0;i<n;i++){
    if(a[i]==x){
      x++;
      no=false;
    }
    else cnt++;
  }
  if(no)cout<<-1<<endl;
  else cout<<cnt<<endl;
  return 0;
}

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

int main()
{
    int n,k;
    vector< long long > h;
    cin >> n >> k;
    for( int i = 0; i < n; i++ )
    {
        long long a;
        cin >> a;
        h.push_back(a);
    }

    sort(h.begin(),h.end());
    for( int i = 0; i < k; i++ )
    {
        if( h.size() <= 0 )
        {
            break;
        }
        h.pop_back();
    }

    long long sum = 0;
    for( int i = 0; i < h.size(); i++ )
    {
        sum = sum + h.at( i );
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  int n,d;
  cin >>n>>d;
  int buf = 2*d+1;
  cout<<(n-1)/buf + 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    string ans = "Yes";
    for(int i=0;i<(int)S.size()-1;i+=2){
        if(!(S[i] == 'h' && S[i+1] == 'i')) ans = "No";
    }
    if((int)S.size() % 2 != 0) ans = "No";
    cout << ans << endl;
}

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

int n, m, q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> A) {
  if (A.size() == n + 1) {
    int now = 0;
    rep(i, q) {
      if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
    }
    ans = max(ans, now);
    return;
  }
  A.push_back(A.back());
  while (A.back() <= m) {
    dfs(A);
    A.back()++;
  }
}

int main() {
  cin >> n >> m >> q;
  a = b = c = d = vector<int>(q);
  rep(i, q) { cin >> a[i] >> b[i] >> c[i] >> d[i]; }
  dfs(vector<int>(1, 1));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <map>
#include <vector>
using namespace std;

const int MOD = 256;
const double EPS = 1e-7;
const int INF = 1<<29;
int n,I[257],R[257],O[257];
vector<int> sharp;

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

void makeR(int S, int A, int C){
  R[0] = S;
  for(int i=1;i<=n;i++){
    R[i] = (A * R[i-1] + C) % MOD;
  }
}

void makeO(){
  map<int,int> mp;
  sharp.clear();

  for(int i=1;i<=n;i++){
    O[i] = (I[i] + R[i]) % MOD;
    if(mp.find(O[i]) == mp.end()) mp[O[i]] = 1;
    else mp[O[i]]++;
  }

  for(map<int,int>::iterator it = mp.begin(); it != mp.end(); it++)
    sharp.push_back(it->second);
}

double calcH(){
  double H = 0, N = (double)n;
  for(int i=0;i<sharp.size();i++){
    double x = (double)sharp[i];
    H += (x / N) * log(x / N);
  }
  return H * -1.0;
}

void solve(){
  vector<int> sharp;
  double H, ans = (double)INF;
  int sum = INF, as, aa, ac;
  for(int S=0;S<=15;S++){
    for(int A=0;A<=15;A++){
      for(int C=0;C<=15;C++){
        makeR(S,A,C);
        makeO();
        H = calcH();
        if(ans > H && !equal(ans,H) /*|| equal(ans,H) && sum > S+A+C*/){
          ans = H;
          sum = S+A+C;
          as = S;
          aa = A;
          ac = C;
        }
      }
    }
  }
  cout << as << ' ' << aa << ' ' << ac << endl;
}

int main(){
  while(cin >> n && n){
    for(int i=1;i<=n;i++){
      cin >> I[i];
    }
    solve();
  }
}

Measured memory_bytes: 1272
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int n;
    cin >> n;
    unordered_map<int, int> mp;
    ll ans = 0;
    rep(i, n) {
        int a;
        cin >> a;
        mp[a]++;
        if(mp[a] > a) ans++;
    }
    for(auto it = mp.begin(); it != mp.end(); it++) {
        if(it->first > it->second) ans += it->second;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4260
#include<stdio.h>
#include<math.h>

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

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

    if(abs(a-c) <= d){
        printf("Yes");
    }else if(abs(a-b)<=d && abs(b-c)<=d){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cctype>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <map> // pair
#include <set>
#define MAXSIZE 200000
#define PI 3.141592653589
using namespace std;

template<typename T>
T add(T a,T b){
  return a+b;
}

namespace A
{
  int f(void){
    return 1;
  }
}

int main(){
  int a,b;
  while (std::cin >>a>>b) {
    int n=a+b;
    int digit=0;
    while (n>0) {
      n /=10;
      digit++;
    }
    std::cout << digit << '\n';
  }

}



Measured memory_bytes: 3076
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoderBC042 {
  class AtCoderBC042 {
    static void Main(string[] args) {
      new AtCoderBC042().solve2();
    }

    private void solve2() {
      string[] input = Console.ReadLine().Split();
      int n = int.Parse(input[0]);
      int l = int.Parse(input[1]);
      string input2 = "";
      List<string> s = new List<string>();      
      string res = "";
      
      for (int i = 0; i < n; i++) {
        input2 = Console.ReadLine();        
        s.Add(input2);        
      }    
      var t = s.OrderBy(x => x).ToList();
      foreach (string u in t)
        res += u;
      Console.WriteLine(res);
    }//end M.
  }
}


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

#define Pi acos(-1.)
#define pb push_back
#define all(x) (x).begin(), x.end()
#define mp make_pair
#define fi first
#define se second
#define pii pair<int, int>
#define FILE "474"
#define standart 1

using namespace std;

typedef long long ll;

const int INF = 1e9 + 322;
const ll LINF = 2e18 + 474;
const int MAXN  = 1e3 + 228;
const int MOD = 1e9 + 7;
const double eps = 1e-14;


void solve() {
    int n, a, b;
    cin >> n >> a >> b;
    int x = abs(a-b);
    if(x % 2 == 1) {
        cout << "Borys";
    }
    else
        cout << "Alice";
}



int main() {
    if(!standart) {
        freopen(FILE".in", "r", stdin);
        freopen(FILE".out", "w", stdout);
    }
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int T = 1;
    while(T--)
        solve();

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int W,H,N;
	scanf("%d%d%d",&W,&H,&N);
	int w1=0,w2=W,h1=0,h2=H,x,y,a;
	while(N--){
		scanf("%d%d%d",&x,&y,&a);
		if(a==1){
			if(x<w1){
				continue;
			}
			w1=x;
		}
		else if(a==2){
			if(w2<x){
				continue;
			}
			w2=x;
		}
		else if(a==3){
			if(h1>y){
				continue;
			}
			h1=y;
		}
		else if(a==4){
			if(h2<y){
				continue;
			}
			h2=y;
		}
	}
	int p,o;
	p=w2-w1;
	if(p<=0){
		p=0;
	}
	o=h2-h1;
	if(o<=0){
		o=0;
	}
	if(o*p<=0){
		printf("0");
	}
	else{
		printf("%d",o*p);
	}
	
}

Measured memory_bytes: 128
#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 Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#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;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<int, int> P;

int main() {
    cin>>A>>B;
    reps(i, 1, 1501){
        if(i * 8 / 100 == A && i * 10 / 100 == B){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}

Measured memory_bytes: 256
def solve(N):
    M = 10**9+7
    DP = [0 for _ in range(N+1)]
    DP[0] = 1
    for n in range(N+1):
        for i in range(3,n+1):
            DP[n] += DP[n-i]
            DP[n] %= M

    return DP[N]

def main():
    S = int(input())
    print(solve(S))

if __name__ == "__main__":
    main()


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

#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);

int main() {
    fast_io;
    char x;
    cin>>x;
    if(isupper(x)) {
        cout<<'A'<<endl;
    }
    else {
        cout<<'a'<<endl;
    }
}




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

using namespace std;

const int MAX = 2000001;
const int VMAX = 10001;

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

  vector <int> A(N + 1), B(N + 1), C(VMAX + 1, 0);

  for(int i = 1; i <= N; i++) {
    cin >> A[i];
  }
  for(int j = 1; j <= N ; j++){
    C[A[j]] = C[A[j]] + 1;
  }
  for(int i = 1; i <= VMAX; i++){
    C[i] = C[i] + C[i-1];
  }

  for(int j = N; j >= 1; j--){
    B[C[A[j]]] = A[j];
    C[A[j]] = C[A[j]] - 1;
  }

  for(int i = 1 ; i <= N; i++){
    if (i > 1) {
      cout << " ";
    }
    cout << B[i];
  }
  cout << endl;
}


Measured memory_bytes: 18340
N = int(input())
list = list(map(int,input().split()))
list_alice = []
list_bob = []
list.sort(reverse=True)
for i in range(N):
    if i % 2 ==0:
        list_alice.append(list[i])
    else:
        list_bob.append(list[i])
print(sum(list_alice) - sum(list_bob))

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio

    lli h , s ;
    cin >> h >> s ;

    lli a[s] ;
    lli cnt [s] = {0} ;

    forrcin (0 , s , a) ;

    lli i = 0 ;
    for (lli i = 0 ; h >= 1 ; i++)
    {
        h -= a[i % s] ;
        cnt [i % s] ++ ;

    }

    lli maxm = cnt [0] ;
    for (lli i = 1 ; i < s ; i++)
    {
        maxm = max (maxm , cnt[i]) ;
    }

    if (maxm >= 2)
        cout << "No" ;
    else
        cout << "Yes" ;
    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <cstdint>
#include <string.h>
#include <queue>

using namespace std;

char map[50][50];

int main()
{
    uint64_t H, W;
    cin >> H >> W;

    for (int y = 0; y < H; ++y) {
        for (int x = 0; x < W; ++x) {
            cin >> map[x][y];
        }
    }

    for (int y = 0; y < H; ++y) {
        for (int x = 0; x < W; ++x) {
            if ('.' == map[x][y]) {
                continue;
            }

            int count = 0;
            if (1 <= y) count += map[x][y - 1] == '#' ? 1 : 0;
            if (y < H-1) count += map[x][y + 1] == '#' ? 1 : 0;
            if (1 <= x) count += map[x-1][y] == '#' ? 1 : 0;
            if (x < W-1) count += map[x+1][y] == '#' ? 1 : 0;

            if (count == 0) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main(){
	bool f=false;
	int n,i,j;
	int a[6];
	char a0[11][10]={"* = ****","* =* ***","* =** **","* =*** *","* =**** "," *= ****"," *=* ***"," *=** **"," *=*** *"," *=**** "};
	while(cin>>n){
		if(f==true) {cout<<endl;}
	a[0]=n/10000;
	a[1]=(n-a[0]*10000)/1000;
	a[2]=(n-a[0]*10000-a[1]*1000)/100;
	a[3]=(n-a[0]*10000-a[1]*1000-a[2]*100)/10;
	a[4]=(n-a[0]*10000-a[1]*1000-a[2]*100-a[3]*10);
	for(i=0;i<8;i++){
		for(j=0;j<5;j++){
			cout<<a0[a[j]][i];
		}
		cout<<endl;
	}
	f=true;
	}
	return 0;
}

Measured memory_bytes: 1152
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
ll in(){ll x; cin >> x; return x;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll n, m;
	cin >> n >> m;
	Vec x(n), y(m);
	rep(i, n) cin >> x[i];
	rep(i, m) cin >> y[i];

	ll sumx = 0;
	rep(i, n){
		sumx += x[i]*(i*2-(n-1));
		sumx %= MOD;
	}
	ll sumy = 0;
	rep(i, m){
		sumy += y[i]*(i*2-(m-1));
		sumy %= MOD;
	}
	co(sumx*sumy%MOD);

	return 0;
}


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

#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define EPS (1e-7)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef pair<double,int> pdi;

int vx[]={0,0,-1,1};
int vy[]={1,-1,0,0};

int dx[]={1,0,-1,1,-1,1,0,-1};
int dy[]={1,1,1,0,0,-1,-1,-1};

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int MAX=1e9;
const int MAX_V=10000;

int main(){
	int x[3];
	cin>>x[0]>>x[1]>>x[2];
	sort(x,x+3);
	int ans=x[2]-x[1]+(x[2]-(x[0]+x[2]-x[1]))/2;
	if((x[2]-(x[0]+x[2]-x[1]))%2==0)cout<<ans<<endl;
	else cout<<ans+2<<endl;
}

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

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

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

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

    cout << vec.at(N - 1) - vec.at(0) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int n;
  cin >> n;
  map<ll, ll> m;
  rep(i, n){
    ll a;
    cin >> a;
    m[a]++;
  }
  ll ans = 0;
  for(auto itr = m.begin(); itr != m.end(); itr++){
    if(itr->second % 2 != 0){
      ans++;
    }
  }
  cout << ans << endl;
  system("pause");
}


Measured memory_bytes: 6776
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.08.14 18:53:25
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int MOD = 1e6 + 3;
struct mint {
public:
    long long x;
    mint(long long x = 0) :x((MOD+x)%MOD) {}
    mint(std::string &s) {
        long long z = 0;
        for (int i = 0; i < s.size(); i++) {
            z *= 10;
            z += s[i] - '0';
            z %= MOD;
        }
        this->x = z;
    }
    mint& operator+=(const mint &a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint &a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint &a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint& operator/=(const mint &a) {
        long long n = MOD - 2;
        mint u = 1, b = a;
        while (n > 0) {
            if (n & 1) {
                u *= b;
            }
            b *= b;
            n >>= 1;
        }
        return *this *= u;
    }
    mint operator+(const mint &a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint &a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint &a) const {
        mint res(*this);
        return res *= a;
    }
    mint operator/(const mint &a) const {
        mint res(*this);
        return res /= a;
    }
    friend std::ostream& operator<<(std::ostream &os, const mint &n) {
        return os << n.x;
    }
    bool operator==(const mint &a) const {
        return this->x == a.x;
    }
};

template<typename T, typename U>
T pow(T k, U n, T unity = 1) {
    while (n > 0) {
        if (n & 1) {
            unity *= k;
        }
        k *= k;
        n >>= 1;
    }
    return unity;
}

struct Combination {
private:
    int N;
    
    mint pow(mint k, long long n) {
        mint res = 1;
        while (n > 0) {
            if (n & 1) {
                res *= k;
            }
            k *= k;
            n >>= 1;
        }
        return res;
    }
public:
    std::vector< mint > FACT, IFACT;
    
    Combination(int n) : N(n) {
        FACT.resize(n + 1);
        IFACT.resize(n + 1);
        FACT[0] = 1;
        IFACT[0] = 1;
        for (int i = 1; i <= n; i++) {
            FACT[i] = FACT[i - 1] * i;
            IFACT[i] = pow(FACT[i], MOD - 2);
        }
    }
    mint comb(int n, int r) {
        if (n < 0 || r < 0 || r > n) return 0;
        if (r > n / 2) r = n - r;
        return FACT[n] * IFACT[n - r] * IFACT[r];
    }
};
int main() {
    int q;cin >> q;
    Combination cb(2 * MOD);
    while(q--) {
        ll x,d,n;cin >> x >> d >> n;
        if (d == 0) {
            cout << pow(mint(x),n) << endl;
            continue;
        }
        mint k = mint(x) / d;
        mint p = mint(0) - k;
        if (0 <= p.x && p.x <= n-1) {
            cout << 0 << endl;
            continue;
        }
        cout << cb.FACT[k.x+n-1] * cb.IFACT[k.x-1] * pow(mint(d),n) << endl;
    }
    return 0;
}


Measured memory_bytes: 34336
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	while(kbd.hasNext()){
	    int n = kbd.nextInt();
	    if(n!=0) solve(n);
	}
    }

    static void solve(int n){
	int ans = 0;
	while(n!=1){
	    if(n%3==0) n /= 3;
	    else{
		n = n/3 + 1;
	    }
	    ans++;
	}
	System.out.println(ans);
    }
}

Measured memory_bytes: 17328
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

a,b,c = iim()
num = a%b

for i in range(1,b):
    if (num*i)%b == c:
        print('YES')
        exit()
print('NO')

Measured memory_bytes: 9020
#Coding: UTF-8

S=input()
delta=0

for i in range(len(S)-2):
    delta=abs(753-(int(S[i])*100+int(S[i+1])*10+int(S[i+2])))
    if i==0:
        max=delta
    elif delta<max:
        max=delta

print(max)


Measured memory_bytes: 3060
#include <functional>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>

using namespace std;

typedef long long LL;
typedef pair<int,int> Pii;
typedef pair<double,double>Pdd;
const int MAXN=1e3+5;
const int INFO=0x3f3f3f3f;
const LL LLINFO=1e18;
LL x,temp;
LL Labs(LL a)
{
    return a<0LL?-a:a;
}
LL bi()
{
    LL L=0,R=(1<<30),mid;
    while(L<R)
    {
        mid=((L+R)>>1);
        temp=mid*(mid+1)>>1;
        if(x>temp) L=mid+1;
        else R=mid;
    }
    return L;
}
int main()
{
    //freopen("E:\\in.txt","r",stdin);
    scanf("%lld",&x);
    LL step=bi();
    printf("%lld\n",step);


    return 0;
}

















Measured memory_bytes: 256
#include<stdio.h>
#define swap(x, y) {int z; z = y ; y = x ; x = z;}


int main()
{
	int a, b, c, div = 0;
	
	scanf("%d %d %d", &a, &b ,&c);
	for(int i = a; i <= b; i++)
	{
		if(c% i == 0)
		{
			div++;
		}
	}
	printf("%d\n", div);
	return 0;
}


Measured memory_bytes: 2748
#include <iostream>
#include <queue>
#include <string>
#include <map>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <vector>
#include <stack>
#include <algorithm>
#include <string.h>
#include <set>
#include <cstdlib>
#include <iostream>
#include <bits/stdc++.h>
#define sl(n) scanf("%lld",&n)
#define s(n) scanf("%d",&n)
#define f(n) for(int i=0;i<n;++i)
#define fo(n) for(int i=1;i<=n;++i)
#define ll long long
#define pb push_back
#define pf printf
#define F first
#define S second
using namespace std;
 typedef pair <int , int> l;
ll arr[150001];

bool comp(l a, l b){
	return a.first< b.first;
}

int main()
{
	string s;
	cin>>s;
	if(s[s.size()-1]=='3')cout<<"bon";
	else if (s[s.size()-1]=='0' || s[s.size()-1]=='1'|| s[s.size()-1]=='6' || s[s.size()-1]=='8')cout<<"pon";
	else cout<<"hon";

}


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

signed main(){
    int x;cin>>x;
    int ans=1;
    for(int i=2;i*i<=x;i++){
        int v=i;
        while(v<=x)v*=i;
        v/=i;
        ans=max(ans,v);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
integer N,M
integer a,b
integer,allocatable::reader(:)
integer key
integer,allocatable::bitDP(:)
read*,N,M
allocate(bitDP(0:2**N-1))
bitDP=10**9
bitDP(0)=0
do i=1,M
  read*,a,b
  allocate(reader(b))
  read*,reader
  key=0
  do j=1,b
    key=IBSET(key,reader(j)-1)
  end do
  do j=0,2**N-1
    bitDP( or(j,key) )=min(bitDP( or(j,key) ), bitDP(j)+a)
  end do
  deallocate(reader)
end do

if(bitDP(2**N-1)==10**9)then
  print"(i0)",-1
else
  print"(i0)",bitDP(2**N-1)
endif

end

Measured memory_bytes: 512
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=9999999999;
int a[510][510];


int main(){
    int h,w;
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            int b;
            cin>>b;
            b%=2;
            a[i][j]=b;
        }
    }
    vector<PP> ans;
    bool f=true;
    for(int i=0;i<h;i++){
        if(i%2==0){
            for(int j=0;j<w;j++){
                if(a[i][j]){
                    if(f){
                        if(j<w-1){
                            ans.push_back(PP(P(i,j),P(i,j+1)));
                        }else if(i<h-1){
                            ans.push_back(PP(P(i,j),P(i+1,j)));
                        }    
                        f=false;
                    }else{
                        f=true;
                    }
                }else{
                    if(!f){
                        if(j<w-1){
                            ans.push_back(PP(P(i,j),P(i,j+1)));
                        }else if(i<h-1){
                            ans.push_back(PP(P(i,j),P(i+1,j)));
                        }    
                    }
                }
            }
        }else{
            for(int j=w-1;j>=0;j--){
                if(a[i][j]){
                    if(f){
                        if(j>0){
                            ans.push_back(PP(P(i,j),P(i,j-1)));
                        }else if(i<h-1){
                            ans.push_back(PP(P(i,j),P(i+1,j)));
                        }    
                        f=false;
                    }else{
                        f=true;
                    }
                }else{
                    if(!f){
                        if(j>0){
                            ans.push_back(PP(P(i,j),P(i,j-1)));
                        }else if(i<h-1){
                            ans.push_back(PP(P(i,j),P(i+1,j)));
                        }    
                    }
                }
            }
        }
    }
    cout<<ans.size()<<endl;
    for(PP pp:ans){
        int q=pp.first.first+1;
        int w=pp.first.second+1;
        int e=pp.second.first+1;
        int r=pp.second.second+1;
        cout<<q<<" "<<w<<" "<<e<<" "<<r<<endl;
    }

}

Measured memory_bytes: 6356
n = int(input())
l = list(map(int,input().split()))
count = 0
for i in range(n-2):
  if min(l[i],min(l[i+1],l[i+2])) != l[i+1] and max(l[i],max(l[i+1],l[i+2])) != l[i+1]:
    count +=1
print(count)

Measured memory_bytes: 38256
#include<iostream>
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>

using namespace std;

class Counting {
	unsigned long long p, n;
	vector<long long> invMemo, facMemo, facInvMemo;
public:
	Counting(unsigned long long nn, unsigned long long np) {
		p = np;
		n = nn;
		invMemo.resize(n + 1);
		facMemo.resize(n + 1);
		facInvMemo.resize(n + 1);
		facMemo[0] = 1;
		facMemo[1] = 1;
		facInvMemo[0] = 1;
		facInvMemo[1] = 1;
		invMemo[0] = 0;
		invMemo[1] = 1;
		for (unsigned long long i = 2; i <= n; i++) {
			invMemo[i] = p - (p / i)*invMemo[p%i] % p;
			facMemo[i] = (facMemo[i - 1] * i) % p;
			facInvMemo[i] = (facInvMemo[i - 1] * invMemo[i]) % p;
		}
	}
	unsigned long long fac(unsigned long long k) {
		return facMemo[k];
	}
	unsigned long long facInv(unsigned long long k) {
		return facInvMemo[k];
	}
	unsigned long long choose(unsigned long long n, unsigned long long k) {
		if (!(0 <= k && k <= n))
			return 0;
		return (((facMemo[n] * facInvMemo[k]) % p)*facMemo[n - k]) % p;
	}
	unsigned long long divide(unsigned long long a, unsigned long long b) {
		return (a * invMemo[b]) % p;
	}
	unsigned long long mod(unsigned long long a) {
		a %= p;
		if (a < 0) a += p;
		return a;
	}
	unsigned long long power(unsigned long long a, unsigned long long e) {
		unsigned long long ans = 1;
		for (; e > 0; e /= 2) {
			if (e % 2 != 0)
				ans = ans * a % p;
			a = a*a%p;
		}
		return ans;
	}
};

int a, b, n;
string s;

int main() {
	cin >> n >> a >> b;
	cin >> s;
	int cnt = 0, Out = 0;
	for (int i = 0; i < n; i++) {
		if (cnt >= a + b) {
			cout << "No" << endl;
			continue;
		}
		if (s[i] == 'a') {
			if (cnt < a + b) {
				cout << "Yes" << endl;
				cnt++;
			}
			else
				cout << "No" << endl;
			continue;
		}
		else if (s[i] == 'b') {
			if (Out < b) {
				cout << "Yes" << endl;
				Out++;
				cnt++;
			}
			else
				cout << "No" << endl;
			continue;
		}
		else
			cout << "No" << endl;

	}
	//cin >> n;
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 101010101000;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;

int main(){
  ll a,b,v,w,t;
  cin >> a >> v >> b >> w >> t;
  ll d = b-a;
  ll s = v-w;
  if(d<0) d *= -1;
  if(d>s*t) cout << "NO";
  else cout << "YES";
}

Measured memory_bytes: 3636
#include<iostream>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
using namespace std;
using ll=long long;

const ll MOD=998244353;
int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    
    map<char,int> mp={{'R',0},{'G',1},{'B',2}};
    vector<int> dp1(3);
    vector<int> dp2(3);

    ll pat=1;
    for(int i=1;i<=n;i++) pat=pat*i%MOD;

    for(int i=0;i<3*n;i++){
        int c=mp[s[i]];
        if(dp2[c]){
            pat=pat*dp2[c]%MOD;
            dp2[c]--;
        }
        else if(accumulate(dp1.begin(),dp1.end(),0)!=dp1[c]){
            int pos=-1;
            for(int i=0;i<3;i++){
                if(i!=c && dp1[i]){
                    pos=i;
                    break;
                }
            }
            pat=pat*dp1[pos]%MOD;
            dp1[pos]--;
            for(int i=0;i<3;i++){
                if(i!=c && pos!=i){
                    dp2[i]++;
                }
            }
        }
        else{
            dp1[c]++;
        }
    }
    cout<<pat<<endl;
    return 0;
}


Measured memory_bytes: 900
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)    (x).begin(),(x).end()
#define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
#define mp        make_pair
#define eb        emplace_back
#define REP(i, a) for (int i = 0; i < (a); i++)
int main() {
	int a, b;
	cin >> a >> b;
	if ((a + b) % 2 == 1) {
		cout << (a + b) / 2 + 1 << endl;
	}
	else {
		cout << (a + b) / 2 << endl;
	}
}

Measured memory_bytes: 256
n = int(input())
b = [int(i) for i in input().split()] 
a = []
for i in range(n):
    for j in range(len(b), 0, -1):
        if b[j-1] == j:
            del b[j-1]
            a.append(str(j))
            break
if len(a) != n:
    print(-1)
else:
    print("\n".join(list(reversed(a))))

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int> a(n+1);

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

    for(int i=n;i>=1;i--){
        int sum=0;
        for(int j=i+i;j<=n;j+=i){
            sum^=b[j];
        }
        b[i]=sum^a[i];
    }
    vector<int> ans;
    for(int i=1;i<=n;i++)
        if(b[i]) ans.push_back(i);
    cout <<ans.size()<<endl;

    for(int i=0;i<ans.size();i++){
        printf("%d%c",ans[i],i+1==ans.size()?'\n':' ');
    }

    return 0;
}


Measured memory_bytes: 3064
//THE DOC

#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
typedef long long int ll;
typedef unsigned long long int ull;
#define fi first
#define se second
#define pb push_back
ll mod1=pow(10,9)+7;
int mod2=998244353;
ll inf=1e9;
ll maxxy=1e6+9;
typedef long double ld;
const double PI =  3.141592653589793238;

ll power(ll x, ll y, ll pp)
{
    ll res = 1;
    x = x % pp;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % pp;
        y = y>>1;
        x = (x*x) % pp;
    }
    return res;
}

ll modInverse(ll n, ll pp)
{
    return power(n, pp-2, pp);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    vector<ll> a(n);
    for (int i = 0; i <n ; ++i) {
        cin>>a[i];
    }
    ll ans=0;
    if(n==1){
        cout<<"0"<<"\n";
    }
    else{
        for (int i = 1; i <n ; ++i) {
            if(a[i]<a[i-1]){
                ans+=(a[i-1]-a[i]);
                a[i]=a[i-1];
            }
        }
        cout<<ans<<"\n";
    }
    return 0;
}


Measured memory_bytes: 4764
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	int t[n * m + 1] = { };
	for(int i = 0; i <= n; i++){
		for(int j = 0; j <= m; j++){
			t[i*m + j*n - 2*i*j] = 1;
		}
	}
	int q;
	cin >> q;
	if(t[q] == 1) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main()
{
    int H, A;
    cin >> H >> A;

    if (H % A == 0) cout << H / A << endl;
    else cout << H / A + 1 << endl;

    return 0;
}

Measured memory_bytes: 256