akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;


int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   
   long int n,m;
   cin>>n>>m;

   for(long int i = 0; i < m; i++){
    long int x;
    cin>>x;
    n -= x;

    if(n < 0)
      return cout<<"-1",0;
   }

   cout<<n;
   return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

int main() {
  ll n;
  cin >> n;
  ll anser = (n * (n - 1)) / 2;
  cout << anser << endl;
  return 0;
}


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

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)

const int mod = 998244353, g = 3, mxn = 1 << 17;

int qp(int x, int n) {
	int ans = 1;
	for (; n; n >>= 1, x = 1LL * x * x % mod)
		if (n & 1) ans = 1LL * ans * x % mod;
	return ans;
}

inline int inv(int x) { return qp(x, mod - 2); }

void FFT(vector <int>& a, bool flag = 0) {
	static int r[mxn];
	int n = a.size(), k = __builtin_ctz(n);
	for (int i = 1; i < n - 1; ++ i) {
		r[i] = (r[i >> 1] >> 1) | (i & 1) << (k - 1);
		if (i < r[i]) swap(a[i], a[r[i]]);
	}
	for (int h = 2; h <= n; h <<= 1) {
		int w = qp(g, (mod - 1) / h);
		for (int i = 0; i < n; i += h) {
			int wn = 1;
			rep(j, h >> 1) {
				int u = a[i + j], v = 1LL * a[i + j + (h >> 1)] * wn % mod;
				a[i + j] = (u + v) % mod;
				a[i + j + (h >> 1)] = (u + mod - v) % mod;
				wn = 1LL * wn * w % mod;
			}
		}
	}
	if (flag) {
		reverse(a.begin() + 1, a.end());
		int in = inv(n);
		rep(i, n) a[i] = 1LL * a[i] * in % mod;
	}
}

struct poly : vector <int> {
	poly(int n) { clear(); resize(n, 0); }
	poly operator* (const poly& rhs) const {
		int sz = 1, n = size() + rhs.size() - 1;
		while (sz < n) sz <<= 1;
		vector <int> A(sz), B(sz), C(sz);
		rep(i, size()) A[i] = at(i);
		rep(i, rhs.size()) B[i] = rhs.at(i);
		FFT(A); FFT(B);
		rep(i, sz) C[i] = 1LL * A[i] * B[i] % mod;
		FFT(C, 1);
		poly ans(n);
		rep(i, ans.size()) ans[i] = C[i];
		return ans;
	}
};

int fac[mxn], ifac[mxn], ways[mxn];

struct __INIT {
	__INIT() {
		rep(i, mxn) ways[i] = i ? 1LL * (i * 2 - 1) * ways[i - 1] % mod : 1;
		rep(i, mxn) fac[i] = i ? 1LL * i * fac[i - 1] % mod : 1;
		ifac[mxn - 1] = inv(fac[mxn - 1]);
		for (int i = mxn - 1; i; -- i) ifac[i - 1] = 1LL * i * ifac[i] % mod;
	}
} __init;

int comb(int n, int m) {
	if (m < 0 || m > n) return 0;
	return 1LL * fac[n] * ifac[m] % mod * ifac[n - m] % mod;
}

vector <int> solve(const vector <int>& a) {
	priority_queue <pair <int, poly> > pq;
	rep(i, a.size()) {
		poly p(a[i] / 2 + 1);
		rep(j, a[i] / 2 + 1)
			p[j] = 1LL * comb(a[i], j * 2) * ways[j] % mod;
		pq.push(mp(-a[i], p));
	}
	while (pq.size() > 1) {
		pair <int, poly> p = pq.top(); pq.pop();
		pair <int, poly> q = pq.top(); pq.pop();
		int nw = p.first + q.first;
		poly po = p.second * q.second;
		pq.push(mp(nw, po));
	}
	return pq.top().second;
}

