akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

string S[2009];
int H,W,ans;
int hig[2009];

bool ck(int i,int j){
    return (1^(S[i][j]==S[i][j-1])^(S[i-1][j]==S[i-1][j-1]));
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>H>>W;
    rep(i,H) cin>>S[i];
    
    ans=max(H,W);
    FOR(i,1,H){
        stack<pii> stc;
        stc.push({0,0});
        FOR(j,1,W){
            if(ck(i,j)) hig[j]++;
            else hig[j]=0;
            int h=stc.top().first;
            int w=stc.top().second;
            int ww=0;
            while(h>hig[j]){
                ww+=w;
                chmax(ans,(h+1)*(ww+1));
                stc.pop();
                h=stc.top().first;
                w=stc.top().second;
            }
            if(h<hig[j]){
                stc.push({hig[j],1+ww});
            }else{
                stc.top().second+=1+ww;
            }
        }
        int ww=0;
        while(!stc.empty()){
            int h=stc.top().first;
            int w=stc.top().second;
            ww+=w;
            chmax(ans,(h+1)*(ww+1));
            stc.pop();
        }
    }
    cout1(ans)
}

Measured memory_bytes: 4480
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <map>
#include <set>

using namespace std;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int main()
{
	int N;
	cin >> N;
	using point = tuple<int, int, int>;
	vector<point> p;
	for (int i = 0; i < N; ++i) {
		int x, y;
		cin >> x >> y;
		p.emplace_back(i, x, y);
	}

	auto geti = [](auto &p) { return get<0>(p); };
	auto getx = [](auto &p) { return get<1>(p); };
	auto gety = [](auto &p) { return get<2>(p); };

	UnionFind s(N);
	sort(p.begin(), p.end(), [&](auto &a, auto &b) {
		return make_tuple(getx(a), gety(a)) < make_tuple(getx(b), gety(b));
	});
	for (int i = 0; i + 1 < N; ++i) {
		if (getx(p[i]) == getx(p[i + 1])) {
			s.unionSet(geti(p[i]), geti(p[i + 1]));
		}
	}

	sort(p.begin(), p.end(), [&](auto &a, auto &b) {
		return make_tuple(gety(a), getx(a)) < make_tuple(gety(b), getx(b));
	});
	for (int i = 0; i + 1 < N; ++i) {
		if (gety(p[i]) == gety(p[i + 1])) {
			s.unionSet(geti(p[i]), geti(p[i + 1]));
		}
	}

	map<int, vector<point>> g;

	sort(p.begin(), p.end());
	for (int i = 0; i < N; ++i) {
		g[s.root(i)].push_back(p[i]);
	}

	long long ans = 0;
	for (const auto &e : g) {
		set<int> x, y;
		for (auto &p : e.second) {
			x.insert(getx(p));
			y.insert(gety(p));
		}
		ans += 1LL * x.size()*  y.size() - e.second.size();
	}
	cout << ans << endl;
}


Measured memory_bytes: 7668
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)

    val n = sc.nextLong()
    val a = sc.nextLong()
    val b = sc.nextLong()

    val c = n / (a + b)
    val t = n % (a + b)
    val d = Math.min(a, t)

    val ans = c * a + d
    println(ans)

}


Measured memory_bytes: 31392
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define mp make_pair
#define INF (1LL<<60)
typedef long long Int;

struct node { int x, t, p; };
bool operator<(const node& l, const node& r) {
    return l.t!=r.t ? l.t<r.t : l.x!=r.x ? l.x<r.x : l.p<r.p;
}

int N, V, XL, XR;
node X[4000];

inline bool connect(int i, int j) {
    return abs(X[j].x-X[i].x)<=(long long)V*abs(X[j].t-X[i].t);
}

pair<int, int> pre[10000];
int vis[10000];
Int h[10000];
vector<int> v[10000];
vector<Int> c[10000];

inline void add_edge(int _u, int _v, Int _c) {
    v[_u].push_back(_v);
    c[_u].push_back(_c);
}

set<pair<Int, int> >::iterator z[10000];
int has[10000];

