akhauriyash/Code-Regression huggingface dataset:
/**
*    created: 03.07.2020 01:01:39
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

// Template for ModInt
template <typename T> T pow(T a, long long n, T e = 1) {
    T ret = e;
    while (n) {if (n & 1) ret *= a; a *= a; n >>= 1;}
    return ret;
}

template <int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {if ((x = x_ % mod + mod) >= mod) x -= mod;}
    ModInt& operator+=(ModInt rhs) {if ((x += rhs.x) >= mod) x -= mod; return *this;}
    ModInt& operator-=(ModInt rhs) {if ((x -= rhs.x) < 0) x += mod; return *this;}
    ModInt& operator*=(ModInt rhs) {x = (unsigned long long)x * rhs.x % mod; return *this;}
    ModInt& operator/=(ModInt rhs) {x = (unsigned long long)x * rhs.inv().x % mod; return *this;}
    ModInt operator-() const {return -x < 0 ? mod - x : -x;}
    ModInt operator+(ModInt rhs) const {return ModInt(*this) += rhs;}
    ModInt operator-(ModInt rhs) const {return ModInt(*this) -= rhs;}
    ModInt operator*(ModInt rhs) const {return ModInt(*this) *= rhs;}
    ModInt operator/(ModInt rhs) const {return ModInt(*this) /= rhs;}
    bool operator==(ModInt rhs) const {return x == rhs.x;}
    bool operator!=(ModInt rhs) const {return x != rhs.x;}
    ModInt inv() const {return pow(*this, mod - 2);}
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {s << a.x; return s;}
    friend istream& operator>>(istream& s, ModInt<mod>& a) {s >> a.x; return s;}
};

using mint = ModInt<MOD>;
const int MAX = 1000010;
mint fac[MAX], finv[MAX], inv[MAX];

// Combination Table
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    rep2(i,2,MAX){
        fac[i] = fac[i-1] * (mint)i;
        inv[i] = (mint)MOD - inv[MOD%i] * (mint)(MOD/i);
        finv[i] = finv[i-1] * inv[i];
    }
}

// nCk
mint COM(int n,int k) {
    if (n < k or n < 0 or k < 0) return 0;
    return fac[n] * finv[k] * finv[n-k];
}

// nPk
mint PER(int n, int k) {
    if (n < k or n < 0 or k < 0) return 0;
    return fac[n] / fac[n-k];
}

mint revFAC(int n, int k) {
    mint ret = 1;
    rep(i,k) ret *= n-i;
    return ret;
}

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    COMinit();
    int n, a, b;
    cin >> n >> a >> b;
    mint ans = pow((mint)2,n);
    ans -= revFAC(n,a) * finv[a];
    ans -= revFAC(n,b) * finv[b];
    ans -= 1;
    cout << ans << endl;
    return 0;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e2 + 5);

int h, w;
char a[MAX_N][MAX_N];

map<int, int> count_parity() {
  map<char, int> cnt;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cnt[a[i][j]] += 1;
    }
  }

  map<int, int> ret;
  for (auto &e : cnt) {
    ret[e.second % 4] += 1;
  }

  return ret;
}

int main(void) {
  // Here your code !
  scanf("%d %d", &h, &w);

  for (int i = 0; i < h; ++i) {
    scanf("%s", a[i]);
  }

  auto pc = count_parity();

  string ans = "No";

  if ((h % 2 == 0) && (w % 2 == 0)) {
    if (pc[1] == 0 && pc[2] == 0 && pc[3] == 0) {
      ans = "Yes";
    }
  } else if ((h % 2 == 1) && (w % 2 == 1)) {
    if (pc[1] == 1 && (pc[2] * 2 <= (h + w - 2)) && pc[3] == 0) {
      ans = "Yes";
    }
  } else {
    int even = (h % 2 == 0) ? h : w;

    if (pc[1] == 0 && (pc[2] * 2 <= even) && pc[3] == 0) {
      ans = "Yes";
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
#define sz(a) ll(a.size())
void solve(){
	ll n,res=0;
	cin>>n;
	vector<p2> v;
	map<ll,ll> m;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		m[x]++;
	}
	for(auto it=m.begin();it!=m.end();it++)
		v.push_back(*it);
	n=sz(v);
	for(ll i=0;i<n;i++)
		for(ll j=i+1;j<n;j++)
			for(ll k=j+1;k<n;k++)
				if(v[k].first<v[i].first+v[j].first)
					res+=v[k].second*v[j].second*v[i].second;
	cout<<res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
    clock_t z=clock();
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++){
        solve();
    }
    debug("Total Time:%.4Lf\n",(ld)(clock()-z)/CLOCKS_PER_SEC);
}

Measured memory_bytes: 3828
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	 int n,k,c=0;
	 cin>>n>>k;
	 vector<int>l(n);
	 for(int i=0;i<n;i++)cin>>l[i];
	 sort(l.begin(),l.end());
	 for(int i=0;i<k;i++)c+=l[n-i-1];
	 cout<<c<<endl;
	return 0;
}


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

int main(void){
    ll l,r;
    cin >> l >> r;
    if(r-l >= 2018){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 2019;
    for(ll i=l;i<r;i++){
        for(ll j=i+1;j<=r;j++){
            ans = min(ans,i*j%MOD);
        }
        if(ans == 0) break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<stdio.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1e9

ll ans = 0;
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	bool f = false;
	rep(i, c) {
		if (!f) {
			ans += 1;
			f = true;
		}
		if (b > 0) {
			ans += 1;
			b--;
			f = false;
		}
		else if (a > 0) {
			a--;
			f = false;
		}
	}
	ans += b;
	cout << ans << endl;
	return 0;
}

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

int main(){

    int N;
    cin >> N;
    vector<long long> a(N);
    for(int i = 0; i < N; i++) cin >> a[i];

    for(int i = 1; i < N; i++) a[i] += a[i - 1];

    long long  ans = (1LL << 60LL);
    for(int i = 0; i < N - 1; i++){
        if(ans > abs(2 * a[i] - a.back())) ans = abs(2 * a[i] - a.back());
    }

    cout << ans << endl;

    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 MAX 100005
#define INF INT_MAX

typedef long long ll;
typedef pair<int, int> P;

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

void preorder(Node u);
void inorder(Node u);

Node root;

Node treeMinimum(Node x)
{
    if (x == NIL) return NIL;

    Node current = x;
    while (current->left != NIL) current = current->left;

    return current;
}
Node treeMaximum(Node x)
{
    if (x == NIL) return NIL;

    Node current = x;
    while (current->right != NIL) current = current->right;

    return current;
}
Node treeSearch(Node u, int k)
{
    Node ret;
    if (u == NIL) return NIL;

    if (k < u->key) ret = treeSearch(u->left, k);
    else if (k > u->key) ret = treeSearch(u->right, k);
    else ret = u;

    return ret;
}
Node treeSuccessor(Node x)
{
    if (x == NIL) return NIL;

    return treeMinimum(x->right);
}
void treeDelete(Node x)
{
    if (x == NIL) return;

    Node y, z;
    if (x->left == NIL || x->right == NIL) {
        if (x->left == NIL) y = x->right;
        else y = x->left;
        z = x->parent;
        if (y != NIL) y->parent = z;
        if (z != NIL) {
            if (x->key < z->key) {
                z->left = y;
            } else {
                z->right = y;
            }
        }
        free(x);
    } else {
        y = treeSuccessor(x);
        x->key = y->key;
        treeDelete(y);
    }
}

void insert(int k)
{
    Node y = NIL;
    Node x = root;
    Node z;

    z = (Node)malloc(sizeof(struct node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    z->parent = NIL;

    while (x != NIL) {
        y = x;
        if (k < x->key) x = x->left;
        else x = x->right;
    }
    if (y == NIL) root = z;
    else if (k < y->key) {
        y->left = z;
        z->parent = y;
    }
    else {
        y->right = z;
        z->parent = y;
    }
}

void inorder(Node u)
{
    if (u == NIL) return;
    
    inorder(u->left);
    cout << " " << u->key;
    inorder(u->right);    
}
void preorder(Node u)
{
    if (u == NIL) return;

    cout << " " << u->key;
    preorder(u->left);
    preorder(u->right);
}

int main(int, char**)
{
    int n, i, x;
    string com;
    cin >> n;

    for ( i = 0; i < n; i++ ){
        cin >> com;
        if ( com[0] == 'f' ){
            cin >> x;
            Node t = treeSearch(root, x);
            if ( t != NIL ) cout << "yes" << endl;
            else cout << "no" << endl;
        } else if ( com[0] == 'i' ){
            cin >> x;
            insert(x);
        } else if ( com[0] == 'p' ){
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        } else if ( com[0] == 'd' ){
            cin >> x;
            treeDelete(treeSearch(root, x));
        }
    }
    return 0;
}



Measured memory_bytes: 21748
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  sort(all(a));
  ll ans=n;
  ll k=1;
  rep(i,n-1){
    if(a[i]*2<a[i+1]){
      ans-=k;
      k=1;
      a[i+1]+=a[i];
    }
    else{
      k++;
      a[i+1]+=a[i];
    }
  }
  COUT(ans);
}

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

double temp(int a, int t, int x){
  return max(a-t+x*0.006, -a+t-x*0.006);
}

int main(){
  int n, t, a;
  cin >>n;
  cin >> t >> a;
  int h[n];
  double min_temp = pow(10, 10);
  int ans=0;
  for(int i=0; i<n; i++){
    cin >> h[i];
    if(temp(a, t, h[i]) < min_temp){
      min_temp = temp(a, t, h[i]);
      ans=i;
    }
  }
  cout << ans+1 <<endl;
}

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

using namespace std;
using ll = long long;


int main(){
    int a, b;
    cin >> a >> b;
    cout << max(a - b * 2, 0) << endl;
}

Measured memory_bytes: 256
h,w,v = map(int,input().split())
c = []
for i in range(h):
    c.append(input())
b = 0
x = []
for i in range(h):
    x.append([0]*w)
    for j in range(w):
        if(c[i][j] == '#'):
            b += 1

p = 0
for i in range(2**h):
    for j in range(2**w):
        x = bin(64^i)
        y = bin(64^j)
        cnt = 0
        for k in range(1,h+1):
            for l in range(1,w+1):
                if(x[-k] == '1' and y[-l] == '1' and c[k-1][l-1] == '#'):
                    cnt += 1
        if(cnt == v):
            p += 1
print(p)

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

int main() {
    int n;
    cin >> n;
    priority_queue<int> pq;

    int h1 = 0;
    int count = 0;
    rep(i, n) {
        int h2;
        cin >> h2;
        if(h2 > h1) {
            pq.push(count);
            count = 0;
        }
        else {
            count++;
        }
        h1 = h2;
    }
    pq.push(count);

    cout << pq.top() << endl;

    return 0;
}

Measured memory_bytes: 892
// abc149_e
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e12)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

ll N, M;
vector<ll> A;
vector<ll> cumsum;

// 幸福度、積だと勘違いした使えそうなので残しとく
//ll count_mul(ll x, ll& sm){
//
//    ll cnt = 0;
//    REP(i, N){
//        ll d = (x + A[i] - 1) / A[i];
//        auto idx = distance(A.begin(), lower_bound(ALL(A), d));
//        cnt += N - idx;
//        sm += A[i] * (cumsum[N] - cumsum[idx]);
//        print(x, i, idx, N-idx, A[i] * (cumsum[N] - cumsum[idx]));
//    }
//
//    return cnt;
//}

ll count_sum(ll x, ll& sm){

    ll cnt = 0;
    REP(i, N){
        ll d = x - A[i];
        auto idx = distance(A.begin(), lower_bound(ALL(A), d));
        cnt += N - idx;
        sm += (N-idx) * A[i] + (cumsum[N] - cumsum[idx]);
//        print(x, i, idx, N-idx, (N-idx) * A[i] + (cumsum[N] - cumsum[idx]));
    }

    return cnt;
}


int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    cin >> N >> M;
    A.assign(N, 0);
    REP(i, N) cin >> A[i];
    sort(ALL(A));

    cumsum.assign(N+1, 0);
    REP(i, N) cumsum[i+1] = A[i] + cumsum[i];

    // x以上の和の数がM以上になる最大のx
    ll ok = 0;
    ll ng = INF;
    while (ng - ok > 1){

        ll mid = (ok + ng) / 2;

        ll sm = 0;
        ll cnt = count_sum(mid, sm);
        if (cnt >= M){
            ok = mid;
        } else {
            ng = mid;
        }
    }

    ll ans = 0;
    ll cnt = count_sum(ok, ans);
    if (cnt > M){
        ans -= (cnt-M) * ok;
    }

    print(ans);

    return 0;
}


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

#define ll long long
#define rep(i,n) for(int i=0;(i)<n;i++)

using namespace std;

int main()
{
	ll n, x; cin>>n>>x;
	ll mini = 1e6;
	rep(i, n){
		ll m; cin>>m;
		x -= m;
		mini = min(mini, m);
	}
	ll ans = n;
	ans += x/mini;
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>

bool is_pailindrome(std::string s, int start, int end) {
	long long l = end - 1;

	for (long long i = start; i < end; i++)
	{
		if (i > l - i) break;
		if (s[i] != s[l - i]) {
			return false;
		}
	}
	return true;
}

int main() {
	std::string s;

	std::cin >> s;

	if (is_pailindrome(s, 0, s.length()) && is_pailindrome(s, 0, (s.length() - 1) / 2) && is_pailindrome(s, (s.length() + 3) / 2, s.length())) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N   100
 
int num[101];
 
int Bubble_sort(int num[], int n) {
    int counter = 0;
    int i, j;
 
    for (i = 1; i <= n; i++) {
        for (j = n; j > i; j--) {
            if (num[j] < num[j-1]) {
                int tmp = num[j];
                num[j] = num[j-1];
                num[j-1] = tmp;
                counter++;
            }
        }
    }
    return counter;
}
 
int main(void) {
    int i, n, count;
    scanf("%d", &n);
 
    for (i = 1; i <= n; i++) {
        scanf("%d", &num[i]);
    }
 
    count = Bubble_sort(num, n);
 
    for (i = 1; i < n; i++) {
        printf("%d ", num[i]);
    }
    printf("%d\n", num[n]);
    printf("%d\n", count);
 
    return 0;
}


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

int main(){
  string a, b, n;
  cin >> a >> b;
  n = a + b;
  int num = stoi(n);
  bool flag = false;
  for (int i=1; i<1e5; i++) {
    if (num%i == 0 && num/i == i) {
      flag = true;
    }
  }
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int mol=1e9+7;
typedef long long ll;

int main(void)
{
	ll k,n,t=0;
	cin>>n>>k;
	for(int i=k;i<=n+1;i++)
	{
		t+=(n-i+1)*i+1;
		t%=mol;
	}
	cout<<t<<endl;
	return 0;
}
	

Measured memory_bytes: 3632
n = int(input())
a,b,c = 0,0,0
for i in range(n):
    a1,b1,c1 = map(int,input().split())
    a,b,c = max(b,c) + a1, max(a,c) + b1, max(a,b) + c1
print(max(a,b,c))

Measured memory_bytes: 3060
K = int(input())
list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

for i in range(K):
    a = list[i]

print(a)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds; 
using namespace std;
using   ll=long long;
using   ld=long double;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set 	tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int             long long int
#define pll				pair<int , int>

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007
#define hell            998244353 

ll mod_pow(ll a,ll b,ll m) 
{
    ll res = 1;
    while(b)	
    {
        if(b&1) 	
        {
        	res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a) 
{
	return mod_pow(a , mod-2 , mod);
}

void solve()
{
	int a , b;
	
	cin >> a >> b;
	
	if(a >= 13) {
		cout << b;
	}
	else if(a >= 6) {
		cout << b/2;
	}
	else {
		cout << 0;
	}
}

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


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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;

using namespace std;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 

	int n;
	cin >> n;
	
	vi a(n);

	rep(i , n){
		int x;
		cin >> a[i];
	}
	
	
	
	vi v[3];
	
	rep(i , n){
		if(a[i] % 4 == 0){
		//	++v[0];
			v[0].pb(a[i]);
		}else if(a[i] % 2 == 0){
			v[1].pb(a[i]);
		}else{
			v[2].pb(a[i]);
		}
	}
	
	vi ck;
	int last = 0;
	rep(i , n){
		if(last == 0){
			if(sz(v[2])){
				ck.pb(v[2][sz(v[2]) - 1]);
				last = 2;
				v[2].ppb();
				continue;
			}else if(sz(v[0])){
				ck.pb(v[0][sz(v[0]) - 1]);
				last = 0;
				v[0].ppb();
				continue;
			}else{
				ck.pb(v[1][sz(v[1]) - 1]);
				last = 1;
				v[1].ppb();
				continue;
			}
		}
		if(last == 2){
			if(sz(v[0])){
				ck.pb(v[0][sz(v[0]) - 1]);
				last = 0;
				v[0].ppb();
				continue;				
			}else{
				dier("No");
			}
		}
		if(last == 1){
			if(sz(v[2])){
				ck.pb(v[2][sz(v[2]) - 1]);
				last = 2;
				v[2].ppb();
				continue;
			}else if(sz(v[0])){
				ck.pb(v[0][sz(v[0]) - 1]);
				last = 0;
				v[0].ppb();
				continue;
			}else{
				ck.pb(v[1][sz(v[1]) - 1]);
				last = 1;
				v[1].ppb();
				continue;
			}			
		}
	}
	
	bool good = 1;
	
	rep(i , n - 1){
		good &= (1ll * ck[i] * ck[i + 1]) % 4 == 0; 
	}
	
	if(good)dier("Yes");
	dier("No");

	
	


	return 0;
}

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main()
{int n,y;
 cin >> n >> y;
 int a,b,c;
 bool kk = false;
 
 for(int i = 0;i <= n ; i++){
  for(int j = 0;j <= n ; j++){
 if (10000*i + 5000*j + 1000*(n-i-j) == y && (n-i-j) >= 0){
   a = i;
   b = j;
   c = n-i-j;
   kk = true;
   break;
 }
   }
   if(kk) break;
 }
 
 if(kk) cout << a << " " << b << " " << c <<endl;
  if(!kk) cout << "-1 -1 -1" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    ll ans = 0;
    ll now = 0;
    for(int i=0;i<n;i++){
        chmax(now,a[i]);
        ans += now - a[i];
    }
    cout << ans << endl;
}   

Measured memory_bytes: 5216
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,d,ans = 0;
	cin >> n >> d;
	for(int i = 0;i < n;i++){
		int x,y;
		cin >> x >> y;
		if(x * x + y * y <= d * d) ans++;
	}
	cout << ans << endl;
}

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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int n,a,b;cin>>n>>a>>b&&n;){
		vi ps(n);
		rep(i,n) cin>>ps[i];
		int x=0,y=0,z=0;
		for(int p:ps){
			if(p<=a)
				x++;
			else if(p<=b)
				y++;
			else
				z++;
		}
		cout<<min({x,y,z})<<endl;
	}
}


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

int main() {

    int c_cakes=0, s_cakes=0;
    cin >> c_cakes >> s_cakes;

    if(c_cakes <= 8 && s_cakes <= 8)
        cout << "Yay!" << endl;
    else
        cout << ":(" << endl;
        
}


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

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

	if ( (a + b)%3 == 0 || a%3 == 0 || b%3 == 0)
		cout << "Possible\n";
	else 
		cout << "Impossible\n";
	return 0;
}

Measured memory_bytes: 256
#pragma region
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define vi vector<int>
#define vd vector<double>
#define vs vector<string>
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m-1);i>=(int)(n);i--)
#define rev(i, n) revi(i, n, 0)
#define each(i, n) for(auto&& i: n)
#define sz(v) ((int)(v).size()) 
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define uniq(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define dump(x) cerr << #x << " = " << x << endl
#define gcd __gcd
int lcm(int a, int b){return a / gcd(a, b) * b;}
const int INF = 1e18;
const int MOD = 1e9 + 7;
const double EPS = 1e-15;
const double PI = acos(-1);
int dig(int n){return (int)(log10(n) + 1);}
int abc(char x){return (int)(x)-(int)('a');} // 0~25
char abc(int x){return (char)(x+(int)('a'));} 
int ABC(char x){return (int)(x)-(int)('A');}
char ABC(int x){return (char)(x+(int)('A'));}
void solve();
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	solve();
}
#pragma endregion

void solve() {
	int n; cin >> n;
	vi v(n); 
	rep(i, n) cin >> v[i];
	map<int, int> m1, m2;
	rep(i, n) {
		if (i % 2 == 0) m1[v[i]]++;
		else m2[v[i]]++;
	}
	vector<pair<int, int>> v1, v2;
	each(m, m1) v1.push_back(make_pair(m.second, m.first));
	each(m, m2) v2.push_back(make_pair(m.second, m.first));
	sort(rall(v1));
	sort(rall(v2));
	int a;
	if (v1[0].second == v2[0].second) {
		a = max(v1[0].first + v2[1].first, v1[1].first + v2[0].first);
	}
	else {
		a = v1[0].first + v2[0].first;
	}
	cout << n - a << endl;
}

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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

int N,K;
list<int> edge [100001];

int dfs(int curr,int prev,int& ans)
{
	int res = 0;
	for(auto&& it : edge [curr]){
		if(it == prev) continue;
		int tmp = dfs(it,curr,ans) + 1;
		if(curr != 1 && tmp == K){
			ans++;
		}
		else{
			chmax(res,tmp);
		}
	}

	return res;
}

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

	cin >> N >> K;
	int ans = 0;
	for(int i = 1;i <= N;i++){
		int A;
		cin >> A;
		if(i == 1){
			ans += A != 1;
		}
		else{
			edge [i].push_back(A);
			edge [A].push_back(i);
		}
	}

	dfs(1,-1,ans);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 14336
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <algorithm>

#define X first
#define Y second
#define PB push_back

using namespace std;

typedef long long ll;
typedef pair < int, int > pii;

const int N = 1e6 + 500;
const int M = 1e8 + 500;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;

int A[N], n;
ll L[N], R[N], uk = 0;

int main(){
	scanf("%d", &n);
	for(int i = 0;i <= n;i++){
		scanf("%d", A + i);
	}
	L[n] = A[n], R[n] = A[n];
	for(int i = n - 1;i >= 0;i--){
		R[i] = R[i + 1] + A[i];
		L[i] = (L[i + 1] + 1) / 2LL + A[i];
		if(i < 60 && (1LL << i) < R[i])
			R[i] = (1LL << i);
	}
	for(int i = 1;i <= n;i++){
		if(2LL * (R[i - 1] - A[i - 1]) < R[i])
			R[i] = 2LL * (R[i - 1] - A[i - 1]);
	}
	for(int i = 0;i <= n;i++){
		uk += R[i];
		if(L[i] > R[i] || !R[i] || (i < 60 && L[i] > (1LL << i))){
			printf("-1\n");
			return 0;
		}
	}
	printf("%lld\n", uk);
	return 0;
}

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

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

    if(a+b>c+d)cout<<"Left"<<endl;
    else if(a+b<c+d)cout<<"Right"<<endl;
    else cout<<"Balanced"<<endl;

    return 0;
}

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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;
struct UnionFind {
  vector<ll> par, sizes;
  ll cnt;
  UnionFind(ll N) : par(N), sizes(N, 1), cnt(N) {
    for (ll i = 0; i < N; i++) par[i] = i;
  }

  ll find(ll x) { return par[x] == x ? x : par[x] = find(par[x]); }

  bool same(ll x, ll y) { return find(x) == find(y); }

  ll size(ll x) { return sizes[find(x)]; }

  void unite(ll x, ll y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (sizes[x] < sizes[y]) swap(x, y);
    par[y] = x;
    sizes[x] += sizes[y];
    cnt--;
  }

  ll count() const { return cnt; }
};
int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  const ll V = 100005;

  ll n;
  cin >> n;

  vll to(2 * V);
  vll exist(2 * V, 0);

  UnionFind uf(2 * V);
  rep(i, n) {
    ll x, y;
    cin >> x >> y;
    exist[x] = 1;
    exist[y + V] = 1;
    uf.unite(x, y + V);
  }

  map<ll, ll> mp;
  rep(j, V) {
    if (exist[j]) mp[uf.find(j)]++;
  }

  ll juee = 0;
  for(auto& x : mp){
    ll cat = x.first;
    ll ncat = x.second;
    ll mcat = uf.size(cat) - ncat;
    juee += ncat * mcat;
  }

  cout << juee - n << endl;

  return 0;
}


Measured memory_bytes: 9572
//----ak_lm10----
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

//TYPEDEFS
typedef long long int ll;
typedef unsigned long long int uli;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<ll,ll>> vpll;
typedef set<int> si;
typedef set<ll> sll;
//DEFINES
#define PI 3.1415926535897932384
#define fastIO  std::ios::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007
#define mod1 1000000009
#define mod2 998244353
#define gcd __gcd
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define rep(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define REP(i, k, n) for (ll (i) = (k); (i) < (n); (i)++)
#define repr(i, k, n) for (ll (i) = (k); (i) >= (n); (i)--)
#define pb push_back
#define popb pop_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define popf pop_front()
#define si size()
#define be begin()
#define en end()
#define all(x) x.be,x.en
#define rall(x) x.rbegin(),x.rend()
#define sortinc(x) sort(all(x))
#define sortdec(x) sort(rall(x))
#define tr(it, a) for(auto (it) = a.begin(); (it) != a.end(); (it)++)
#define p0(a) cout << (a) << " "
#define p1(a) cout << (a) << endl
#define p2(a, b) cout << (a) << " " << (b) << endl
#define p3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl
#define p4(a, b, c, d) cout << (a) << " " << (b) << " " << (c) << " " << (d) << endl
#define cend cout<<endl
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define inpi in<int>()
#define inpll in<ll>()
#define inps in<string>()
#define r0 return 0
#define e0 exit(0)
#define F first
#define S second
#define setBits(x) _builtin_popcount(x)
#define setBitsll(x) _builtin_popcountll(x)
#define parity(x) _builtin_parity(x)
#define leadZero(x) __builtin_clz(x)
#define leadZeroll(x) __builtin_clzll(x)
#define trailZero(x) __builtin_ctz(x)
#define w(t) int t; cin>>t; while(t--)
#define CASE(t) int t; cin>>t; rep(i,t){cout<<"Case #"<<i+1<<":\n";}
#define debug(x) cout << #x << " is " << x << endl;
//TEMPLATES
template <typename T>
T in(){
    T x;
    cin >> x;
    return x;
}
template <typename T>
void print(vector<T> v){
    for (auto i : v){
        cout << i << " ";
    }
    cout << endl;
}
template <typename T>
void printArr(T *arr, int s, int n){
    for(int i=s;i<=n;i++){
        cout<<arr[i]<<" ";
    }
    cout<<endl;
}
template <typename T>
void cmp(pair<T, T> &a, pair<T, T> &b ){
    return a.S>b.S;
}
int main(){
    fastIO;
    
    int t=1;
    // cin>>t;
    while(t--){
        string s=inps;
        int cnt=0;
        if(s=="SSS")
            p1("0");
        else if(s=="SRR" || s=="RRS")
            p1("2");
        else if(s=="RSR" || s=="RSS" || s=="SSR" || s=="SRS")
            p1("1");
        else 
            p1("3");
    }
    return 0;
}


Measured memory_bytes: 3608
<?php
$n = (int)trim(fgets(STDIN));
$s1 = trim(fgets(STDIN));
$s2 = trim(fgets(STDIN));
$mod = 1000000007;
if ($s1[0] === $s2[0]) {
	$sum = 3;
}else{
	$sum = 6;
}

for ($i=1; $i < $n; $i++) { 
	$cur_s1 = $s1[$i];
	$cur_s2 = $s2[$i];
	// tate
	if ($cur_s1 === $cur_s2) {
		if ($s1[$i-1] === $s2[$i-1]) {
			$sum = ($sum * 2) % $mod;
		}
	}else{
		// yoko
		if ($s1[$i-1] === $cur_s1) {
			continue;
		}
		if ($s1[$i-1] === $s2[$i-1]) {
			$sum = ($sum * 2) % $mod;
		}else{
			$sum = ($sum * 3) % $mod;
		}
	}
}
echo $sum;

Measured memory_bytes: 4732
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)

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

int main() {
    string S,T;
    cin >>S>>T;
    P p[S.length()];
    rep(i, 0, S.length()){
        p[i]=P(T[i], S[i]);
    }
    sort(p ,p+S.length());
    bool t=true;
    if (S.length()==1) cout <<"Yes" <<endl;
    else {
        rep(i, 1, S.length()){
        if (p[i].first == p[i-1].first && p[i].second!=p[i-1].second) t=false;
        }
        P q[S.length()];
        rep(i, 0, S.length()){
            q[i]=P(S[i], T[i]);
        }
        sort(q ,q+S.length());
            rep(i, 1, S.length()){
                if (q[i].first == q[i-1].first && q[i].second!=q[i-1].second) t=false;
            }
            if (t) cout <<"Yes" <<endl;
            else cout <<"No" <<endl;
    }
}


Measured memory_bytes: 3976
N=int(input())
C=[0 for i in range(8)]
R=0
a=list(map(int,input().split()))
for i in range(N):
    if int(a[i]/400)<=7:
        C[int(a[i]/400)]=1
    else:
        R+=1
min=max(1,sum(C))
max=sum(C)+R
print(min,max)

Measured memory_bytes: 3064
using System;
using System.Text;

namespace AOJ_Hello_World {
	class Program {
		static void Main (string[] args) {
			var sab = Console.ReadLine();
			long[] a = new long[2];
			for (int i = 0;i < 2;i++) {
				a[i] = long.Parse( sab.Split(' ')[i]);
			}
			Console.WriteLine("{0} {1}",a[0]*a[1],(a[0]+a[1])*2);
		}
	}
}

Measured memory_bytes: 5624
/* ex5_3
   kohei0713 */