int main() {
	int n;
	scanf("%d", &n);
	vector <int> cnt(mxn);
	rep(i, n * 2) {
		int a;
		scanf("%d", &a);
		cnt[a] ++;
	}
	vector <int> a;
	rep(i, cnt.size()) if (cnt[i]) a.pb(cnt[i]);
	vector <int> po = solve(a);
	int ans = 0;
	rep(i, po.size()) {
		int cur = po[i];
		cur = 1LL * cur * ways[n - i] % mod;
		// cerr << i << " " << cur << endl;
		if (i & 1) ans = (ans + mod - cur) % mod;
		else ans = (ans + cur) % mod;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 11940
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds; 
using ll = long long int;
#define INF             1e14
#define dd              double
#define MOD             1000000007
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define nl              cout<<endl
#define fill(a,val)     memset(a,val,sizeof(a))
#define mp              make_pair
#define endl            "\n"
#define pb              push_back
#define ff              first    
#define ss              second
#define SIZE            200005
#define all(v)          v.begin(),v.end()
#define s(ar,n)         sort(ar,ar+n)
#define rs(ar,n)        sort(ar, ar+n, greater<ll>()) 
#define oa(a,n)         for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n)         for(ll i=0;i<n;i++)cin>>a[i];
#define maxa(ar,N)      *max_element(ar,ar+N)
#define mina(ar,N)      *min_element(ar,ar+N)
#define fastio()        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define printclock      cerr<<"Time : "<<1000*(long double)clock()/(long double)CLOCKS_PER_SEC<<"ms\n";
typedef tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order() - 0 indexing
// order_of_key() - number of elements strictly smaller
ll power(ll x, ll y){
    ll res=1;x=x;
    while(y>0){
        if(y&1)
            res = (res*x);
        y = y>>1;
        x = (x*x);
    }
    return res;
}  
ll logtwo(ll n){
    if(n==1)
        return 0;
    return logtwo(n/2)+1;
}
//---------------------------------------GL HF------------------------------------------------------
// -------------------------------------ManavJ07----------------------------------------------------
signed main()
{
    fastio();   
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll N,D;
        cin>>N>>D;
        D*=D;
        ll x,y,count=0;
        for(int i=0;i<N;i++){
            cin>>x>>y;
            if(x*x+y*y<=D)
                count++;
        }
        cout<<count<<endl;
    }
}

Measured memory_bytes: 3612
S = input()
n = 0
if S[0] =='+':
    n += 1
else:
    n -=1
if S[1] =='+':
    n += 1
else:
    n -=1
if S[2] =='+':
    n += 1
else:
    n -=1
if S[3] =='+':
    n += 1
else:
    n -=1
print(n)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
int main() {
	long long num; std::cin >> num;
	std::vector<long long>v(num + 1, 0);
	for (long long x = 1; x <= num; x++) {
		v[x]++;
		for (long long z = x * 2; z <= num; z += x) {
			v[z]++;
		}
	}
	long long ans = 0;
	for (long long x = 1; x <= num; x++) {
		ans += (1LL * x * v[x]);
	}

	std::cout << ans;
}


Measured memory_bytes: 81380
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAXN int(1e5)
int n,tot;
int poi[MAXN+5];
int main()
{
    //freopen("in.txt","r",stdin);
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&poi[i]),tot+=abs(poi[i-1]-poi[i]);
    tot+=abs(poi[n]);
    for(int i=1;i<=n;i++)
    {
        int ans=tot;
        if(i==n)
            ans=ans-abs(poi[n])-abs(poi[n-1]-poi[n])+abs(poi[n-1]);
        else
            ans=ans-abs(poi[i-1]-poi[i])-abs(poi[i]-poi[i+1])+abs(poi[i-1]-poi[i+1]);
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 1536
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)(305)
#define mod (ll)(1e9+7)
#define mod1 (ll)(998244353)
#define ll long long
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
ld d[mxn][mxn][mxn];int c[4];
int main(){
	int n,i,j,k;cin>>n;for(i=0;i<n;i++) cin>>j,c[j]++;
	for(k=0;k<mxn;k++){
		for(j=0;j<mxn;j++){
			for(i=0;i<mxn;i++){
				if(!(i+j+k)||i+j+k>n) continue;
				ld p0=1.0*n/(i+j+k);
				ld p1=(1.0*i/(i+j+k));
				ld p2=(1.0*j/(i+j+k));
				ld p3=(1.0*k/(i+j+k));
				if(i) d[i][j][k]+=d[i-1][j][k]*p1;
				if(j) d[i][j][k]+=d[i+1][j-1][k]*p2;
				if(k) d[i][j][k]+=d[i][j+1][k-1]*p3;
				d[i][j][k]+=p0;
			}
		}
	}printf("%.10Lf\n",d[c[1]][c[2]][c[3]]);
}


Measured memory_bytes: 436480
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    long long a,b,c;
    cin>>a>>b>>c;
    if(a%2 == 0 || b%2 == 0 || c%2 == 0){
        cout<<0;
    }else {
        cout<<min(a*b,min(b*c,c*a));
    }
}

Measured memory_bytes: 256
n = int(input())
p = [int(i) for i in input().split()]
ans = 0

for i in range(1,n-1):
    if((p[i-1] < p[i] and p[i] < p[i+1]) or (p[i-1] > p[i] and p[i] > p[i+1])):
        ans += 1

print(ans)

Measured memory_bytes: 9048
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	string s;
	cin >> s;
	
	int n = s.size();
	int ans = MOD;
	for(int i = 0; i < n - 2; ++i) {
		int x = 100 * (s[i] - '0') + 10 * (s[i + 1] - '0') + (s[i + 2] - '0');
		
		ans = min(ans, abs(753 - x));
	}
	
	cout << ans << endl;
	
	return 0;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<bool> safe(n, true);
    rep(i, m) {
        int a;
        cin >> a;
        safe[a] = false;
    }

    vector<ll> dp(n + 1, 0);
    dp[0] = 1;
    dp[1] = safe[1] ? 1 : 0;
    rep(i, n + 1) {
        if (i == 0 || i == 1) continue;
        if (safe[i]) dp[i] = (dp[i - 1] + dp[i - 2]) % MOD;
    }
    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

void sort(int *a,int n)
{
        int i,j,min,index;
        for(i=0;i<n;i++){
                min=a[i];index=i;
                for(j=i+1;j<n;j++){
                        if(min>a[j]){
                                min=a[j];
                                index=j;
                        }
                        a[index]=a[i];a[i]=min;
                }
        }
                return ;
}
int main(void)
{
        int n,x,s=0,c=0,i;
        scanf("%d%d",&n,&x);
        int m[n];
        for(i=0;i<n;i++){
                scanf("%d",&m[i]);
                s+=m[i];
        }

        c=x-s;
        if(c<m[0])printf("%d\n",n);
        else {
                sort(m,n);
                n=n+(c/m[0]);
                printf("%d\n",n);
        }
        return 0;
}


