akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    ll a, b;
    cin >> a >> b;
    if(a <= 5) cout << 0;
    else if(a <= 12) cout << b/2;
    else cout << b;
    return 0;
}

Measured memory_bytes: 3600
#include<iostream>
using namespace std;
int main()
{
    int n,i,j,k,m;
    cin >> n;
    if(n<105)
        cout << 0 << endl;
    else
    {
        m=1;
        for(i=107;i<=n;i+=2)
        {
            k=0;
            for(j=i;j>0;j--)
                if(i%j==0)
                    k++;
            if(k==8)
                m++;
        }


        cout << m << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll to;
	ll d;
};


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

ll f(ll b, ll n) {
	if (n < b) { return n; }
	return f(b, n / b) + n % b;
}


int main() {

	ll n, s;
	cin >> n >> s;

	ll k = n - s;//n=sのとき？



	vector<ll> ans;

	if (k > 0) {
		repn(i, sqrt(k)) {
			if (k%i != 0) { continue; }

			ll b = i + 1;

			if (f(b, n) == s) { ans.push_back(b); }

			b = (k / i) + 1;

			if (f(b, n) == s) { ans.push_back(b); }

		}
	}

	if (k == 0) { ans.push_back(n + 1); }

	if (ans.size() == 0) { cout << -1; }
	else {
		sort(ans.begin(), ans.end());
		cout << ans[0];
	}
	

	system("PAUSE");
}


Measured memory_bytes: 504
#include "bits/stdc++.h"

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
//int dx[] = { 1, 0 };
//int dy[] = { 0, 1 };
#define mod7 1e9+7;
#define mod9 1e9+9;

int nextInt(){
	int a;	cin >> a;return a;
}
string next(){
	string s;cin >> s;return s;
}
char nextChar(){
	char c;cin >> c;return c;
}

unsigned long long strtoint(std::string str) {
	unsigned long long ret;
	std::stringstream ss; ss << str;
	ss >> ret;
	return ret;
}

int dp[35000];
void solve(){

	int a = nextInt();
	int b = nextInt();
	int c = nextInt();
	int x = nextInt();
	int count = 0;

	rep(i,a+1){
		rep(j,b+1){
			rep(k,c+1){
				if(500*i + 100*j + 50*k == x){
					count++;
				}
			}
		}
	}
	P(count);
}

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


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.range, std.string, std.math, std.typecons;

auto mknm()
{
    int[100001] ret;
    int cnt;
    foreach (i; 10000..100000) {
        auto s = i.to!(wchar[]);
        auto pal = true;
        foreach (j; 0..2) if (s[j] != s[4-j]) pal = false;
        if (pal) ++cnt;
        ret[i] = cnt;
    }
    return ret;
}

enum NM = mknm();

void main()
{
    auto ab = readln.split.to!(int[]);
    writeln(NM[ab[1]] - NM[ab[0]-1]);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
    int N,L;
    cin >> N >> L;
    vector<string> v(N);
    for (int i=0;i<N;i++){
        cin >> v.at(i);
    }
    sort(v.begin(),v.end());

    for (int i=0;i<N;i++){
        cout << v.at(i);
     }
     cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

void No() {
    cout << "No\n";
    exit(0);
}
void Yes() {
    cout << "Yes\n";
    exit(0);
}

int n, m;
vector<int> G[100009];

vector<int> x;

bool used[100009];
int cnt = 0;

void dfs(int v) {
    used[v] = 1;
    for(int u : G[v]) {
        if(u == x[1])
            cnt++;
        else if(!used[u])
            dfs(u);
    }
}

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

    cin >> n >> m;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    rep(i, n) if(G[i].size() & 1) No();
    int cnt4 = 0;
    rep(i, n) {
        if(G[i].size() >= 6) Yes();
        if(G[i].size() == 4) cnt4++;
    }
    if(cnt4 <= 1) No();
    if(cnt4 >= 3) Yes();

    rep(i, n) if(G[i].size() == 4) x.push_back(i);

    dfs(x[0]);

    (cnt == 2 ? Yes : No)();

    return 0;
}

Measured memory_bytes: 10340
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);++i)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;--i)
#define FOR(i,s,n) for(int i = s;i < (int)n;++i)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;--i)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline void out(T t){cout<<t<<"\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout<<t<<" ";out(ts...);}
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;}
constexpr int INF = 1e18;

int dx[]={0,1,1,1,0,-1,-1,-1};
int dy[]={1,1,0,-1,-1,-1,0,1};
void dfs(vector<string>&s,int H){
	auto check = [&](int i,int j){
		REP(k,8){
			REP(_,8){
				int ni = i+dx[k]*_,nj = j+dy[k]*_;
				if(!IN(0,ni,8))continue;
				if(!IN(0,nj,8))continue;
				if(s[ni][nj]=='Q')return false;
			}
		}
		return true;
	};
	if(H==8){
		int flg = 1;
		REP(i,8){
			REP(j,8){
				if(s[i][j]=='Q'){
					s[i][j]='.';
					if(check(i,j)==false)flg=0;
					s[i][j]='Q';
				}
			}
		}
		if(flg==0)return ;
		REP(i,8)cout<<s[i]<<endl;
		exit(0);
	}
	REP(j,8)if(s[H][j]=='Q')dfs(s,H+1);
	REP(j,8){
		if(check(H,j)){
			s[H][j]='Q';
			dfs(s,H+1);
			s[H][j]='.';
		}
	}
}