#include <stdio.h>

int main(void){
    
    int height, width, i, j;
    
    //input
    scanf("%d %d", &height, &width);

    char block[height][width];
    int destroyHeight[height], destroyWidth[width];

    //destroyHeightをすべて0の配列にする
    for(i = 0; i < height; i++){
        destroyHeight[i] = 0; 
    }

    //destroyWidthをすべて0の配列にする
    for(j = 0; j < width; j++){
        destroyWidth[j] = 0;
    } 

    for(i = 0; i < height; i++){
        for(j = 0; j < width; j++){
            //行列のマス(i,j)を読み取る
            scanf(" %c", &block[i][j]);
            if(block[i][j] == '#'){
                //マス(i,j)が黒のとき,destroyHeight[i],destroyWidth[j]を1にする
                destroyHeight[i] = 1;
                destroyWidth[j] = 1;
            }
        }   
    }

    for(i = 0; i < height; i++){
        if(destroyHeight[i] == 1){
            for(j = 0; j < width; j++){
                if(destroyWidth[j] == 1){
                    //destroyHeight[i] = 1かつdestroyWidth[j] = 1のときblock[i][j]を表示
                    printf("%c", block[i][j]);
                }
            }
            //1行すべて処理が終わると改行する
            printf("\n");  
        } 
    }

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define   sz(s)         s.size()
#define   ll            long long int
#define   ull           unsigned ll
#define   ld            long double
#define   print(v)      for(ll i=0;i<v.size();i++)cout<<v[i]<<" "
#define   printpair(v)  for(ll i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second<<"\n"
#define   bmd           1000000007
#define   bmd1          998244353
#define   umll          unordered_map<ll,ll>
#define   mll           map<ll,ll>
#define   mcl           map<char,ll>
#define   pll           pair<ll,ll>
#define   F             first
#define   S             second
#define   setp(x)       setprecision(x)
#define   pb            push_back
#define   all(v)        v.begin(),v.end()
#define   tr(a)         for(auto it=a.begin();it!=a.end();it++)
#define   trr(a)        for(auto it1=a.begin();it1!=a.end();it1++)
#define   vll           vector<long long int>
#define   sorty(v)      sort(v.begin(),v.end())
#define   rsort(v)      sort(v.rbegin(),v.rend())
#define   unik(v)       v.erase(unique(all(v)),v.end())
#define   PI            3.1415926535897932384626
#define   db()          cout<<"\n"<<"here"<<"\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


//---------------------------------------------------------------------------
const int MOD = bmd;
const int N=2e5+100;
inline  ll sqr(ll x){return x*x;}
inline  void normal(ll &a) { a = (a+MOD)%MOD; }
inline  ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline  ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline  ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline  ll modPow(ll b, ll p) { ll r = 1;b=b%MOD; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline  ll modInv(ll a) { return modPow(a, MOD-2); }
inline  ll modDiv(ll a,ll b) { return modMul(a, modInv(b)); }
//---------------------------------------------------------------------------
void solve()
{
    ll n;
    cin>>n;
    if(n%1000 == 0){
        cout << 0 <<"\n";
        
    }
    else cout << 1000 - n%1000 <<"\n";
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);//first give all input then gives output
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3648
N[]={6,10,18,14,2,13,22,11,3,5,21,19,1,17,23,7,0,9,20,15,4,12,16,8};
E[]={15,7,11,19,8,3,14,23,16,0,6,22,4,2,18,20,12,1,10,21,9,5,13,17};
W[24],S[24];

n,d,a,i;
char s[9];
main(c)
{
	for(i=24;i--;)for(c=24;c--;)W[i]=E[c]==i?c:W[i],S[i]=N[c]==i?c:S[i];
for(;c-48&&scanf("%s",s);)
c=*s,
c<60&&a?printf("%d\n",a),a=d=0:0,
d=
(c-78?0:N[d])+
(c-69?0:E[d])+
(c-87?0:W[d])+
(c-83?0:S[d])+
(c-82?0:d&28|d%4+1&3)+
(c-76?0:d&28|d%4+3&3),
a+=d/4+1,d%=24;
}

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

int main(){
  ll n;
  cin>>n;
  ll a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  sort(a,a+n);
  ll num = a[0] + a[1];
  ll val = 2;
  for(int i=2;i<n;i++,val*=2) num+=val*a[i];
  long double ans = (long double) num / (long double) val; 
   cout<<setprecision(15)<<ans<<"\n";
  return 0;
}

Measured memory_bytes: 256
s_s = input()
s_t = input()

#S->Tの変換ができるか確認するディクショナリー
check_ST_dic = {} 
check_TS_dic = {}

for i in range(len(s_s)):
    s = s_s[i]
    t = s_t[i]
    if s not in check_ST_dic:
        check_ST_dic[s] = t
    elif check_ST_dic[s] != t:
        print('No')
        break

    if t not in check_TS_dic:
        check_TS_dic[t] = s
    elif check_TS_dic[t] != s:
        print('No')
        break

else:
    print('Yes') #breakで抜けなかった時のみ実行

Measured memory_bytes: 3632
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    string c;
    cin>>c;
    if (c.length()%2==1){
    	cout<<"No"<<endl;
    }
    else{
     int k=1;
	 for (int i=0;i<c.length()/2;i++){
    	if (c[2*i]!='h'){
    		k=0;
    	}
    	if (c[2*i+1]!='i'){
    		k=0;
    	}
  	  }
  	  if (k==1){
  	  	cout<<"Yes"<<endl;
  	  }
  	  else{
  	  	cout<<"No"<<endl;
  	  }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

//関数の宣言
void func(int building, int floor, int room, int v, int info[4][3][10]);
void output(int info[4][3][10]);

int main(){
	int n;				//情報の数
	int building;		//棟
	int floor;			//階
	int room;			//部屋
	int v;				//人数
	const int a = 4;
	const int b = 3;
	const int c = 10;

	int info[a][b][c];

	for (int i = 0; i < 4; ++i){
		for (int j = 0; j < 3; ++j){
			for (int k = 0; k < 10; ++k){
				info[i][j][k] = 0;
			}
		}
	}

	std::cin >> n;

	for (int l = 0; l < n; ++l){
		std::cin >> building >> floor >> room >> v;
		func(building, floor, room, v, info);
	}
	output(info);
}

//関数の定義
void func(int building, int floor, int room, int v, int info[4][3][10]){
	info[building-1][floor-1][room-1] += v;
}

//void output(int info[4][3][10]){
//	for (int p = 0; p < 15; ++p){
//		for (int q = 0; q < 10; ++q){
//			if (p == 3 || p == 7 || p == 11){
//				if (q == 9){
//					std::cout << "##\n";
//				}
//				else
//					std::cout << "##";
//			}
//			else if (0 <= p && p <= 2){
//				if (q == 9){
//					std::cout << info[1][p + 1][q + 1] << '\n';
//				}
//				else
//					std::cout << info[1][p + 1][q + 1] << ' ';
//			}
//			else if (4 <= p && p <= 6){
//				if (q == 9){
//					std::cout << info[2][p - 3][q + 1] << '\n';
//				}
//				else
//					std::cout << info[2][p - 3][q + 1] << ' ';
//			}
//			else if (8 <= p && p <= 10){
//				if (q == 9){
//					std::cout << info[3][p - 7][q + 1] << '\n';
//				}
//				else
//					std::cout << info[3][p - 7][q + 1] << ' ';
//			}
//			else if (12 <= p && p <= 14){
//				if (q == 9){
//					std::cout << info[4][p - 11][q + 1] << '\n';
//				}
//				else
//					std::cout << info[4][p - 11][q + 1] << ' ';
//			}
//		}
//	}
//}

void output(int info[4][3][10]){
	for (int i = 0; i < 4; ++i){
		for (int j = 0; j < 3; ++j){
			for (int k = 0; k < 10; ++k){
				std::cout <<' '<< info[i][j][k];
			}
			std::cout << std::endl;
		}
		if (i < 3){
			std::cout << "####################\n";
		}
	}
}


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

// 23:19 - 23:22
int main(void){
    int n = 0; 

    scanf("%d", &n);

    if(n % 2 == 0){
        printf("%d\n", n);
    }else{
        printf("%d\n", n * 2);
    }

    return 0;

} 



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

vector<int64_t> prime(int64_t x)
{
  vector<int64_t> pri;
  for(int64_t d=2;d*d<=x;d++)
  {
    if(x%d!=0)
      continue;
    int64_t ex=0;
    while(x%d==0)
    {
      ex++;
      x/=d;
    }
    pri.push_back(ex);
  }
  if(x!=1)
    pri.push_back(1);
  return pri;
}

int64_t tri(int64_t a)
{
  int64_t h;
  for(int64_t i=1;;i++)
  {
    if(a*2<i*(i+1))
    {
      h=i-1;
      break;
    }
  }
  return h;
}

int main()
{
  int64_t n,ans;
  ans=0;
  cin>>n;
  for(int64_t i=0;i<prime(n).size();i++)
  {
    ans+=tri(prime(n).at(i));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3624