Measured memory_bytes: 1680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
using Graph=vector<vector<int>>;
const ll INF=1000000000;

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

int V;
Graph G(200);
vector<int> color(200,0);

bool BipartiteGraph (int v,int c){
    color[v]=c;
    rep(i,G[v].size()){
        if (color[G[v][i]]==c){
            return false;
        }
        else if (color[G[v][i]]==0&&!BipartiteGraph(G[v][i],-c)){
            return false;
        }
    }
    return true;
}

int ans=0;
vector<vector<int>> d(200,vector<int>(200,INF));
void WarshallFloyd(){
    rep(k,V){
        rep(i,V){
            rep(j,V){
                chmin(d[i][j],d[i][k]+d[k][j]);
                if (k==V-1){
                    chmax(ans,d[i][j]);
                }
            }
        }
    }
}

int main(){
    cin >> V;
    rep(i,V){
        rep(j,V){
            char x;
            cin >> x;
            if (i==j){
                d[i][j]=0;
            }
            if (x=='1'){
                G[i].push_back(j);
                d[i][j]=1;
            }
        }
    }
    WarshallFloyd();
    ans+=1;
    if (!(BipartiteGraph(0,1))){
        ans=-1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
  int i,j,k;
  int n;
  while(cin>>n&&n){
    int a[2][502][502],w[2],h[2],sx[2],sy[2];
    memset(a,-1,sizeof(a));
    for(i=0;i<2;i++){
      cin>>w[i]>>h[i]>>sx[i]>>sy[i];
      for(j=1;j<h[i]+1;j++)
	for(k=1;k<w[i]+1;k++)
	  cin>>a[i][k][j];
    }
    vector<pair<int,int> > b[2];
    for(i=0;i<2;i++){
      b[i].reserve(w[i]*h[i]);
      b[i].push_back(make_pair(0,0));
      priority_queue<pair<int,pair<int,int> >,deque<pair<int,pair<int,int> > >,greater<pair<int,pair<int,int> > > > c;
      c.push(make_pair(1,make_pair(sx[i],sy[i])));
      while(c.empty()==0){
	int p,x,y;
	p=c.top().first;
	x=c.top().second.first;
	y=c.top().second.second;
	c.pop();
	if(a[i][x][y]!=-1){
	  a[i][x][y]=-1;
	  if(b[i].back().first==p){
	    b[i].back().second++;
	  }else{
	    b[i].push_back(make_pair(p,b[i].back().second+1));
	  }
	  if(a[i][x+1][y]!=-1)
	    c.push(make_pair(max(p,a[i][x+1][y]),make_pair(x+1,y)));
	  if(a[i][x-1][y]!=-1)
	    c.push(make_pair(max(p,a[i][x-1][y]),make_pair(x-1,y)));
	  if(a[i][x][y+1]!=-1)
	    c.push(make_pair(max(p,a[i][x][y+1]),make_pair(x,y+1)));
	  if(a[i][x][y-1]!=-1)
	    c.push(make_pair(max(p,a[i][x][y-1]),make_pair(x,y-1)));  
	}
      }
    }
    int sm=200000000;
    for(i=0;i<(int)b[0].size()&&b[0][i].second+b[1][(int)b[1].size()-1].second<n;i++);
    for(;i<(int)b[0].size()&&b[0][i].second<n;i++){
      int mn=1,mx=b[1].size()-1;
      for(;;){
	if(0){
	}else if(b[1][(mn+mx)/2-1].second>=n-b[0][i].second){
	  mx=(mn+mx)/2-1;
	}else if(b[1][(mn+mx)/2].second<n-b[0][i].second){
	  mn=(mn+mx)/2+1;
	}else{
	  break;
	}
      }
      sm=min(sm,b[0][i].first+b[1][(mn+mx)/2].first);
    }
    if(i<(int)b[0].size())
      sm=min(sm,b[0][i].first);
    cout<<sm<<endl;
  }
  return 0;
}

Measured memory_bytes: 5140
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
const int N=303;
short dp[N][N][N];
int32_t main(){
    string s;int k;
    cin>>s>>k;
    int n=sz(s);
    string t=s+"#";
    reverse(t.begin(), t.end());
    s="#"+s;
    for(int i=1;i<=n;++i){
        for(int j=1;j<=n;++j){
            for(int c=0;c<=k;++c){
                dp[i][j][c]=max(dp[i-1][j][c],dp[i][j-1][c]);
                if(s[i]==t[j])upx(dp[i][j][c],dp[i-1][j-1][c]+1);
                else if(c)upx(dp[i][j][c],dp[i-1][j-1][c-1]+1);
            }
        }
    }
    int ans=0;
    for(int i=1;i<=n;++i){
        int j=n-i+1;
        upx(ans,1+2*dp[i-1][j-1][k]);
        upx(ans,2*dp[i][j-1][k]);
    }
    cout<<ans<<'\n';
    return 0;
}

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

map <char,int> ABC;

int main(){
	string s;
	string sol="Yes";
	cin >> s;
	for (int i = 0; i < s.length(); ++i)
	{
		ABC[s[i]]++;
	}
	for (int i = 0; i < s.length(); ++i)
	{
		if (ABC[s[i]]%2==1){
			sol="No";
			break;
		}
	}
	cout << sol;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N= 2e5 + 5;
const ll MOD=1e9 + 7;
ll ans[305][305],r,c,k;
void chk1(ll clr,ll row,ll l,ll r){
    if(row<0)return;
    for(ll i=l;i<=r;i++)if(ans[row][i]!=0)return;
    for(ll i=l;i<=r;i++)ans[row][i]=clr;
    chk1(clr,row-1,l,r);
}
void chk2(ll clr,ll row,ll l,ll _r){
    if(row>=r)return ;
    for(ll i=l;i<=_r;i++)if(ans[row][i]!=0)return;
    for(ll i=l;i<=_r;i++)ans[row][i]=clr;
    chk2(clr,row+1,l,_r);
}

bool cmp(pair< pair<ll,ll> , pair<ll,ll> > a , pair< pair<ll,ll> , pair<ll,ll> >  b){
    ll v1 = a.second.second - a.second.first;
    ll v2 = b.second.second - b.second.first;
    return v1>v2;
}
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    cin>>r>>c>>k;
    char arr[r][c];
    for(ll i=0;i<r;i++)cin>>arr[i];
    vector<ll> row[r];
    for(ll i=0;i<r;i++)for(ll j=0;j<c;j++)if(arr[i][j]=='#')row[i].push_back(j);
    ll idx = 1;

    map<ll , vector< pair<ll,ll> > >store;
    for(ll i=0;i<r;i++){
        if(row[i].size()==0)continue;

        ll s = 0;
        for(ll j=0;j<row[i].size()-1;j++){
            for(ll l=s;l<=row[i][j];l++)ans[i][l]=idx;
            store[i].push_back(make_pair(s,row[i][j]));
            idx++;
            s=row[i][j]+1;
        }
        for(ll j=s;j<c;j++)ans[i][j]=idx;
        store[i].push_back( make_pair(s,c-1) );
        idx++;
    }

  /*  for(ll i=0;i<r;i++){
        for(ll j=0;j<c;j++){
            cout<<ans[i][j]<<" ";
        }
        cout<<"\n";
    }*/

    bool up=false;
    for(ll i=0;i<r;i++){
        if(store[i].size()==0)continue;
        for(ll j=0;j<store[i].size();j++)chk2(ans[i][store[i][j].first],i+1,store[i][j].first,store[i][j].second);
        //if(up)continue;
        for(ll j=0;j<store[i].size();j++)chk1(ans[i][store[i][j].first],i-1,store[i][j].first,store[i][j].second);
       // up=1;
    }

    for(ll i=0;i<r;i++){
        for(ll j=0;j<c;j++){
            cout<<ans[i][j]<<" ";
        }
        cout<<"\n";
    }


}



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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if(A + B > C + D){
    cout << "Left" << endl;
  }
  if(A + B == C + D){
    cout << "Balanced" << endl;
  }
  if(A + B < C + D){
    cout << "Right" << endl;
  }
  
}

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

