akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	vector<UL> Solve2(UL N, UL B) {
		if (N == 1) {
			if ((B & 1) == 0) return {};
			else return { 0, 1 };
		}
		vector<UL> ans;
		if ((B & (1 << (N - 1))) == 0) {
			vector<UL> buf1 = Solve2(N - 1, B);
			UL L = buf1.size(); if (!L) return {};
			vector<UL> buf2 = Solve2(N - 1, buf1[1]);
			ans.push_back(buf1[0]);
			rep(i, buf2.size()) ans.push_back(buf2[i] ^ (1 << (N - 1)));
			rep(i, L - 1) ans.push_back(buf1[i + 1]);
		}
		else {
			vector<UL> buf1 = Solve2(N - 1, 1);
			UL f = buf1[1];
			vector<UL> buf2 = Solve2(N - 1, B ^ (1 << (N - 1)) ^ 1);
			UL L = buf2.size(); if (!L) return {};
			rep(i, L) buf2[i] |= (1 << (N - 1));
			rep(i, L) buf2[i] ^= 1;
			rep(i, L) buf1.push_back(buf2[i]);
			ans = move(buf1);
		}
		return move(ans);
	}

	void Solve() {
		UL N, A, B; cin >> N >> A >> B;
		vector<UL> ans = Solve2(N, A^B);
		bool ok = true;
		if (ans.size() == 0) { cout << "NO" << endl; return; }

		rep(i, ans.size()) ans[i] ^= A;
		cout << "YES" << endl;
		rep(i, ans.size()) { if (i) cout << " "; cout << ans[i]; }
		cout << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

Measured memory_bytes: 2064
a,b,c = gets.chomp.split.map(&:to_f)
s = Math.sin(c / 180 * Math::PI) * a * b / 2
l = a + b + Math.sqrt(a**2 + b**2 -2*a*b*Math.cos(c / 180 * Math::PI))
h = Math.sin(c / 180 * Math::PI) * b

puts s,l,h


Measured memory_bytes: 6960
<?php

while (true) {
    fscanf(STDIN, '%d %d', $H, $W);
    if (!($H || $W)) { break; }

    $rects[] = draw($H, $W);
}

echo implode(PHP_EOL, $rects), PHP_EOL;

function draw($H, $W)
{
    $edge = sprintf('%s%s', str_repeat('#', $W), PHP_EOL);
    $mid  = sprintf('%s%s', '#' . str_repeat('.', $W - 2) . '#', PHP_EOL);

    return $edge . str_repeat($mid, $H - 2) . $edge;
}

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

int main() {
	int n, m;
	cin >> n >> m;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	vector<pair<ll, int>> b(m);
	rep(i, m) {
		int p, q;
		cin >> p >> q;
		b[i] = {q, p};
	}
	sort(all(a));
	sort(all(b));
	reverse(all(b));
	int p = 0;
	rep(i, m) {
		ll now = b[i].first;
		int num = b[i].second;
		while(1) {
			if(a[p] > now) break;
			if(num <= 0) break;
			a[p] = now;
			num--;
			p++;
		}
	}
	ll ans = 0;
	rep(i, n) ans += a[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll solve (vector<ll> &a, ll i, ll n, vector<ll> &dp,ll k)
{
    if (i == n)
    {
        return 0;
    }

    if (dp[i] != -1)
    {
        return dp[i];
    }

    //logic
    int ans=INT_MAX;int temp=INT_MAX;
    for(int j=1;j<=k;j++){
        if(i+j<=n){
         temp=abs(a[i]-a[i+j])+solve(a,i+j,n,dp,k);
        }
         ans=min(temp,ans);

    }
    dp[i]=ans;

   /*) for(int i=1;i<=n;i++){
        cout<<dp[i]<<" ";
    }
    cout<<endl<<"*********************************"<<endl;*/
//cout<<c1<<" "<<c2<<endl;
    return dp[i];
}
ll solve2 (vector<ll> a, int n)
{
    vector<ll> dp (n + 1);
    dp[n] = 0;

    for (int i = n - 1; i >= 1; i--)
    {
        int c1 = INT_MAX;
        int c2 = INT_MAX;

        if (i + 1 <= n)
        {
            c1 = abs (a[i + 1] - a[i]) + dp[i + 1];
        }

        if (i + 2 <= n)
        {
            c2 = abs (a[i + 2] - a[i]) + dp[i + 2];
        }

        dp[i] = min (c1, c2);
    }

    return dp[1];
}
int main()
{
    ll n,k;
    cin >> n>>k;
    vector<ll> a (n + 1);


    for (int i = 1; i <= n; i++)
    {

        cin >> a[i];
    }
    // if(k>=n){
    //     k=n-1;
    //     //cout<<"hey"<<endl;
    // }

    vector<ll> dp(n+1,-1);
    cout<<solve(a,1,n,dp,k)<<endl;
    //cout << solve2 (a, n) << endl;

    return 0;
}


Measured memory_bytes: 14080
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <unordered_map>


using namespace std;

int main()
{
  char s[55];
  scanf("%s",s);
  string ss(s);
  cout<<ss.substr(0,ss.length()-8);
  return 0;
}

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

using namespace std;

#define loopinc(i, a, b, inc) for(int i = a; i < (b); i += inc)
#define loop(i, a, b) for(int i = a; i < (b); i++)
#define rep(i, n) loop(i, 0, n)
#define endl "\n"
#define all(c) (c).begin(),(c).end()
typedef long long ll;
#define lloopinc(i, a, b, inc) for(ll i = a; i < (b); i += inc)
#define lloop(i, a, b) for(ll i = a; i < (b); i++)
#define lrep(i, n) lloop(i, 0, n)
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tuple<int, int, int> tiii;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main() {
	// freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	
	ll n, m;
	cin >> n >> m;
	string s, t;
	cin >> s >> t;

	ll l = n*m/__gcd(n, m);

	rep(i, m) {
		ll j = i*l/m;
		if (j % (l/n) == 0 and s[j/(l/n)] != t[i]) {
			l = -1;
			break;
		}
	}
	cout << l << endl;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>

int main(void){
	int a , b ,C;
	double L,S,h;
	scanf("%d %d %d",&a,&b,&C);

	h=(double)b*sin((double)C/180*3.1415926535);
	S=(double)a*h/2;
	L=(double)a+(double)b+sqrt((double)(a*a)+(double)(b*b)-(double)(2*a*b)*cos((double)C/180*3.1415926535));
	printf("%lf\n",S);
	printf("%lf\n",L);
	printf("%lf\n",h);


	return 0;
}

Measured memory_bytes: 636
import sys

def solve():
    input = sys.stdin.readline
    N, X = map(int, input().split())
    L = [int(l) for l in input().split()]
    count = 1
    now = 0
    for i, l in enumerate(L):
        now += l
        if now <= X: count += 1
    print(count)


    return 0

if __name__ == "__main__":
    solve()

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

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define ll long long
#define pii pair<int, int>
#define is insert
#define er erase

using namespace std;

int solve();

#define TASK ""

int main()
{
    #ifdef DEBUG
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
        //freopen(TASK".in", "r", stdin);
        //freopen(TASK".out", "w", stdout);
    #endif // DEBUG
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

string s;

ll cnt = 0;
ll ans = 0;

int solve()
{
    cin >> s;
    for (char it : s)
    {
        if (it == 'B')
        {
            cnt++;
        }
        else
        {
            ans += cnt;
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 720
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
using namespace std;

void print_output(int* in, int N)
{
    for (int i = 0; i < N; i++)
    {
        if (i != 0)
        {
            cout << " ";
        }
        cout << in[i];
    }
    cout << endl;
}

void swap(int& a, int& b)
{
    int tmp = a;
    a = b;
    b = tmp;
}

int main()
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    std::ifstream in("in.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;

    int A[100];
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    int cnt = 0;

    for (int i = 0; i < N; i++)
    {
        for (int j = N-1; j > i; j--)
        {
            if (A[j] < A[j-1])
            {
                swap(A[j], A[j-1]);
                cnt++;
            }
        }
    }

    print_output(A, N);

    cout << cnt << endl;


    return 0;
}



Measured memory_bytes: 3108
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int Q, H, S, D;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> Q >> H >> S >> D;
  int N;
  cin >> N;
  int one = min({4*Q, 2*H, S});
  long long sum = 0;
  if (N%2 == 1) {
    sum += one;
    N--;
  }
  sum += 1LL * min(one*2, D) * (N/2);
  cout << sum << "\n";
  return 0;
}


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

int main()
{
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    F(n) cin >> h[i];
    sort(h.begin(),h.end());
    int min=pow(10,9)+1;
    F(n-k+1){
        if(h[i+k-1]-h[i]<min) min = h[i+k-1]-h[i];
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define pa cout << ans << endl
#define p(x) cout << x << endl
#define pall(x) for(auto iter : x) p(iter)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define yn(x) cout << (x ? "Yes" : "No") << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int MOD = 1000000007;
const int INF = 2000000000;
const long double PI = acosl(-1);
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}
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; }

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int N;
    cin >> N;
    VPII a;
    vector<int> X(N), L(N);
    REP (i, N) {
        cin >> X[i] >> L[i];
        a.PB({X[i]+L[i],X[i]-L[i]});
    }
    SORT(a);
    int M = -INF, ans = 0;
    REP(i,N) {
        if (a[i].second >= M) {
            ans++;
            M = a[i].first;
        }
    }

    pa;


    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/keyence2020/keyence2020_b && sh test.sh
cd ~/Desktop/Programming/AtCoder/contest/keyence2020/keyence2020_b && sh etest.sh
cd ~/Desktop/Programming/AtCoder/contest/keyence2020/keyence2020_b && sh submit.sh
*/


Measured memory_bytes: 3956
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

struct stones{
  int col;
  int num;
  struct stones *next;
};

int main(){
  int n;
  while(n = getInt()){
    stones *st = NULL;
    REP(i,n){
      int col = getInt();
      if(i % 2 == 0 || st->col == col){
	if(st == NULL || st->col != col){
	  stones *tmp = (stones *)malloc(sizeof(stones));
	  tmp->col = col;
	  tmp->num = 1;
	  tmp->next = st;
	  st = tmp;
	}else{
	  st->num++;
	}
      }else{
	stones *tmp = st;
	st = tmp->next;
	if(st == NULL){
	  st = tmp;
	  st->col = col;
	  st->num++;
	}else{
	  st->num += 1 + tmp->num;
	  free(tmp);
	}
      }

      /*
      {
	stones *tmp = st;
	while(tmp != NULL){
	  REP(i, tmp->num){
	    putchar(tmp->col == 0 ? 'W' : 'B');
	  }
	    putchar(' ');
	  tmp = tmp->next;
	}
	puts("");
      }
      */
    }
    int ans = 0;
    while(st != NULL){
      stones *tmp = st;
      if(st->col == 0)
	ans += st->num;
      st = tmp->next;
      free(tmp);
    }

    print(ans);
  }

  return 0;
}

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

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

  int n, m; cin >> n >> m;
  vector<int> vec(100010);

  rep(i, m) {
    int l, r; cin >> l >> r;
    --l, --r;
    vec[l]++, vec[r+1]--;
  }
  rep(i, n-1) {
    vec[i+1] += vec[i];
  }
  int ans = 0;
  rep(i, n) {
    if(vec[i] == m) ans++;
  }
  
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 640
""" D
    https://atcoder.jp/contests/abc173/tasks/abc173_d
"""
import sys
import math
from functools import reduce
from bisect import bisect_left

def readString():
    return sys.stdin.readline()

def readInteger():
    return int(readString())

def readStringSet(n):
    return sys.stdin.readline().split(" ")[:n]

def readIntegerSet(n):
    return list(map(int, readStringSet(n)))

def readIntegerMatrix(n, m):
    return reduce(lambda acc, _: acc + [readIntegerSet(m)], range(0, n), [])

def main(N, A):
    A.sort(reverse=True)

    sum = A[0]
    for i in range(1, N-1):
        sum += A[int((i-1)/2)+1]

    return sum

if __name__ == "__main__":
    _N = readInteger()
    _A = readIntegerSet(_N)

    print(main(_N, _A))

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

const int addn = 8005;

int x[2*addn][2];
int y[2*addn][2];

vector<int> vx;
vector<int> vy;

string s;
int main()
{
    int t = 0;
    int tx,ty;
    cin >> s >> tx >> ty;
    int sz = s.size();
    int cnt = 0;

    int first = 1;

    _for(i,0,sz){
        if(s[i] == 'F'){
            cnt++;
        }
        else{
            if(cnt){
                if(t%2) vy.push_back(cnt);
                else{
                    if(first) vx.push_back(-cnt);
                    else vx.push_back(cnt);
                }
            }
            cnt = 0;
            t^=1;
            first = 0;
        }
    }

    if(cnt){
        if(t%2) vy.push_back(cnt);
        else{
            if(first) vx.push_back(-cnt);
            else vx.push_back(cnt);
        }

    }


    int szx = vx.size();
    int szy = vy.size();
    x[addn][0] = 1;
    y[addn][0] = 1;


    t = 0;
    _for(i,0,szx){
        int d = vx[i];
        //cout << d << endl;
        _for(j,0,2*addn){
            x[j][t^1] = 0;
        }
        if(d > 0){
            _for(j,0,2*addn){
                if(x[j][t]) x[j-d][t^1] = (x[j+d][t^1] = 1);
            }
        }
        else{
            _for(j,0,2*addn){
                if(x[j][t]) x[j-d][t^1] = 1;
            }
        }

        t = t^1;
    }
    if(!x[tx+addn][t]){printf("No\n");return 0;}

    t = 0;
     _for(i,0,szy){
        int d = vy[i];
        //cout << d << endl;
        _for(j,0,2*addn){
            y[j][t^1] = 0;
        }
        _for(j,0,2*addn){
            if(y[j][t]) y[j-d][t^1] = (y[j+d][t^1] = 1);
        }
        t = t^1;
    }
    if(!y[ty+addn][t]){printf("No\n");return 0;}

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


Measured memory_bytes: 512
#include<stdio.h>

int main(void)
{
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	(((-100<=x)&&(x<=100))&&((y>=-100)&&(y<=100)));
	(((0<W)&&(W>100))&&((0<H)&&(H<100))&&((0<r)&&(r<100)));
	if(((x+r) > W)||((x+r) <= 0))
	{
		printf("No\n");
	}
	else
	{
		if(((y+r) >H)||((y+r) <= 0))
		{
		printf("No\n");
		}	
	else
	{
		printf("Yes\n");
	}
	}
	
	return 0;
}

Measured memory_bytes: 580
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    string S; cin >> S;
    int K; cin >> K;
    
    set<string> st;
    int N = S.size();
    FOR(i,0,N) {
        FOR(j,i,N) {
            if (j - i + 1 > K) break;
            st.insert(S.substr(i, j - i + 1));
        }
    }

    vs v;
    for (string s : st) v.push_back(s);
    sort(v.begin(), v.end());

    string ans = v[K-1];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1920
#include<stdio.h>

int main(void)
{
	int m,n;
	int i,j,k,l,ll;
	int a[100][100]={0};
	int b[100]={0};
	int c;

	
	scanf("%d %d",&m,&n);

	for(i=0;i<m;i++){
		for(j=0;j<n;j++){
			scanf("%d",&a[i][j]);
		}
	}
	
	for(k=0;k<n;k++){
		scanf("%d",&b[k]);
	}

	for(l=0;l<m;l++){
		c=0;
		for(ll=0;ll<n;ll++){
			c= c +a[l][ll]*b[ll];
		}
	printf("%d\n",c);
	}
	return 0;
}
	

Measured memory_bytes: 648
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

const int MAX_N = 18;
int n;
int a[MAX_N], b[MAX_N];

vec<pii> altput(vec<pii>& odds, vec<pii>& evnes) {
    int i = 0, j = 0;
    vec<pii> ans;
    forn(k, odds.size() + evnes.size()) {
        if (k % 2 == 0) {
            ans.push_back(odds[i]);
            i++;
        } else {
            ans.push_back(evnes[j]);
            j++;
        }
    }
    return ans;
}

int cnt(vec<pii>& v) {
    vi l(n);
    iota(l.begin(), l.end(), 0);
    int c = 0;
    for (int i = 0; i < n; i++) {
        int x = v[i].snd;
        auto idx = find(l.begin(), l.end(), x) - l.begin();
        for (int j = idx - 1; j >= i; j--) {
            swap(l[j + 1], l[j]);
            c++;
        }
    }
    return c;
}

int main() {
    fastio();

    cin >> n;
    forn(i, n) cin >> a[i];
    forn(i, n) cin >> b[i];

    int c = 1000000;
    bool found = false;
    for (int p = 0; p < (1 << n); p++) {
        vec<pii> odds, evnes;
        int c1 = 0, c2 = 0;
        forn(i, n) {
            if ((p >> i) & 1) {
                odds.emplace_back(i % 2 == 0 ? a[i] : b[i], i);
                c1 += i % 2 == 1;
            } else {
                evnes.emplace_back(i % 2 == 0 ? b[i] : a[i], i);
                c2 += i % 2 == 0;
            }
        }

        if (c1 != c2) continue;

        sort(all(odds));
        sort(all(evnes));

        auto comp = [](pii a, pii b) { return a.fst < b.fst; };

        if (odds.size() == evnes.size() || odds.size() == evnes.size() + 1) {
            vec<pii> v = altput(odds, evnes);
            if (is_sorted(v.begin(), v.end(), comp)) {
                int k = cnt(v);
                if (k < c) {
                    c = k;
                    found = true;
                }
            }
        }
    }

    if (found) {
        cout << c << '\n';
    } else {
        cout << -1 << '\n';
    }

    return 0;
}

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

int main()
{
    int a = 0, b = 0, i = 0, j = 0, x = 1, y = 0, total = 0;
    cin >> a >> b;
    for(i = 1; i <= 999; i++)
    {
        total += x;
        if(total - a == total + x + 1 - b)
        {
            total -= a;
            cout << total;
            break;
        }
        x++;
    }




return 0;
}


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

#define F                      first
#define S                      second
#define pb                      push_back
#define endl                    '\n'
#define all(x)                  x.begin(),x.end()
#define pii                     pair<int,int>
#define pll                     pair< long long int, long long int> 
#define fast                    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define SZ(x)                   ((int)x.size())

#define FOR(i,a,b)              for(int i = a; i < b; ++i)
#define REV(i,a,b)              for(int i = a; i >= b; --i)
#define FORE(i,a,b)             for(int i = a; i <= b; ++i)

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve();

int main()
{
        fast;
        solve();
}

const int N = 3000+2;
int dp[N][N];

void solve() {
        string s,t;
        cin >> s >> t;
        memset(dp,0,sizeof(dp));
        FOR(i,1,SZ(s)+1) {
                FOR(j,1,SZ(t)+1) {
                        if(s[i-1] == t[j-1]) {
                                dp[i][j] = max(dp[i][j], 1 + dp[i-1][j-1]);
                        }
                        else {
                                dp[i][j] = max(dp[i][j], dp[i-1][j]);
                                dp[i][j] = max(dp[i][j], dp[i][j-1]);
                        }
                }
        }

        string ans = "";
        int x = SZ(s);
        int y = SZ(t);

        while(x > 0 and y > 0) {
                if(s[x-1] == t[y-1]) {
                        ans.pb(s[x-1]);
                        x--;
                        y--;
                }
                else if(dp[x-1][y] > dp[x][y-1]) {
                        x--;
                }
                else {
                        y--;
                }
        }
        reverse(all(ans));
        cout << ans << endl;
}

Measured memory_bytes: 35584
#include<bits/stdc++.h>
#define ll long long int
#define mi map<int,int>
#define mcr map<char,int>
using namespace std;

int main()
{
    ll n, a, b, d, ans = 0;
    cin >> n;
    for(ll i = 1; i <= n; i++){
            cin >> a;
        if(i % 2 == 1 && a % 2 == 1){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

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

        int m = scan.nextInt();
        int f = scan.nextInt();
        int b = scan.nextInt();

        if (m >= b) {
            System.out.println("0");
        } else if (m + f >= b) {
            System.out.println(b - m);
        } else {
            System.out.println("NA");
        }

    }
}



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

int main(){
    int n,k,q;
    cin >> n >> k >> q;
    int a[q];
    int pp[n] = {};
    for(int i = 0;i < q;i++){
        cin >> a[i];
        pp[a[i]-1]++;
    }
    for(int i = 0;i < n;i++){
        if(k - q + pp[i] > 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
        
    }
  
}

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

#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795
#define INF 9223372036854775807LL


int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,a,b;
	cin >> n >> a >> b;
	cout << min(b,a*n);
	return 0;
}



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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<int> p(m); vector<ll> y(m);
	map<int, string> ans;//左が市の誕生年数
	vector<pair<int, ll>> res(m);
	rep(i, m) {
		cin >> p[i] >> y[i];
		res[i].first = p[i];
		res[i].second = y[i];
	}
	sort(res.begin(), res.end());
	int a = 1;
	rep(i, m) {
		string T = "";
		string s = to_string(res[i].first);
		rep(ri, 6 - s.size()) {
			T += "0";
		}
		T += s;
		if (i != 0 && res[i].first != res[i-1].first) {
			a = 1;
		}
		string t = to_string(a);
		rep(ri, 6 - t.size()) {
			T += "0";
		}
		T += t;
		ans[res[i].second] = T;
		a++;
	}
	rep(i, m) {
		cout << ans[y[i]] << endl;
	}
	return 0;
}

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

#define inf INT_MAX

int main(){
    int n, k;
    cin >> n >> k;

    int arr[n];

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

    int dp[n];

    dp[0] = 0;
    for(int j=1; j<n; j++){
        dp[j] = inf;
        for(int i=j-1; i>=0 && j-i<=k; i--){
            dp[j] = min(dp[j], abs(arr[j]-arr[i])+dp[i]);
        }
    }

    cout << dp[n-1] << endl;
    return 0;
}


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

namespace AtCoder.Abc
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
			var ny = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int n = ny[0];
			int y = ny[1];

			int senMax = y / 1000;
			int fiveMax = y / 5000;
			for (int i = 0; i <= senMax; i++) {
				for (int j = 0; j <= fiveMax; j++) {
					int k = n - i - j;
					if (k < 0) {
						continue;
					}

					long sum = 1000L * i + 5000L * j + 10000L * k;
					if (sum == y) {
						Console.WriteLine($"{k} {j} {i}");
						return;
					}
				}
			}

			Console.WriteLine($"{-1} {-1} {-1}");

		}
    }
}

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

int main() {
  
  int A;
  
  cin >> A;
  
  int s1 = A / 100;
  int s2 = ( A - s1 * 100 ) / 10;
  int s3 = ( A - s1 * 100 - s2 * 10) / 1;
  
  cout << s1 + s2 + s3  << endl;
}

Measured memory_bytes: 256
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int N;
map< vector<int>, int > dp;

int solve(vector<int>& vec, int sum = 0, int id = 1) {
    int res = 0;
    if(sum == 10) {
        res++;
        sum = 0; id = 1;
    }
    if(dp.count(vec)) return dp[vec];
    if(sum > 10) return 0;

    int add = 0;
    for(int i=id; i<=9; i++) {
        if(vec[i] > 0) {
            vec[i]--; sum += i;
            chmax(add, solve(vec, sum, i));
            vec[i]++; sum -= i;
        }
    }
    res += add;

    if(sum == 0) dp[vec] = res;
    return res;
}

signed main() {
    while(cin >> N, N) {
        dp.clear();
        vector<int> countManju(11);

        for(int i=0; i<N; i++) {
            int val; cin >> val;
            countManju[val]++;
        }
        
        int ans = 0;
        for(int i=1; i<5; i++) {
            int add = min(countManju[i], countManju[10 - i]);
            ans += add;
            countManju[i     ] -= add;
            countManju[10 - i] -= add;
        }
        ans += countManju[5] / 2;
        countManju[5] %= 2;

        ans += solve(countManju);
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 12084
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np
# from numpy import cumsum  # accumulate

def solve():
    N, M, Q = MI()
    E = [[] for _ in range(Q)]
    for i in range(Q):
        a, b, c, d = MI()
        E[i] = [a, b, c, d]

    q = deque([
        [1]
    ])
    ans = 0
    while q:
        # print(q)
        A = q.popleft()
        if len(A) == N+1:
            res = 0
            for (a, b, c, d) in E:
                if A[b] - A[a] == c:
                    res += d
            ans = max(ans, res)
            continue

        A.append(A[-1])
        while A[-1] <= M:
            q.appendleft(A.copy())
            A[-1] += 1

    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9392
#include <bits/stdc++.h>
#define ll      	long long int
#define PI      	acos(-1)
#define read    	freopen("in.txt","r",stdin)
#define uu      	first
#define vv      	second
#define write   	freopen("out.txt","w",stdout)
#define pii     	pair<int,int>
#define pll         pair<ll,ll>
#define INF     	1e9
#define EPS     	1e-8
#define MAX     	1000006
#define MOD     	1000000007
#define fastRead 	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
int n ;
ll ara[3003] ,dp[3003][3003][2];

ll solve(int l , int r , int turn) {

    if(l  > r) return 0;

    ll &ret= dp[l][r][turn];
    if( ret != -1) return ret;


    if( turn == 1 )
        ret = min( solve(l+ 1 , r , 0) - ara[l]  , solve(l , r-1 , 0) - ara[r]);
    else
        ret = max( solve(l+ 1 , r , 1) + ara[l]  , solve(l , r-1 , 1) + ara[r]);
    return ret;
}

int main()
{
    fastRead;
    cin>>n;
    for(int i =0 ; i < n ; i++ ) cin>>ara[i];
    memset(dp , - 1, sizeof dp);
    cout<<solve(0 , n-1 , 0)<<endl;
    return 0;
}



Measured memory_bytes: 141312
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) (V).begin(),(V).end()
#define MOD 998244353

int main(){
	int N;
	cin >> N;
	vector<pair<int, int>> A(N);
	for (int i = 0;i < N;i++) {
		cin >> A[i].second;
	}
	for (int i = 0;i < N;i++) {
		cin >> A[i].first;
	}
	sort(all(A));

	vector<int> B(N), C(N);
	for (int i = 0;i < N;i++) {
		B[i] = A[i].first;
		C[i] = A[i].second;
	}

	for (int i = 0;i < N;i++) {
		auto it = lower_bound(all(B), C[i]);
		if (it == B.end()) {
			cout << "No" << endl;
			return 0;
		}
		C[i] = *it;
	}

	vector<int> D = C;
	sort(all(D));
	bool db = 0;
	for (int i = 0;i < N;i++) {
		if (D[i] > B[i]) {
			cout << "No" << endl;
			return 0;
		}
		if (i != 0 && D[i] == D[i - 1])db = 1;
	}
	if (db) {
		cout << "Yes" << endl;
		return 0;
	}
	vector<int> E(N);
	for (int i = 0;i < N;i++) {
		auto it = lower_bound(all(D), C[i]);
		E[i] = it - D.begin();
	}

	int n = 0, next, cnt = 0;
	while (E[n] >= 0) {
		cnt++;
		next = E[n];
		E[n] = -1;
		n = next;
	}
	if (cnt == N)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
}

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

int main() {
  int N;
  cin >> N;
  int N1 = (N/1)%10;
  int N2 = (N/10)%10;
  int N3 = (N/100)%10;
  int N4 = (N/1000)%10;
  
  if (N1 == N2 && N1 == N3) {
    cout << "Yes" << endl;
  }
  else if (N2 == N3 && N2 == N4) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main(){
    int A,B,C,D;
    int E,F;
    cin >> A >> B >> C >> D;

    E = A * B ;
    F = C * D ;

    if(E > F){
        cout << E << endl;
    }
    else if((E < F)||(E == F)){
        cout << F << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
void trace(int A[],int N){
  int i;
  for(i=0;i<N;i++){
    if (i>0) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
}
void insertionSort(int A[],int N){
  int j,i,v;
  for(i=1;i<N;i++){
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    trace(A,N);
  }
}
int main(){
  int N,i,j;
  int A[100];
  scanf("%d",&N);
  for(i=0;i<N;i++) scanf("%d",&A[i]);
  trace(A,N);
  insertionSort(A,N);
  return 0;
}



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

int main(){
  int a;
  int b;
  int c;
  cin>>a;
  cin>>b;
  cin>>c;
  int d;
  d=b+c-a;
  if(d>0){
  cout<<d<<endl;
  }
  else{
    cout<<0<<endl;
  }

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
//↓✟MLE魔、TLE魔✟
#define int long long
//↑✟MLE魔、TLE魔✟
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
int gcd(int a,int b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
signed main(){
    int a,b;
    cin>>a>>b;
    if(a<=0&&b>=0)cout<<"Zero"<<endl;
    else if((b>0&&a>0)||(b-a)%2==1)cout<<"Positive"<<endl;
    else cout<<"Negative"<<endl;
}

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

using namespace std;

template <typename T>
using vec1 = vector<T>;

template <typename T>
T cin2var()
{
    T val;
    cin >> val;
    return val;
}

template <typename T>
vec1<T> cin2vec(size_t size)
{
    vec1<T> vec1(size);
    for (auto& v : vec1) {
        v = cin2var<T>();
    }
    return vec1;
}

void sub()
{
    const auto N(cin2var<size_t>());
    const auto M(cin2var<size_t>());
    const auto As(cin2vec<uint64_t>(N));

    priority_queue<uint64_t> pq{As.cbegin(), As.cend()};

    for (auto m = M; m > 0; --m) {
        const auto& price = pq.top();
        const auto discount = price / 2;
        pq.pop();
        pq.push(discount);
    }

    uint64_t sum = 0ull;
    while (!pq.empty()) {
        const auto& price = pq.top();
        sum += price;
        pq.pop();
    }
    cout << sum << endl;
}

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

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <iomanip>
#include <cmath>

#define vi vector<int>
#define tests int t; cin>>t; while(t--)
#define ll long long
#define vll vector<long long>
#define srt(v) sort(v.begin(), v.end())
#define srtg(v) sort(v.begin(), v.end(), greater<int> ())
#define FOR(k, n) for(int k=0; k<n; k++)



using namespace std;

char nums[10] = { '0','1','2','3','4','5','6','7','8','9' };
char alphsl[26] = { 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' };
const ll MOD = 1000000007;
char alphs[26] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

void solve() {

    int n, k;
    cin >> n>>k;
    vi v(n);
    for (auto& x : v) cin >> x;
    vll dp(n);
    if (k >= n-1) {
        cout << abs(v[0] - v[n - 1]) << endl;
        return;
    }
    for (int i = n - 1; i >= n - k; i--) {
        dp[i] = abs(v[i] - v[n - 1]);
        
    }

    for (int i = n - k-1; i >= 0; i--) {
        ll miny = abs(v[i] - v[i + 1]) + dp[i + 1];
        for (int j = 1; j <= k; j++) {
            miny = min(miny, abs(v[i] - v[i + j]) + dp[i + j]);
        }
        dp[i] = miny;
    }

    cout << dp[0] << endl;
}


int main() {

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


    solve();



    return 0;
}


Measured memory_bytes: 4512
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>

using namespace std;

#define REP(i, x) for(int i=0;i<(int)(x);i++)
#define REPS(i, x) for(int i=1;i<=(int)(x);i++)
#define RREP(i, x) for(int i=(int)(x)-1;i>=0;i--)
#define RREPS(i, x) for(int i=(int)(x);i>0;i--)
#define FOR(it, x) for(auto it=x.begin();it!=x.end();++it)
#define pb push_back
typedef long long ll;
typedef vector<int> vi;

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v){
        os << "[";
        FOR(it, v) os << *it << ", ";
        return os << "]";
}

int h, w, C;
int d[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
int s[10][10];
int ans;

int fill(vector<vi> &s, int x, int y, int c){
        int sum = 1;
        int p = s[y][x];
        s[y][x] = c;
        REP(i, 4){
                int dx = x + d[i][0];
                int dy = y + d[i][1];
                if(s[dy][dx] != p) continue;
                sum += fill(s, dx, dy, c);
        }
        return sum;
}

void solve(int r, vector<vi> s){
        if(r == -1){
                ans = max(ans, fill(s, 1, 1, 10));
                return ;
        }
        REPS(c, 6)if(r || c == C){
                auto t = s;
                //cout << "!" << c << endl;
                //FOR(it, t) cout << *it << endl;
                if(c != t[1][1]) fill(t, 1, 1, c);
                solve(r-1, t);
        }
}

int main(){
        while(cin >> h >> w >> C, h){
                vector<vi> s(h+2, vi(w+2, -1));
                REPS(i, h)REPS(j, w) cin >> s[i][j];
                ans = 0;
                solve(4, s);
                cout << ans << endl;
        }
        return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
int main()
{
	ld d;
	cin>>d;
	ld x=d/3;
	ld y=d/3;
	y=(y*x);
	y=(y*x);
	
	cout<<fixed<<setprecision(10)<<y<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

/*
 * ???????????§??????????´? EightQueen.java
 *
 * Copyright(C) 2016 Nagasaki Team All Rights Reserved.
 */
/**
 * ??????????????????????????????????????????????????¢???????±??????????
 * AIZU???Circle???????????¨
 *@author Iwanaga
 * @version 1.00
 */

public class Main{
	/*
	 * main????????????
	 */
	public static void main(String[] args) throws IOException{
		/*?????°??£?¨?*/
		BufferedReader br =
			new BufferedReader(new InputStreamReader(System.in));
		String str = null; //??\?????¨?????????
		double radius = 0; //??????

		//??\?????????
		str = br.readLine();
		radius = Double.parseDouble(str); //??°????????????

		//??¢?????¨???
		System.out.printf("%.6f %.6f",getCircleArea(radius)
								,getCirum(radius));
	}

	/**
	  * ????????¢???????±???????
	  * @param radius ??????
	  * @return ??¢???
	  */
	public static double getCircleArea(double radius){
		/*?????°??£?¨?*/
		double area = 0;

		area = radius*radius*Math.PI;

		return area;
	}
	
	/**
	  * ?????¨?????????????±???????
	  * @param radius ??????
	  * @return ?????¨?????????
	  */
	public static double getCirum(double radius){
		/*?????°??£?¨?*/
		double cirum = 0;
		
		cirum = 2*Math.PI*radius;
		
		return cirum;
	}
}
		

Measured memory_bytes: 24528
N,M=map(int,input().split())
s=[]
g=[]
for i in range(M):
    a,b=map(int,input().split())
    if a==1:
        s.append(b)
    elif b==N:
        g.append(a)
s.sort()
g.sort()
S=len(s)
G=len(g)
x,y=0,0
while x<S and y<G:
    if s[x]>g[y]:
        y+=1
    elif s[x]<g[y]:
        x+=1
    else:
        print("POSSIBLE")
        break
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 11420
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=0;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
typedef long long ll;
using namespace std;
int main(){
    int n,m,Q;cin>>n>>m>>Q;
    vector<vector<int>> t(n+3,vector<int>(n+3,0)),u(n+3,vector<int>(n+3,0));
    rep(i,m){
        int l,r;cin>>l>>r;
        t[l][r]++;
    }
    rep(i,n+1){
        rep(j,n+1) u[i][j+1]=u[i][j]+t[i][j+1];
    }
    rep(i,Q){
        int res=0;
        int p,q;cin>>p>>q;
        for(int i=p;i<=q;i++)res+=u[i][q]-u[i][p-1];
        cout<<res<<endl;
    }
}


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

int main() {
	
	string A, B;
	int a, b;
	
	int power[14] = { 0,13,1,2,3,4,5,6,7,8,9,10,11,12 };
	
	cin >> A;
	cin >> B;
	
	a = std::stoi(A);
	b = std::stoi(B);
	
	if ( a == b ) { cout << "Draw" << endl; }
	else {
		cout << ( (power[a] > power[b]) ? "Alice" : "Bob" );
	}
	
	
	
	return 0;
}

Measured memory_bytes: 256
def is_palindrome(s):
    return s == s[::-1]


S = input()
if (
    is_palindrome(S)
    and is_palindrome(S[: len(S) // 2])
    and is_palindrome(S[(len(S) + 3) // 2 - 1 :])
):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,e) for (int i=s;i<e;i++)
#define FOE(i,s,e) for (int i=s;i<=e;i++)
#define FOD(i,s,e) for (int i=s;i>=e;i--)
#define SET(a,e) memset(a,e,sizeof(a))
#define LL long long
#define LD long double
#define pb push_back
#define x first
#define y second
#define PII pair<int,int>
#define PLI pair<LL,int>
#define PIL pair<int,LL>
#define PLL pair<LL,LL>
#define PDD pair<LD,LD>
#define eps 1e-9
#define HH1 402653189
#define HH2 1610612741

const LL MOD = 1000000007;

int n, a[100055];
LL ans, buffer, beforeu;

int main () {
	
	scanf("%d", &n);
	
	FOR(i, 0, n) scanf("%d", a + i);
	
	buffer = a[0] - 1;
	ans = 1;
	beforeu = 0;
	
	FOR(i, 1, n) {
//		printf("i = %d : buffer = %lld beforeu = %lld\n", i, buffer, beforeu);
		ans *= (i + 1 - (beforeu + 1) / 2);
		ans %= MOD;
		if (a[i] - 1 == a[i - 1]) {
			if (buffer == 0) beforeu++;
			else buffer--;
		}
		else if (a[i] - 2 > a[i - 1]) {
			buffer += a[i] - 2 - a[i - 1];
		}
	}
	
	printf("%lld\n", ans);
	
	return 0;
	
}

Measured memory_bytes: 640
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  string s;
  cin >> s;

  int n = s.length();
  for(int i = 0; i < n; i++){
    for(int j = i; j <= n; j++){
      string t;
      for(int k = 0; k < n; k++){
        if(k < i || k >= j){
          t.push_back(s[k]);
        }
      }
      if(t == "keyence"){
        cout << "YES" << endl;
        return 0;
      }
    }
  }

  cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256