signed main(){
	int K,bit = 0,day = 0;
	cin >> K;
	vector<string>s(8,string(8,'.'));
	REP(i,K){
		int a,b;
		cin >> a >> b;
		s[a][b] = 'Q';
	}
	dfs(s,0);
}


Measured memory_bytes: 3184
#include<iostream>
#include<stdio.h>
#include<cctype>
#include<string>
using namespace std;


int main() {
	int turn,tpoint=0, hpoint=0;
	string  str, str2;

	cin >> turn;
	for (int a = 0; a < turn;a++) {
		cin >> str >> str2;

		if (str > str2) {
			tpoint += 3;
		}
		else if (str < str2) {
			hpoint += 3;
		}
		else {
			tpoint += 1;
			hpoint += 1;
		}

	}
	cout << tpoint << ' ' << hpoint << endl;
	return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

#define rep(i, n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  int sum = 0;
  rep(i, N)
  {
    sum += L + i;
  }

  int mn = 200000;
  int rest_;
  rep(i, N)
  {
    int now = L + i;
    int rest = sum - now;
    int diff = std::abs(rest - sum);

    if (mn > diff)
    {
      mn = diff;
      rest_ = rest;
    }
  }

  cout << rest_ << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define INF 10000000000

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

	int c[3][3];
	REP(i,3){
		REP(j,3){
			cin>>c[i][j];
		}
	}
	if(c[0][0]-c[0][1]==c[1][0]-c[1][1] && c[2][0]-c[2][1]==c[1][0]-c[1][1]){
	if(c[0][2]-c[0][1]==c[1][2]-c[1][1] && c[2][2]-c[2][1]==c[1][2]-c[1][1]){
	if(c[0][0]-c[0][2]==c[1][0]-c[1][2] && c[2][0]-c[2][2]==c[1][0]-c[1][2]){
	if(c[0][0]-c[1][0]==c[0][1]-c[1][1] && c[0][2]-c[1][2]==c[0][0]-c[1][0]){
	if(c[0][0]-c[2][0]==c[0][1]-c[2][1] && c[0][2]-c[2][2]==c[0][0]-c[2][0]){
	if(c[2][0]-c[1][0]==c[2][1]-c[1][1] && c[2][2]-c[1][2]==c[2][0]-c[1][0]){
		cout<<"Yes"<<endl;
		return 0;
	}}}}}}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repa(i,a,n) for(int i=a;i<=n;i++)
#define repd(i,a,n) for(int i=a;i>=n;i--)
#define trav(a,x) for(auto& a:x)
#define all(c) c.begin(), c.end()
#define fst first
#define sec second
#define pb push_back
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX 100007
 
typedef vector<int> vi;
typedef pair<int,int> pii;


int32_t main()
{
  int n=3,val;
  vi v;
  rep(i,n)
  {
    cin>>val;
    v.pb(val);
  }
  sort(all(v));
  val=v[2]-v[0];
  cout<<val<<endl;
  return 0;

}

Measured memory_bytes: 256
N = int(input())
al = [int(a) for a in input().split()]
      
def gcd(a, b):
    while b > 0:
        a, b = b, a%b
    return a

l = [0]*N
r = [0]*N

# 左から右
for i in range(N-1):
    if i == 0:
        a = al[i]
        l[i+1] = a
    if i >= 1:
        a = gcd(a, al[i])
        l[i+1] = a

# 右から左
for i in range(N-1):
    if i == 0:
        a = al[-i-1]
        r[-i-2] = a
    if i >= 1:
        a = gcd(a, al[-i-1])
        r[-i-2] = a

# 最大公約数リスト
ansl = [0]*N
for i in range(N):
    if i == 0:
        ansl[i] = r[i]
    elif i == N-1:
        ansl[i] = l[i]
    else:
        ansl[i] = gcd(r[i], l[i])
print(max(ansl))

Measured memory_bytes: 14428
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
toTuple (x : y : _) = (x, y)

main = do
    [n, m] <- getIntList
    as <- zip [1,1..] <$> getIntList
    bcs <- map toTuple <$> replicateM m getIntList
    print . (solve n) . reverse $ sortOn snd (as ++ bcs)

solve _ [] = 0
solve 0 _ = 0
solve n ((b, c) : bcs) | n <= b = c * n
                       | otherwise = c * b + solve (n - b) bcs

Measured memory_bytes: 98684
#include <bits/stdc++.h>
#define int long long
#define all(c) (c).begin(),(c).end()
#define pii pair<long long,long long>
#define endl '\n'

using namespace std;

signed main(){
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--){
        int a,b,n;
        cin >> a >> b >> n;
        int mx=a*min(b-1,n);
        mx/=b;
        int mn=min(b-1,n);
        mn/=b;
        mn*=a;
        int ans=mx-mn;
        cout << ans;
    }
}