using namespace std;

int main(void)
{
	int n;
	cin >> n;

	string s;
	
	bool result = false;

	for (int i = 0; i < n; i++)
	{
		cin >> s;
		if (s[0] == 'Y')
			result = true;
	}

	if (result)
		cout << "Four" << endl;
	else
		cout << "Three" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int m1,m2,d1,d2;

  scanf("%d %d",&m1,&d1);
  scanf("%d %d",&m2,&d2);
//  printf("flag1\n");
  if(d2-d1==1)printf("0\n");
  else printf("1\n");

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main()
{
	long long a,b,c;
	cin>>a>>b>>c;
	long long k=c;
	if (a<b)  swap(a,b);
	if (a<c)  swap(a,c);
	if (b<c)  swap(b,c);
	if (b==k)  cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int x, y, z, n;
  char a, b;
  scanf("%4d %c %1d %1d %c %2d", &x, &a, &y, &n, &b, &z);
  if(x<2019){
    printf("Heisei\n");
  }else if(x==2019 && y==0 && n<=4 ){
  printf("Heisei\n");
  }else{
  printf("TBD\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; ++i){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    int A = 0, B = 0;
    for (int i = 0; i < N; ++i){
        if(i%2!=1){
            A += a[i];
        }
        else {
            B += a[i];
        }
    }
    cout << A - B << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  char A,B;
  cin >> A >> B;
  
  if (A == 'H'){
    cout << B << endl;
  }
  else if (B == 'H'){
    cout << 'D' << endl;
  }
  else {
    cout << 'H' << endl;
  }
}
  

Measured memory_bytes: 3576
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const int N = 1e5 + 5;
ll n, m, ans, a[N], acc[N];
ll sum(int l, int r){
    if(l > r) return 0;
    if(!l) return acc[r];
    return acc[r] - acc[l - 1];
}
int between(int s, int e){
    auto l = lower_bound(a, a + n, s) - a;
    auto r = upper_bound(a, a + n, e) - a;
    if(a[0] > e || a[n - 1] < s) return 0;
    return r - l;
}
bool ok(int mid){
    ll res = 0;
    for(int i = 0; i < n; i++){
        if(a[i] >= mid) res += n;
        else res += between(mid - a[i], 2 * N);
    }
    return res >= m;
}
int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> m;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a + n);
    for(int i = 0; i < n; i++)
        acc[i] = a[i] + (i? acc[i - 1] : 0);
    ll s = 0, e = 2e5, mid, res = 2;
    while(s <= e){
        mid = s + e >> 1;
        if(ok(mid))
            s = mid + 1, res = mid;
        else
            e = mid - 1;
    }
    res++;
    for(int i = 0; i < n; i++){
        if(a[i] >= res)
            ans += n * a[i] + acc[n - 1], m -= n;
        else{
            auto l = lower_bound(a, a + n, res - a[i]) - a;
            auto r = upper_bound(a, a + n, 2 * N) - a;
            r--;
            if(l > r) continue;
            ans += a[i] * (r - l + 1) + sum(l, r);
            m -= r - l + 1;
        }
    }
    res--;
    cout << ans + m * res;
    return 0;
}


Measured memory_bytes: 5152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    string s;
    cin >> s;
    deque<char> dq;
    rep(i, s.size()){
        if (s[i] == 'B'){
            if (dq.size() != 0) dq.pop_back();
        }else{
            dq.push_back(s[i]);
        }
    }
    string ans = "";
    while(!dq.empty()){
        ans += dq.front();
        dq.pop_front();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
program test;
{$mode objfpc}{$H+}{$R+}{$S+}
Uses sysutils,math;
var
	N	        :integer;
	a,b,ans     :integer;
begin
    readln(N);
    ans:=0;
    for a:=1 to N do
    begin
        for b:=1 to (N div a) do
        begin
            if ((a*b)<N) then inc(ans);
        end;
    end;

    writeln(stdout,ans);
end.

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

int main() {
    int N, K, R, S, P;
    string T;
    cin >> N >> K >> R >> S >> P >> T;
    
    long long ans = 0;
    for (int k = 0; k < K; k++) {
        bool last = false;
        for (int i = k; i < N; i+=K) {
            if (i >= K && T[i-K] == T[i] && last) last = false;
            else {
                if (T[i] == 'r') ans += P;
                else if (T[i] == 's') ans += R;
                else ans += S;
                last = true;
            }
        }
    }
    cout << ans << endl;
}

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

int main()
{
    string S;

    cin >> S;

    string l = S.substr(0, 2);
    string r = S.substr(2, 2);

    bool isYYMM = false;
    bool isMMYY = false;
    // l = YY

    int yy = stoi(l);
    int mm = stoi(r);
    if (0 < mm && mm <= 12)
    {
        isYYMM = true;
    }

    // l = MM
    yy = stoi(r);
    mm = stoi(l);
    if (0 < mm && mm <= 12)
    {
        isMMYY = true;
    }

    if (!isYYMM && !isMMYY)
    {
        cout << "NA" << endl;
    }

    if (isYYMM && !isMMYY)
    {
        cout << "YYMM" << endl;
    }
    if (!isYYMM && isMMYY)
    {
        cout << "MMYY" << endl;
    }
    if (isYYMM && isMMYY)
    {
        cout << "AMBIGUOUS" << endl;
    }

    return 0;
}


Measured memory_bytes: 3556
#include<iostream>
#include<string>
#include <math.h>
#include<stack>/*** LIFO *** stack<type> var;
push(), top():to get data, pop():to remove, size(), empty() ***/
using namespace std;

#define Fp(I, STAT, END) for(int I = STAT; I < END; I++)
#define Fm(I, STAT, END) for(int I = STAT; I > END; I--)

int main(){
    int N, D;
    cin >> N >> D;
    int X[N][D];
    Fp(i, 0, N){
        Fp(j, 0, D) cin >> X[i][j];
    }
    int num = 0;
    Fp(i, 0, N - 1){
        Fp(j, i + 1, N){
            double ans = 0;
            Fp(k, 0, D){
                ans += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
            }
            ans = sqrt(ans);
            if((double)(int)ans == ans) num++;
        }
    }
    cout << num << endl;
}

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

using namespace std;

int N ;
vector<int> A;
int main() {
    cin >> N ;
    for (int i = 0; i < N; ++i) {
        int b;
        cin >> b;
        A.push_back(b);
    }
    sort(A.begin(), A.end());
    cout << A.at(N-1) - A.at(0) << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
 
#include<bits/stdc++.h>
 
using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define repi(i,a) for(auto i = a.begin(); i!= a.end() ;++i) 
#define repdi(i,a) for(auto i = a.rbegin(); i!=a.rend();++i) 
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define INF 1e18
#define sz(a) (int)a.size() 
#define all(a) a.begin(),a.end()
#define mod 998244353
#define limit 1000
#define fl(a,x) memset(a,x,sizeof(a));
#define pt(a,x) cout << get<x>(a) << " " ;   

typedef vector<int> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef vector<vector<int> > vv;
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int n;
double dp[3000][3000];
double a[3000];

double ans(int head, int tail, int i) {
	if(i==n+1) {
		if(head > tail) return 1.0;
		return 0.0;
	}
	if(dp[head][tail]!=-1.0) return dp[head][tail] ;
	return dp[head][tail] = (a[i] * ans(head+1,tail,i+1) + (1.0-a[i]) * ans(head,tail+1,i+1));
}

void solve() {
	cin >> n;
	rep(i,0,3000) rep(j,0,3000) dp[i][j] = -1.0;
	rep(i,1,n+1) {
		// float t; cin >> t;
		// a[i] = (int) 100*t;
		cin >> a[i] ;
	}
	// rep(i,1,n+1) cout << a[i] << " ";
	printf("%.10f", ans(0,0,1));
}

int32_t main() {

    fast; 
	int t=1;
	// cin>>t;
	rep(i,0,t) {
		solve() ;
	}

	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 70912
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		if (a - b >= 0)
			System.out.println("delicious");
		else if (Math.abs(a - b) <= x)
			System.out.println("safe");
		else
			System.out.println("dangerous");
		sc.close();
	}
}

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

int main() {
  string s[3];
  cin >> s[0] >> s[1] >> s[2];
  const char* p[] {s[0].c_str(), s[1].c_str(), s[2].c_str()};
  int i = 0;
  while (true) {
    const char c = *p[i]++;
    if (!c) {
      cout << "ABC"[i] << "\n";
      return 0;
    }
    i = c - 'a';
  }

  return 0;
}


Measured memory_bytes: 256
N = int(input())

n = [0] * (N+1)
for i in range(N+1):
    if i == 0:
        n[i] = 2
    elif i == 1:
        n[i] = 1
    else:
        n[i] = n[i-1] + n[i-2]

print(n[N])


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
string s;
int l;
bool ans=true;
signed main(){
    cin>>s;
    l=s.size();
    s+="-----------------------";
    if(l<5){
        puts("NO");
        return 0;
    }
    rep(i,l){
        if(s.substr(i,11)=="dreameraser")i+=10;
        else if(s.substr(i,10)=="dreamerase")i+=9;
        else if(s.substr(i,7)=="dreamer")i+=6;
        else if(s.substr(i,6)=="eraser")i+=5;
        else if(s.substr(i,5)=="erase")i+=4;
        else if(s.substr(i,5)=="dream")i+=4;
        else ans=false;
    }
    if(ans)puts("YES");
    else puts("NO");
    return 0;
}

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

n = int(input())
s = list(input())
w = [0] * n
e = [0] * n

cntw = 0
cnte = 0
for i in range(n):
    if s[i] == "W":
        cntw += 1
        w[i] = cntw
    else:
        w[i] = cntw
    if s[i] == "E":
        cnte += 1
        e[i] = cnte
    else:
        e[i] = cnte

ans = float("inf")

for i in range(n):
    num = 0
    if i-1 >= 0:
        num += w[i-1]
    num += e[-1] - e[i]
    ans = min(num,ans)

print(ans)


Measured memory_bytes: 21624
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int X = sc.nextInt();
      int T = sc.nextInt();
      if(N%X==0){
        System.out.println(N/X*T);
      }else{
        System.out.println((N/X+1)*T);
      }
    }
}

