akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <iterator>
#include <cmath>

using namespace std;

int main()
{
    //freopen("in", "r", stdin);
    //freopen("out", "w", stdout);

    int n, m, k, i, j;
    scanf("%d%d%d", &n, &m, &k);

    for(i = 0; i <= n; i++)
    {
        for(j = 0; j <= m; j++)
        {
            if(i * m + j * n - 2 * i * j == k)
            {
                printf("Yes\n");
                return 0;
            }
        }
    }

    printf("No\n");
    return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;
#include <bits/stdc++.h>

int main(){
  double a,b,h,m;
  cin >> a >> b >> h >> m;

  double tansin = h*30 + m*0.5;
  double tyousin = m*6;

  double c = sqrt(a*a + b*b - 2*a*b*cos(M_PI*(tansin-tyousin)/180));
  cout << fixed << setprecision(20);

  cout << c;
  
   
}


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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

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

Measured memory_bytes: 1408
x, k, d = map(int, input().split())

x1 = abs(x)
mod1 = x1 % d
mod2 = mod1 - d
if mod1 > abs(mod2):
    mod = mod2
    modx = mod1
else:
    mod = mod1
    modx = mod2

a = abs(x1-mod) / d 

if k*d < x1-mod:
   print(x1-k*d)
elif (k-a) % 2 == 0:
    print(abs(mod))
else:
    print(abs(modx))


Measured memory_bytes: 9164
//file_name:ABC43_B.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    string s;
    cin >> s;
    string ss = s;
    int c = 0;

    rep(i,s.size()){
        if(s[i]=='0'){
            ss[c] = '0';
            c++;
        }
        if(s[i]=='1'){
            ss[c] = '1';
            c++;
        }
        if(s[i]=='B'){
            c = max(0,c-1);
        }
    }
    rep(i,c){
        cout << ss[i];
    }
    cout << endl;

    return 0;
}



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

int main() {
    string S;
    cin >> S;
    int len = 0;
    int ans = 0;
    rep(i, S.size()) {
        bool isA = (S[i] == 'A');
        bool isT = (S[i] == 'T');
        bool isC = (S[i] == 'C');
        bool isG = (S[i] == 'G');
        if (isA || isT || isC || isG) {
            len++;
        } else {
            len = 0;
            ans = max(ans, len);
        }
        ans = max(ans, len);
    }
    cout << ans << endl;
}

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

int main() {
  int n, t, ci, ti;
  vector<int> cost;
  cin >> n >> t;
  for (int i=0; i<n; i++) {
    cin >> ci >> ti;
    if (ti>t) continue;
    cost.push_back(ci);
  }
  if (cost.size()==0) cout << "TLE";
  else cout << *min_element(cost.begin(), cost.end());
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
 
int main(){
	int n,k;
  	cin>>n>>k;
  	vector<ll> h(n);
  for(int i=0;i<n;i++) cin>>h[i];
  vector<ll> dp(n,INT_MAX);
  dp[0] = 0;
  for(int i=1;i<n;i++){
  	for(int j=i-1;j>=0&&j>=i-k;j--){
    	dp[i] = min(dp[i],abs(h[i]-h[j])+dp[j]);
    }
  }
  cout<<dp[n-1];
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

ll calc(int n, int m, ll *x, ll *y, ll *z, int fx, int fy, int fz) {
  int ord[1010];
  ll nx[1010], ny[1010], nz[1010];
  for (int i = 0; i < n; i++) {
    nx[i] = !fx ? x[i] : -x[i];
    ny[i] = !fy ? y[i] : -y[i];
    nz[i] = !fz ? z[i] : -z[i];
  }
  iota(ord, ord + n, 0);
  sort(ord, ord + n, [&](int a, int b) {
    return nx[a] + ny[a] + nz[a] > nx[b] + ny[b] + nz[b];
  });
  ll sx = 0, sy = 0, sz = 0;
  for (int i = 0; i < m; i++) {
    sx += nx[ord[i]];
    sy += ny[ord[i]];
    sz += nz[ord[i]];
  }
  return abs(sx) + abs(sy) + abs(sz);
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int N, M;
  cin >> N >> M;
  ll x[1010], y[1010], z[1010];
  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i] >> z[i];
  }

  ll ans = 0;
  for (int i = 0; i < 1 << 3; i++) {
    ans = max(ans, calc(N, M, x, y, z, i >> 0 & 1, i >> 1 & 1, i >> 2 & 1));
  }
  cout << ans << endl;

  return 0;
}

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

int main() {
	long long a;

	std::cin >> a;

	long long ans = 0;

	ans += (a / 500) * 1000;
	a %= 500;

	ans += (a / 5) * 5;

	std::cout << ans << std::endl;

	return 0;
}


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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

