akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(5)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<short, short> P;
typedef complex<double> Point;
typedef long long ll;
const int INF = 114514810;
const int MOD = 100000007;
const double EPS = 1e-10;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

vector<P> v;
int n, m;
int dp[201][1001];

int solve(int i, int r)
{
	if (i == v.size()) return 0;
	if (dp[i][r] >= 0) return dp[i][r];
	int res;
	if (-v[i].second > r)
	{
		res = max(solve(i + 1, r), solve(i + 1, -v[i].second) + 1);
	}
	else res = solve(i + 1, r);
	return dp[i][r] = res;
}

int main()
{
	while (cin >> n, n)
	{
		v.clear();
		MS(dp, -1);
		REP(i, n)
		{
			int a, b; cin >> a >> b;
			v.push_back(P(a, -b));
		}
		cin >> m;
		REP(i, m)
		{
			int a, b; cin >> a >> b;
			v.push_back(P(a, -b));
		}
		sort(ALL(v));

		cout << solve(0, 0) << endl;
	}
	return 0;

}

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

int main(){
    int k, x;
    cin >> k >> x;
    //石は2,000,001個

    int num_min = x - k + 1, num_max = x + k - 1;

    for (int tsumugi = num_min; tsumugi <= num_max; tsumugi++){
        cout << tsumugi << " ";
    }
    cout << endl;

    return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct set{
    char name[11];
    int line[30];
    int sum;
}set;
int c(const void *v1,const void *v2){
    set x=*(set *)v1;
    set y=*(set *)v2;
    if(x.sum == y.sum)
        return strcmp(x.name,y.name);
    else
        return x.sum-y.sum;
}
set s[20];
int main(void){
    int n,line[30],i,o,temp,num;
    for(;memset(s,0,sizeof(s)),memset(line,0,sizeof(line)),scanf("%d",&n),n;){
        for(i=0;i<n;i++){
            scanf("%s %d",s[i].name,&num);
            for(o=0;o<num;o++){
                scanf("%d",&temp);
                line[temp]++;
                s[i].line[temp]++;
            }
        }
        for(i=0;i<n;i++)
            for(o=0;o<30;o++)
                if(s[i].line[o] != 0)
                    s[i].sum+=(n-line[o])+1;
        qsort(s,n,sizeof(set),c);
        printf("%d %s\n",s[0].sum,s[0].name);
    }
    return 0;
}

Measured memory_bytes: 612
//Use valgrind once if the submission doesn't go through. It can detect uninitialized variables and see where they could be an issue.
#include <bits/stdc++.h>
using namespace std;

int main(){

	ios_base::sync_with_stdio(false);
    	cin.tie(NULL);
	
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	if(0<k&&k<=a)
	{
		cout<<k<<endl;
	}
	else if(a<k&&k<=a+b)
	{
		cout<<a<<endl;
	}
	else
	{
		cout<<2*a+b-k<<endl;
	}
	return 0;
}


Measured memory_bytes: 3652
#include <vector>
#include <iostream>

using namespace std;
typedef long long LL;

#define SIZEOF(x) sizeof(x)/sizeof(x[0])

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(){
    LL n ;
    cin >> n;
    LL a[n];
    REP(i,n){
        cin >> a[i];
    }
    LL ballsum =0;
    vector <LL> f(0);

    LL b[n];
    LL j = (int)n/2;

    REP(i,n){
        LL t = n-i-1;
        LL sum = 0;
        if(t>j){
            b[t] = a[t];
            if(b[t] == 1){
                ballsum +=1;
                f.push_back(t+1);
            }
        }else{
            for(LL k = t ; k < n ; k+=t+1){
                if(k!=t)sum += b[k];
            }
            if(sum%2==a[t]){
                b[t] = 0;
            }else{ 
                b[t] = 1;
                ballsum +=1;
                f.push_back(t+1);
            }
        }

    }
    cout << ballsum;
    if(ballsum !=0){
        cout << "\n";
    }
    REP(i , f.size()){
        cout << f[f.size()-i-1];
        if(i !=f.size()-1){
            cout<<"\n";
        }
    }
    return 0;

}


Measured memory_bytes: 4980
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
string s[1001];
ll dp[1001][1001];

int main(int argc, char const* argv[])
{
  int h, w;
  cin >> h >> w;
  rep(i, h)cin >> s[i];
  dp[0][0] = 1;
  rep(i, h){
    rep(j, w){
      if(i != 0 || j != 0)dp[i][j] = 0;
      if(s[i][j] == '.'){
        if(i>0)dp[i][j] = (dp[i][j] + dp[i-1][j]) % mod;
        if(j>0)dp[i][j] = (dp[i][j] + dp[i][j-1]) % mod;
      }
    }
  }
  cout << dp[h-1][w-1] << endl;
	return 0;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pi 3.1415926536
#define pb push_back
#define N 1000000007
#define M 998244353
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define nrep(i,a,b) for(int i=a;i>=b;i--)
#define pl pair<ll,ll>
#define pi pair<int,int>
#define pll pair< ll, pair<ll,ll> > 
#define pii pair< int, pair<int,int> >
vector<ll> v[1000005];
ll seive[1000005];
void seiv(){
	for(int i =2; i<1000005; i++){
		if(!seive[i]){
			v[i].pb(i);
			for(int j = 2*i ; j<1000005; j+=i){
				seive[j] = 1;
				v[j].pb(i);
			}
		}
	}
}
ll a[1000005],check[1000005];
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll l,t,T,x,m,y,z,n;
    seiv();
    cin>>n;
    rep(i,1,n) cin>>a[i];
    bool flag = false;
    rep(i,1,n){
    	if(a[i] == 1) continue;
    	rep(j,0,v[a[i]].size()-1){
    		if(check[v[a[i]][j]]){
    			flag = true;
    			break;
			}
    		check[v[a[i]][j]] = 1;
		}
		if(flag) break;
	}
	if(!flag) cout<<"pairwise coprime";
	else{
		x = __gcd(a[1],a[2]);
		rep(i,3,n){
			x = __gcd(x,a[i]);
		}
		if(x == 1) cout<<"setwise coprime";
		else cout<<"not coprime";
	}
}

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

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


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

int main(void) {
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	n-=1,a -= 1;b -= 1;c -= 1;d -= 1;
	char s[200001];
	for (int i = 0;i < n;i++)cin >> s[i];
	if (c < d) {
		if (c > a + 1) {
			for (int i = a;i <= c - 1;i++) {
				if (s[i] == '#') {
					if (s[i + 1] == '#') {
						cout << "No"<<endl;
						return 0;
					}
				}
			}
		}
		if (d > b + 1) {
			for (int i = b;i <= d - 1;i++) {
				if (s[i] == '#') {
					if (s[i + 1] == '#') {
						cout << "No"<<endl;
						return 0;
					}
				}
			}
		}
		cout << "Yes"<<endl;
	}
	if (c > d) {
		for (int i = a;i <= c - 1;i++) {
			if (s[i] == '#') {
				if (s[i + 1] == '#') {
					cout << "No"<<endl;
					return 0;
				}
			}
		}
		bool flag1 = false,flag2 = false;
		if (s[b - 1] == '.'&&s[b + 1] == '.')flag1 = true;
		for (int i = b;i < d;i++) {
			if (s[i] == '.') {
				if (s[i + 1] == '.') {
					if (s[i + 2] == '.') {
						flag2 = true;
						break;
					}
				}
			}
		}
		if (flag1 || flag2) cout << "Yes" <<endl;
		else cout << "No" <<endl;
	}
	return 0;
}

Measured memory_bytes: 384
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)