Measured memory_bytes: 35848
#include <stdio.h>

int main(){
	int L,R,d,i;
  	int count=0;
    scanf("%d",&L);
  	scanf(" %d",&R);
  	scanf(" %d",&d);
  	for(i=L;i<=R;i++){
    	if(i%d==0){
        	count++;
        }
    }
  	printf("%d\n",count);
  	return 0;
}

Measured memory_bytes: 1696
#include <cstdio>
using namespace std;
// 00010111.1000

int main(){
    double d;
    while(scanf("%lf",&d), d>=0){
        d*=16;
        int id = d;
        if(d-id!=0 || d>0xFFF) puts("NA");
        else {
            for(int i=0;i<12;i++){
                putchar(id&1<<(11-i) ? '1' : '0');
                if(i==7)putchar('.');
            }
            putchar('\n');
        }
    }
}

Measured memory_bytes: 1040
// ref. https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

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

fn main() {
    input!{
        n: usize,
        d: [i32; n],
    }

    let mut sum = 0;
    for i in 0..n-1{
        for j in i+1..n{
            sum += d[i] * d[j];
        }
    }

    println!("{}", sum)
}


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

vector< ll > q;
vector< ll > a;
int x, y;

void dfs(int v, int c = -1, int p = -1) {
    if (q[v] != -1) {
        x = v;
        y = p;
        return;
    }
    q[v] = c + 1;
    dfs(a[v], c + 1, v);
}