Measured memory_bytes: 3636
//実装が重そうな問題はある程度考えてから書く
//初期化を忘れずに（特に二分探索とか）
//コーナーケースを考えて（特に場合分けとか）
//不可解すぎるバグは配列外参照（配列の長さ）を検討
#include <bits/stdc++.h>
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define int LL
#define zero 0LL
using namespace std;
template<typename T> inline void maximize(T &a,T b){a=max(a,b);}
template<typename T> inline void minimize(T &a,T b){a=min(a,b);}
template<typename T> inline bool middle(T a,T b,T c){return b<=a && a<=c;}
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
inline void outputVI(VI x){REP(i,SI(x)){cout << three(i," ","") << x[i];}OUT("");}
const int SIZE1=5*1e5+1000;
const int SIZE2=5010;
const int SIZE3=400;
const int SIZE=SIZE1;
const LL p=7+1e9;
const LL INF=1LL<<60;
const long double EPS=1e-7;
string s;
ut N,M,K,X,L,Y;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE],nums[SIZE],maps[SIZE2][SIZE2],answer=zero;
 
////////////////////////////////////////////////////////////////////////////////////////////
 
////////////////////////////////////////////////////////////////////////////////////////////
void init(){
 
}
int A[SIZE];
LL solve(){
 	cin >> N;
 	VI v=VI(N);
 	REP(i,N){
 		cin >> A[i];
 		v[i]=A[i];
 	}
 	sort(ALL(v));
 	REP(i,N){
 		if(A[i]<=v[N/2-1]) cout << v[N/2] << endl;
 		else cout <<v[N/2-1] << endl;
 	}
	return 0;
}
signed main(){
	solve();
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<pll, ll> P;

const ll INF = 1e17;
const int max_n = 303;

int n;
ll L;
ll dist[max_n][max_n];

pll g[max_n][max_n];

pll calc_dist(pll x, ll dnow){
	ll cnt = x.first;
	ll d = x.second;
	if(d + dnow > L){
		return (pll){cnt+1, dnow};
	}else{
		return (pll){cnt, d + dnow};
	}
}

void dijkstra(int s){
	rep(i, n) g[s][i] = (pll){INF, INF};
	g[s][s] = (pll){0, 0};

	// P = (基準頂点から今の点iまで距離,今の点の番号i)
	priority_queue<P, vector<P>, greater<P> > q;
	q.push(P((pll){0, 0}, s));

	while(!q.empty()){
		P p = q.top();
		q.pop();

		if(p.first > g[s][p.second]) continue;
		rep(i, n){
			if(i == p.second) continue;

			pll dis = calc_dist(p.first, dist[p.second][i]);
			if(dist[p.second][i] < INF && g[s][i] > dis) {
				// cout << s << "," << i << "," << g[s][i].first << "," << g[s][i].second << "," << dis.first << "," << dis.second << "," << dist[p.second][i] << endl;
				g[s][i] = dis;
				q.push(P(g[s][i], i));
			}
		}
	}
}

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

	int m;
	cin >> n >> m >> L;

	rep(i, n) rep(j, n) dist[i][j] = INF;

	rep(i, m){
		int a, b;
		ll c;
		cin >> a >> b >> c;
		a--; b--;

		if(c > L) continue;
		dist[a][b] = c;
		dist[b][a] = c;
	}

	rep(i, n){
		dijkstra(i);
	}

	// rep(i, n) rep(j, n){
	// 	if(i == j) continue;
	// 	cout << i << "," << j << "," << g[i][j].first << "," << g[i][j].second << endl;
	// }

	int q;
	cin >> q;
	rep(_, q){
		int s, t;
		cin >> s >> t;
		s--; t--;

		cout << (g[s][t].first >= INF ? -1 : g[s][t].first) << endl;
	}


}


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