s=list(input())
t=list(input())
s.sort()
t.sort(reverse=True)
s="".join(s)
t="".join(t)
if(s<t):
    print("Yes")
else:
    print("No")



Measured memory_bytes: 5124
{-# LANGUAGE CPP #-}
#define MAXNUM maxBound :: Int

import Control.Monad

main :: IO ()
main = do
  [h, w] <- map read . words <$> getLine
  putStrLn . show =<< getMin (h, w)


getMin :: (Int, Int) -> IO Int
getMin (h, w) = do
  minWH <- calcDiff (w, h)
  minHW <- calcDiff (h, w)
  return $ min minHW minWH

calcDiff :: (Int, Int) -> IO Int
calcDiff (h, w) = do
  let maxHW = if h < w then w else h
  mins <- forM [1..maxHW - 1] $ \i -> do
    --putStrLn ("splitByWidth " ++ (show i) ++ " (" ++ (show h) ++ " " ++ (show w) ++ ") = "++ (show $ splitByWidth i (h, w)))
    --putStrLn ("splitByHeight " ++ (show i) ++ " (" ++ (show h) ++ " " ++ (show w) ++ ") = "++ (show $ splitByHeight i (h, w)))
    return $ min (splitByWidth i (h, w)) (splitByHeight i (h, w))
   
  return $ minimum mins

splitByWidth :: Int -> (Int, Int) -> Int
splitByWidth n (h, w) = let b = (h - n) `div` 2
                            c = (h - n + 1) `div` 2
                            splits = [n, b, c]
                        in (if h - n > 1 then w * ((maximum splits) - (minimum splits))
                                         else MAXNUM)

splitByHeight :: Int -> (Int, Int) -> Int
splitByHeight n (h, w) = let a = w * n
                             b = (h - n) * (w `div` 2)
                             c = (h - n) * ((w + 1) `div` 2)
                             splits = [a, b ,c]
                         in (if w > 1 then (maximum splits - (minimum splits))
                                      else MAXNUM)

Measured memory_bytes: 32124
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
using namespace std;
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;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;
//|\_
//g++ -std=c++1z temp.cpp
//./a.out


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    int n;
    cin>>n;
    int front=0;
    if(n%2==1)front=1;
    int d;
    list<int> li;
    for(int i=0;i<n;i++){
        cin>>d;
        if(front==1)li.push_front(d);
        else li.push_back(d);
        front=1-front;
    }
    int i=0;
    for(auto it=li.begin();it!=li.end();it++){
        cout<<*it;
        if(i!=n-1)cout<<" ";
        else cout<<endl;
        i++;
    }

//////////////////////////////////////////////////////
return 0;}