int main() {
    int n;
    cin >> n;
    ll k;
    cin >> k;
    q.resize(n, -1);
    a.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
    }
    dfs(0);
    if (q[x] >= k) {
        for (int i = 0; i < n; i++) {
            if (q[i] == k) {
                cout << i + 1 << endl;
                return 0;
            }
        }
    }
    else {
        k -= q[x];
        k %= q[y] - q[x] + 1;
        for (int i = 0; i < n; i++) {
            if (q[i] - q[x] == k) {
                cout << i + 1 << endl;
                return 0;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 6400
#include<cstdio>
#include<cmath>
using ll = long long;
constexpr ll p=1e9+7;
//sqrt(1e9)==31622.77...
//dp[i][0][j]=長さiの正整数列で、i番目の数がjであるようなものの個数 (j<=sqrt(n))
//dp[i][1][j]=長さiの正整数列で、(i番目の数)*j<=n,(i番目の数)*(j+1)>nであるようなものの個数 (j<=sqrt(n))
//dp[i+1][0][j]=sum_{l<=j}dp[i][1][l]+sum_l dp[i][0][l]
//dp[i+1][1][j]=(sum_{l<=j}dp[i][0][l])*dp[1][1][j]
//累積和をとると更新を1個当たりO(1)でできる
ll dp[101][2][31624];
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    int sqrtn=static_cast<int>(std::sqrt(n));
    for(int j=1;j<=sqrtn;j++){
        dp[1][0][j]=1;
        dp[1][1][j]=n/j-n/(j+1);
    }
    //もしsqrtnがdp[1][1][sqrtn]でカウントされていたら、dp[1][0][sqrtn]ではカウントしない
    if(sqrtn*(sqrtn+1)>n)dp[1][1][sqrtn]=0;
    for(int i=1;i<k;i++){
        ll psum=0;
        for(int j=1;j<=sqrtn;j++){
            psum+=dp[i][0][j];
            psum%=p;
            dp[i+1][1][j]=psum*dp[1][1][j]%p;
            //printf("%lld ",dp[i+1][1][j]);
        }
        //printf(": ");
        for(int j=sqrtn;j>=1;j--){
            psum+=dp[i][1][j];
            psum%=p;
            dp[i+1][0][j]=psum;
            //printf("%lld ",dp[i+1][0][j]);
        }
        //printf("\n");
    }
    ll ans=0;
    for(int j=1;j<=sqrtn;j++){
        ans+=dp[k][0][j]+dp[k][1][j];
        ans%=p;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 49536
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int A = sc.nextInt();
	int B = sc.nextInt();
	int C = sc.nextInt();
	int K = sc.nextInt();
	int count=0;

	if(K>=A){
	    count = A;
	    K -= A;
	}else{
	    count = K;
	    K = 0;
	}
	if(K>0){
	    if(K>=B){
		K -= B;
	    }else{
		K = 0;
	    }
	}
	if(K>0){
	    count -= K;
	}
	System.out.print(count);
    }
}


Measured memory_bytes: 35776
use std::io;
use std::str::FromStr;
use std::cmp::min;

fn input_tuple() -> (i32, i32, i32, i32) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<i32> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1], vec[2], vec[3])
}

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn dfs(idx: usize, l_vec: &Vec<i32>, a: i32, b: i32, c: i32, _a: i32, _b: i32, _c: i32) -> i32 {
    if idx == l_vec.len() {
        if _a == 0 || _b == 0 || _c == 0 {
            return 1000000;
        }
        let mp = (a - _a).abs() + (b - _b).abs() + (c - _c).abs();        
        // if mp < 150 {
        //     println!("mp = {}: {}, {}, {}", mp, _a, _b, _c);
        // }
        return mp;
    }
    let val1 = dfs(idx+1, l_vec, a, b, c, _a + l_vec[idx], _b, _c) + 10;
    let val2 = dfs(idx+1, l_vec, a, b, c, _a, _b + l_vec[idx], _c) + 10;
    let val3 = dfs(idx+1, l_vec, a, b, c, _a, _b, _c + l_vec[idx]) + 10;
    let val4 = dfs(idx+1, l_vec, a, b, c, _a, _b, _c);
    return min(min(val1, val2), min(val3, val4));
}