int main(int argc, const char* argv[]) {
	ll h, w;
	cin >> h >> w;
	vector<string> s(h);
	rep(i, h) cin >> s[i];

	vector<vector<ll>> a(h, vector<ll>(w, 0));
	vector<vector<ll>> b(h, vector<ll>(w, 0));

	rep(i, h) {
		ll lb = 0;
		rep(j, w) {
			if(s[i][j] == '#') {
				repd(k, lb, j) {
					a[i][k] = j - lb;
				}
				lb = j + 1;
			}
		}

		repd(j, lb, w) {
			a[i][j] = w - lb;
		}
	}

	rep(j, w) {
		ll ub = 0;
		rep(i, h) {
			if(s[i][j] == '#') {
				repd(k, ub, i) {
					b[k][j] = i - ub;
				}
				ub = i + 1;
			}
		}

		repd(i, ub, h) {
			b[i][j] = h - ub;
		}
	}

	/*
	rep(i, h) {
		rep(j, w) {
			cerr << a[i][j] << " ";
		}
		cerr << endl;
	}
	cerr << endl;

	rep(i, h) {
		rep(j, w) {
			cerr << b[i][j] << " ";
		}
		cerr << endl;
	}
	cerr << endl;
	*/

	ll ret = 0;
	rep(i, h) {
		rep(j, w) {
			ll tmp = a[i][j] + b[i][j] - 1;
			//cerr << "(" << i << ", " << j << ") = " << tmp << endl;
			if(ret < tmp) {
				ret = tmp;
			}
		}
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 67072
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
ll INF=pow(10,18)+1;

vec A;
int N,zero=0;
ll K;
//x以下のペアの個数
ll func(ll x){
    ll rev=0;
    if(x>=0){
        for(int i=0;i<N-1;i++){
            if(A[i]<0 && A[N-1]>=x/A[i]){
                auto itr=lower_bound(A.begin(),A.end(),x/A[i]);
                rev+=N-max((ll)i+1,(ll)distance(A.begin(),itr));
            }
            if(A[i]==0){
                rev+=N-1-i;
            }
            if(A[i]>0){
                if(A[N-1]>x/A[i]){
                    auto itr=upper_bound(A.begin(),A.end(),x/A[i]);
                    rev+=max((ll)0,(ll)distance(A.begin(),itr)-i-1);
                }
                else rev+=N-i-1;
            }
        }
        return rev-K;
    }
    else{
        for(int i=0;i<N;i++){
            if(A[i]<0){
                ll j;
                if((-x)%(-A[i])==0)j=x/A[i];
                else j=x/A[i]+1;
                if(A[N-1]>=j){
                    auto itr=lower_bound(A.begin(),A.end(),j);
                    rev+=N-max((ll)i+1,(ll)distance(A.begin(),itr));
                }
            }
            if(A[i]>0){
                ll j;
                if((-x)%(-A[i])==0)j=x/A[i];
                else j=x/A[i]-1;
                if(A[N-1]>j){
                    auto itr=upper_bound(A.begin(),A.end(),j);
                    rev+=max((ll)0,(ll)distance(A.begin(),itr)-i-1);
                }
                else rev+=N-i-1;
            }
        }
        return rev-K;
    }
    return 0;
}

ll binary_search(ll l,ll r){
    if(r-l==1)return r;
    ll m=(l+r)/2;
    if(func(m)>=0)return binary_search(l,m);
    else return binary_search(m,r);
}

int main(){
    cin>>N;
    cin>>K;
    for(int i=0;i<N;i++){
        ll a;cin>>a;
        A.push_back(a);
    }
    sort(A.begin(),A.end());
    cout<<binary_search(-INF,INF)<<endl;
    return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    vector<int> b(n-1);
    vector<int> a(n);
    rep(i, n-1){
        cin >> b[i];
    }
    a[0] = b[0];
    a[n-1] = b[n-2];
    for(int i = 1; i < n-1; i++){
        a[i] = min(b[i-1], b[i]);
    }
    int ans = 0;
    rep(i, n){
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}


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

#define PRINT(STR) cout << STR << endl;
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()

typedef long long ll;

using namespace std;

int nextInt() { int n = -1; cin >> n; return n; }
double nextDouble() { double d = -1; cin >> d; return d; }
ll nextll() { ll n = -1; cin >> n; return n; }
string nextString() { string str; cin >> str; return str; }

int INF = 1LL << 25;
double EPS = 1e-9;

// BEGIN //////////////////////////////////////////////////////////////

int main() {
	int N = nextInt();
	double xa, ya, ra, xb, yb, rb;
	REP(i, N) {
		cin >> xa >> ya >> ra >> xb >> yb >> rb;
		double distance = sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb));
		if (distance < ra - rb) {
			PRINT(2);
		} else {
			if (distance < rb - ra) {
				PRINT(-2);
			} else {
				if (distance <= ra + rb) {
					PRINT(1);
				} else {
					PRINT(0);
				}
			}
		}
	}
	return 0;
}

// END   //////////////////////////////////////////////////////////////

Measured memory_bytes: 1232
#include <stdio.h>
#include <stdlib.h>

int compara(const void * x, const void * y){
    int a = *((int *) x), b = *((int *) y);
    if(a < b)
        return -1;
    else if(a > b)
        return 1;
    
    return 0;
}


int main(){
    int n;
    scanf("%d", &n);
    
    int v[n+1];
    for(int i=0; i < n; ++i)
        scanf("%d", &v[i]);
    
    qsort(v, n, sizeof(v[0]), compara);
    
    int total = 0;
    printf("%d\n", v[n-1] - v[0]);

    return 0;
}


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

int main(){

    long long n;
    cin >> n;

    vector<long long> dsides(n,0);
    for(int i=0;i<n;i++){
        cin >> dsides[i];
    }

    // set<long long> s(sides.begin(),sides.end());
    // vector<long long> dsides(s.begin(),s.end());

    long long int ans = 0;

    for(int i=0;i<n-2;i++)
        for(int j=i+1;j<n-1;j++)
            for(int k=j+1;k<n;k++){
                if(dsides[i]!=dsides[j] && dsides[k]!=dsides[j] && dsides[i]!=dsides[k] && dsides[i] < dsides[j]+dsides[k] && dsides[k] < dsides[j]+dsides[i] && dsides[j] < dsides[i]+dsides[k])
                    ans++;
            }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <cstring>
#include <map>
using namespace std;
int main()
{
    char s[100000 + 10];
    cin>>s;

    if(strlen(s) == 2){
        if(s[0] == s[1]) cout<<1<<" "<<2<<endl;
        else cout<<-1<<" "<<-1<<endl;
        return 0;
    }

    bool ok = false;
    for(int i = 0; s[i + 2]; i++){
        map<char, int> m;
        for(int j = 0; j < 3; j++){
            m[s[i + j]]++;
            if(m[s[i + j]] > 1) ok = true;
        }
        if(ok){
            cout<<i + 1<<" "<<i + 3<<endl;
            return 0;
        }
    }

    cout<<-1<<" "<<-1<<endl;

    return 0;
}


Measured memory_bytes: 384
A,B,C = map(int,input().split())
K = int(input())


for i in range(K):
    if A >= B and A >= C:
        A = A*2

    if B > A and B >= C:
        B = B*2

    if C > B and C > A:
        C = C*2


sum = A + B + C

print(sum)


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

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<Integer> $1 = new ArrayList<>();
		ArrayList<Integer> $2 = new ArrayList<>();
		ArrayList<Integer> $3 = new ArrayList<>();
		for(int i = 0; i < n; i++) {
			$1.add(sc.nextInt());
		}
		for(int i = 0; i < n; i++) {
			$2.add(sc.nextInt());
		}
		for(int i = 0; i < n; i++) {
			$3.add(sc.nextInt());
		}
		$1.sort(null);$3.sort(null);
		long ans = 0L;
		for(int i = 0; i < n; i++) {
			int s = $2.get(i);//中央を全探索
			long ok1 = 0L;
			long ok3 = 0L;
			//lower_bound
			ok1 = Collections.binarySearch($1, s, (Integer x, Integer y) ->  (x.compareTo(y) >= 0 ? 1 : -1));
			ok1 = ok1 >= 0 ? ok1 : ~ok1;
			//upper_bound
			ok3 = Collections.binarySearch($3, s, (Integer x, Integer y) ->  (x.compareTo(y) > 0 ? 1 : -1));
			ok3 = ok3 >= 0 ? ok3 : ~ok3;
			ok3 = n - ok3;
			//System.out.println(String.format("%sのとき$1は%s  $3は%s", s,ok1,ok3));
			ans += ok1 * ok3;
		}
		System.out.println(ans);
	}
}

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

