akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示

void solve(long long N){
  ll ans = 0;
  for (int i = 1; i <= N; i+=2) {
    ll c=0;
    for (int l = 1; l <= i; l++) {
      if(i%l == 0)c++;
    }
    if(c == 8)ans++;
  }
  cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
}


Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
	ll a,b,c;
	cin>>a>>b>>c;
	if(c>=a&&c<=b)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n; 
  string s;
  cin >> n >> s;
  ll r = 0, g = 0, b = 0, sum = 0;
  for (int i = 1; i <= (n - 1) / 2; i++) {
    for (int j = 0; j + 2 * i < n; j++) {
      if (s[j] != s[j + i] && s[j + i] != s[j + 2 * i] && s[j] != s[j + 2 * i]) {
        sum++;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (s[i] == 'R') {
      r++;
    } else if (s[i] == 'G') {
      g++;
    } else {
      b++;
    }
  }
  cout << r * g * b - sum;
  return 0;
}

Measured memory_bytes: 3640
import heapq

N, M = map(int, input().split())
A = [-int(A) for A in input().split()]
heapq.heapify(A)

for x in range(M):
  most = -heapq.heappop(A)
  most //= 2
  heapq.heappush(A, -most)

print(-sum(A))

Measured memory_bytes: 14180
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  int a,b;
  cin >> a >> b;
  if (a*b%2==0) cout << "No" << endl;
  else cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main() {
	long long int N, K, Q;
	cin >> N >> K >> Q;
	vector<long long int> A(Q);
	vector<int> B(N, K - Q);
	for (int i = 0; i < Q; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < Q; i++) {
		B[A[i] - 1]++;
	}
	for (int i = 0; i < N; i++) {
		if (B[i] > 0) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	return 0;
}

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

int main() {
    int N, K;
    std::string S;
    std::cin >> N >> K;
    std::cin >> S;

    K = K - 1;
    if (S[K] == 'A') {
        S[K] = 'a';
    } else if (S[K] == 'B') {
        S[K] = 'b';
    } else if (S[K] == 'C') {
        S[K] = 'c';
    }

    std::cout << S << std::endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=100100;
int i,j,k,n,m,ch,ff,En,ans;
int a[N],f[N],h[N];
struct edge { int s,n;} E[N];
void R(int &x) {
	ff=x=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
void E_add(int x,int y) {
	E[++En].s=y;E[En].n=h[x];h[x]=En;
}
void dfs(int x) {
	f[x]=1;
	for (int k=h[x];k;k=E[k].n) {
		dfs(E[k].s);
		f[x]=max(f[x],f[E[k].s]+1);
	}
	if (a[x]!=1 && f[x]>=m) f[x]=0,ans++;
}
int main() {
	R(n);R(m);
	for (i=1;i<=n;i++) R(a[i]);
	for (i=2;i<=n;i++) E_add(a[i],i);
	if (a[1]!=1) ans++;
	a[1]=1;
	dfs(1);
	printf("%d\n",ans);
}

Measured memory_bytes: 5248
//カタラン数を語らん!w

#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 2000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*2
#define REP(a,b) for(long long a = 0;a < b;++a)
long long cnt[3000] = {};
long long mae[3000] = {};
int main() {
#define int long long
	int n;
	cin >> n;
	REP(i, n) {
		int a;
		cin >> a;
		cnt[a]++;
	}
	for (int i = 1; i <= 2000; ++i) {
		mae[i] = mae[i - 1] + cnt[i];
	}
	long long ans = 0;
	for (int i = 1; i <= 1000; ++i) {
		ans += cnt[i] * (cnt[i] - 1LL) * (cnt[i] - 2LL) / 6LL;
	}
	for (int i = 1; i <= 1000; ++i) {
		long long hoge = cnt[i] * (cnt[i] - 1LL) / 2LL;
		hoge *= (mae[i * 2 - 1] - cnt[i]);
		ans += hoge;
	}
	for (int i = 1; i <= 1000; ++i) {
		for (int q = i + 1; q <= 1000; ++q) {
			long long hoge = mae[i + q - 1] - mae[q];
			hoge *= cnt[i] * cnt[q];
			ans += hoge;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 888
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

ll dp[100001];
int main(){
  int N, W;
  cin >> N >> W;
  rep(i, N * 1000 + 1){
    dp[i] = W + 1;
  }
  dp[0] = 0;
  rep(i, N){
    ll w, v;
    cin >> w >> v;
    rrep(j, (N - 1) * 1000 + 1){
      ll val = j + v;
      dp[val] = min(dp[val], dp[j] + w);
    }
  }
  ll ans = 0;
  rrep(i, N * 1000 + 1){
    if(dp[i] <= W){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<ll,ll> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
//大きな数を扱うときは素因数分解した形で持っておく
// (l/a[i]) = l*powmod(a[i],MOD-2)%MOD;
//auto itr=lower_bound(ALL(a),key) a[itr-a.begin()]

int main(){
    int h,w,d; cin >> h >> w >> d;
    vector<P> v(h*w+1);
    map<P,int> mp;
    rep(i,h){
        rep(j,w){
            int a; cin >> a;
            v[a]=make_pair(i,j);
        }
    }
    for(int i=1;i<=d;i++){
        for(int k=1;i+k*d<=h*w;k++){
            mp[{i,i+k*d}]=mp[{i,i+(k-1)*d}]+abs(v[i+(k-1)*d].fi-v[i+k*d].fi)+abs(v[i+(k-1)*d].se-v[i+k*d].se);
        }
    }
    int q; cin >> q;
    rep(i,q){
        int l,r; cin >> l >> r;
        int x=l%d;
        if(x==0) x=d;
        cout << mp[{x,r}]-mp[{x,l}] << endl;
    }
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

int powmod(int x, int y, int mod)
{
    int res = 1;
    x %= mod;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % mod;
        y = y >> 1;
        x = (x * x) % mod;
    }
    return res;
}

void solve()
{
}

int main()
{
    // freopen("filename.in","r",stdin);
    // freopen("filename.out","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, x, t;
    cin >> n >> x >> t;
    int c = n / x;
    // cout<<"c is "<<c<<"\n";
    int rem = n % x;
    // cout<<rem<<"\n";
    int ans = 0;
    if (rem > 0)
    {
        ans++;
    }

    ans += c;
    // cout<<ans<<"\n";
    cout << ans * t << "\n";

    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(VECTOR) (VECTOR).begin(),(VECTOR).end()

int main(){

	int H, W, h, w;
	cin >> H >> W >> h >> w;
	cout << H * W - h * W - H * w + h * w << endl;

	return 0;
}

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

typedef long long int ll;
ll n, k, a[107];
bool dp[100007];

int main() {
    cin >> n >> k;
    for(ll i = 0; i < n; ++i) {
        cin >> a[i];
    }

    for(ll i = 1; i <= k; ++i) {
        for(ll j = 0; j < n; ++j) {
            if(i - a[j] >= 0) dp[i] |= !dp[i - a[j]];
        }
    }

    if(dp[k]) cout << "First" << endl;
    else cout << "Second" << endl;
    
    return 0;
}

Measured memory_bytes: 3716
import sys
sys.setrecursionlimit(10**6)

#a = int(input())
#b = list(map(int, input().split()))
a, b = map(str, input().split())
#s = input()
#s,t = input().split()
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

from decimal import *

ans = Decimal(a)*Decimal(b)
ans = int(ans)

print(ans)

Measured memory_bytes: 9944
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
#define int long long
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000000000000;

signed main(){
	double a,b;
	cin>>a>>b;
	printf("%08lf",a/b);
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int N,M;
vector<int> A;

int main(){
  cin>>N;
  M=(1<<N);
  A.resize(M);
  rep(i,M) cin>>A[i];

  int ans=0;
  for(int i=0;i<M;i++){
    bool fir=true;
    for(int j=0;j<=20;j++){
      if(i&(1<<j)){
        int tar=i^(1<<j);
        if(A[i]==0&&A[tar]==1){
          cout<<"-1"<<endl;
          return 0;
        }

        if(A[i]==1&&A[tar]==1) fir=false;
      }
    }

    if(A[i]==1&&fir) ans++;
  }

  cout<<ans<<endl;



  return 0;
}



Measured memory_bytes: 7032
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){

    int n,k;
    string s;

    cin >> n >> s >> k;

    rep(i,0,n){
	if(s[k-1] != s[i])cout << "*";
	else cout << s[i];
    }
    cout << endl;
    return  0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    string s;
    cin >> s;
    string youbi[7] = {"SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"};
    rep(i, 7){
        if(youbi[i]==s){
            cout << i + 1 << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3580
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>

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

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

int p[20010];
int a[20010], b[20010];

int main() {
    int n;
    cin>>n;
    for (int i = 0; i < n; i++) {
        cin>>p[i];
    }
    for (int i = 1, pos=0; i <= n; i++, pos++) {
        a[pos]=i*n;
        b[pos]=(n-i+1)*n;
    }
    for (int i = 0; i < n; i++) {
        a[p[i]-1]+=i;
    }

    for (int i = 0; i < n; i++) {
        if(i!=0)cout<<" ";
        cout<<a[i];
    }
    cout<<endl;

    for (int i = 0; i < n; i++) {
        if(i!=0)cout<<" ";
        cout<<b[i];
    }
    cout<<endl;

    return 0;
}

Measured memory_bytes: 896
#include<stdio.h>
#define SIZE 200000

int main(void)
{
  int i, j, k, max;
  int N, M, K;
  int A[SIZE], B[SIZE];
  long long a[SIZE+1], b[SIZE+1];
  
  scanf("%d %d %d", &N, &M, &K);
  for ( i=0; i<N; ++i)
    scanf("%d", &A[i]);
  for ( i=0; i<M; ++i)
    scanf("%d", &B[i]);
  max = 0;
  
  /* a[i] (b[i]): A (B) から i 冊読む時間 */
  a[0] = b[0] = 0;
  for ( i=1; i<=N; ++i)
    a[i] = a[i-1] + A[i-1];
  for ( i=1; i<=M; ++i)
    b[i] = b[i-1] + B[i-1];
  
  /* A から i 冊，B から j 冊読む */
  j = M;
  for ( i=0; i<=N; ++i) {
    if ( A[i] > K)
      break;
    while ( a[i]+b[j] > K)
      --j;
    if ( max < i+j)
      max = i+j;
  }
  printf("%d\n", max);
  return 0;
}

Measured memory_bytes: 6392
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define endl '\n';
const int maxn=20;
int a[maxn][maxn],c[maxn],x,n,m;
int ans=1e9;
bool f(int val){
	vector<int>under(m,0);
	int temp=0;
	for (int i = 0; i < n; ++i)
	{
		if((val & (1<<i)) == 0) continue;
		temp += c[i];
		for (int j = 0; j < m; ++j)
		{
			under[j] += a[i][j];
		}
	}
	for (int i = 0; i < m; ++i)
	{
		if(under[i] < x) return 0;
	}
	ans = min(ans, temp);
	return 1;
}
int32_t main(){
	ios::sync_with_stdio(0); 
	cin.tie(0); 
	cout.tie(0);
	cin>>n>>m>>x;
	for (int i = 0; i < n; ++i)
	{
		cin>>c[i];
		for (int j = 0; j < m; ++j)
		{
			cin>>a[i][j];
		}
	}
	int r=(1<<n)-1;
	if(!f(r)){
		cout<<-1<<endl;
		return 0;
	}
	for (int i = 1; i < r; ++i)
	{
		f(i);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3660
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

const MOD = 10^^9 + 7;

int[int] fac(int n) {
    assert(n > 1);

    int[int] ps;
    while (n % 2 == 0) {
        ps[2]++;
        n /= 2;
    }
    for (int i = 3; i * i <= n; i += 2) {
        while (n % i == 0) {
            ps[i]++;
            n /= i;
        }
    }
    if (n > 1) ps[n]++;
    return ps;
}

long calc(int n, int m) {
    if (m == 1) return 1;
    if (n == 1) return 1;

    initFactTable(n * 3);

    import std.exception;
//    enforce(n > 1);

    long ans = 1;
    foreach (v; fac(m).values) {
        // v 個の素因数と n - 1 個の仕切りの並べ方
        ans = (ans * nck(v + n - 1, n - 1)) % MOD;
    }
    return ans;
}

void main() {
    int n, m; scan(n, m);
    writeln(calc(n, m));
}

long[] fact; // 階乗
long[] factInv; // 階乗の逆元

void initFactTable(int n) {
    fact = new long[n + 1];
    fact[0] = 1;
    for (int i = 1; i <= n; i++)
        fact[i] = i * fact[i - 1] % MOD;

    factInv = new long[n + 1];
    factInv[n] = modPow(fact[n], MOD - 2, MOD);
    for (int i = n - 1; i >= 0; i--)
        factInv[i] = factInv[i + 1] * (i + 1) % MOD;
}

long modPow(long x, long k, long m) {
    if (k == 0) return 1;
    if (k % 2 == 0) return modPow(x * x % m, k / 2, m);
    return x * modPow(x, k - 1, m) % m;
}

long nck(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return (fact[n] * factInv[k] % MOD) * factInv[n - k] % MOD;
}


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

int main() {
    int H,W;
    char png[200][100];

    cin>>H>>W;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>png[i*2][j];
        }
    }
    for(int i=0;i<2*H;i++){
        for(int j=0;j<W;j++){
            if(i%2==1){
                png[i][j]=png[i-1][j];
            }
        }
    }

    for(int i=0;i<2*H;i++){
        for(int j=0;j<W;j++){
            cout<<png[i][j];
        }
        cout<<endl;
    }

    return 0;

}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-12;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N;
	string s;
	cin >> s;
	cin >> K;
	vector<set<int>>st(26);
	for (int i = 0; i < N; i++) {
		st[s[i] - 'a'].insert(i);
	}
	while (K--) {
		cin >> M;
		if (M == 2) {
			cin >> L >> R;
			L--, R--;
			int ans = 0;
			for (int i = 0; i < 26; i++) {
				auto it = st[i].lower_bound(L);
				if (it != st[i].end() && *it <= R)ans++;
			}
			cout << ans << endl;
		}
		else {
			cin >> L;
			L--;
			char a;
			cin >> a;
			if (s[L] == a)continue;
			st[s[L] - 'a'].erase(L);
			st[a - 'a'].insert(L);
			s[L] = a;
		}
	}
	return 0;
}

Measured memory_bytes: 24220
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		double output = 0;
		ArrayList<Double> arr = new ArrayList<>();
		for(int i = 0;i<N;i++) {
			arr.add(sc.nextDouble());
		}
		Collections.sort(arr);
		while(arr.size()>1) {
			double temp = (arr.get(0)+arr.get(1))/2;
			//System.out.println(temp);
			output=temp;
			arr.set(0, temp);
			arr.remove(1);	
		}
		System.out.println(output);
		
		
		

	}

}


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

int main() {
    int n, k;
    cin>>n >>k;
    vector<int> h(n);
    int ans=0;
    rep(i,n){
        cin>>h[i];
        if(h[i]>=k) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3712
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int a,b,c;
    cin>>a>>b>>c;
    if((4*a*b)<(c*c+a*a+b*b+2*(a*b-a*c-c*b))&&(c-a-b)>=0){
        cout<<"Yes"<<endl;   
    }
    else{
        cout<<"No"<<endl;
    }
    
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

    int a,b,c;

    for(a=0;a<a+1;a++){
       scanf("%d %d",&b,&c);
       if(b==0 && c==0){
         break;
       }
       if(c<b){
         a=c;
         c=b;
         b=a;
       }

       printf("%d %d\n",b,c);
    }

    return 0;
}

Measured memory_bytes: 600
import java.io.File;
import java.io.IOException;
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		String S = sc.next();
		
		for(int index = S.length()-3; index >= 0; index -= 2){
			String s1 = S.substring(0, (index + 1) / 2);
			String s2 = S.substring((index + 1) / 2, index + 1);
			//System.out.println(s1 + " " + s2);
			if(s1.equals(s2)){
				System.out.println(s1.length() * 2);
				return;
			}
		}
	}
}

Measured memory_bytes: 21972
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

H, W, D = list(map(int, sys.stdin.readline().split()))

X, Y = np.meshgrid(np.arange(H), np.arange(W))
# 45度回転
X, Y = X + Y, X - Y
X = X.ravel()
Y = Y.ravel()
# いい感じに埋める
colors = np.zeros(H * W, dtype=str)
colors[(X % (D * 2) < D) & (Y % (D * 2) < D)] = 'R'
colors[(X % (D * 2) < D) & (Y % (D * 2) >= D)] = 'Y'
colors[(X % (D * 2) >= D) & (Y % (D * 2) < D)] = 'G'
colors[(X % (D * 2) >= D) & (Y % (D * 2) >= D)] = 'B'
# 復元
x, y = (X + Y) // 2, (X - Y) // 2
ans = np.zeros((H, W), dtype=str)
ans[x, y] = colors
print('\n'.join(map(lambda r: ''.join(r), ans)))


Measured memory_bytes: 23420
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

class UnionFind {
    vector<int> par;
    int n;
public:
    UnionFind(int n) : par(n, -1) {}
    int find(int x) {
        if (par[x] < 0) return x;
        return par[x] = find(par[x]);
    }
    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
};

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

    ll n, m;
    cin >> n >> m;

    UnionFind uf(2*n);

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        uf.unite(a, b+n);
        uf.unite(a+n, b);
    }

    for (int i = 0; i < n; i++) {
        if (uf.find(i) == uf.find(i+n)) {
            cout << (n*(n-1)/2)-m;
            return 0;
        }
    }

    ll c = 1;
    for (int i = 1; i < n; i++) {
        if (uf.find(0) == uf.find(i)) c++;
    }
    cout << c*(n-c)-m;
    return 0;
}

Measured memory_bytes: 1024
s = input()

A = 0
B = 0
C = 0

for x in s:
    if x == 'a':
        A += 1
    elif x == 'b':
        B += 1
    else:
        C += 1

l = sorted([A, B, C])

print('YES' if (l[2] <= l[1] + 1 and l[0] == l[1]) or (l[2] == l[1] and l[0] == l[1] - 1) else 'NO')


Measured memory_bytes: 9080
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if (H == 0 && W == 0) {
				break;
			}
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					System.out.print("#");
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}
	}
}



Measured memory_bytes: 35204
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, s, e) for (ll i = s; i < e; i++)
#define Forr(i, s, e) for (ll i = s; i > e; i--)
#define pb push_back
#define ll long long
#define int ll
#define mp make_pair
#define infi 1e12
const ll mod = 1e9 + 7;
signed main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout << fixed << setprecision(8);
    ll r, c, m;
    cin >> r >> c >> m;
    ll row[r];
    ll col[c];
    For(i, 0, r) row[i] = 0;
    For(i, 0, c) col[i] = 0;
    set<pair<ll, ll>> st;
    For(i, 0, m)
    {
        ll x, y;
        cin >> x >> y;
        st.insert({x - 1, y - 1});
        row[x - 1]++;
        col[y - 1]++;
    }
    ll maxrow = 0;
    For(i, 0, r) if (row[i] > row[maxrow]) maxrow = i;
    ll maxcol = 0;
    For(i, 0, c) if (col[i] > col[maxcol]) maxcol = i;
    vector<ll> rows;
    vector<ll> cols;
    For(i, 0, r) if (row[i] == row[maxrow]) rows.pb(i);
    For(i, 0, c) if (col[i] == col[maxcol]) cols.pb(i);
    bool nob = false;
    For(i, 0, rows.size())
    {
        For(j, 0, cols.size())
        {
            auto itr = st.find({rows[i], cols[j]});
            if (itr == st.end())
            {
                nob = true;
                break;
            }
        }
        if (nob)
            break;
    }
    if (nob)
        cout << max(row[maxrow] + col[maxcol], (ll)0);
    else
    {
        cout << max(row[maxrow] + col[maxcol] - 1, (ll)0);
    }
    return 0;
}

Measured memory_bytes: 35056
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_i64_asc(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_f(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_f2(const void* a, const void* b) {
    return *((uint64_t*)a) > * ((uint64_t*)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t gcdU64(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

int main(void) {
    int64_t a, b;

    scanf("%"PRId64" %"PRId64, &a, &b);

    int64_t xSum = 0;
    int64_t abssMin = INT64_MAX;

    if (a <= 0) {
        if (b < 0) {
            puts((b - a + 1) % 2 == 0 ? "Positive" : "Negative");
        }
        else {
            puts("Zero");
        }
    }
    else {
        puts("Positive");
    }

    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(void){
    int A[100];
    int x,minj,tmp,c=0;
    
    scanf("%d",&x);
    for(int i=0;i<x;i++){
        scanf("%d",&A[i]);
    }
	
	for(int i=0;i<x;i++){
		minj=i;
		for(int j=i;j<x;j++){
			if(A[j]<A[minj]){
				minj=j;
			}
		}
		if(i!=minj){
			tmp=A[i];
			A[i]=A[minj];
			A[minj]=tmp;
			c++;
		}
	}
	
	printf("%d",A[0]);
    for(int i=1;i<x;i++){
        printf(" %d",A[i]);
    }
	printf("\n");
	printf("%d\n",c);
	
    return 0;
}



Measured memory_bytes: 2040
import std.stdio, std.string, std.conv, std.range, std.algorithm;
void main() {
	long n, m, l;
	"%d %d %d\n".readf(&n, &m, &l);
	long[][] a, b;
	foreach (_n; 0..n) a ~= readln.split.to!(long[]);
	foreach (_m; 0..m) b ~= readln.split.to!(long[]);
	foreach (_a; a) {
		long[] c = [];
		foreach (_l; 0..l) c ~= iota(m).map!(_m => _a[_m] * b[_m][_l]).sum;
		c.to!(string[]).join(" ").writeln;
	}
}

Measured memory_bytes: 3560
use std::io::*;

// const SP: u8 = b' ';
const LF: u8 = b'\n';

struct CharacterInput<'a> {
    locked_stdin: StdinLock<'a>,
    bytes_buffer: Vec<u8>,
}

impl<'a> CharacterInput<'a> {
    fn read(&mut self, delimiter: u8) -> &[u8] {
        self.bytes_buffer.clear();

        let len = self
            .locked_stdin
            .read_until(delimiter, &mut self.bytes_buffer)
            .unwrap();

        let end_index = match self.bytes_buffer.last() {
            Some(byte) => {
                if *byte == delimiter {
                    len - 1
                } else {
                    len
                }
            }
            None => len,
        };

        &self.bytes_buffer[0..end_index]
    }

    fn scan_u(&mut self, delimiter: u8) -> u32 {
        self.read(delimiter)
            .into_iter()
            .fold(0, |accumulator, byte| {
                (byte - b'0') as u32 + accumulator * 10
            })
    }

    fn scan_s(&mut self, delimiter: u8) -> &str {
        unsafe { std::str::from_utf8_unchecked(self.read(delimiter)) }
    }

    fn scan_chars(&mut self, delimiter: u8) -> Vec<char> {
        self.scan_s(delimiter).chars().collect()
    }
}

fn create_cin<'a>(input: StdinLock<'a>, buffer_capacity: usize) -> CharacterInput {
    CharacterInput {
        locked_stdin: input,
        bytes_buffer: Vec::with_capacity(buffer_capacity),
    }
}

fn println<T: std::string::ToString>(s: T) {
    println!("{}", s.to_string());
}

// ------------------------------------------------------------------------

fn main() {
    let cin = stdin();
    let cin = &mut create_cin(cin.lock(), 16);

    let n = cin.scan_u(LF) as usize;

    let mut s: Vec<Vec<char>> = (0..n)
        .map(|_| {
            let mut chars = cin.scan_chars(LF);
            chars.sort();
            chars
        })
        .collect();
    s.sort();

    let mut total_count: u64 = 0;
    let mut current_count: u64 = 0;
    for slice in s.windows(2) {
        if slice[0] == slice[1] {
            current_count += 1;
            total_count += current_count;
        } else {
            current_count = 0;
        }
    }

    println(total_count);
}


Measured memory_bytes: 14588
#include <stdio.h>

int array[128][128];
char done[128][128];
int memo[128][128];

int max(int line, int column, int line_num)
{
	int a, b;
	
	if (done[line][column] == 1){
		return (memo[line][column]);
	}
	
	if (column < 0 || array[line][column] == -1){
		return (0);
	}

	if (line == line_num - 1){
		return (array[line][column]);
	}
	
	a = array[line][column] + max(line + 1, column, line_num);
	if (line < line_num / 2){
		b = array[line][column] + max(line + 1, column + 1, line_num);
	}
	else {
		b = array[line][column] + max(line + 1, column - 1, line_num);
	}
	
	done[line][column] = 1;
	
	if (a > b){
		memo[line][column] = a;
		return (a);
	}
	
	memo[line][column] = b;
	return (b);
}

int main(void)
{
	int line_num, int_num;
	char str[512];
	int i, j;
	
	for (i = 0; i < 128; i++){
		for (j = 0; j < 128; j++){
			array[i][j] = -1;
		}
	}
	
	line_num = 0;
	while (fgets(str, 512, stdin) != NULL){
		i = 0;
		int_num = 0;
		while (str[i] != '\0'){
			j = 0;
			while (str[i] >= '0' && str[i] <= '9'){
				j = j * 10 + str[i] - '0';
				i++;
			}
			
			array[line_num][int_num] = j;
			i++;
			int_num++;
		}
		
		line_num++;
	}
	
	printf("%d\n", max(0, 0, line_num));
	
	return (0);
}

Measured memory_bytes: 648
import           Control.Monad
import           Data.Array.IO
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Maybe
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM

readInt = fst . fromJust . BS.readInt
getInt = readInt <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

main = do
  n <- getInt
  as <- getIntVec n

  cs <- VM.new 61
  VM.set cs (0::Int)

  forM_ [0..n-1] $ \i -> do
    let a = as V.! i
    forM_ [0..60] $ \j ->
      when (testBit a j) $ do
        c <- VM.read cs j
        VM.write cs j (c+1)
  cs' <- V.freeze cs

  let calc i c a = let c1 = fromIntegral c :: Integer
                       c2 = fromIntegral (n-c) :: Integer
                   in
                     c1 * c2 * bit i + a

  print $ V.ifoldr' calc 0 cs' `mod` 1000000007

Measured memory_bytes: 15868
a, b, c, d = map(int, input().split())
x = c - a
y = d - b
print(y*'U'+x*'R'+y*'D'+(x+1)*'L'+(y+1)*'U' +
      (x+1)*'R'+"DR"+(y+1)*'D'+(x+1)*'L'+'U')

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>

using namespace std;

void print(int a[], int n) {
    for (int i = 0; i < n; ++i) {
        if (i) printf(" %d", a[i]);
        else printf("%d", a[i]);
    }
    printf("\n");
}

void insertion_sort(int a[], int n) {
    for (int i = 1; i < n; ++i) {
        int t = a[i];
        int j = i - 1;
        while (j >= 0 && a[j] > t) {
            a[j+1] = a[j];
            --j;
        }
        a[j+1] = t;
        print(a, n);
    }
}

int a[100+10];

int main()
{
    int N;
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> a[i];
    print(a, N);
    insertion_sort(a, N);
    
    return 0;
}

Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9
#define EPS 1e-10

struct point{
	double x,y;
	point(){}
	point(double x,double y) :x(x),y(y){}

	point operator - (point p) {return point(x-p.x,y-p.y); }
	void make() { cin>>x>>y;}
	double norm() { return x*x+y*y; }
};

double dot(point a,point b){return a.x*b.x + a.y*b.y; }
double cross(point a,point b){ return a.x*b.y - a.y*b.x ;}

typedef vector<point> polygon;
int contain(polygon g,point p){
	int n = g.size();
	bool f = false;
	for(int i=0;i<n;i++){
		point a = g[i]-p,b = g[(i+1)%n]-p;
		if( fabs(cross(a,b) ) < EPS && dot(a,b) <EPS)return 1;
		if( a.y > b.y )swap(a,b);
		if( a.y < EPS && EPS < b.y && cross(a,b) >EPS) f = !f;
	}
	return (f?2:0);
// iN 2 ON 1OUT 0
}
static const int CCW_COUNTER_CLOCKWISE = 1;
static const int CCW_CLOCKWISE = -1;
static const int CCW_ONLINE_BACK = 2;
static const int CCW_ONLINE_FRONT = -2;
static const int CCW_ON_SEGMENT = 0;
int ccw(point p0,point p1,point p2){
	point a = p1-p0,b = p2-p0;
	if(cross(a,b) > EPS) return 1;
	if(cross(a,b) < -EPS) return -1;
	if(dot(a,b) < -EPS ) return 2;
	if(a.norm() < b.norm() ) return -2;
	return 0;
}
bool intersect(point a,point b,point c,point d){
	return ( ccw(a,b,c)*ccw(a,b,d) <= 0 && ccw(c,d,a)*ccw(c,d,b) <= 0 );
}
struct  disjointset{
	vector<int> rank,p;
	disjointset(){}
	disjointset(int size){
		rank.resize(size,0);
		p.resize(size,0);
		for(int i=0;i<size;i++)makeSet(i);
	}
	void makeSet(int x){
		p[x] = x;
		rank[x] = 0;
	}
	bool same(int x,int y){
		return findSet(x) == findSet(y);
	}
	void unite(int x,int y){
		link(findSet(x),findSet(y) );
	}
	void link(int x,int y){
		if(rank[x] > rank[y]){
			p[y] = x;
		}else{	
			p[x] = y;
			if(rank[x] == rank[y] ) rank[y]++;
		}
	}
	int findSet(int x){
		if(x!=p[x]) p[x] = findSet(p[x]);
		return p[x];
	}

};

int main(){
	while(1){
		int n;
		cin>>n;
		if(n==0)break;
		for(int k=0;k<n;k++){
		    	int m;
			cin>>m;
			vector<polygon> g(m,vector<point>(4,point(0,0)) );
			for(int i=0;i<m;i++)for(int j=0;j<4;j++) g[i][j].make();
		/*	for(int i=0;i<m;i++){
				for(int j=0;j<4;j++){
					cout<<g[i][j].x<<' '<<g[i][j].y;
				}
				cout<<endl;
			}*/
			disjointset ds = disjointset(m);
			for(int i=0;i<m;i++){
			    	polygon p = g[i];
				for(int j=0;j<m;j++){
				    	bool flag = false;
					for(int k=0;k<4;k++){
						if( contain(g[j],p[k])!=0 ){
							flag = true;
							break;
							//cout<<"ok"<<endl;
						}
					}
					for(int k =0 ;k<4;k++){
						for(int l = 0;l<4;l++){
							if(intersect(p[k],p[(k+1)%4],g[j][l],g[j][(l+1)%4] ) ){
								flag = true;
								break;
							}
						}
					}
					if(flag){
					    ds.unite(i,j);
					}
				}
			}
			int res = 0;
			for(int i=0;i<m;i++) if(ds.p[i] == i) res++;
			cout<<res<<endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3244
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max 100
using namespace std;
using ll=long long;
using P = pair<int,int>;
int main(){
    int a;
    cin >> a;
    cout << a*(1+a+a*a) <<endl;
}

Measured memory_bytes: 3600
N,M = (int(i) for i in input().split())  

class Box:
      def __init__(self):
         self.ball = 1
         self.pos = False
box = [] 
for i in range(N):
    box.append(Box())
box[0].pos = True

for i in range(M):
    x,y = (int(i) for i in input().split())  
    if box[x - 1].pos:
       box[y - 1].pos = True
    box[x - 1].ball -= 1
    box[y - 1].ball += 1
    if box[x - 1].ball == 0:
       box[x - 1].pos = False
cnt = 0;
for i in range(N):
   if box[i].pos:
      cnt += 1
print(cnt)

Measured memory_bytes: 20340
#include<stdio.h>

int a[100001],p[100001];

int dfs(int x){
  if(a[x]==x)
    return x;
  else 
    a[x]=dfs(a[x]);
  return a[x];
}

int main(){
  int i,n,m,x,y,cnt=0,l,r;
  scanf("%d %d",&n,&m);
  for(i=0;i<=n;i++)
    a[i]=i;
  p[0]=0;
  for(i=0;i<n;i++)
    scanf("%d",&p[i+1]);
  for(i=0;i<m;i++){
    scanf("%d %d",&x,&y);
    if(x>y)
      a[dfs(x)]=a[dfs(y)];
    else
      a[dfs(y)]=a[dfs(x)];
  }
  for(i=1;i<=n;i++){
    x=dfs(i);
    y=dfs(p[i]);
    if(x==y)
      cnt++;
  }
  printf("%d\n",cnt);
}

Measured memory_bytes: 896
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll c(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
ll t[10], pre[10];
int main(void) {
	int H, W, K, p, cut, ans = 1 << 30;
	bool ok;
	cin >> H >> W >> K;
	vector<string> s(H);
	rep(i, 0, H)cin >> s[i];
	rep(i, 0, 1 << (H - 1)) {
		ok = true;
		cut = 0;
		rep(i2, 0, H - 1)if (i >> i2 & 1)cut++;
		rep(i2, 0, H)t[i2] = 0;
		rep(i2, 0, W) {
			if (!ok)break;
			p = 0;
			rep(i3, 0, H)pre[i3] = t[i3];
			rep(i3, 0, H) {
				t[p] += s[i3][i2] - '0';
				if (i >> i3 & 1)p++;
			}
			rep(i3, 0, H) {
				if (t[i3] > K) {
					cut++;
					rep(i4, 0, H) {
						t[i4] -= pre[i4];
						if (t[i4] < 0)t[i4] = 0;
						if (t[i4] > K)ok = false;
					}
					break;
				}
			}
		}
		if (ok) {
			ans = min(ans, cut);
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
A = []
B = []

for i in range(5):
    x = int(input())
    if x % 10 == 0:
        a = x
        A.append(a)
    else:
        a = (x // 10 + 1) * 10
        A.append(a)
        
    b = a - x
    B.append(b)
    
print(sum(A) - max(B))

Measured memory_bytes: 3060
#include <iostream>
#include <stack>

using namespace std;

struct Vertex {
  int id;
  bool flag[8];

  Vertex(const int mid) : id(mid) {
    for(int i=0; i<8; i++) {
      flag[i] = false;
    }
  }

  Vertex(const Vertex& o) : id(o.id) {
    for(int i=0; i<8; i++) {
      flag[i] = o.flag[i];
    }
  }

  bool is_end(const int N) {
    for(int i=0; i<N; i++) {
      if(flag[i] == false) {
        return false;
      }
    }
    return true;
  }
};

int g[8][8];
int main() {
  for(int i=0; i<8; i++) {
    for(int j=0; j<8; j++) {
      g[i][j] = 0;
    }
  }

  int N, M;
  cin >> N >> M;

  int v, e;
  for(int i=0; i<M; i++) {
    cin >> v >> e;
    v--;
    e--;
    g[v][e] = g[e][v] = 1;
  }

  stack<Vertex> s;
  s.push(Vertex(0));
  int count = 0;
  while(!s.empty()) {
    Vertex targ = s.top();
    s.pop();
    targ.flag[targ.id] = true;

    if(targ.is_end(N)) {
      count++;
    }
    else {
      for(int i=0; i<N; i++) {
        if(g[targ.id][i] == 1 && targ.flag[i] == false) {
          Vertex tmp(targ);
          tmp.id = i;
          s.push(tmp);
        }
      }
    }
  }

  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{
  public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	String S = sc.next();
    StringBuilder first = new StringBuilder();
    StringBuilder last = new StringBuilder();
	int Q = sc.nextInt();
	int revCount =0;
	
	//命令実行部
	for(int i=0; i<Q; i++) {
		int T = Integer.parseInt(sc.next());
		if( T == 1)
			revCount++;	    
	else {
	    int F = Integer.parseInt(sc.next());
	    char C = sc.next().charAt(0);
	    if (revCount%2 == 0 && F==1 || revCount%2==1 && F==2)
	    	first.append(C);
	    else
	    	last.append(C);
		}
		
	}
	
		if ( revCount %2 == 0) {
			first.reverse();
			System.out.println(first + S + last);
		}
		else {
			StringBuilder s = new StringBuilder();
			s.append(S);
			s.reverse();
			last.reverse();
			System.out.println(last + s.toString() + first);
		}

  }
}


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

const char NL = '\n';
const int MOD = 1e9 + 7;

void solve()
{
    int n; cin >> n;
    vector<vector<int>> dp(n, vector<int>(3, 0));
    cin >> dp[0][0] >> dp[0][1] >> dp[0][2];
    for (int i = 1; i < n; ++i) {
        int a, b, c; cin >> a >> b >> c;
        dp[i][0] = a + max(dp[i - 1][1], dp[i - 1][2]);
        dp[i][1] = b + max(dp[i - 1][0], dp[i - 1][2]);
        dp[i][2] = c + max(dp[i - 1][0], dp[i - 1][1]);
    }
    cout << *max_element(dp[n - 1].begin(), dp[n - 1].end()) << NL;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 8664
#include <stdio.h>

int main() {
  int N;
  char s[200];
  int i=0;
  scanf("%d\n", &N);
  fgets(s, 200, stdin);
  while (N--) {
    if (s[i] == 'Y') {
      puts("Four");
      return 0;
    }
    i=i+2;
  }
  puts("Three");
  return 0;
}


Measured memory_bytes: 128