fn main() {
    let (n, a, b, c) = input_tuple();
    let mut l_vec: Vec<i32> = Vec::new();
    for _ in 0..n {
        let l: i32 = input();
        l_vec.push(l);
    }
    println!("{}", dfs(0, &l_vec, a, b, c, 0, 0, 0) - 30);
}


Measured memory_bytes: 2160
n, m, x = map(int, input().split())

costs = []
a = []
ans = 10 ** 9

for i in range(n):
    c, *j = map(int, input().split())
    costs.append(c)
    a.append(j)

for y in range(2 ** n):
    total = 0
    b = [0] * m
    bi = '{:b}'.format(y).zfill(n)
    for i in range(n):
        if bi[i] == '1':
            total += costs[i]
            r = a[i]
            for j in range(m):
                b[j] += r[j]
    if all([k >= x for k in b]):
        ans = min(ans, total)

if ans == 10 ** 9:
    ans = -1
print(ans)


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

#include <boost/range/adaptors.hpp>
#include <boost/range/combine.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n;
    cin >> n;

    vector<pair<int64_t, int64_t>> pos;
    for (auto i : irange(0L, n)) {
        int64_t a;
        cin >> a;
        pos.emplace_back(a, 1);
    }
    for (auto i : irange(0L, n)) {
        int64_t b;
        cin >> b;
        pos.emplace_back(b, -1);
    }

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

    constexpr auto M = 1000000007L;

    int64_t ans = 1, c = 0;
    for (const auto& p : pos) {
        if (c * p.second < 0) {
            ans *= abs(c);
            ans %= M;
        }
        c += p.second;
    }

    cout << ans << endl;
}

Measured memory_bytes: 6256
#include "bits/stdc++.h"
 
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<VVLL> VVVLL;

#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FORL(i,a,b) for(LL i=(a);i<(b);++i)
#define REPL(i,n)  FORL(i,0,n)
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
   /* Credits: Thomas Draper */
   if ((first == last) || (first == k) || (last == k))
      return false;
   Iterator itr1 = first;
   Iterator itr2 = last;
   ++itr1;
   if (last == itr1)
      return false;
   itr1 = last;
   --itr1;
   itr1 = k;
   --itr2;
   while (first != itr1)
   {
      if (*--itr1 < *itr2)
      {
         Iterator j = k;
         while (!(*itr1 < *j)) ++j;
         iter_swap(itr1,j);
         ++itr1;
         ++j;
         itr2 = k;
         rotate(itr1,j,last);
         while (last != j)
         {
            ++j;
            ++itr2;
         }
         rotate(k,itr2,last);
         return true;
      }
   }
   rotate(first,k,last);
   return false;
}