int gcd(int a, int b){
	return b==0?a:gcd(b,a%b);
}

int main(){
	int a,b,k;
	cin >>a>> b>>k;
	int t = gcd(a,b);
	int ans = t;
	for (int i=t; i>=0,k>0;i--){
		if (t%i==0){
			k--;
			ans = i;
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll M;
    cin>>M;
    vl D(M), C(M);
    rep(i, M) cin >> D[i] >> C[i];

    ll dig = accumulate(all(C), 0ll), sum = 0;
    rep(i, M) sum += D[i] * C[i];
    sum--;

    cout << (dig - 1 + sum / 9) << endl;
}


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

struct Card { char suit, value; };

void print(Card card[], int size) {
	for (int i = 0; i < size; i++) {
		if (i) cout << ' ';
		cout << card[i].suit << card[i].value;
	}
	cout << endl;
}

void selection(Card cards[], int size) {
	int minj;
	for (int i = 0; i < size; i++) {
		minj = i;
		for (int j = i; j < size; j++) {
			if (cards[minj].value > cards[j].value) minj = j;
		}
		Card c = cards[i]; cards[i] = cards[minj]; cards[minj] = c;
	}
}

void bubble(Card cards[], int size) {
	bool flag = true;
	int i = 0;
	while (flag){
		flag = false;
		for (int j = size - 1; j > i; j--) {
			if (cards[j].value < cards[j - 1].value) {
				Card c = cards[j]; cards[j] = cards[j-1]; cards[j-1] = c;
				flag = true;
			}
		}
		i++;
	}
}

bool isStable(Card unknown[], Card stable[], int size) {
	for (int i = 0; i < size; i++) {
		if (unknown[i].suit != stable[i].suit) return false;
	}
	return true;
}


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

	Card* bubbleCards = new Card[N];    // Cards for BubbleSort
	Card* selectionCards = new Card[N]; // Cards for SelectionSort

	for (int i = 0; i < N; i++) {
		cin >> bubbleCards[i].suit >> bubbleCards[i].value;
	}

	for (int i = 0; i < N; i++) {
		selectionCards[i] = bubbleCards[i];
	}

	// sort
	bubble(bubbleCards, N);
	selection(selectionCards, N);

	// output
	print(bubbleCards, N);
	cout << "Stable" << endl;

	print(selectionCards, N);
	if (isStable(selectionCards, bubbleCards, N)) cout << "Stable" << endl;
	else cout << "Not stable" << endl;
}

Measured memory_bytes: 3088
char buf[1<<17],out[2<<17];
outsz=2<<17;
sz;
K;
main()
{
	int id=read(0,buf,1<<17)-2;
	while(buf[sz]>='0')++sz;
	++sz;
	for(;;)
	{
		int k=buf[sz++];
		if(k<'0')break;
		K=K*10+k-'0';
	}
	while(id>sz)
	{
		int nxt=-1;
		for(int j=id-sz<K?id-sz:K;j;--j)
		{
			if(~buf[id-j]&1)
			{
				nxt=id-j;
				do{
					out[--outsz]=j%10+'0';
				}while(j/=10);
				out[--outsz]=32;
				break;
			}
		}
		if(nxt<0)
		{
			puts("-1");
			return 0;
		}
		id=nxt;
	}
	write(1,out+outsz,(2<<17)-outsz);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

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

    int n, k, s;
    cin >> n >> k >> s;
    vector<int> a(n, 0);
    rep(i, k) a[i] = s;
    for (int i = k; i < n; i++)
    {
        if (s == 1000000000)
            a[i] = 1;
        else
            a[i] = 1000000000;
    }
    rep(i, n) cout << a[i] << " ";
    cout << endl;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=200002 ;
ll  power(ll  i,ll  j)
{
    if(j==0)
    return 1 ;
    ll t=power(i,j/2)%maa ;
    if(j%2==0)
    return (t%maa*t%maa)%maa ;
    else
    return ((t%maa*t%maa)%maa*(i%maa)%maa)%maa ;
}
int main()
{
   fast ;
   ll n,l ;
   cin>>n>>l ;
   vector<string>v ;
   for(ll i=0;i<n;i++)
   {
       string o ;
       cin>>o ;
       v.pb(o) ;
   }
   sort(all(v)) ;
   for(string s:v)
    cout<<s ;


}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		scan.nextLine();

		Dice[] dz = new Dice[n];
		for (int i = 0; i < n; i++) {
			String[] labeldata = scan.nextLine().split(" ");
			dz[i] = new Dice(labeldata);
		}

		loop:
		for (int i = 0; i < n; i++) {
			for (int j = i+1; j < n; j++) {
				if ( dicematch(dz[i], dz[j]) ) {
					System.out.println("No");
					break loop;
				}
			}
			if (i == n-2) {
				System.out.println("Yes");
				break loop;
			}
		}
	}

	static boolean dicematch(Dice d1, Dice d2) {
		int top;
		for (top = 0; top < 6; top++) {
			if ( d1.label[0].equals(d2.label[top]) ) break;
		}

		//System.out.println(top);

		switch (top) {
		case 0:
			break;
		case 1:
			d2.koroN();
			break;
		case 2:
			d2.koroW();
			break;
		case 3:
			d2.koroE();
			break;
		case 4:
			d2.koroS();
			break;
		case 5:
			d2.koroN().koroN();
			break;
		default:
			return false;
		}

		int front;
		for (front = 1; front <= 4; front++) {
			if ( d1.label[1].equals(d2.label[front]) ) break;
		}

		//System.out.println(front);

		switch (front) {
		case 1:
			break;
		case 2:
			d2.kaitenTokei();
			break;
		case 3:
			d2.kaitenHanTokei();
			break;
		case 4:
			d2.kaitenTokei().kaitenTokei();
			break;
		default:
			return false;
		}

		if ( d1.label[2].equals(d2.label[2]) &&
				d1.label[3].equals(d2.label[3]) &&
				d1.label[4].equals(d2.label[4]) &&
				d1.label[5].equals(d2.label[5]) ) {
			return true;
		} else {
			return false;
		}
	}
}