Measured memory_bytes: 8448
#include <cmath>
#include <complex>
#include <cstdio>
#include <iomanip>
#include <iostream>
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define REP(i,n) FOR(i,0,n)

using namespace std;

typedef complex<double> xy_t;
double cross_product(xy_t a, xy_t b){ return (conj(a) * b).imag(); }

int main(){
    int n = 0;
    double x,y,area = 0;
    xy_t p[20];
    while(~scanf("%lf,%lf", &x, &y)){
        p[n] = xy_t(x, y);
        n++;
    }

    REP(i,n - 2){
        area += fabs(cross_product(p[i+1] - p[0], p[i+2] - p[0])) / 2;
    }
    cout << area << endl;

}

Measured memory_bytes: 1292
#include <stdio.h>
void printArray(int var[], int num) {
    int i;
    for (i = 0; i < num; i++) {
        if (i > 0) printf(" ");
        printf("%d", var[i]);
    }
    printf("\n");
}

void bubbleSort(int var[], int num) {
    int i, tmp;
    int flag = 1;
    int counter = 0;
    while (flag) {
        flag = 0;
        for (i = 1; i < num; i++) {
            if (var[i] < var[i - 1]) {
                tmp = var[i];
                var[i] = var[i - 1];
                var[i - 1] = tmp;
                flag = 1;
                counter++;
            }
        }
    }
    printArray(var, num);
    printf("%d\n", counter);
}

int main(void) {
    int i, num;
    scanf("%d", &num);
    int var[num];
    for (i = 0; i < num; i++) scanf("%d", &var[i]);

    bubbleSort(var, num);

    return 0;
}


Measured memory_bytes: 2052
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w));
    rep(i,h)rep(j,w) cin >> a[i][j];
    int ans = 0;
    vector<pair<P, P>> prc;
    rep(i,h){
        if(i%2 == 0){
            rep(j,w){
                if(j < w-1){
                    if(a[i][j]%2 == 1){
                        a[i][j]--;
                        a[i][j+1]++;
                        ans++;
                        prc.emplace_back(P(i+1,j+1), P(i+1, j+2));
                    }
                }
                else{
                    if(a[i][j]%2 == 1 && i+1 < h){
                        a[i][j]--;
                        a[i+1][j]++;
                        ans++;
                        prc.emplace_back(P(i+1,j+1), P(i+2,j+1));
                    }
                }
            }
        }
        else{
            for(int j = w-1; j >= 0; j--){
                if(j > 0){
                    if(a[i][j]%2 == 1){
                        a[i][j]--;
                        a[i][j-1]++;
                        ans++;
                        prc.emplace_back(P(i+1,j+1), P(i+1,j));
                    }
                }
                else{
                    if(a[i][j]%2 == 1 && i+1 < h){
                        a[i][j]--;
                        a[i+1][j]++;
                        ans++;
                        prc.emplace_back(P(i+1,j+1), P(i+2,j+1));
                    }
                }
            }
        }
    }
    cout << ans << endl;
    for(auto p : prc){
        cout << p.first.first << " " << p.first.second << " ";
        cout << p.second.first << " " << p.second.second << endl;
    }
    return 0;
}

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