inline double get_time_sec(void){
    return static_cast<double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count())/1000000000;
}

template<typename T>
T gcd(T a, T b) {
    if(a > b) swap(a, b);
    if(a == 0) return b;
    else return gcd(b%a, a);
}

template<typename T>
map<T, T> prime_list(T n) {
    map<T, T> ret;
    for(T i = 2; i*i <= n; i++) {
        if(n % i == 0) {
            ret[i] = 0;
            while(n % i == 0) {
                n /= i;
                ret[i]++;
            }
        } 
    }
    if(n != 1) ret[n]++;
    return ret;
}

#define MOD 1000000007

LL mypow(LL a, LL n) {
    if(n == 1) return a % MOD;
    if(n % 2 == 1) return (a * mypow(a, n-1)) % MOD;
    LL t = mypow(a, n/2);
    return (t * t) % MOD; 
}

int main(void) {
    int n;
    cin >> n;
    VI a(n, 0);
    int ans = 0;
    REP(i, n) {
        int tmp;
        cin >> tmp;
        if(tmp > n) ans++;
        else a[tmp-1]++;
    }
    REP(i, n) {
        if(a[i] < i+1) ans += a[i];
        else ans += a[i] - i - 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define LOCAL 0
#define lli long long int
const lli mod=1e9+7;
const lli pINF=LLONG_MAX;
const lli nINF=-LLONG_MAX;
void fast() {std::ios::sync_with_stdio(false);cin.tie(NULL);}
lli power(lli a,lli b){lli ans=1;while(b!=0){ if(b%2==1){ans*=a;}b/=2;a*=a;} return ans;}
lli invmod(lli a) {return pow(a,mod-2);}
#define vi vector<int>
#define vlli vector<lli>
#define pb push_back
#define mp make_pair
#define F first
#define S second
const int INT=1000000000;
const int INF=0x3f3f3f3f;
#define Pa pair<int,int>
#define si(n) scanf("%d",&n)
#define sli(n) scanf("%lld",&n)
#define printi(n) printf("%d\n",n)
#define ld long double
#define printli(n) printf("%lld\n",n)
#define all(v) v.begin(),v.end()
#define forn(i,n) for(int i=0;i<n;i++)
void print(int a[],int n){for(int i=0;i<n;i++) cout<<a[i]<<" ";}

int main() 
{
    int a,b;
    si(a);si(b);
    
    cout<<max(a+b,max(a-b,a*b))<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=1000000+100;
const db pi=acos(-1.0);
#define lowbit(x) ((x)&(-x))
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

inline ll readll()
{
    ll x=0;int f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

int n,ch[N][26],ed[N],tot=1;
bool vis[30];
string s[N];
vi pos[N];

int main()
{
    n=read();
    rep(i,1,n)
    {
        cin >> s[i];
        int m=s[i].size(),now=1;
        reverse(s[i].begin(),s[i].end());
        rep(j,0,m-1)
        {
            pos[i].pb(now);
            int x=s[i][j]-'a';
            if (!ch[now][x]) ch[now][x]=(++tot);
            now=ch[now][x];
        }
        ed[now]=1;
    }
    ll ans=0;
    rep(i,1,n)
    {
        int m=s[i].size();
        rep(j,0,25) vis[j]=0;
        per(j,m-1,0)
        {
            int p=pos[i][j];vis[s[i][j]-'a']=1;
            //cout << p << " " << s[i][j] << endl;
            rep(c,0,25) 
                if (vis[c]) 
                {
                    //cout << "char " << c << endl;
                    ans+=ed[ch[p][c]];
                }
            
        }
        //cout << endl;
    }
    ans-=n;
    printf("%d",ans);
    return 0;
}

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

char str[100001];

int main()
{
	scanf( "%s", str );
	
	bool bit = 0;
	int ans1 = 0, ans2 = 0;
	for( int i = 0; str[i] != 0; ++i )
	{
		ans1 += ( '0'+bit != str[i] );
		ans2 += ( '0'+!bit != str[i] );
		bit = !bit;	// ビットを反転
	}

	cout << min( ans1, ans2 ) << endl;
	return 0;
}

Measured memory_bytes: 384
#include<cstdio>

int main(){
    int n;
    int i;
    scanf("%d", &n);

    for(i=1;i*i<n;i++);
    if(i*i==n){
        printf("%d\n", n);
    }else{
        printf("%d\n", (i-1)*(i-1));
    }

    return 0;
}


Measured memory_bytes: 128
import numpy as np
N = int(input())
list_a = [int(input()) for _ in range(N)]
list_np = np.array(list_a)
maxnum=list_np.max()
index_list = np.where(list_np == maxnum)[0]
if len(index_list) == 1:
  list_drop = [i for i in list_a if i != maxnum]
  a=[]
  for i in range(N):
    if i in index_list:
      a.append(max(list_drop))
    else:
      a.append(maxnum)
else:
  a = [maxnum for i in range(N)]
for i in range(N):
  print(a[i])

Measured memory_bytes: 28168