class Dice {
	String[] label;

	Dice(String[] labeldata) {
		label = new String[labeldata.length];

		for (int i = 0; i < labeldata.length; i++) {
			label[i] = labeldata[i];
		}
	}

	Dice koroN() {
		String temp;
		temp = label[0];
		label[0] = label[1];
		label[1] = label[5];
		label[5] = label[4];
		label[4] = temp;
		return this;
	}

	Dice koroS() {
		String temp;
		temp = label[0];
		label[0] = label[4];
		label[4] = label[5];
		label[5] = label[1];
		label[1] = temp;
		return this;
	}

	Dice koroE() {
		String temp;
		temp = label[0];
		label[0] = label[3];
		label[3] = label[5];
		label[5] = label[2];
		label[2] = temp;
		return this;
	}

	Dice koroW() {
		String temp;
		temp = label[0];
		label[0] = label[2];
		label[2] = label[5];
		label[5] = label[3];
		label[3] = temp;
		return this;
	}

	Dice kaitenTokei() {
		String temp;
		temp = label[1];
		label[1] = label[2];
		label[2] = label[4];
		label[4] = label[3];
		label[3] = temp;
		return this;
	}

	Dice kaitenHanTokei() {
		String temp;
		temp = label[1];
		label[1] = label[3];
		label[3] = label[4];
		label[4] = label[2];
		label[2] = temp;
		return this;
	}

}