int main() {
    scanf("%d%d%d%d", &N, &V, &XL, &XR);
    X[0].x = XL;
    X[1].x = XR;
    rep(i, N) scanf("%d%d%d", &X[i+2].x, &X[i+2].t, &X[i+2].p);
    N += 2;
    sort(X, X+N);

    rep(i, 2+N*2) h[i] = INF;
    h[0] = 0;
    rep(i, 2) add_edge(0, 2+i*2, 0), h[2+i*2] = 0, pre[2+i*2] = mp(0, i);
    rep(i, N) {
        const int f = 2+2*i+1;
        add_edge(f-1, f, -X[i].p);
        h[f] = h[f-1] - X[i].p;
        pre[f] = mp(f-1, 0);
        add_edge(f, 1, 0);
        if(h[1]>h[f]) {
            h[1] = h[f];
            pre[1] = mp(f, 0);
        }
        for(int j=i+1; j<N; j++) if(connect(i, j)) {
            const int t = 2+2*j;
            add_edge(f, t, 0);
            if(h[t]>h[f]) {
                h[t] = h[f];
                pre[t] = mp(f, v[f].size()-1);
            }
        }
    }

    int cur = 1;
    while(cur!=0) {
        const int f = pre[cur].first;
        const int k = pre[cur].second;
        add_edge(cur, f, -c[f][k]);
        c[f][k] = INF;
        cur = f;
    }

    set<pair<Int, int> > q;
    q.insert(mp(0, 0));
    while(!q.empty()) {
        const pair<Int, int> vv(*q.begin());
        q.erase(q.begin());
        const int cc = vv.first;
        const int ix = vv.second;
        vis[ix] = 1;
        if(ix==1) {
            cout << -(h[1]*2+cc) << endl;
            break;
        }
        rep(i, v[ix].size()) if(!vis[v[ix][i]]) {
            const Int nc = cc + c[ix][i] + h[ix] - h[v[ix][i]];
            if(has[v[ix][i]]) {
                if(z[v[ix][i]]->first <= nc) continue;
                q.erase(z[v[ix][i]]);
            }
            has[v[ix][i]] = true;
            z[v[ix][i]] = q.insert(mp(nc, v[ix][i])).first;
            if(nc==0) vis[v[ix][i]] = true;
        }
    }
    return 0;
}

Measured memory_bytes: 68000
#include <iostream>
using namespace std;
#include <vector>
#include <sstream>
#include <algorithm>

bool myfunction(string a, string b){
    return lexicographical_compare(a.begin(), a.end(), b.begin(), b.end());
}

int main(void){
    // 自分の得意な言語で
    // Let's チャレンジ！！

    string str;
    int N, L;
    vector<string> S;
    int count = 0;
    while(getline(cin, str)){
        stringstream ss;
        ss << str;
        if(count == 0){
            ss >> N;
            ss >> L;
        }
        else if(count < N + 1)
        {
            string temp;
            ss >> temp;
            S.push_back(temp);
        }
        else {
            break;
        }

        count++;
    }

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


    for (int i = 0; i < N; ++i) {
        cout << S[i];
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  double a,b,c,d,e,f;
  double x,y;

  while(scanf("%lf %lf %lf %lf %lf %lf" ,&a ,&b ,&c ,&d ,&e ,&f) != EOF){
  
  x = (c*e - b*f)/(a*e - b*d);
  y = (a*f - c*d)/(a*e - b*d);

  if(x == 0) x = 0.000;
  else if(y == 0) y = 0.000; 
 
  printf("%.3f %.3f\n" ,x ,y);
  
}
  return 0;
}

Measured memory_bytes: 652
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll a,b;
    string s;
    cin>>a;
    cin>>s;
    cin>>b;
    if(s=="+")
    {
        cout<<(a+b);
    }
    else
    {
        cout<<(a-b);
    }
}


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


int main() {
    int N,T;
    cin >> N >> T;
    vector<pair<int,int>> H(N);
    rep(i,N) {
        cin >> H[i].first >> H[i].second;
    }
    int tle = 0;
    int costmin = 100000;
    rep(j,N) {
        if (H[j].second <= T ) {
            tle++;
            if (H[j].first < costmin) {
                costmin = H[j].first;
            }
        }
    }
    if (tle == 0) {
        cout << "TLE" << endl;
    }
    else {
        cout << costmin << endl;
    }
}



Measured memory_bytes: 3596
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

int solve(const std::vector<int>& values)
{
  for (int i = 0; i < 5; ++i) {
    if (values.at(i) == 0) return i + 1;
  }
  return 0;
}

int main()
{
  std::vector<int> values(5);
  for (auto& v : values) {
    std::cin >> v;
  }

  std::cout << std::setprecision(20);
  std::cout << solve(values) << std::endl;
}


Measured memory_bytes: 3588
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(void){

	vector< double > ds;
	double d;

	while( scanf("%lf",&d) != EOF ) {
		ds.push_back( d );
	}
	sort( ds.begin(), ds.end() );
	printf("%.4lf\n",  ds[ds.size()-1] - ds[0] );

    return 0;
}

Measured memory_bytes: 1252
//                             In The Name Of Allah                                           
//                             	Mohammad Hosseini
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std; 

const int N = 3e5 + 100, OO = 1e16, T = 4500 + 100, M = 1e9 + 7, P = 6151, SQ = 280, lg = 30;
typedef pair <int, int> pii;
int n, a[N];