int main() {
    long long int a , b , x ;
    cin >> a >> b >> x ;
    if(a%x==0)
    cout <<(b/x-a/x) +1 << endl;
    else
     cout <<(b/x-a/x) << endl;
	return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <vector>
#include <utility>


using namespace std;

#define MAX 200000
#define SENTINEL 200000000

pair<char,int> L[MAX/2+2], R[MAX/2+2];

void merge(pair<char,int> A[], int n, int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    for(int i=0; i<n1;++i) L[i] = A[left+i];
    for(int i=0; i<n2;++i) R[i] = A[mid+i];
    L[n1].second = R[n2].second = SENTINEL;

    int i = 0, j = 0;
    for(int k=left;k<right;++k){
        if(L[i].second <= R[j].second) A[k] = L[i++];
        else
        {
            A[k] = R[j++];
        }
        
    }

}

void mergeSort(pair<char,int> A[], int n, int left, int right){
    if(left+1<right){
        int mid = (left+right)/2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}


void swap(pair<char,int> *a, pair<char, int> *b){
    pair<char,int> temp;
    temp = *a;
    *a = *b;
    *b = temp;
}

int partition(pair<char,int> A[], int p, int r){
    int x = A[r].second;
    int i = p-1;
    for(int j=p;j<r;++j){
        if(A[j].second <= x){
            ++i;
            swap(&(A[i]),&(A[j]));
        }
    }
    swap(&(A[i+1]), &(A[r]));
    return i+1;
}

void quickSort(pair<char,int> A[], int p, int r){
    int q;
    if(p < r){
        q = partition(A, p, r);
        quickSort(A, p, q-1);
        quickSort(A, q+1, r);
    }
}


int main(){
    int n;
    cin >> n;
    pair<char,int> A[n], B[n];
    int v;
    char c;
    for(int i=0;i<n;++i){
         cin >> c >> v;
         A[i].first = B[i].first = c;
         A[i].second = B[i].second = v;
    }

    quickSort(A,0, n-1);
    mergeSort(B, n, 0, n);

    bool stable=true;

    for(int i=0; i< n; ++i){
        if(A[i].first != B[i].first) stable = false;
    }
    

    if(stable) cout << "Stable" << endl;
    else cout << "Not stable" << endl;

    for(int i=0; i<n; ++i) cout << A[i].first << " " << A[i].second << endl;
    

    return 0;

}


Measured memory_bytes: 6244
#include<bits/stdc++.h> //ABC 167_c
#define ll long long
using namespace std;
int n,m,x;
int c[15],a[15][15],pos[15];
int ans=1e9+7;
int main(){
	cin>>n>>m>>x;
	for(int i=1;i<=n;i++){
		cin>>c[i];
		for(int j=1;j<=m;j++)
			cin>>a[i][j];
	}
	while(pos[0]==0){
		int in[15]={0},money=0;
		for(int i=1;i<=n;i++){
			if(pos[i]==1){
				money+=c[i];
				for(int j=1;j<=m;j++)
					in[j]+=a[i][j];
			}
		}
		int flag=1;
		for(int i=1;i<=m;i++){
			if(in[i]<x){
				flag=0;break;
			}
		}
		if(flag==1){
			ans=min(ans,money);
		}
		for(int i=n;i>=0;i--){
			if(pos[i]==1)
				pos[i]=0;
			else{
				pos[i]=1;break;
			}
		}
	}
	if(ans!=1e9+7)
		cout<<ans;
	else
		cout<<-1;
	return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main(){
  int n;
  cin >> n;
  if (n % 2 == 0){
    cout << n / 2 << '\n';
  }
  else
  {
    cout << n / 2 + 1 << '\n';
  }
  return 0;   
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

long ans = 0;
void solver(int i, int m,int a, int b);

int main() {

	int n, a, b;
	cin >> n >> a >> b;
	int Hairetu[5];



	for (int i = 1; i <= n; i++) {
		if (i < 10) {
			solver(i,i, a, b);
		}
		else {
			int tmp = i;
			for(int j=0;j<5;j++){
			Hairetu[j] = tmp%10;
			tmp/=10;
			}
			
			solver(i, Hairetu[0] + Hairetu[1] + Hairetu[2] + Hairetu[3] + Hairetu[4], a, b);
			}
		}
	cout << ans;


	return 0;
}

void solver(int i,int m, int a, int b) {
 // cout<<m<<endl;
	if (m >= a&&m <= b) {
		ans += i;
	}

}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int r;
	static int c;
	static int[][] a;
	static int initialCount;
	static int answer;

	public static void main(String[] args) {
		while (read()) {
			solve(0);
			System.out.println(answer);
		}
		
	}

	public static void solve(int rownum) {
		if (rownum == r) {
			swapColumns();
			return;
		}
		// ????????????????????´???
		swapRow(rownum);
		// ???????????????????????´???
		notSwapRow(rownum);
	}

	public static void notSwapRow(int n) {
		solve(++n);
	}

	public static void swapRow(int n) {
		for (int j = 0; j < c; j++) {
			a[n][j] = a[n][j] == 1 ? 0 : 1;
		}
		solve(++n);
	}

	public static void swapColumns() {
		for (int j = 0; j < c; j++) {
			if (countUpColumns(j) > r / 2) {
				// swap j Columns
				for (int i = 0; i < r; i++) {
					a[i][j] = a[i][j] == 1 ? 0 : 1;
				}
			}
		}
		if (countUpZero() > initialCount && countUpZero() > answer) {
			answer = countUpZero();
		}

	}

	public static int countUpColumns(int j) {
		int num = 0;
		for (int i = 0; i < r; i++) {
			if (a[i][j] == 1) {
				num++;
			}
		}
		return num;
	}

	public static int countUpZero() {
		int count = 0;
		// height
		for (int i = 0; i < r; i++) {
			// width
			for (int j = 0; j < c; j++) {
				if (a[i][j] == 0) {
					count++;
				}
			}
		}
		return count;
	}

	public static boolean read() {
		initialCount =0;
		r = sc.nextInt();
		c = sc.nextInt();
		if (r == 0 && c == 0) {
			return false;
		}
		a = new int[r][c];
		// end

		// height
		for (int i = 0; i < r; i++) {
			// width
			for (int j = 0; j < c; j++) {
				a[i][j] = sc.nextInt();
				if (a[i][j] == 0) {
					initialCount++;
				}
			}
		}
		answer = initialCount;
		return true;

	}

}

Measured memory_bytes: 68228
var dict={};
    dict["yotta"] = 24;
    dict["zetta"] = 21;
    dict["exa"] = 18;
    dict["peta"] = 15;
    dict["tera"] = 12;
    dict["giga"] = 9;
    dict["mega"] = 6;
    dict["kilo"] = 3;
    dict["hecto"] = 2;
    dict["deca"] = 1;
    dict["deci"] = -1;
    dict["centi"] = -2;
    dict["milli"] = -3;
    dict["micro"] = -6;
    dict["nano"] = -9;
    dict["pico"] = -12;
    dict["femto"] = -15;
    dict["ato"] = -18;
    dict["zepto"] = -21;
    dict["yocto"] = -24;
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
var n=arr.shift()-0;
while(n--){
   var ary=arr.shift().split(" ");
   var a=ary[0].split("");
   var str="";
   var flag=true;
   a.forEach(function(v){
      if(v!="0" && v!="." && flag){str+=v+"#";flag=false;}
      else str+=v;
   });
   a=str.split("");
   var cnt=0;
   var one=0;
   var k;
   a.forEach(function(v){
      if(v=="." && one==0){k=-1;one=1;}
      else if(v=="#" && one==0){k=1;one=1;}
      else if(one==1 && v!="." && v!="#")cnt++;
      else if(one==1 && (v=="." || v=="#") )one=2;
   });
   var plus=(ary.length==3)?dict[ary[1]]:0;
   var b="10^"+(cnt*k+plus);
   var ans=a.join("").replace(/\./,"").replace(/#/g,".");
   ans=ans.replace(/^0+/,"");
   ans=ans.replace(/\.$/,"");
   console.log(ans+" * "+b+" "+ary[ary.length-1]);
}

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

using namespace std;

int num;
int data[8] = {0,1,2,3,5,7,8,9};
vector<int> make(){
  vector<int> out;
  while(num){
    out.push_back(num%8);
    num/=8;
  }
  reverse(out.begin(),out.end());
  return out;
}

int main(){
  while(cin >> num && num){
    vector<int> V = make();
    for(int i = 0; i < V.size(); i++) cout << data[V[i]];
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 904
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#include<string.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

int main() {
	makei(H);
	makei(W);
	vs s;
	string sc;
	rep(W + 2)sc.push_back('.');
	s.push_back(sc);
	rep(H) {
		string t;
		cin >> t;
		s.push_back("." + t + ".");
	}
	s.push_back(sc);
	FOR(i, 1, H + 1) {
		FOR(j, 1, W + 1) {
			if (s[i][j] == '#')cout << "#";
			else {
				int cnt = 0;
				if (s[i - 1][j - 1] == '#')++cnt;
				if (s[i - 1][j] == '#')++cnt;
				if (s[i - 1][j + 1] == '#')++cnt;
				if (s[i][j - 1] == '#')++cnt;
				if (s[i][j + 1] == '#')++cnt;
				if (s[i + 1][j - 1] == '#')++cnt;
				if (s[i + 1][j] == '#')++cnt;
				if (s[i + 1][j + 1] == '#')++cnt;
				cout << cnt;
			}
		}
		cout << endl;
	}
}

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

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


Measured memory_bytes: 3584
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.Keyence_2020
{
    class C
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] nks = ReadInts();
            int n = nks[0];
            int k = nks[1];
            int s = nks[2];
            int other = s == 1000000000 ? s - 1 : s + 1;
            for(int i = 0; i < n; i++)
            {
                if (i < k) Write(s);
                else Write(other);
                if (i < n - 1) Write(' ');
            }
            WriteLine();
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 14288
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;


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

    if (N % 2 == 0) {
        cout << N << endl;
    }
    else {
        cout << N * 2 << endl;
    }
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

ll n;
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>n;
    ll ans = 0;

    if(n%2==1) {
        cout << "0" << endl;
        return 0;
    }

    ll d = 5;
    n = n/2;
    while(true){
        if(n/d==0) break;
        ans += n/d;
        d *= 5;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define endl "\n"

const ll mod = 1e9 + 7;
// const ll mod = 998244353;
const ll sz = 1e6 + 5;
vector<ll> fac(sz, 1);

ll powmod(ll a, ll b) { ll res=1; a%=mod; assert(b>=0); for(;b;b>>=1) { if(b&1) res=res*a%mod; a=a*a%mod; } return res; }
ll nCr(ll n, ll r) { return ( ( ( (fac[n] * powmod(fac[n-r], mod-2)) % mod ) * powmod(fac[r], mod-2) ) % mod ); }
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a; }
ll lcm(ll a, ll b) { return (a / gcd(a,b)) * b; }
ll extended_gcd(ll a, ll b, ll &x, ll &y) {
    if (b == 0) { x = 1; y = 0; return a; }
    ll xx, yy;
    ll res = extended_gcd(b, a%b, xx, yy); x = yy; y = xx - yy * (a / b);
    return res;
}

// * ALways PASS arrays, strings etc to functions BY REFERENCE

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    // for (ll i = 2; i < sz; i++)
    //     fac[i] = (fac[i-1] * i) % mod;
    
    int t = 1;
    // cin >> t;

    while(t--) {
        string s;
        cin >> s;
        
        int sz = s.size();
        if (s[sz-1] == 's')
            cout << (s + "es") << endl;
        else
            cout << (s + "s") << endl;
    }
    
	return 0;
}


Measured memory_bytes: 10984
#include <iostream>
#include <string>
#include <vector>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  std::set<char> c;
  rep(i, S.size()) {
    c.insert(S[i]);
  }

  if (c.size() == S.size()) cout << "yes" << endl;
  else cout << "no" << endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(long long i=(long long)(a);i<(long long)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	string s;

	cin>>s;

	int min=1e9;
	for(int i=0; i<s.size()-2; i++){
		string sub=s.substr(i, 3);
		int d=abs(stoi(sub)-753);
		if(min>d) min=d;
	}
	cout<<min<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,n) (int i=a;i<n;i++)
#define per(i,a,n,s) (int i=n-1;i>=a;i--)
#define range(...) _overload3(__VA_ARGS__,per,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vecin(x) for(auto&youso_: (x) ) cin >>  youso_
#define vecout(x) for(auto&youso_: (x) ) cout << youso_ << " " ; cout << endl
template<class T>inline bool chmax(T &a, const T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T b) { if (b<a) { a=b; return 1; } return 0; }
const int inf = 1e9+10;
const int mod = 1e9+7;
const long long llinf = 1e18;
#define _GLIBCXX_DEBUG
// head

int main(){
    int n;
    cin >> n;
    vector<int> A(n);
    vecin(A);
    long long sum=0,now=0;
    long long ans=llinf;
    for (auto ai:A) { sum+=ai;}
    for range(i,n-1){
        sum-=A[i];
        now+=A[i];
        chmin(ans,abs(sum-now));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <string>
#include <utility>
#include <numeric>

intmax_t gcd(intmax_t m, intmax_t n) {
  while (n) std::swap(m%=n, n);
  return m;
}

std::pair<std::string, std::string> parse(const std::string &s) {
  std::pair<std::string, std::string> res("", "");
  size_t i=0;
  while (i < s.length() && isdigit(s[i]))
    res.first += s[i++];

  if (i == s.length()) {
    assert(!res.first.empty());
    return res;
  }
  assert(s[i] == '(');
  while (++i < s.length() && isdigit(s[i]))
    res.second += s[i];

  return res;
}

int main() {
  int intpart;
  char buf[8];
  scanf("%d.%s", &intpart, buf);
  std::string fracpart=buf;

  constexpr intmax_t tenpow[]={
    1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000
  };

  // intpart "." frac.first "(" frac.second ")"
  std::pair<std::string, std::string> frac=parse(fracpart);
  if (frac.first.empty()) {
    frac.first = frac.second;
  } else if (frac.second.empty()) {
    frac.second = "0";
  }
  intmax_t numer=intpart, denom=tenpow[frac.first.length()];
  numer *= denom;
  numer += std::stoll(frac.first);

  numer *= tenpow[frac.second.length()]-1;
  numer += std::stoll(frac.second);
  denom *= tenpow[frac.second.length()]-1;
  intmax_t g=gcd(numer, denom);
  numer /= g;
  denom /= g;
  printf("%jd/%jd\n", numer, denom);
}



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

int main() {
	int N, L;
	scanf("%d %d", &N, &L);
//	printf("N = %d, L = %d\n", N, L);
	int sum = 0;
	for (int i = 0; i < N; i++) {
		sum+=i+L;
	}
	int low = L;
	for (int i = 0; i < N; i++) {
		if (low*low > (i+L)*(i+L)) low = i+L;
	}
	sum -= low;
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 256
use std::io;
use std::io::BufRead;

fn main() {
    let stdin = io::stdin();
    let mut stdin = stdin.lock();
    
    let n = {
        let mut n = String::new();
        stdin.read_line(&mut n).unwrap();
        n.trim().parse::<i32>().unwrap()
    };

    if n == 1 {
        println!("1");
        return;
    }

    let k = (n as f64).log10().floor() as u32;
    
    let mut answer = {
        if k%2==0 {
            n - 10i32.pow(k) + 1
        } else {
            0
        }
    };

    for i in 0..k {
        if i%2 == 0 {
            answer += 9 * 10i32.pow(i);
        }
    }

    println!("{}", answer );
}


Measured memory_bytes: 4352
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

struct TNode
{
	int Index;
	TNode* Parent;
	TNode* Left;
	TNode* Right;
	
	TNode* PreOrderNext;
	std::vector<int>::iterator InOrder;
	
	TNode();
};

TNode::TNode()
{
	Index  = -1;
	Parent = NULL;
	Left   = NULL;
	Right  = NULL;
	PreOrderNext = NULL;
}

typedef std::vector<TNode> TBinaryTree;

TNode* InputNodes(TBinaryTree& Tree, std::vector<int>& InOrder)
{
	TNode* Temp = NULL;
	TNode* Root = NULL;
	for(unsigned int i = 0; i < Tree.size(); ++i){
		int Index;
		std::cin >> Index;
		Tree[Index - 1].Index = Index;
		if(Temp) Temp->PreOrderNext = &(Tree[Index - 1]);
		Temp = &(Tree[Index - 1]);
		if(i == 0) Root = Temp;
	}
	
	std::vector<int>::iterator It = InOrder.begin();
	for(unsigned int i = 0; i < Tree.size(); ++i){
		int Index;
		std::cin >> Index;
		Tree[Index - 1].InOrder = It;
		InOrder[i] = Index;
		++It;
	}
	return Root;
}

TNode* GetPreOrderNext(TNode* Node, int Count)
{
	TNode* Next = Node;
	for(int i = 0; i < Count && Next != NULL; ++i) Next = Next->PreOrderNext;
	return Next;
}

void SetChildren(TNode* Root, std::vector<int>::iterator InOrderBegin, std::vector<int>::iterator InOrderEnd)
{
	if(Root->PreOrderNext == NULL) return;
	int Position = distance(InOrderBegin, Root->InOrder);
	if(Root->PreOrderNext->Parent == NULL && Position > 0){
		Root->Left = Root->PreOrderNext;
		Root->PreOrderNext->Parent = Root;
		SetChildren(Root->Left, InOrderBegin, Root->InOrder);
	}
	if(Root->InOrder != InOrderEnd - 1){
		Root->Right = GetPreOrderNext(Root, 1 + distance(InOrderBegin, Root->InOrder));
		Root->Right->Parent = Root;
		SetChildren(Root->Right, Root->InOrder + 1, InOrderEnd);
	}
}

void OutputPostOrder(const TNode* Root, const TNode* End)
{
	if(Root == NULL) return;
	OutputPostOrder(Root->Left, End);
	OutputPostOrder(Root->Right, End);
	std::cout << Root->Index;
	if(Root != End){
		std::cout << " ";
	}else{
		std::cout << std::endl;
	}
}

int main()
{
	int Count;
	std::cin >> Count;
	TBinaryTree BinaryTree(Count);
	std::vector<int> InOrder(Count);
	
	TNode* Root = InputNodes(BinaryTree, InOrder);
	
	SetChildren(Root, InOrder.begin(), InOrder.end());

	OutputPostOrder(Root, Root);
	
	return 0;
}

Measured memory_bytes: 3096
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>

using namespace std;

const int N=2e5+5,M=N*4;

typedef long long LL;

int n,q,a[N],f[N],s[N],ans,T[M];

vector <int> h[N];

vector <int> ::iterator it;

char c;

int read()
{
	int x=0,sig=1;
	for (c=getchar();c<'0' || c>'9';c=getchar()) if (c=='-') sig=-1;
	for (;c>='0' && c<='9';c=getchar()) x=x*10+c-48;
	return x*sig;
}

void Ins(int l,int r,int g,int v,int x)
{
	if (l==r)
	{
		T[x]=min(T[x],v); return;
	}
	int mid=l+r>>1;
	if (g<=mid) Ins(l,mid,g,v,x<<1);else Ins(mid+1,r,g,v,x<<1|1);
	T[x]=min(T[x<<1],T[x<<1|1]);
}

int Query(int l,int r,int a,int b,int x)
{
	if (l==a && r==b) return T[x];
	int mid=l+r>>1;
	if (b<=mid) return Query(l,mid,a,b,x<<1);
	if (a>mid) return Query(mid+1,r,a,b,x<<1|1);
	return min(Query(l,mid,a,mid,x<<1),Query(mid+1,r,mid+1,b,x<<1|1));
}

int main()
{
	n=read();
	for (int i=1;i<=n;i++)
	{
		a[i]=read(); s[i]=s[i-1]+(a[i]^1);
	}
	q=read();
	for (int l,r;q--;)
	{
		l=read(); r=read(); h[l].push_back(r);
	}
	memset(f,127,sizeof(f));
	memset(T,127,sizeof(T));
	f[0]=ans=0;
	for (int i=1;i<=n;i++)
	{
		for (it=h[i].begin();it!=h[i].end();it++)
		{
			int j=s[*it]+min(Query(1,n,i,*it,1),ans-s[i-1]);
			Ins(1,n,*it,j-s[*it],1);
		}
		ans=min(ans+a[i],Query(1,n,i,i,1)+s[i]);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 14336
listNAB = input().split()
listNABint = [int(s) for s in listNAB]

def Placesum(x):
    y = str(x)
    counter = 0
    for i in range(len(y)):
        counter += int(y[i])
    return counter

sumcounter = 0
for i in range(listNABint[0]):
    if listNABint[1] <= Placesum(i+1) & Placesum(i+1) <= listNABint[2]:
        sumcounter += i+1
print(sumcounter)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
using namespace std;
int main() {
	string a, b;
	cin >> a >> b;
	if (a.size() > b.size()) {
		for (int i = 0; i < b.size(); i++)cout << a[i] << b[i];
		cout << a[b.size()];
	}
	else {
		for (int i = 0; i < a.size(); i++)cout << a[i] << b[i];
		cout << endl;
	}
		return 0;
}


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

int main(){
    string a,b,c;
    cin >> a >> b >> c;
    cout << 'A' << b[0] << 'C' << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
void int_swap(int *a, int *b){
    int temp;
    temp=*b;
    *b=*a;
    *a=temp;
}
int gcd(int a, int b){
    int c;
    c=a%b;
    if(c==0) return b;
    if(c==1) return 1;
    gcd(b,c);
}

main(){
    int i,j,k;
    scanf("%d %d",&i,&j);
    if(i<j) int_swap(&i,&j);
    printf("%d\n",gcd(i,j));
    return 0;
}

Measured memory_bytes: 2712
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>

using namespace std;
typedef long long  ll;

int main() {
	ll n;
	cin >> n;
	int place[4][3][10];
	for (ll i = 0; i < 10; i++)
	{
		for (ll j = 0; j < 3; j++)
		{
			for (ll k = 0; k < 4; k++)
			{
				place[k][j][i] = 0;
			}
		}
	}
	for (ll i = 0; i < n; i++)
	{
		int b, f, r, v;
		cin >> b >> f >> r >> v;
		place[b - 1][f - 1][r - 1] += v;
	}
	for (ll i = 0; i < 4; i++)
	{
		for (ll j = 0; j < 3; j++)
		{
			for (ll k = 0; k < 10; k++)
			{
				cout << " ";
				cout << place[i][j][k];
			}
			cout << endl;
		}
		if (i != 3) {
			cout << "####################" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3076
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <random>
#include <cstdlib>
#define INT_MAX 2147483647
#define INT_MIN -2147483646
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

int main() {
	int n;
	cin >> n;
	vi L(n * 2);
	Loop(i, n * 2) {
		int x;
		cin >> x;
		L[i] = x;
	}
	sort(L.begin(), L.end());
	int ret = 0;
	Loop(i, n) {
		int x = L[i * 2], y = L[i * 2 + 1];
		ret += min(x, y);
	}
	cout << ret << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;

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

int main()
{
    string s;
    cin >> s;
    int lon = s.size();
    int c = lon;
    lon -= 2;
    rep(i, c)
    {
        int a = lon;
        int b = a / 2;
        vector<int> v1(b);
        vector<int> v2(b);
        for (int i = 0; i < b; i++)
        {
            v1[i] = s[i];
        }
        bool fin = true;
        for (int i = 0; i < b; i++)
        {
            v2[i] = s[i + b];
            if (v1[i] != v2[i])
            {
                fin = false;
                break;
            }
        }
        if (fin)
        {
            cout << lon << endl;
            break;
        }
        else
        {
            lon -= 2;
        }
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		char[][] weather = new char[h][w + 1];
		int[][] result = new int[h][w + 1];
		for (int i = 0; i < h; i++) {
			weather[i] = sc.next().toCharArray();
		}
		int cnt;
		for(int i = 0; i < h; i++) {
			cnt = -1;
			for(int k = 0; k < w; k++) {
				if(weather[i][k] == 'c') {
					cnt = 0;
					result[i][k] = cnt;
					cnt = cnt + 1;
				} else if(cnt >= 0) {
					result[i][k] = cnt;
					cnt = cnt + 1;
				} else {
					result[i][k] = cnt;
				}
				
			}
		}
		for(int i = 0; i < h; i++) {
			for(int k = 0; k < w; k++) {
				if(k == w - 1) {
					System.out.println(result[i][k]);
				} else {
					System.out.print(result[i][k] + " ");
				}
			}
		}
	}

}

Measured memory_bytes: 32824
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    char tmp = str.charAt(0);
    int sum = 0;
    for(int i = 1; i < str.length(); i++){
      if(tmp != str.charAt(i)){
        tmp = str.charAt(i);
        sum++;
      }
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 25532
#include <algorithm>
#include <iostream>
#include <math.h>
#include <memory>
#include <stdio.h>

#define MAX_N 100'000
#define MAX_H 1'000'000'000

using namespace std;

int H[MAX_N];
bool B[MAX_N];

int main() {
  int N, K;
  cin >> N >> K;
  for (int i = 0; i < N; ++i) {
    cin >> H[i];
  }
  sort(H, H + N);
  int res = MAX_H;
  for (int i = 0; i < N - K + 1; ++i) {
    int _h = MAX_H;
    int h = 0;
    for (int j = i; j < i + K; ++j) {
      _h = min(_h, H[j]);
      h = max(h, H[j]);
    }
    res = min(res, h - _h);
    if (res == 0) {
      break;
    }
  }
  printf("%d\n", res);
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if (a == 1) {
    if (b == 2) cout << 3 << endl;
    else cout << 2 << endl;
  }
  else if (a == 2) {
    if (b == 1) cout << 3 << endl;
    else cout << 1 << endl;
  }
  else {
    if (b == 1) cout << 2 << endl;
    else cout << 1 << endl;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<int,int>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
ll dp[305][305];
int main(){
for(int i=0;i<305;i++)for(int j=0;j<305;j++)dp[i][j]=inf;
ll n;
cin>>n;
for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
        ll  a;
        cin>>a;
        dp[i][j]=a;
    }
}
ll ans=0;
for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
        bool exist=true;
        for(int k=0;k<n;k++){
            if(i==k||j==k)continue;
            if(dp[i][j]>dp[i][k]+dp[k][j]){
                cout<<-1<<endl;
                return 0;
            }
            if(dp[i][j]==dp[i][k]+dp[k][j])exist=false;
        }
        if(exist){
            ans+=dp[i][j];
        }
    }
}
cout<<ans<<endl;
}

Measured memory_bytes: 1024