Measured memory_bytes: 26852
#include <cstdio>
#include <algorithm>
using namespace std;
int n, m, c[1009], s[1000009];
int main() {
	while (scanf("%d%d", &n, &m), n) {
		for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
		int b = 0;
		for (int i = 0; i <= n; i++) {
			for (int j = i; j <= n; j++) {
				if (c[i] + c[j] <= m) s[b++] = c[i] + c[j];
			}
		}
		sort(s, s + b);
		int r = b - 1, ret = 0;
		for (int i = 0; i < b && i <= r; i++) {
			while (r > 0 && s[i] + s[r] > m) r--;
			ret = max(ret, s[i] + s[r]);
		}
		printf("%d\n", ret);
	}
	return 0;
}

Measured memory_bytes: 4600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Double_Helix
{
    class Program
    {
        static void Main(string[] args)
        {
            string bs = Console.ReadLine();
            string[] bs2 = new string[4] { "A", "T", "C", "G" };
            string ans = "";
            

            for (int n = 0; ans == ""; ++n)
            {
                if (bs == bs2[n])
                {
                    if(n == 1 || n == 3)
                    {
                        ans = bs2[n-1];
                    }
                    else
                    {
                        ans = bs2[n+1];
                    }
                }
            }
            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 13140
#include <stdio.h>

long gcd(long a, long b){
  if(a % b == 0) return b;
  else return gcd(b, a % b);
}

int main(void)
{
  int K;
  int a, b, c;
  scanf("%d", &K);
  long ans = 0;

  for(a = 1; a <= K; a++){
    for(b = 1; b <= K; b++){
      for(c = 1; c <= K; c++){
        ans += gcd(gcd(a, b), c);
      }
    }
  }
  printf("%ld\n", ans);
	return 0;
}


Measured memory_bytes: 1704
#include<stdio.h>
int search(int A[],int i,int j){
int k=0;
A[i]=j;
while(A[k]!=j)
k++;
return k!=i;
}

int main(void){
int i,j,k,l,A[100001],sum;
scanf("%d",&i);
for(k=0;k<i;k++)
scanf("%d",&A[k]);
scanf("%d",&l);
for(k=0;k<l;k++){
scanf("%d",&j);
if(search(A,i,j))
sum++;
}
printf("%d\n",sum);

return 0;
}

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

int main(){
  int N,lp = 0,count = 0;
  int d[100];int many[101];
  cin >> N;

  while (lp < 101){
    many[lp] = 0;//many配列の初期化
    lp ++;
  }

  lp = 0;
  while (lp < N){
    cin >> d[lp];//入力処理
    lp ++;
  }

  lp = 0;
  while (lp < N){
    many[d[lp]]++;//分別
    lp ++;
  }

  lp = 0;
  while (lp <= 100){
    if (many[lp] != 0){
      //分別してそれぞれの数字の数が０で無かったらインクリメント
        count ++;
    }
    lp++;
  }

  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(1e9 + 7)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////
const int N = 5005;

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);
	
	int n;
	cin >> n;

	vector<int> a(n),b(n),c(n-1);

	rep(i,n) {
		cin >> a[i];
		a[i]--;
	}
	rep(i,n) cin >> b[i];
	rep(i,n-1) cin >> c[i];

	int sum = 0;
	rep(i,n) {
		if(i > 0 and a[i] == a[i-1]+1)
			sum += c[a[i-1]];
		sum += b[a[i]];
	}
	cout << sum << '\n';
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.algorithm;

void main()
{
  auto n=map!(to!int)(readln.strip.split);
  int cnt = 0;
  for(int i = n[0];i<=n[1];i++)
      if(n[2] % i == 0)
          cnt++;
  writeln(cnt);
}

Measured memory_bytes: 2456
#include <cstdio>

class Dice{
    private:
        int t, b, n, e, s, w;
    public:
        void roll(char d);
        void showTop(){printf("%d\n", t);}
        Dice(int t, int s, int e, int w, int n, int b) : t(t), s(s), e(e), w(w), n(n), b(b) {}
};

void Dice::roll(char d){
    int tmp = 0;
    if (d == 'S') {
        tmp = s;
        s = t;
        t = n;
        n = b;
        b = tmp;
    }else if (d == 'E') {
        tmp = e;
        e = t;
        t = w;
        w = b;
        b = tmp;
    }else if (d == 'N') {
        tmp = n;
        n = t;
        t = s;
        s = b;
        b = tmp;
    }else{
        tmp = w;
        w = t;
        t = e;
        e = b;
        b = tmp;
    }
}

int main(){
    int a, b, c, d, e, f;
    scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);
    Dice dice(a, b, c, d, e, f);
    char s[200];
    scanf("%s", s);
    for(int i = 0; s[i] != '\0'; i++){
        dice.roll(s[i]);
    }
    dice.showTop();
    return 0;
}


Measured memory_bytes: 2756
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
int main(){
  int k,a,b;
  cin >> k >> a >> b;
  REP(i,a,b + 1){
    if(i % k == 0){
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
  return 0;
}


Measured memory_bytes: 3544
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,m = list(map(int, input().split()))
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))
vx = 0
vy = 0
M  = 10**9+7
for i in range(n-1):
    vx += (xs[i+1]-xs[i]) * (i+1) * (n-i-1)
    vx %= M
for i in range(m-1):
    vy += (ys[i+1]-ys[i]) * (i+1) * (m-i-1)
    vy %= M
ans = (vx*vy)%M
print(ans%M)

Measured memory_bytes: 97816
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K,i;
  cin>>N>>K;
  int ans=0;

  int a[N];
  for (i=0;i<N;i++)cin>>a[i];
  sort(a,a+N);
  reverse(a,a+N);
  
  for (i=0;i<K;i++){
    ans += a[i];
  }
  cout << ans << endl;
}

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

int main() {
  int K, A, B;

  cin >> K;
  cin >> A >> B;
  for (int i = A; i <= B; ++i) {
    if (i % K == 0) {
      cout << "OK";
      return 0;
    }
  }
  cout << "NG";
}

Measured memory_bytes: 3640
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

void solve(){
    ll N,K;
    cin >> N >> K;
    double A[200010];
    rep(i,0,N) cin >> A[i];
    double lv = 0.0, rv = 1e10;
    rep(iter,0,100){
        double mid = (lv + rv) / 2.0;
        // print(mid);
        ll cnt = 0;
        rep(i,0,N){
            ll v = round(ceil(A[i] / mid));
            // print(mid,A[i],v);
            cnt += v-1;
        }
        // print(mid, cnt);
        if(cnt > K){
            lv = mid;
        }else{
            rv = mid;
        }
    }
    ll ans = round(ceil(rv));
    print(ans);

    

}

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

Measured memory_bytes: 5284
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
int main() {
  ll n,a,b[214514];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    b[i]=a-i-1;
  }
  sort(b,b+n);
  ll ans=0;
  if(n==1)ans=0;
  else if(n%2){
    ll x=n/2;
    ll num1=0,num2=0;
    for(int i=0;i<n;i++)num1+=abs(b[i]-b[x]);
    x++;
    for(int i=0;i<n;i++)num2+=abs(b[i]-b[x]);
    ans=min(num1,num2);
  }else{
    ll x=n/2;
    for(int i=0;i<n;i++)ans+=abs(b[i]-b[x]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

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;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int mod_pow(int x,int y,int m=mod){
	int res=1;
	while(y>0){
		if(y&1)(res*=x)%=m;
		(x*=x)%=m;
		y>>=1;
	}
	return res;
}
vector<int>perm,inv;
void init_perm(){
	int x=1e6+1;perm.resize(x);inv.resize(x);
	perm[0]=1;
	REP(i,x+1)perm[i]=perm[i-1]*i%mod;
	inv[x]=mod_pow(perm[x],mod-2);
	for(int i=x-1;i>=0;i--){
		inv[i]=inv[i+1]*(i+1)%mod;
	}
}
int nCk(int x,int y){
	if(x<y)return 0;
	return perm[x]*inv[x-y]%mod*inv[y]%mod;
}
int N,A,B,C,D;
int dp[1005][1005];
signed main(){
	init_perm();
	cin>>N>>A>>B>>C>>D;
	dp[0][A]=1;
	rep(i,N){
		for(int j=A;j<=B;j++){
			(dp[i][j+1]+=dp[i][j])%=mod;
			int now=1,rem=N-i;
			for(int k=1;k<=D&&i+j*k<=N;k++){
				(now*=nCk(rem,j))%=mod;rem-=j;
				if(C<=k)(dp[i+k*j][j+1]+=dp[i][j]*now%mod*inv[k]%mod)%=mod;
			}
		}
	}
	int ans=0;
	rep(i,N+2)(ans+=dp[N][i])%=mod;
	cout<<ans<<endl;
}


Measured memory_bytes: 23680
-- https://github.com/minoki/my-atcoder-solutions
import Data.Char (isSpace)
import Data.Int (Int64)
import Data.List (unfoldr)
import qualified Data.ByteString.Char8 as BS

main = do
  [n,k] <- map fromIntegral . unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  print (sum [ m * n - m * (m - 1) + 1 | m <- [k..n+1] ] `mod` (10^9+7) :: Int64)


Measured memory_bytes: 4752
#include <iostream>
#include<algorithm>
#include<vector>
#include<numeric>
using namespace std;

int main() {
	int d;cin>>d;
	long long g;cin>>g;
	long long p[d],c[d];
	for(int i=0;i<d;i++){
		cin>>p[i]>>c[i];
	}
	vector<int> v(d);
	iota(v.begin(),v.end(),0);
	int ans=1000;
	long long point=0;
	do{
		int ans2=0;
		point=0;
//		for(int i=0;i<d;i++){
//			cout<<v[i];
//		}
//		cout<<endl;
		for(int i=0;i<d;i++){
			if(point+p[v[i]]*100*(v[i]+1)<g){
				ans2+=p[v[i]];
				point+=p[v[i]]*100*(v[i]+1);
				point+=c[v[i]];

			}else{
				ans2+=(g-point-1)/(v[i]+1)/100+1;
				point=g;
			}
//			cout<<point<<endl;
			if(point>=g)break;
		}
//		cout<<ans2<<endl;
		if(ans2<ans)ans=ans2;
	}while(next_permutation(v.begin(),v.end()));
	cout<<ans<<endl;

//	int num=1;
//	for(int i=0;i<d;i++){
//		num*=i+1;
//	}
//	for(int i=0;i<num;i++){
//		int tempi=i;
//		for(int j=d;j>0;j--){
//			int k=tempi%d;
//			tempi/=d;
//
//		}
//	}
//	cout<<num<<endl;
	return 0;
}

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

int main(){
  int X;
  cin >> X;
  if((X>=400)&&(X<=599)){
    cout << 8 << endl;
  }else if((X>=600)&&(X<=799)){
    cout << 7 << endl;
  }else if((X>=800)&&(X<=999)){
    cout << 6 << endl;
  }else if((X>=1000)&&(X<=1199)){
    cout << 5 << endl;
  }else if((X>=1200)&&(X<=1399)){
    cout << 4 << endl;
  }else if((X>=1400)&&(X<=1599)){
    cout << 3 << endl;
  }else if((X>=1600)&&(X<=1799)){
    cout << 2 << endl;
  }else{
    cout << 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 3552
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>



using namespace std;
int main() {
    int h;
    cin >> h;


    int n;
    cin>>n;

    int a[n];

  //  vector<int> a(n);
    //cin>>a;



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

    }

    if (M >= h) {
        cout <<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;

    }

    return 0;

}



Measured memory_bytes: 640
var
	s:Array[0..9]of String;
	H,W,K,i,j,l,z,now,id,ans:Longint;
	cnt:Array[0..14]of Longint;
	out,take:Boolean;
begin
	readln(H,W,K);
	for i:=0 to H-1 do readln(s[i]);
	ans:=1000000000;
	for z:=0 to (1<<(H-1))-1 do begin
		for j:=0 to 14 do cnt[j]:=0;
		now:=0;
		for j:=0 to H-1 do if ((z>>j)and 1)=1 then inc(now);
		out:=False;
		for j:=0 to W-1 do begin
			id:=0;
			take:=False;
			for l:=0 to H-1 do begin
				if s[l][j+1]='1'then inc(cnt[id]);
				if cnt[id]>K then take:=True;
				if ((z>>l)and 1)=1 then inc(id);
			end;
			if take then begin
				inc(now);
				for l:=0 to id do cnt[l]:=0;
				id:=0;
				for l:=0 to H-1 do begin
					if s[l][j+1]='1'then inc(cnt[id]);
					if cnt[id]>K then out:=True;
					if((z>>l)and 1)=1 then inc(id);
				end;
			end;
		end;
		if(not out)and(ans>now)then ans:=now;
	end;
	writeln(ans);
end.


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>
#include<cassert>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = INF+7;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define rep(i,n) FOR(i,0,n)

struct edge{int to,cost;};

void dump_line(int *b,int n){
	for(int i=0;i<n;i++){
		cout << b[i] << " ";
	}
	cout << "\n";
}

ll mypow(ll x,ll n){
	if(n==0) return 1;
	ll res=mypow(x*x,n/2);
	if(n&1) res=res*x;
	return res;
}

ll mod_pow(ll x,ll n,ll mod){
	if(n==0) return 1;
	ll res=mod_pow(x*x%mod,n/2,mod);
	if(n&1) res=res*x%mod;
	return res;
}

bool notprime[101];
int divs[101];


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

	string s;
	cin >> s;

	ll ans=0;
	ll n=0;
	rep(i,s.size()){
		if(s[i] == 'B') n++;
		else			ans+=n;
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 720
#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)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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;
}

template<typename T>
struct TreeDiameter{
    vector<T> dp;
    vector<vector<pair<int,T>>> G;
    TreeDiameter(int n):dp(n),G(n){}
    void add_edge(int u,int v,T c){
        G[u].emplace_back(v,c);
        G[v].emplace_back(u,c);
    }
    void dfs(int v,int p,int &s){
        if (p<0) dp[v]=T(0);
        if (dp[s]<dp[v]) s=v;
        for (auto e:G[v]){
            int u=e.first;
            if (u==p) continue;
            dp[u]=dp[v]+e.second;
            dfs(u,v,s);
        }
    }
    Pii endPoints(){
        int s=0;
        dfs(s,-1,s);
        int t=s;
        dfs(t,-1,t);
        return Pii{s,t};
    }
    T build(){
        int t=endPoints().second;
        return dp[t];
    }
    vector<T> distance(int v){
        dfs(v,-1,v);
        return dp;
    }
    vector<T> farthest(){
        int t=endPoints().second;
        auto ds=dp;
        auto dt=distance(t);
        rep(i,ds.size()) chmax(ds[i],dt[i]);
        return ds;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    TreeDiameter<int> TD(N);
    rep(i,N-1){
        int a,b; cin >> a >> b;
        TD.add_edge(--a,--b,1);
    }
    int d=TD.build();
    if (d%3!=1) cout << "First" << endl;
    else cout << "Second" << endl;
}

Measured memory_bytes: 18560
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

		int X = sc.nextInt();

		if(X == 7 || X == 5 || X == 3){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
vector<pair<ll,ll>> prime_factorize(ll n){
    vector<pair<ll,ll>> res;
    for(ll p=2;p*p<=n;p++){
        if(n%p!=0) continue;
        int num=0;
        while(n%p==0){
            num++;
            n/=p;
        }
        res.push_back(make_pair(p,num));
    }
    if(n!=1) res.push_back(make_pair(n,1));
    return res;
}

const int MAX=210000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0 || k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int main(void){
    int N,M;
    COMinit();
    cin>>N>>M;
    auto vec=prime_factorize(M);
    ll res=1;
    for(auto pa : vec){
        int num=pa.second;
        ll tmp=COM(num+N-1,N-1);
        res=(res*tmp)%MOD;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 5120
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    long long a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    long long ans = 1LL;
    for(int i = 0; i < n; i++){
        if(a[i] > 1000000000000000000LL/ans){
            cout << -1 << endl;
            return 0;
        }
        ans *= a[i];
    }

    if (ans > 1000000000000000000LL){
        cout << -1 << endl;
    }else {
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 4344
//
// Created by 26019 on 2020/6/14/014.
//

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    n %= 26;
    for (char &i : s) {
        char &i1 = i;
        i1 += n;
        if (i1 > 90) {
            i1 -= 26;
        }
        i = i1;
    }
    cout << s;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
a = [''] * h
for i in range(h):
	a[i] = input()
 
row = [False] * h
col = [False] * w
for i in range(h):
	for j in range(w):
		if a[i][j] == '#':
			row[i] = True
			col[j] = True
 
for i in range(h):
	if row[i]:
		for j in range(w):
			if col[j]:
				print(a[i][j], end = '')
		print()

Measured memory_bytes: 9144
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    float c=0.0;
    vector<float> v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
   sort(v.begin(),v.end());
   c=v[0];
   for(int i=1;i<n;i++)
   {
       c=(c+v[i])/2.0;
   }
   cout<<c<<endl;
}

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

using namespace std;

using i32 = int32_t;
using u32 = uint32_t;
using f32 = float;
using f64 = double;
using i64 = int64_t; 
using u64 = uint64_t; 

#define SELECTER(_1, _2, _3, _4, _5, _6, _7, _8, SELECT, ...) SELECT

#define _FC1(func, type, _1)      func(type, _1) 
#define _FC2(func, type, _1, ...) func(type, _1); _FC1(func, type, __VA_ARGS__)
#define _FC3(func, type, _1, ...) func(type, _1); _FC2(func, type, __VA_ARGS__) 
#define _FC4(func, type, _1, ...) func(type, _1); _FC3(func, type, __VA_ARGS__)
#define _FC5(func, type, _1, ...) func(type, _1); _FC4(func, type, __VA_ARGS__)
#define _FC6(func, type, _1, ...) func(type, _1); _FC5(func, type, __VA_ARGS__)
#define _FC7(func, type, _1, ...) func(type, _1); _FC6(func, type, __VA_ARGS__)
#define _FC8(func, type, _1, ...) func(type, _1); _FC7(func, type, __VA_ARGS__)

#define _FCN(func, type, ...) SELECTER(__VA_ARGS__, _FC8, _FC7, _FC6, _FC5, _FC4, _FC3, _FC2, _FC1)(func, type, __VA_ARGS__)

constexpr const char *type2fmt(const char *fmt) {
  if(strcmp(fmt, "i32") == 0) return "%d";
  if(strcmp(fmt, "u32") == 0) return "%u";
  if(strcmp(fmt, "f32") == 0) return "%f";
  if(strcmp(fmt, "f64") == 0) return "%lf";
  if(strcmp(fmt, "i64") == 0) return "%lld";
  if(strcmp(fmt, "u64") == 0) return "%llu";
  return "";
}

#define _R(type, _1) type _1; { type _t; scanf(type2fmt(#type), &_t); _1 = _t; }
#define _P(type, _1) { const type _t = (_1); printf(type2fmt(#type), _t); putchar('\n'); }

#define RI(...)   _FCN(_R, i32, __VA_ARGS__)
#define RUI(...)  _FCN(_R, u32, __VA_ARGS__)
#define RF(...)   _FCN(_R, f32, __VA_ARGS__)
#define RD(...)   _FCN(_R, f64, __VA_ARGS__)
#define RLL(...)  _FCN(_R, i64, __VA_ARGS__)
#define RULL(...) _FCN(_R, u64, __VA_ARGS__)

#define PI(...)   _FCN(_P, i32, __VA_ARGS__)
#define PUI(...)  _FCN(_P, u32, __VA_ARGS__)
#define PF(...)   _FCN(_P, f32, __VA_ARGS__)
#define PD(...)   _FCN(_P, f64, __VA_ARGS__)
#define PLL(...)  _FCN(_P, i64, __VA_ARGS__)
#define PULL(...) _FCN(_P, u64, __VA_ARGS__)

#define REP(n) for (int _i = 0; _i < n; _i++)

const u64 mod = 1000000007;

u64 arr[200000];

int main() {
  RULL(N, M);
  vector<pair<u64, u64>> v;
  REP(N) { RULL(A, B); v.push_back(make_pair(A, B)); }

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

  u64 t = 0;
  for (auto &p : v) {
    u64 A = p.first, B = p.second;
    t += min(B, M) * A;
    M -= min(B, M);
    if (M == 0) break;
  }

  PULL(t);
}


Measured memory_bytes: 2420