bool check() {
	int od, ev, sum;
	od = ev = sum = 0;
	bool b = false;
	for(int i = 0; i < n; i++) {
		sum += a[i] - 1;
		if(a[i] == 1)
			b = true;
	}
	if(b) {
		if(sum % 2)
			return true;
		return false;
	}
	for(int i = 0; i < n; i++)
		od += (a[i] % 2), ev += ((a[i] + 1) % 2);
	if(ev % 2 == 1) 
		return true;
	if(od > 1)
		return false;
	int gc = 0;
	for(int i = 0; i < n; i++) {
		if(a[i] % 2 == 1)
			a[i]--;
		gc = __gcd(a[i], gc);
	}
	for(int i = 0; i < n; i++)
		a[i] /= gc;
	return !check();
}

int32_t main() {
	use_fast;
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	if(check()) 
		cout << "First" << endl;
	else
		cout << "Second" << endl;
	return 0;
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- uploaded by ubuntu 20.04 
5- ...
*/



Measured memory_bytes: 4432
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

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

  if (D==0) {
    cout << (N!=100 ? N*1 : N*1+1)<< endl;
  }
  else if (D==1) {
    cout << (N!=100 ? N*100 : (N+1)*100) << endl;
  }
  else {
    cout << (N!=100 ? N*10000 : (N+1)*10000)<< endl;
  }
}



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

int main(void){
	int H,W,N,count=0,n=1;
	cin>>H>>W;
	vector<vector<int> >color (W,vector<int>(H,0));
	cin>>N;
	vector<int> a(N,0);
	for(int i=0;i<N;i++){
		cin>>a[i];
	}
	for(int i=0;i<H;i++){
		if(i%2==0){
			for(int k=0;k<W;k++){
				if(count!=a[n-1]){
					color[k][i]=n;
					count++;
				}
				else{
					n++;
					color[k][i]=n;
					count=1;
				}
			}
		}
		else{
			for(int k=W-1;k>=0;k--){
				if(count!=a[n-1]){
					color[k][i]=n;
					count++;
				}
				else{
					n++;
					color[k][i]=n;
					count=1;
				}
			}
		}
	}

	for(int i=0;i<H;i++){
		for(int k=0;k<W;k++){
			cout<<color[k][i]<<" ";
		}
		cout<<endl;
	}
return 0;
}

Measured memory_bytes: 384
N = int(input())
P = input().split()
Q = input().split()
p = [int(x) for x in P]
q = [int(x) for x in Q]
k = 1
a = 0
b = 0

for r in range(1, N):
  k *= r

for r in range(N):
  a += p[r]*k
  b += q[r]*k
  for s in range (r+1, N):
    if(p[s] > p[r]):
      p[s] -= 1
    if(q[s] > q[r]):
      q[s] -= 1
  if not N-1-r == 0:
    k /= N-1-r
  
if(b-a>=0):
  print(int(b-a))
else:
  print(int(a-b))

Measured memory_bytes: 3064
# 再帰的なDFS
def rec(d, val, nums):
    nums.append(val)
    if d == 10:
        return
    
    for delta in (-1, 0, 1):
        add = val % 10 + delta
        if add >= 0 and add <= 9:
            rec(d+1, val * 10 + add, nums)

def main():
    K = int(input())
    nums = []
    for val in range(1, 10):
        rec(1, val, nums)
    nums.sort()
    print(nums[K-1])

main()

Measured memory_bytes: 19404
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

ll modminus(ll x, ll y) {
    return (x - y + mod) % mod;
}

ll multiply(ll x, ll y) {
    return (x % mod) * (y % mod) % mod;
}

ll modpower(ll x, ll y) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else if (y % 2 == 0) {
        ll p = modpower(x, y / 2);
        return p * p % mod;
    } else {
        ll p = modpower (x, y / 2);
        return (p * p) % mod * (x % mod) % mod;
    }
}

ll divide(ll x, ll y) {
    return multiply(x, modpower(y, mod - 2));
}

ll frac[1000000];
ll invfrac[1000000];

void fracinvfrac(ll n) {
    frac[0] = 1;
    for (int i = 1; i <= n; i++) {
        frac[i] = multiply(frac[i - 1], i);
    }
    invfrac[n] = divide(1, frac[n]);
    for (int i = n - 1; i >= 0; i--) {
        invfrac[i] = multiply(invfrac[i + 1], i + 1);
    }
}