int main()
{
  int n,b,f,r,v;
  cin >> n;
  int a[4][3][10]={};

  for(int i=0;i<n;i++)
    {
      cin >> b >> f >> r >> v;
      a[b-1][f-1][r-1]+=v;
    }

  for(int i=0;i<4;i++)
    {
      for(int j=0;j<3;j++)
	{
	  for(int k=0;k<10;k++)
	    {
	      cout << " " << a[i][j][k];
	    }
	  cout << endl;
	}

      if(i!=3)
	{
	  for(int l=0;l<20;l++)
	    {
	      cout << '#';
	    }
	  cout << endl;
	}
    }

  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

class A{
public:
	Int n;
	vector<Int> d, l;
	A(Int _n){
		n = _n;
		d.resize(n);
		l.resize(n);
	}
	void b(Int i, Int x1, Int y1, Int x2, Int y2){
//		cout << i << " " << x1 << " " << y1 << " " << x2 << " " << y2 << "\n";
		if(x1 == x2){
			if(y1 < y2){
				d[i] = 0;
				l[i] = y2 - y1;
			}else{
				d[i] = 3;
				l[i] = y1 - y2;
			}
		}else{
			if(x1 < x2){
				d[i] = 1;
				l[i] = x2 - x1;
			}else{
				d[i] = 2;
				l[i] = x1 - x2;
			}
		}
	}
	void print(){
		for(Int i=0; i<n; ++i)
			cout << i << " " << d[i] << " " << l[i] << "\n";
	}
};

A D(A a){
	A r(a);
	for(Int i=0; i<a.n; ++i){
		r.l[i] = a.l[a.n-1-i];
		r.d[i] = 3 - a.d[a.n-1-i];
	}
	return r;
}

bool C(A a, A b){
	if(a.n != b.n) return false;
	vector<Int> e = {2, 0, 3, 1};
	for(Int i=0; i<4; ++i){
//		a.print();
//		b.print();
		bool f = true;
		for(Int j=0; j<a.n; ++j)
			if(a.d[j] != b.d[j] || a.l[j] != b.l[j])
				f = false;
		if(f) return true;
		for(Int j=0; j<b.n; ++j)
			b.d[j] = e[b.d[j]];
	}
	return false;
}

void solve(Int n){
	Int m, x, y; cin >> m >> x >> y;
	A a0(m-1);
	for(Int i=0; i<m-1; ++i){
		Int z, w; cin >> z >> w;
		a0.b(i, x, y, z, w);
		x = z;
		y = w;
	}
//	a0.print();
	for(Int i=0; i<n; ++i){
		cin >> m >> x >> y;
		A a(m-1);
//		cout << "1\n";
//		a.print();
		for(Int j=0; j<m-1; ++j){
			Int z, w; cin >> z >> w;
			a.b(j, x, y, z, w);
			x = z;
			y = w;
		}
//		cout << "2\n";
//		a.print();
		if(C(a0, a) || C(a0, D(a))) cout << i+1 << "\n";
	}
	cout << "+++++\n";
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(1){
		Int n; cin >> n;
		if(n == 0) break;
		solve(n);
	}
}


Measured memory_bytes: 3084
#include <iostream>
#include <string>
#include <vector>
#define int long long
using namespace std;

signed main() {
  int N;
  string S_1, S_2;
  cin >> N >> S_1 >> S_2;
  
  vector<int> S;
  int i = 0;
  while (i < N) {
    if (S_1[i] == S_2[i]) {
      S.push_back(0);
    } else {
      S.push_back(1);
      ++i;
    }
    ++i;
  }
  
  int ans = 1;
  int mod = 1000000007;
  for (int i = 0; i < S.size(); ++i) {
    if (i == 0) {
      if (S[i] == 0) ans = 3;
      else ans = 6;
    } else {
      if (S[i] == 0 && S[i - 1] == 0) {
        ans *= 2;
        ans %= mod;
      }
      if (S[i] == 1 && S[i - 1] == 0) {
        ans *= 2;
        ans %= mod;
      }
      if (S[i] == 1 && S[i - 1] == 1) {
        ans *= 3;
        ans %= mod;
      }
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, ll>;
 
void dfs(int v, int p, vector<vector<P>> &g, vector<ll> &dist, ll d){
    dist.at(v) = d;
    for(auto &u: g.at(v)){
        if(dist.at(u.first)!=-1) continue;
        dfs(u.first, v, g, dist, d+u.second);
    }
}
 
int main() {
    int n; cin >> n;
    vector<vector<P>> g(n+1);
    vector<ll> dist(n+1, -1);
    
    rep(i, n-1){
        int a, b, c; cin >> a >> b >> c;
        g.at(a).push_back(make_pair(b, c));
        g.at(b).push_back(make_pair(a, c));
    }
 
    int q, k; cin >> q >> k;
    dfs(k, -1, g, dist, 0);
 
    rep(i, q){
        int x, y; cin >> x >> y;
        cout << dist.at(x) + dist.at(y) << endl;
    }
    
 
    return 0;
}

Measured memory_bytes: 15872
#include <iostream>
using namespace std;
int main() {
    string s;
    cin >> s;
    if (s[0] == 'S') {
        cout << "Cloudy" << endl;
    }
    else if (s[0] == 'C') {
        cout << "Rainy" << endl;
    }
    else {
        cout << "Sunny" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 2000000
int A[MAX+1],n;
int left(int i){ return 2*i;}
int right(int i){ return 2*i+1;}
int parent(int i){ return i/2;}

/*void print(int u){
  printf("node %d: key = %d, ",u,A[u]);
  if(u>1) printf("parent key = %d, ",A[parent(u)]);
  if(left(u)<=n) printf("left key = %d, ",A[left(u)]);
  if(right(u)<=n) printf("right key = %d, ",A[right(u)]);
  printf("\n");
}*/

void maxHeapify(int i){
  int l,r,largest,tmp;
  l=left(i);
  r=right(i);

  if(A[i]<A[l]&&l<=n) largest=l;
  else largest=i;
  if(A[largest]<A[r]&&r<=n) largest=r;

  if(largest!=i){
    tmp=A[i]; A[i]=A[largest]; A[largest]=tmp;
    maxHeapify(largest);
  }
}
void buildMaxHeap(void){
  int i;
  for(i=n/2;i>0;i--) maxHeapify(i);
}
int main(){
  int i;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }
  buildMaxHeap();
  for(i=1;i<=n;i++){
    printf(" %d",A[i]);
  }
  printf("\n");

  return 0;
}




Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<vector>
using namespace std;
string s;
#define rep2(x,from,to) for(int x=from;x<to;x++)
#define rep(x,to) rep2(x,0,to)
int n;
int b[100006];
int a[100006];
int ans;
int main()
{
    cin>>n;
    rep(i,n-1)cin>>b[i];
    b[n-1]=b[n-2];
    rep(i,n)
    {
        if(i==0)a[i]=b[i];
        else
        {
            a[i]=min(b[i],b[i-1]);
        }
        ans+=a[i];
    }
    cout<<ans<<endl;

}

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

#define ul unsigned long long
#define ll long long

int isok(ll lim,ll n,ll k,ll w[100000]) {
  ll ct=0,cw=0,ci=0;
  while (ct<k)
  {
    while (ci < n && cw + w[ci] <= lim)
    {
      cw+=w[ci];
      ci++;
    }
    if (ci==n)return 1;
    cw=0;
    ct++;
  }
  return 0;

}


int main()
{
  ll n,k,w[100000];
  cin>>n>>k;
  ll sw=0;
  for (ll i = 0; i < n; i++)
  {
    cin>>w[i];
    sw+=w[i];
  }
  
  ll left=0,right=sw;
  ll mid=(left+right)/2,ans=sw;
  while (left<=right)
  {
    if (isok(mid,n,k,w)) {
      ans=mid;
      right=mid-1;
    } else {
      left=mid+1;
    }
    mid=(left+right)/2;
  }
  cout<<ans<<endl;

  return 0;
}



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

#define int long long

#define mod (int)1000000007
#define inf (int)1000000007

#define rep(i, n) for(int i = 0; i < (n); i++)
#define trep(i, n) for(int i = 0; i <= (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define trrep(i, n) for(int i = (n); i >= 0; i--)
#define For(i, s, t) for(int i = (s); i < (t); i++)
#define tfor(i, s, t) for(int i = (s); i <= (t); i++)
#define rfor(i, s, t) for(int i = (t) - 1; i >= (s); i--)
#define trfor(i, s, t) for(int i = (t); i >= (s); i--)

int d[222];

signed main() {
  tfor(i, -100, 100) {
    d[i + 100] = 0;
  }
  int n;
  cin >> n;
  rep(i, n) {
    int w;
    cin >> w;
    tfor(j, -100, 100) {
      d[j + 100] += (w - j) * (w - j);
    }
  }
  sort(d, d + 201);
  cout << d[0] << endl;
}


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

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

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

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

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

int N;
int d[100010];

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> d[i];

    sort(d, d+N);

    cout << d[N / 2] - d[N / 2 - 1] << endl;

    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
        int c=sc.nextInt();
        
        if(a<b){
            if(b<c){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else{
            System.out.println("No");
        }
    }
}


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

int main() {
    deque<char> S;
    string tmp;
    cin >> tmp;
    for (int i = 0; i < tmp.size(); i++) {
        S.push_back(tmp[i]);
    }

    int Q;
    cin >> Q;

    bool rev = false;
    for (int i = 0; i < Q; i++) {
        int T;
        cin >> T;
        if (T == 1) {
            // rev
            rev = !rev;
        } else {
            int F;
            cin >> F;
            char C;
            cin >> C;
            if (F == 1) {
                // append C to head
                if (!rev) {
                    S.push_front(C);
                } else {
                    S.push_back(C);
                }
            } else {
                // append C to tail
                if (!rev) {
                    S.push_back(C);
                } else {
                    S.push_front(C);
                }
            }
        }
    }
    string output = "";
    if (rev) {
        for (int i = S.size() - 1; i >= 0; i--) {
            output += S[i];
        }
    } else {
        for (int i = 0; i < S.size(); i++) {
            output += S[i];
        }
    }

    cout << output << endl;

    return 0;
}


Measured memory_bytes: 1412
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int arr[3];
  cin>>arr[0]>>arr[1]>>arr[2];
  sort(arr,arr+3);
    if(arr[0]==5 && arr[1]==5 && arr[2]==7)
    {
      cout<<"YES"<<endl;
    }
  else
  {
    cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3608
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Pair[] tasks = new Pair[n];
        for(int i = 0; i < n; i++) {
          tasks[i] = new Pair(sc.nextInt(), sc.nextInt());
        }
        Arrays.sort(tasks, (i, j) -> i.endTime - j.endTime);
        int currentTime = 0;
        for(int i = 0; i < n; i++) {
            Pair t = tasks[i];
            currentTime += t.time;
            if(currentTime > t.endTime) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
    static class Pair {
        int time;
        int endTime;
        Pair(int time, int endTime) {
            this.time = time;
            this.endTime = endTime;
        }
    }
}


Measured memory_bytes: 103308
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return int(i)
}

func nextInt64() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	n := nextInt()
	k := nextInt64()
	q := nextInt()

	ps := make([]int64, n)

	// for index := 0; index < n; index++ {
	// 	ps[index] = k
	// }

	for index := 0; index < q; index++ {
		a := nextInt() - 1
		ps[a]++
	}

	for _, item := range ps {
		if item > int64(q)-k {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}


Measured memory_bytes: 3968
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int sn(int n){
	int sum=0;
	while(n){
		sum+=n%10;
		n/=10;
	}
	return sum;
}
int main(){
	int N,SN;
	scanf("%d",&N);
	SN=sn(N);
	if(N%SN==0){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}


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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    string t = "";
    for (int i = 0; i < n; i++) {
        if (s[i] != 'x') {
            t += s[i];
        }
    }
    int m = t.size();
    if (m == 0) {
        cout << 0 << endl;
        return 0;
    }
    for (int i = 0; i < m / 2; i++) {
        if (t[i] != t[m - 1 - i]) {
            cout << -1 << endl;
            return 0;
        }
    }
    int f = 0;
    int b = 0;
    int idx = 0;
    if (m % 2 == 0) {
        bool first = true;
        for (int i = 0; i < n; i++) {
            if (first && s[i] != 'x' && idx == m / 2 - 1) {
                f = i;
                first = false;
            } else if (!first && s[i] != 'x' && idx == m / 2) {
                b = i;
                break;
            }
            if (s[i] != 'x') {
                idx++;
            }
        }
    } else {
        for (int i = 0; i < n; i++) {
            if (s[i] != 'x' && idx == m / 2) {
                f = i;
                b = i;
                break;
            }
            if (s[i] != 'x') {
                idx++;
            }
        }
    }

    int c = 0;
    while (b >= 0 || f < n) {

        if (b < 0) {
            c += n - f;
            break;
        }
        if (f >= n) {
            c += b + 1;
            break;
        }
        if (s[b] != s[f]) {
            c++;
            if (s[b] == 'x') {
                b--;
            } else if (s[f] == 'x') {
                f++;
            }
        } else {
            b--;
            f++;
        }
    }

    cout << c << endl;
}


Measured memory_bytes: 640
#include <iostream>

int main() {
    
    int a,b,c;
    int temp = 0;
    
    std::cin >> a >> b >> c;
    
    while(!(a <= b && b <= c)){
        
        if(a > b){
            temp = a;
            a = b;
            b = temp;
        }
        if(b > c){
            temp = b;
            b = c;
            c = temp;
        }
    
    }
    
    std::cout << a << " " << b << " "<< c << "\n";
    return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repA(i,a,b) for(ll i=a;i<=b;i++)
#define repD(i,b,a) for(int i=b;i>=a;i--)
#define fill(a,val) memset(a,val,sizeof(a))
#define f first
#define s second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int mod=1000000007;
const int maxN=3000;
double p[maxN];
double dp[maxN][maxN];
int n;
double solve(int id,int h_cnt)
{
    if(h_cnt==0)
        return 1;
    if(id==0)
        return 0;
    if(dp[id][h_cnt]>-0.9)
        return dp[id][h_cnt];
    return dp[id][h_cnt]=p[id]*solve(id-1,h_cnt-1)+(1-p[id])*solve(id-1,h_cnt);
   // return ans;
}
int main()
{
    cin>>n;
    repA(i,1,n)
    cin>>p[i];
   fill(dp,-1);
    cout<<fixed<<setprecision(10);
    cout<<solve(n,(n+1)/2)<<endl;
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  
  for (int i = 1; i < 50000; i++) {
    if (n <= i * (double) 1.08 && i * (double) 1.08 < n + 1) {
      cout << i << endl;
      break;
    }
    else if (i == 49999) {
      cout << ":(" << endl;
    }
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	char a[1005];
	gets(a);
	for(int i = 0; a[i] != '\0'; i++){
		if(a[i] == ' ') {
			for(int j = i; a[j+1] != '\0'; j++) printf("%c",a[j+1]);
			a[i] = '\0';
			break;
		}
	}
	puts(a);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
using namespace std;
long long f[100000],a[100000];
int n;
int main()
{
    cin>>n;
    for (int i=0;i<n;++i) cin>>a[i];
    f[0]=0;
    f[1]=abs(a[1]-a[0]);
    for (int i=2;i<n;++i) f[i]=min(f[i-1]+abs(a[i]-a[i-1]),f[i-2]+abs(a[i]-a[i-2]));
    cout<<f[n-1];
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  string S;
  cin >> S;
  int N = S.size();
  map<int, ll> count;
  ll ans = 0;
  ll num = 0;
  ll ten = 1;
  for (int i = N - 1; i >= 0; i--) {
    num = (S[i] - '0') * ten + num;
    num %= 2019;
    ten = (ten * 10) % 2019;
    if (num == 0) {
      ans++;
    }
    ans += count[num];
    ++count[num];
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

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

int main() {
  int64_t a,b,c,d;
  cin>>a>>b>>c>>d;

  int64_t ans = max(max(max(a*c, a*d), b*c), b*d);

  cout<<ans<<endl;


  return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
int64_t gcd(int64_t a,int64_t b){
  while(b>0){
    int64_t r=a%b;
    a=b;
    b=r;
  }
  return a;
}
int main() {
  int64_t a,b;
  cin >> a >> b;
  cout << a*b/gcd(a,b);
}
  


Measured memory_bytes: 256
n = int(input())
minnums = [[] for _ in range(n)]
maxnums = [[] for _ in range(n)]

for i in range(n):
  minnums[i], maxnums[i] = map(int, input().split())
  
minnums.sort()
maxnums.sort()

if n % 2:
  minmedian = minnums[n // 2]
  maxmedian = maxnums[n // 2]
  print(maxmedian - minmedian + 1)
else:
  minmedian = (minnums[n // 2 - 1] + minnums[n // 2]) / 2
  maxmedian = (maxnums[n // 2 - 1] + maxnums[n // 2]) / 2
  print(int((maxmedian - minmedian) * 2 + 1))

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

int main() {
  int N,K;
  cin >> N >> K;
  vector<bool>data(N+1,false);
  for(int i=0;i<K;i++){
    int a;
    cin >> a;
    for(int j=0;j<a;j++){
      int b;
      cin >> b;
      data.at(b)=true;
    }
  }
  int ans=0;
  for(int i=1;i<N+1;i++){
    if(!data.at(i)) ans++;
  }
  cout << ans << endl;
}


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

int main () {
	vector<int> cnt(10004);


	for (int x = 1; x < 101; x++) {
		for (int y = 1; y < 101; y++) {
			for (int z = 1; z < 101; z++) {
				int t = x*x + y*y + z*z + x*y + y*z + z*x;
				if (t > 10000) break;
				cnt[t]++;
			}
		}
	}
	int N;
	cin >> N;
	for (int t = 1; t <= N; t++) {
		cout << cnt[t] << endl;
	}

}

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

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

	int sum = 0;
	int mini = __INT_MAX__;
	rep(i, n){
		sum += l+i;
		if(abs(l+i) < abs(mini)) mini = l+i;
	}

	cout << sum - mini << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int N=100100,P=1e9+7;
int n,m,R,T,a[N],b[N],c[N],d[N],f[N];
struct vec{
	int x,y;
	bool operator == (const vec&a)const{return x==a.x&&y==a.y;}
	bool operator < (const vec&a)const{return x!=a.x?x<a.x:y>a.y;}
}p[N];
void add(int x,int y){ for(;x<=R;x+=x&-x) (c[x]+=y)%=P;}
int ask(int x){int y=0;for(;x;x-=x&-x) (y+=c[x])%=P; return y;}
int main(){
	scanf("%d%d",&n,&m);
	FOR(i,1,n) scanf("%d",&a[i]);
	FOR(i,1,m) scanf("%d",&b[i]);
	FOR(i,1,n){
		if(a[i]<b[1] || b[m]<a[i]) continue;
		p[++T].x=*lower_bound(b+1,b+m+1,a[i])-a[i];
		p[T].y=a[i]-*(lower_bound(b+1,b+m+1,a[i])-1);
		d[T]=p[T].y;
	}
	sort(d+1,d+T+1);R=unique(d+1,d+T+1)-d-1;
	sort(p+1,p+T+1);T=unique(p+1,p+T+1)-p-1;
	//FOR(i,1,T) cout<<p[i].x<<' '<<p[i].y<<'\n';
	FOR(i,1,T) p[i].y=lower_bound(d+1,d+R+1,p[i].y)-d,f[i]=ask(p[i].y-1)+1,add(p[i].y,f[i]);
	cout<<ask(R)+1<<'\n';
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>N>>A>>B;
    cout<<max({N,A,B})*9 + N+A+B<<endl;
}


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


int main(){
    long N;
    string S;
    cin>>N>>S;

    long E[N+1];
    for(int i=0;i<=N;i++)E[i]=0;
    for(long i=0;i<N;i++){
        if(S[i]=='E')E[i+1]++;
        E[i+2]+=E[i+1];
    }
    long ans[N];
    for(long i=0;i<N;i++){
        ans[i]=i-E[i]+E[N]-E[i+1];
    }
    sort(ans,ans+N);
    cout<<ans[0]<<endl;
}

Measured memory_bytes: 5380
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long A,B,C;
  cin>>A>>B>>C;
  if(A%2==0||B%2==0||C%2==0){
    cout<<0<<endl;
  }
  else{
    cout<<min(A*B,min(B*C,C*A))<<endl;
  }
}
  
  

Measured memory_bytes: 3636
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return ((fact(i - 1)) * i) % MOD;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
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;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された

    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}
int main(void){
    ll a, b, x;
    cin >> a >> b >> x;
    ll ans;
    if (a == 0)ans = b / x + 1;
    else ans = b / x - (a - 1) / x;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
use std::io;

fn gets() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let line = gets();
    let mut it = line
        .trim()
        .split_whitespace()
        .map(|x| x.parse::<i32>().unwrap());
    let x = it.next().unwrap();
    let a = it.next().unwrap();
    let b = it.next().unwrap();
    if (x - a).abs() < (x - b).abs() {
        println!("A");
    } else {
        println!("B");
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

int main() {
	ios_base::sync_with_stdio(0);
	int t, i, j, k, p, q, r, x, y, u, v, n, m;
	cin>>n;
	memset(a,0,sizeof(a));
	for(i=1;i<101;i++){
		for(j=1;j<101;j++){
			for(k=1;k<101;k++){
				v=i*i+j*j+k*k+i*j+j*k+k*i;
				if(v<10001){
					a[v]++;
				}
			}
		}
	}
	for(i=0;i<n;i++){
		cout<<a[i+1]<<endl;
	}
	return 0;
}

int mpow(int base, int exp) {
	base %= mod;
	int result = 1;
	while (exp > 0) {
		if (exp & 1) result = ((ll)result * base) % mod;
		base = ((ll)base * base) % mod;
		exp >>= 1;
	}
	return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}




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

int main() {
  ll n,sum=0,count=0;
  cin>>n;
  vector<ll> a,b,c;
  for(int i=0; i<n+1; i++){
    int x;
    cin>>x;
    a.push_back(x);
    sum+=x;
  }
  for(int i=0; i<n; i++){
    int x;
    cin>>x;
    b.push_back(x);
  }
  for(int i=0; i<n; i++){
    if(a[i]<=b[i]) {
      if(a[i]+a[i+1]<=b[i]) a[i+1]=0;
      else a[i+1] -= (b[i]-a[i]);
      a[i]=0;
    }
    else a[i] -= b[i];
  }
  for(int i=0; i<n+1; i++) count += a[i];
  cout << sum-count;
}

Measured memory_bytes: 2548
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <string>
using namespace std;
typedef vector<int> vi;
typedef vector<bool> vb;
#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()

int solve(int n){
    set<int> s;
    int c = 0;
    while (1){
        if (n < 10) return c;
        auto it=s.insert(n);
        if (!it.second) return -1;
        string s = to_string(n);
        vector<int> v;
        rep(i, s.size() - 1){
            string a = s.substr(0, i + 1);
            string b = s.substr(i + 1);
            v.push_back(stoi(a)*stoi(b));
        }
        sort(all(v));
        n = v.back();
        c++;
    }
}

int main(){
    int q; cin >> q;
    rep(i, q){
        int n; cin >> n;
        cout << solve(n) << endl;
    }
}

Measured memory_bytes: 1260
#include<bits/stdc++.h>
//priority_queue<ll, vector<ll>, std::greater<ll> > q;
#define ull 		unsigned long long
#define ll 			long long
#define M 			1000000007
#define pb 			emplace_back
#define p_q 		priority_queue
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) // gcd((a),(b))
#define ios	    	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp 			make_pair
#define lb 			lower_bound
#define ub			upper_bound
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ini(a,n,b)	for(ll int i=0;i<n;i++) a[i]=0;
#define hell 		(ull)1e9
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
using namespace std;

void boost()
{
    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
    cout.tie(NULL);
}



int main(void)
{
    boost();
    ll n;
    cin>>n;
    vi p(n) , q(n) , r(n);
    rep(i,0,n){
        cin>>p[i];
        cin>>q[i];
        cin>>r[i];
    }
    ll a[n][3];
    a[0][0] = p[0];
    a[0][1] = q[0];
    a[0][2] = r[0];
    
    rep(i,1,n){
        a[i][0] = max(a[i-1][1] , a[i-1][2]) + p[i];
        a[i][1] = max(a[i-1][0] , a[i-1][2]) + q[i];
        a[i][2] = max(a[i-1][0] , a[i-1][1]) + r[i];        
    }
    // rep(i,0,n){
    //     cout<<a[i][0]<<" "<<a[i][1]<<" "<<a[i][2]<<"\n";
    // }
    ll ans = max(a[n-1][0] , a[n-1][1]);
    ans = max(ans, a[n-1][2]);
    cout<<ans;
    

   
}   

Measured memory_bytes: 4992
#include <algorithm>
#include <iostream>
#include <cstring>
#include <iomanip>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair <ll, ll> pii;
#define X first
#define Y second

const ll MAX_N = 8e3 + 12, MOD = 2e9 + 7, BASE = 101;
ll n, ans;

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> n;
    cout << (n - 1) / 2 << "\n";
    return 0;
}

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

int main(){
	
	int t;
	
	while(cin >> t,t){
		int ice[10]={},i,g,n,p;
		
		for(p=0;p<t;p++){
			cin >> i;
			
			ice[i]++;
		}
		
		for(g=0;g<=9;g++){
			if(ice[g]==0){
				cout << "-" << endl;
			}
			
			else if(ice[g]>0){
				for(n=0;n<ice[g];n++){
					cout << "*";
					
					if(n==ice[g]-1){
					cout << endl;
					}
				}
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int N, M, X;
  cin >> N >> M >> X;
  vi C(N);
  vvi A(N, vi(M));
  rep(i, 0, N) { cin >> C[i] >> A[i]; }

  int ans = INF;
  rep(s, 0, 1 << N) {
    vi tmp(M);
    int cost = 0;
    rep(j, 0, N) {
      if (s >> j & 1) {
        cost += C[j];
        rep(k, 0, M) { tmp[k] += A[j][k]; }
      }
    }
    bool ng = false;
    rep(j, 0, M) {
      if (tmp[j] < X) ng = true;
    }
    if (!ng) chmin(ans, cost);
  }
  if (ans == INF) ans = -1;
  cout << ans << endl;
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 3652