int main() {
    ll N;
    cin >> N;
    ll A[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    ll invs[N + 1];
    invs[0] = 0;
    for (int i = 1; i < N + 1; i++) {
        invs[i] = invs[i - 1] + divide(1, i);
    }
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ans += multiply(invs[i + 1] + invs[N - i] - 1, A[i]);
    }
    for (int i = 1; i <= N; i++) {
        ans = multiply(ans, i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long x,y,z,k;
    cin>>x>>y>>z>>k;
    long long a[x],b[y],c[z];
    for(int i=0;i<x;i++)cin>>a[i];
    for(int i=0;i<y;i++)cin>>b[i];
    for(int i=0;i<z;i++)cin>>c[i];
    vector<long long>ab;
    for(int i=0;i<min(x,k);i++){
        for(int j=0;j<min(y,k);j++){
            ab.push_back(a[i]+b[j]);
        }
    }
    sort(ab.begin(),ab.end(),greater<long long>());
    vector<long long>abc;
    long long s=ab.size();
    for(int i=0;i<min(s,k);i++){
        for(int j=0;j<min(z,k);j++){
            abc.push_back(ab[i]+c[j]);
        }
    }
    sort(abc.begin(),abc.end(),greater<long long>());
    for(int i=0;i<k;i++)cout<<abc[i]<<endl;
    return 0;
}

Measured memory_bytes: 43364
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

using namespace std;

typedef long long int ll;

const int N = (int) 1e5 + 10;
const ll oo = 1e18;

void solve() {
  int a, b, c;
  cin >> a >> b >> c;
  int more = a - b;
  int transfer = min(more, c);
  cout << c - transfer << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);
  cout << fixed;
  solve();
  return 0;
}


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

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 200000;
const int N = 200000;

int a[N];

int main() {
	int n;cin>>n;
	rep(i,n){cin>>a[i];a[i]-=i+1;}
	sort(a,a+n);
	ll ans=0;
	rep(i,n) ans+=abs(a[i]-a[n/2]);
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
L, R = map(int, input().split())
L1 = 0
R0 = 0
ans = 2019
if R - L >= 2018 or L % 2019 > R % 2019:
    ans = 0
else:
    L = L % 2019
    R = R % 2019

    for i in range(L, R):
        for j in range(i+1, R+1):
            if i*j % 2019 < ans:
                ans = i*j % 2019

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=1<<30;


int main(){
	string s1,s2;
	cin>>s1>>s2;
	int a,b;
	cin>>a>>b;
	string s3;
	cin>>s3;
	if(s3==s1) a--;
	else b--;
	cout<<a<<" "<<b;
	
	
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e5 + 5;


int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  int a,b,c; cin>>a>>b>>c;
  vector<int> ans = {a+b,c+b,b+c,a+c,c+a,b+a};

  sort(ans.begin(),ans.end());
  cout<<ans.front()<<endl;
  
  return 0;
}



Measured memory_bytes: 256
H, W, K = map(int, input().split())
c = [input() for i in range(H)]

listH = [i for i in range(H)]
listW = [i for i in range(W)]
hlist = []
wlist = []
ans = 0

for i in range(1, 2**H):
  list1 = []
  for j in range(H):
    if (i >> j) &1 == 1:
      list1.append(listH[j])
  hlist.append(list1)

for i in range(1, 2**W):
  list1 = []
  for j in range(W):
    if (i >> j) &1 == 1:
      list1.append(listW[j])
  wlist.append(list1)

for i in hlist:
  for j in wlist:
    black = 0
    for x in i:
      for y in j:
        if c[x][y]=='#':
          black += 1
    if black == K:
      ans += 1
print(ans)


Measured memory_bytes: 73328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    int n;
    cin>>n;
    vector<pair<int, int>> vp;
    rep(i, n)
    {
        int a,b;
        cin>>a>>b;
        vp.push_back({b, a});
    }
    sort(all(vp));
    ll sum=0;
    rep(i,n){
        sum += vp[i].second;
        if(sum > vp[i].first) {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 5352
import math
N,P = map(int,input().split())
A = list(map(int,input().split()))

odd = []
even = []
ans = 0
for i in A:
  if (i % 2 == 1):
    odd.append(i)
  else:
    even.append(i)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
  
if (P == 0):
  l_odd = len(odd)
  num = 0
  while l_odd >= num:
    ans += combinations_count(l_odd, num)
    num += 2
  if (len(even)!=0):
    ans *= 2**len(even)
else:
  l_odd = len(odd)
  num = 1
  while l_odd >= num:
    ans += combinations_count(l_odd, num)
    num += 2
  if (len(odd)!=0):
    ans *= 2**len(even)
print(ans)
  

Measured memory_bytes: 38384
import sys
from fractions import gcd
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))


mod = 10 ** 9 + 7

l = 1
ans = 0
for i in A:
    l = (l * i) // gcd(l,i)
    ans += pow(i, mod-2, mod)
    ans %= mod
l %= mod
ans = (l * ans) % mod

print(ans)

Measured memory_bytes: 6200
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
#define mod ((ll)1e9+7)
#define inf ((ll)1e18+5)
#define maxx ((ll)1e6+5)
#define pb push_back
#define endl "\n"
#define time(i) cout<<"\nTime Elapsed "<<i<<" : " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
#define usefile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll expm(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
/*
bool sv[maxx]={0};    // returns 0 if a num is prime
int sp[maxx]={0};     // gives smallest prime factor of the number
void Sieve() {for(int i= 2; i< maxx; i+= 2) sv[i]=1,sp[i] = 2;sv[2]=0;for(ll i = 3; i < maxx; i += 2){if (!sv[i]){sp[i] = i;for (ll j = i; (j*i) < maxx; j += 2){if (!sv[j*i])sv[j*i] = true, sp[j*i] = i;}}}}
ll fact[maxx]={0}; // returns factorial of that number
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<maxx;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncrm(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expm(fact[r],mod-2)))%mod; res=(res*(expm(fact[n-r],mod-2)))%mod; return res;}
ll inv[maxx];   // returns the modular inverse of number
void inversify( ll m){inv[1]=1;for(int i=2;i<maxx;i++){inv[i]= m- m/i*inv[m%i]%m;}}
ll ncr(ll n,ll r,ll m){int ans=1;for (int i = 0; i < r; i++){ans=ans*(n-i)%m*inv[i+1]%m;}return ans;}
*/
signed main(){
  fast;
  //usefile;
  //test
  {
      int k,n;
      cin>>k>>n;
      int f;
      cin>>f;
      int diff=0;
      int temp,prev=f;
      for(int i=1;i<n;i++)
      {
          cin>>temp;
          diff=max(diff,abs(temp-prev));
          prev=temp;
      }
      diff=max(diff,abs(k-prev+f));
      cout<<(k-min(diff,abs(k-diff)));
    
  }
  //time("");
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
import bisect
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def bit_count(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#############
# Main Code #
#############

l = inputILs(5)

SUM = sum(-(-i//10)*10 for i in l)
R = [i%10 for i in l]

if max(R) == 0:
  print(SUM)
else:
  R.sort()
  print(SUM-10+R[bisect.bisect(R,0)])

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

int main(){
  int a, b, q;
  cin >> a >> b >> q;
  vector<long>s(a+2), t(b+2);
  s[0]=t[0]=-100000000000L;
  s[a+1]=t[b+1]=10000000000000L;
  long x;
  for(int i=1; i<=a; i++)cin >> s[i];
  for(int i=1; i<=b; i++)cin >> t[i];
  for(int i=0; i<q; i++){
    cin >> x;
    decltype(s)::iterator slit = lower_bound(s.begin(), s.end(), x);
    decltype(t)::iterator tlit = lower_bound(t.begin(), t.end(), x);
    long ret=1000000000000L;
    for(int j=0; j<2; j++){
      for(int k=0; k<2; k++){
        decltype(t)::iterator tlitt = lower_bound(t.begin(), t.end(), *(slit-j));
        ret=min(ret, abs(x-*(slit-j))+abs(*(slit-j)-*(tlitt-k)));
      }
    }
    for(int j=0; j<2; j++){
      for(int k=0; k<2; k++){
        decltype(s)::iterator slitt = lower_bound(s.begin(), s.end(), *(tlit-j));
        ret=min(ret, abs(x-*(tlit-j))+abs(*(tlit-j)-*(slitt-k)));
      }
    }
    cout << ret << endl;
  }
  return 0;
}


Measured memory_bytes: 2944
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
#define LEAD (lead && !i)
#define LIM (lim && i == buc[pos])
#define ABS(x) (x) < 0 ? (-x) : (x)
#define RG register
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 300000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int INF = 0x3f3f3f3f;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
// const double PI = acos(-1);
const double PI = 3.14159;

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

namespace Comb{
const int N = 10 + 5;
inline void exgcd(ll a, ll b, ll &g, ll &x, ll &y) {
    if (!b) g = a, x = 1, y = 0;
    else exgcd(b, a % b, g, y, x), y -= x * (a / b);
}
 
inline ll inv(ll a) {
    ll g, res, tmp;
    exgcd(a, MOD, g, res, tmp);
    return ((res % MOD) + MOD) % MOD;
}
 
ll f[N], invFact[N];
 
inline void prepare() {
    f[0] = 1;
    int n = 200000;
    for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i % MOD;
    invFact[n] = inv(f[n]);
    for (int i = n - 1; i >= 1; i--) invFact[i] = invFact[i + 1] * (i + 1) % MOD;
}
 
inline ll C(int n, int m) {
    if (!m) return 1;
    if (n == m) return 1;
    if (m > n) return 0;
    if (m < 0) return 0;
    return f[n] * invFact[m] % MOD * invFact[n - m] % MOD;
}
}

int n, m;
char map[55][55];
bool vis[55][55];

inline bool check(int x, int y) {
    if (x < 1 || x > n) return false;
    if (y < 1 || y > m) return false;
    return !vis[x][y] && map[x][y] == '#';
}

inline void bfs() {
    std::queue< Pair > q;
    q.push(mp(1, 1));
    vis[1][1] = true;
    while (!q.empty()) {
        int x = q.front().fi, y = q.front().se;
        q.pop();
        for (int i = 0; i < 2; i++) {
            int nx = x + dx[i], ny = y + dy[i];
            if (check(nx, ny)) {
                vis[nx][ny] = true;
                q.push(mp(nx, ny));
            }
        }
    }
}

int main() {
    cin >> n >> m;
    for (int i = 1; i <= n; i++) scanf("%s", map[i] + 1);
    int cnt = 0;
    for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) if (map[i][j] == '#') cnt++;
    puts(cnt == n + m - 1 ? "Possible" : "Impossible");
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace Project
{
	class MainClass
	{
		public static bool[,] dp;
		public static int n;
		public static int[] A;

		public static void Main(string[] args)
		{
			n = int.Parse(Console.ReadLine());
			A = new int[n];
			string[] s = Console.ReadLine().Split(' ');
			for (int i = 0; i < n; i++)
			{
				A[i] = int.Parse(s[i]);
			}
			int q = int.Parse(Console.ReadLine());
			int[] m = new int[q];
			s = Console.ReadLine().Split(' ');
			for (int i = 0; i < q; i++)
			{
				m[i] = int.Parse(s[i]);
			}
			foreach (int x in m)
			{
				dp = new bool[n + 1, x + 1];
				ope(x);
				Console.WriteLine(dp[0, x] ? "yes" : "no");
			}
		}

		public static void ope(int x)
		{
			for (int i = 0; i < n + 1; i++)
			{
				dp[i, 0] = true;
			}
			for (int i = n - 1; i >= 0; i--)
			{
				for (int j = 0; j < x + 1; j++)
				{
					dp[i, j] = dp[i + 1, j] || (j - A[i] < 0 ? false : dp[i + 1, j - A[i]]);
				}
			}
		}
	}
}

Measured memory_bytes: 9224
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

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

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

const int INF=5e8;


char S[5005],T[5005];
int n;

int distL[5005],distR[5005];

int distL2[5005];
int solve(){
  set<int> posi;
  int res=INF;
  REP(r,n) {
    REP(i, n) posi.insert(i);
    REP(i, n) distL[i] = distR[i] = distL2[i] = INF;
    REP(i, n) if (T[i] == '1') {
        int pos = (i + r) % n;
        distR[pos] = 0;
        distL2[pos] = 0;
        distL[i] = 0;
      }

    int lef = 0;
    REP(t, 3) for (int i = n - 1; i >= 0; --i) {
        chmin(distL[(i - 1 + n) % n], distL[i] + 1);
        chmin(distL2[(i - 1 + n) % n], distL2[i] + 1);
      }
    REP(t, 3) REP(i, n) chmin(distR[(i + 1) % n], distR[i] + 1);

    int cost = 0;
    vector<pi> br;
    REP(i, n) if (S[i] != T[(i + n - r) % n]) {
        if (distL2[i] < r) continue;
        br.pb({distL[i], distR[i]});
      }

    int prefmx[2005] = {0};
    sort(ALL(br));
    reverse(ALL(br));
    int m = br.size();
    REP(i, m) {
      prefmx[i + 1] = max(prefmx[i], br[i].sc);
    }

    int range=INF;
    br.pb({0,0});
    REP(i, m + 1) {
      chmin(range,br[i].fr+prefmx[i]);
    }
    REP(i,n) {
      if(T[i]!=S[(i+r)%n]) ++cost;
    }
    chmin(res,range*2+r+cost);
  }
  return res;
}
int main(){
#ifdef LOCAL_REDIR
  freopen("/home/hog/Dropbox/pg/working/in.txt","r",stdin);
#endif
  scanf("%s%s",S,T);
  n=strlen(S);

  bool exS=false,exT=false;
  REP(i,n){
    if(S[i]=='1') exS=true;
    if(T[i]=='1') exT=true;
  }
  if(!exT && exS){
    puts("-1");
    return 0;
  }
  if(!exT && !exS){
    puts("0");
    return 0;
  }

  int res=solve();
  reverse(S,S+n);
  reverse(T,T+n);
  chmin(res,solve());
  cout<<res<<endl;
  return 0;
}






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

int main()
{
	string s,t;
	cin >> s >> t;
	if(s==t.substr(0,t.size()-1))
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	
}

Measured memory_bytes: 3632
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef vector<int> vint;
typedef vector< vector<int> > vvint;
typedef vector<string> vstr;


int main(void) {
	long long int N,cou;
	cou = 0;
	cin >> N;
	vector<long long int> A(N);
	vector<long long int> sum(N);
	map<long long int, long long int> mp;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (i == 0)sum[i] = A[i];
		else sum[i] = sum[i - 1] + A[i];
}
	sum.push_back(0);
	for (int i = 0; i <= N; i++) {
		mp[sum[i]]++;
		cou+=mp[sum[i]]-1;
	}

	cout << cou << endl;
}


Measured memory_bytes: 15844
#include<iostream>
#include<vector>
#include<numeric>
using namespace std;
int main(){
  int n,ans=0;
  cin>>n;
  vector<int>a(n),b(n);
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++)cin>>b[i];  
  for(int i=0,A=a[i],B=accumulate(b.begin(),b.end(),0);i<n;A+=a[i+1],B-=b[i],i++)ans=max(ans,A+B);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int n; cin >> n;
  int cnt = 0;
  if (n >= 105)
    for (int i = 105; i <= n; i = i + 2)
    {
      int cd = 0;
      for (int j = 1; j <= i; j++)
        if (i % j == 0) cd++;
      if (cd == 8) cnt++;
    }
  cout << cnt << endl;
}

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

using namespace std;

#define li long long int
#define FOR(i,l,r) for( li i = l-(l>r); i != r-(l>r); i += 1-2*(l>r) )

int main() {
    li m,k; cin>>m>>k;
    li u = (1ll<<m)-1;
    if( k > u || ( k == 1 && m <= 1 ) ) {
        cout<<"-1\n";
        return 0;
    }
    if( k == 0 ) {
        FOR(i,0,u+1) cout<<i<<" "<<i<<" ";
        cout<<"\n";
        return 0;
    }
    int a = 1;
    if( k == 1 ) a++;
    cout<<0<<" "<<k<<" "<<0<<" "<<a<<" "<<(k^a);
    deque<li> q;
    q.push_back(k);
    FOR(i,0,u+1) {
        if( i != k && i != 0 && i != a && i != (k^a) ) {
            q.push_back(i);
            q.push_front(i);
        }
    }
    while( !q.empty() ) {
        cout<<" "<<q.front();
        q.pop_front();
    }
    cout<<" "<<(k^a)<<" "<<a<<"\n";
    return 0;
}

Measured memory_bytes: 3968
// CODE © by 𝕌𝕥𝕜𝕒𝕣𝕤𝕙 𝔾𝕒𝕣𝕘
// Copying or sharing of this code without permission of the Author is strictly prohibited!!!
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Speed ios::sync_with_stdio(0); cin.tie(0);
#define pb push_back
#define endl "\n"
double dp[3000][3000];
double f(double p[], int k, int n, int c) {
	// cout << "k " << k << " n " << n << endl;
	if (n < 0)return 0.0;
	if (n == 0 && k < c) {return 0.0;}
	if (n == 0 && k >= c) {return 1.0;}
	if (dp[n][k] != -1.0)return (double)dp[n][k];
	return dp[n][k] = (double)(f(p, k, n - 1, c) * (1.0 - p[n - 1]) + f(p, k + 1, n - 1, c) * p[n - 1]);
}
signed main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
#endif
	for (int i = 0; i < 3000; i++)for (int j = 0; j < 3000; j++)dp[i][j] = -1.0;
	int a = 0, b = 0, c = 0, d = 0, i = 0, j = 0, k = 0, t = 0, n = 0, q = 0;
	cin >> n;
	double p[n];
	for (i = 0; i < n; i++)cin >> p[i];
	// cout << n << endl;;
	cout << fixed << setprecision(10) << f(p, 0, n, n / 2 + 1);
}

Measured memory_bytes: 74356
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro nlet (name args &body body)
  (labels ((ensure-list (x) (if (listp x) x (list x))))
    (let ((args (mapcar #'ensure-list args)))
      `(labels ((,name ,(mapcar #'car args) ,@body))
         (,name ,@(mapcar #'cadr args))))))

(declaim (inline split-ints-into-vector))
(defun split-ints-into-vector (string dest-vector &key (offset 0) (key #'identity))
  (declare (string string)
           (function key)
           ((simple-array * (*)) dest-vector)
           ((integer 0 #.most-positive-fixnum) offset))
  (loop for idx from offset below (length dest-vector)
        for pos1 = 0 then (1+ pos2)
        for pos2 = (position #\space string :start pos1 :test #'char=)
        do (setf (aref dest-vector idx)
                 (funcall key (parse-integer string :start pos1 :end pos2)))
        finally (return dest-vector)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(defmacro println (obj &optional (stream '*standard-output*))
  `(let ((*read-default-float-format* 'double-float))
     (prog1 (princ ,obj ,stream) (terpri ,stream))))

(defconstant +mod+ 1000000007)

;; Hauptteil

(let ((num 0))
  (defun reset-num () (setf num 0)) 
  (defun solve (hs l r)
    (unless (= l r)
      (let ((min (reduce #'min hs :start l :end r)))
        (loop for i from l below r
              do (decf (aref hs i) min))
        (incf num min)
        (let ((base l))
          (loop while (< base r)
                do (loop for i from base below r
                         while (zerop (aref hs i))
                         do (setf base (1+ i)))
                   (loop for i from base below r
                         until (zerop (aref hs i))
                         finally (solve hs base i)
                                 (setf base i)))))
      num)))

(defun main ()
  (let* ((n (read))
         (hs (make-array n :element-type 'uint32)))
    (reset-num)
    (split-ints-into-vector (read-line) hs)
    (println (solve hs 0 n))))

#-swank(main)


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

int main(void){
  int x, a, b; cin >> x >> a >> b;
  int ans = a * 10 + b;
  if(ans % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio> 
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm> 
#include<set>
#define  endl '\n'
#define all(s) s.begin(),s.end()
#define lowbit(x) (x&-x)
#define fi first
#define se second 
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f; 
const int N=2e5+10;
int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	int n,m,q,k;
	int a[N];
	cin>>n>>m;
	int sum=0,num=0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		sum+=a[i];
	}	
	int sb=sum/(4*m);
	double mmp=sum/(double)(4*m);
	int f;
	if(mmp>sb) f=sb+1;
	else f=sb; 
	for(int i=1;i<=n;i++){
		if(a[i]>=f) num++;
	}
	if(num>=m) cout<<"Yes";
	else cout<<"No";
}

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

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

    vector<int> hs(N);
    for(int i = 0; i < N; ++i){
        cin >> hs[i];
    }
    sort(hs.begin(), hs.end());

    int ans = INT_MAX;
    for(int i = 0; i < N - (K - 1); ++i){
        int tmp = hs[i + K - 1] - hs[i];
        ans = min(ans, tmp);
    }
  
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 640
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
# fractions.gcd() を用いること
# math.log2()はatcoderでは対応していない．留意せよ．

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def find_gcd(list_l):
    x = reduce(gcd, list_l)
    return x


def main():
    S = set(list("abcdefghijklmnopqrstuvwxyz")) - set(list(input().strip())) 
    if len(list(S))!=0:
        print( sorted(list(S))[0] )
    else:
        print("None")
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 6484
#include<stdio.h>
int main(void){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if(a==b){
    if(b!=c){
      puts("Yes");
    }else{
      puts("No");
    }
  }else if(b==c){
    puts("Yes");
  }else if(a==c){
    puts("Yes");
  }else {
    puts("No");
  }
  return 0;
}


Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Scanner;

/**
 * Created 2017/06/01.
 */
  public class Main {
    public static void main(String[] args) {
      //??\?????¨?????????
      Scanner sc = new Scanner(System.in);
      ArrayList<Integer> ary = new ArrayList<>();

      while (true) {
        int input = Integer.parseInt(sc.next());
        ary.add(input);
        if (input == 0)break;
      }

      for(int i = 0; i < ary.size()-1; i++){
        System.out.println("Case " + (i+1) + ": " +ary.get(i));
      }

    }
  }

Measured memory_bytes: 42580
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<class T1, class T2>
istream &operator>>(istream &in, pair<T1, T2> &P){
	in >> P.first >> P.second;
	return in;
}
template<class T1, class T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &P){
	out << "(" << P.first << ", " << P.second << ")";
	return out;
}
template<class T>
istream &operator>>(istream &in, vector<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const vector<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
template<class T>
istream &operator>>(istream &in, deque<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const deque<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}

vector<int> idx[10];

int32_t main(){
	int n;
	string s;
	cin>>n>>s;
	rep(i,0,n){
		idx[s[i] - '0'].push_back(i);
	}
	long long ans = 0;
	for(char a = '0' ; a <= '9' ; a ++){
		for(char b = '0' ; b <= '9' ; b++){
			for(char c = '0' ; c <= '9' ; c++){
				if(idx[a-'0'].size() && idx[b-'0'].size() && idx[c-'0'].size()){
					int l = idx[a-'0'][0] , r = idx[c-'0'].back();
					if(l<r){
						auto u = upper_bound(idx[b-'0'].begin() , idx[b-'0'].end() , l);
						if(u != idx[b-'0'].end()){
							if(l < *u && *u < r){
								ans++;
							}
						}
					}
				}
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<tll> points;
    for(int i = 0; i < N; i++)
    {
        ll x, y, h;
        cin >> x >> y >> h;
        points.emplace_back(h, x, y);
    }
    sort(points.begin(), points.end(), greater<tll>());
    for(ll i = 0; i <= 100; i++)//x座標
    {
        for(ll j = 0; j <= 100; j++)//y座標
        {
            ll x, y, h;
            tie(h, x, y) = points.at(0);
            ll H = h + abs(x - i) + abs(y - j);
            bool isAnswer = true;
            for(int k = 0; k < N; k++)
            {
                ll curx, cury, curh;
                tie(curh, curx, cury) = points.at(k);
                if(max(H - abs(curx - i) - abs(cury - j), (ll)0) != curh)
                {
                    isAnswer = false;
                    break;
                }
            }
            if(isAnswer)
            {
                cout << i << " " << j << " " << H << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256