akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define endl "\n"
#define fcout cout<<fixed<<setprecision(15)
typedef pair<int, int> P;
//struct edge { int to, cost; };

int dx[8] = { 1,0,0,-1,1,1,-1,-1 };
int dy[8] = { 0,-1,1,0,-1,1,-1,1 };

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 (b < a) { a = b; return 1; } return 0; }

bool prime(int n) {
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0)return false;
    }
    return n != 1;
}
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
int lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
int modinv(int a, int m) {
    int b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int modinv2(int a, int mod) {
    return mod_pow(a, mod - 2, mod);
}
int digit(int x) {
    int cnt = 0;
    while (x > 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}
int read() {
    int tmp;
    cin >> tmp;
    return tmp;
}
int xor128() {
    static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    int t = (x xor (x << 11));
    x = y; y = z; z = w;
    return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
    map<int, int>ans;
    int now = 2;
    while (now * now <= x) {
        if (x % now == 0) {
            x /= now;
            ans[now]++;
        }
        else now++;
    }
    if (x != 1) ans[x]++;
    return ans;
}
int comb(int n, int k, int mod) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    k = min(k, n - k);
    int x = 1, y = 1;
    rep(i, k) {
        y *= i + 1;
        y %= mod;
    }
    for (int i = n - k + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }
    return x * modinv(y, mod) % mod;
}

signed main() {
    //srand((unsigned)time(NULL));

    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int a;
    long double b;
    cin >> a >> b;
    cout << (int)floor(a * b) << endl;

    return 0;
}


Measured memory_bytes: 3736
#include<stdio.h>
int main(void){
  int N,K,X,Y,m=0;
  scanf("%d",&N);
  scanf("%d",&K);
  scanf("%d",&X);
  scanf("%d",&Y);
  if(N>K){
    m+=K*X+(N-K)*Y;
  }else{
    m+=N*X;
  }
  printf("%d\n",m);
  return 0;
}

Measured memory_bytes: 128
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::process;
fn main() {
    input!{
        s:chars,
    }

        for j in -1..2 {
            let jj = if j==-1 {'-'}else {'+'};
            for k in -1..2 {
                let kk = if k==-1 {'-'}else {'+'};
                for l in -1..2 {
                    let ll = if l==-1 {'-'}else {'+'};
                    if j ==0 || k==0 || l==0 {continue;}
                    if (s[0] as i32 - 48) + (s[1] as i32 - 48)*j + (s[2] as i32 - 48)*k + (s[3] as i32 - 48)*l == 7 {
                        let mut ans = "".to_string();
                        ans.push(s[0]);
                        ans.push(jj);
                        ans.push(s[1]);
                        ans.push(kk);
                        ans.push(s[2]);
                        ans.push(ll);
                        ans.push(s[3]);
                        ans.push('=');
                        ans.push('7');
                        println!("{}", ans);
                        process::exit(0);
                    }
                }
            }
        }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
//#define int long long
using namespace std;

int delta[3][2] = {{-1, -1}, {-1, 0}, {0, -1}};

int dp[3000][3000];
char carac[3000][3000];

string a, b;

int lcs(int iA, int iB){
    if (iA == -1 || iB == -1)
        return 0;
    
    if (dp[iA][iB] != -1)
        return dp[iA][iB];
    
    int rep = 0;
    int temp = 0;

    if (a[iA] == b[iB]){
        rep = lcs(iA - 1, iB - 1) + 1;
        carac[iA][iB] = a[iA];
    }
    else{
        rep = lcs(iA - 1, iB);
        temp = lcs(iA, iB - 1);

        if (temp > rep)
            rep = temp;
    }

    dp[iA][iB] = rep;
    return rep;
}

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

    for (int i = 0; i < 3000; i++){
        for (int a = 0; a < 3000; a++){
            dp[i][a] = -1;
        }
    }

    lcs(a.length()-1, b.length() - 1);
    pair<int,int> pos = {a.length()-1, b.length() -1};

    string chaine = "";
    bool  continuer = true;
    while (continuer){
        //cout << pos.first << ' ' << pos.second << endl;

        continuer = false;
        
        if (pos.first >= 0 && pos.second >= 0 && carac[pos.first][pos.second]){
            chaine = carac[pos.first][pos.second] + chaine;
            --pos.first; --pos.second; 
            continuer = (pos.first >= 0 && pos.second >= 0);
            continue;
        }
        
        int maxi = -1;
        pair<int,int>  nextPos = {-1,-1};

        for (int i = 0; i < 3; i++){
            int dx = delta[i][0]; int dy = delta[i][1];

            bool inGrid = (0 <= pos.first + dx && 0 <= pos.second + dy);
            if (inGrid && dp[pos.first + dx][pos.second + dy] > maxi){
                maxi = dp[pos.first + dx][pos.second + dy];
                nextPos.first = pos.first + dx;
                nextPos.second = pos.second + dy;
                continuer = true;
            }
        }
        pos.first = nextPos.first;
        pos.second = nextPos.second;
    }
    
    cout << chaine;

}






Measured memory_bytes: 44544
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())

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

    ll n,m;
    cin>>n>>m;
    if(n>m)
    {
        for(ll i=1;i<=n;i++) cout<<m;
    }
    else
    {
        for(ll i=1;i<=m;i++) cout<<n;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define pfi(a) printf("%d",a);
#define pfl(a) printf("%lld",a);
#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define pfis(a) printf("%d ",a);
#define pfls(a) printf("%lld ",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,a,b) for(int i=a;i<b;i++)
#define pb(a) push_back(a);
#define mp(a,b) make_pair(a,b)
#define ll long long   

const ll mod=1e9+7;

int main()
{
    ll x,y,n,t,res,x1=0,y1=0,t2,flag=-1,j,t1=0,t3=0;
    sfl(n);
    for(j=0;j<n;j++)
    {
        sfl(t);
        sfl(x);
        sfl(y);
        x1=abs(x-x1);
        y1=abs(y-y1);
        t1=(x1+y1);
       // cout<<x1<<" "<<y1<<" "<<t1<<endl;
        t2=t-t3;
        if(t1>t)
        {
            cout<<"No"<<endl;
            flag=0;
            break;
        }
       if((t2-t1)%2==1)
        {
            cout<<"No"<<endl;
            flag=0;
            break;
        }
        x1=x;
        y1=y;
        t3=t;
    }
      if(flag!=0)
        {
            cout<<"Yes"<<endl;
        }
        return 0;
}

Measured memory_bytes: 256
//#include<iostream>
//#include<algorithm>
//#include<string>
//#include <cmath>
//#include <vector>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define REP(x,n) for(int x=0;x<n;x++)

// vector 操作  vector<int> data(10,5) 5が10個　data(10) 要素数10
// v.size(), v.empty(), v.insert(itr,値), v.erase(itr) (first,last),
// sort(itr), find(all(x),値),reverse(itr),accumulate(itr,0) 積算,
//v.swap
// stringも同じ itrがただの数字になる
// s.substr(n,m)n番目以降m文字取り出す　erase(n,m)も  s.find
#define vei vector<int> 
#define velli vector<long long int> 
#define pb(x) push_back(x) // 末尾にxを加える
#define pb2 pop_back() // 末尾削除
#define all(x) (x).begin(),(x).end() //イテレーター
#define be(x) (x).begin()
//auto  auto begin = v.begin()とか

// map 操作  map<string,int> mp キー=string 値=int型  pair< , >型
// 代入:mp["abc"]=123  mp.erase(キー)
// itr = mp.begin()のとき　itr->first = key, itr->second = val
// mp.find(key) itrを返す
typedef pair<int,int> P;  //q(p.first,p.second)で定義できる？

// lcm( , ) gcd( , ) 最大公約数　最小公倍数
//if(cin.eof()) break; 入力数が決まってないとき
//ifstream  while(ifs>>data)

// 浮動小数点
// cout << fixed; 以下と組み合わせで小数点以下n桁
// cout << setprecision(n) << 値; n桁表記
// defaultfloat
int main (){
    ll int a,b;
    cin >> a >> b;
    ll int x;
    cin >> x;

    ll int N1,N2;
    if(a%x==0) N1 = a/x - 1;
    else  N1 = a/x;
    if(b%x==0) N2 = b/x;
    else N2 = b/x ;

    cout << N2 - N1;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define MOD 1000000007LL
#define rep(i,a,n) for (int i=a ; i<n ; i++)
#define per(i,a,n) for (int i=n-1 ; i>=a ; i--)
#define INF 1e9+5

using namespace std;
using llong = long long;
using VI = vector<int>;
using PII = pair<int, int>;

int n, k;
VI a;
VI dp;

int dfs(int t) // t번째 돌에 있을 때(0-n-1) 최솟값
{
	if (t == n - 1) return 0;
	if (dp[t] != -1) return dp[t];
	int minn = INF;
	rep(i, 1, k + 1)
	{
		if(t+i<=n-1)
			minn = min(minn, dfs(t + i) + abs(a[t + i] - a[t]));
	}
	return dp[t] = minn;
}

int main()
{
	IOS;
	cin >> n >> k;
	a.resize(n);
	dp.resize(n);
	fill(all(dp), -1);
	rep(i, 0, n) cin >> a[i];
	cout << dfs(0);

	return 0;
}



Measured memory_bytes: 8724
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=1e6+5;
const ll mod=1e9+7;
ll fact[N+2],inv[N+2];
void Init(){
    fact[0]=1;
    for(int i=1;i<=N;i++)
        fact[i]=(fact[i-1]*i)%mod;
    inv[1]=1;
    for(int i=2;i<=N;i++)
        inv[i]=((mod-mod/i)*inv[mod%i])%mod;
    inv[0]=1;
    for(int i=1;i<=N;i++)
        inv[i]=inv[i]*inv[i-1]%mod;
}
int c[N],w[N];
int fa[N];
int mv[N],mp[N];
int cnt[N];
int find_father(int x){
    if(x==fa[x])
        return x;
    return fa[x]=find_father(fa[x]);
}
void Merge(int x,int y){
    int f1=find_father(x),f2=find_father(y);
    if(f1==f2)
        return ;
    fa[f2]=f1;
}
int n,x,y;
int main()
{
    memset(mv,0x3f,sizeof mv);
    Init();
    scanf("%d%d%d",&n,&x,&y);
    for(int i=1;i<=n;i++)
        scanf("%d%d",&c[i],&w[i]),fa[i]=i;
    int mn1=-1,mn2=-1;
    for(int i=1;i<=n;i++){
        if(mv[c[i]]>w[i]){
            mv[c[i]]=w[i];
            mp[c[i]]=i;
        }
        if(mn1==-1||w[mn1]>w[i])
            mn1=i;
        else if(mn2==-1||(w[mn2]>w[i]&&c[mn2]!=c[mn1]))
            mn2=i;
    }
    for(int i=1;i<=n;i++){
        if(mv[c[i]]+w[i]<=x)
            Merge(mp[c[i]],i);
        if(c[i]!=c[mn1]&&w[i]+w[mn1]<=y)
            Merge(mn1,i);
        if(mn2!=-1&&c[i]==c[mn1]&&w[i]+w[mn2]<=y)
            Merge(mn2,i);
    }
    int rt=find_father(mn1);
    int sz=0;
    for(int i=1;i<=n;i++)
        if(find_father(i)==rt){
            sz++;
            cnt[c[i]]++;
        }
    ll ans=fact[sz];
    for(int i=1;i<=n;i++){
        ans=ans*inv[cnt[i]]%mod;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 35968
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();
		if (A==2||B==2) {
			System.out.println("No");
			return ;
		}
		int a[]= {4,6,9,11};
		int indexa ,indexb;
		for (indexa=0;indexa<a.length;indexa++) {
			if (a[indexa]==A) {
				break;
			}
		}
		for (indexb=0;indexb<a.length;indexb++) {
			if (a[indexb]==B) {
				break;
			}
		}
		if (indexa>=4&&indexb>=4) {
			System.out.println("Yes");
			return ;
		}
		if (indexa<4&&indexb<4) {
			System.out.println("Yes");
			return ;
		}
		System.out.println("No");
	}
}

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

using namespace std;
#define rep(i, n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
typedef long double Double;

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif

int cnt = 0;
int sum = 0;

int compute(int x, int p, int n, int d, int c) {
    if (x == 0) {
        sum += c;
        cnt++;
        return 0;
    }
    for (int i = 0; i < n; i++) {
        int cn = c;
        if (p != -1) {
            cn += abs(p - i) == d;
        }
        compute(x - 1, i, n, d, cn);
    }
}

void solve(ll n, ll m, ll d) {

    if (d == 0) {
        printf("%.10lf\n", 1. * (m - 1) / n);
    } else {
        printf("%.10lf\n", 1. * (n - d) * 2 / n / n * (m - 1));
    }
}


void main_(istream &cin) {
    ll d;
    ll n;
    ll m;
    cin >> n;
    cin >> m;
    cin >> d;
    solve(n, m, d);

}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    main_(cin);
#endif
}





Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
	long N, K;

	cin >> N >> K;

	long cnt = 0;
	for (long b = 1; b <= N; b++) {
		if (b - K > 0) cnt += (N / b) * (b - K);
		if (N % b >= K) {
			cnt += N % b - K + 1;
		}
		if (K == 0) cnt -= 1;
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iomanip>
#include <random>
#include <time.h>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <typeinfo>
#include <math.h>
#include <algorithm>
#include <iostream>
#include <list>
#include <stack>
#include <set>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
using namespace std;
int main() {
	ll a, b;
	cin >> a >> b;
	cout << (a + b + 1) / 2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int a[1000001];
signed main()
{
	int n,k,sum=0;
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=1;i<=n-k;i++)
		sum+=a[i];
	printf("%lld",sum);
	return 0;
}


Measured memory_bytes: 1792
<?php

while (true) {
    $stdin = preg_split('/ /', trim(fgets(STDIN)));
    $h = intval($stdin[0]);
    $w = intval($stdin[1]);

    if ($h === 0 && $w === 0) {
        return;
    }

    for ($i = 1; $i <= $h; $i++) {
        for ($j = 1; $j <= $w; $j++) {
            if (($i + $j) % 2 == 0) {
                print '#';
            } else {
                print '.';
            }
        }
        print "\n";
    }
    print "\n";
}

Measured memory_bytes: 6660
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<(n);i++)
#define REP1(i,n) for(long long i=1;i<=(n);i++)
#define REP2D(i,j,h,w) for(long long i=0;i<(h);i++) for(long long j=0;j<(w);j++)
#define REP2D1(i,j,h,w) for(long long i=1;i<=(h);i++) for(long long j=1;j<=(w);j++)
#define PER(i,n) for(long long i=((n)-1);i>=0;i--)
#define PER1(i,n) for(long long i=(n);i>0;i--)
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define FORE(i,a,b) for(long long i=(a);i<=(b);i++)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();++ite)
#define ALL(a) ((a).begin()),((a).end())
#define RANGE(a) (a),((a)+sizeof(a))
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define ENTER printf("\n")
#define REV(arr) reverse(ALL(arr))
#define PRT(a) cout<<(a)<<endl

#ifdef DEBUG
#define DBPRT(a) cout << "[Debug] - " << #a << " : " << (a) << endl
#define DBSTART if(1){
#define DBEND }
#define PRTLST(arr,num) REP(_i,num) cout<<_i<<" - "<<arr[_i]<<endl;
#define PRTLST2(arr2,d1,d2) REP(_i,d1) REP(_j,d2) cout<<_i<<","<<_j<<" : "<<arr2[_i][_j]<<endl;
#define PRTLST2D(arr2,d1,d2) do{cout<<"L\t";REP(_i,d2) cout<<_i<<"\t"; cout<<endl; REP(_i,d1){cout<<_i<<"\t";REP(_j,d2){cout<<arr2[_i][_j]<<"\t";}cout<<endl;}}while(0);
#else
#define DBPRT(a) if(0){}
#define DBSTART if(0){
#define DBEND }
#define PRTLST(arr,num) if(0){}
#define PRTLST2(arr2,d1,d2) if(0){}
#define PRTLST2D(arr2,d1,d2) if(0){}
#endif

#define TOSUM(arr,sum,n) {sum[0]=arr[0];REP1(i,n-1) sum[i]=sum[i-1]+arr[i];}

#define MIN(target,v1) (target)=min(target,v1)
#define MAX(target,v1) (target)=max(target,v1) 
#define P1 first
#define P2 second
#define PB push_back
#define UB upper_bound
#define LB lower_bound
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;
const int Move[4][2] = {-1,0,0,1,1,0,0,-1};
const int Move_[8][2] = {-1,0,-1,-1,0,1,1,1,1,0,1,-1,0,-1,-1,-1};
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p) {os<<"( "<<p.P1<<" , "<<p.P2<<" )";return os;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {ITE(v) os << (ite-v.begin()) << " : " << *ite <<endl;return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v) {os<<" { ";ITE(v) {os<<*ite;if(ite!=--v.end()){os<<" , ";}} os<<" } ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& m) {ITE(m) {os<<ite->P1<<"\t\t|->\t\t"<<ite->P2<<endl;} return os;}

//---------------------
#define MAXN 200005
//---------------------

ll n;

ll firstn(ll c){
	while(c>=10){
		c/=10;
	}
	return c;
}
ll lastn(ll c){
	return c%10;
}


ll dp[10][10];

int main(){
	cin >> n;
	ll ct =0;
	ZERO(dp);
	REP1(i,n){
		ll a = firstn(i);
		ll b = lastn(i);
		dp[a][b]++;
	}
	REP1(i,n){
		ll a = firstn(i);
		ll b = lastn(i);
		swap(a,b);
		if(a==0) continue;
		ct+=dp[a][b];
	}
	PRT(ct);
	return 0;
}









Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	long N; cin >> N;
	vector<long>A(N);
	long ans = 0;
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
		if (A.at(i) % 2 == 0) ans++;
	}
	cout << ans << endl;
}


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

typedef vector<int> vi;
typedef set<int> si;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define onesNumber(x) builtin_popcount(x) //builtin_popcount(ll)
#define testCases int t; cin >> t; while(t--)
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) (x * y / gcd(x, y))
const double PI = acos(-1.0);
const int N = 1e3 + 6;
const int MD = 1e5 * 4;

void solve(){

}

int main()
{
    //ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //testCases
        //solve();
    int n, ac = 0, tle = 0, wa = 0, re = 0;
    cin >> n;
    while(n--){
        string s;
        cin >> s;
        if(s == "AC")
            ac++;
        else if(s == "WA")
            wa++;
        else if(s == "TLE")
            tle++;
        else
            re++;
    }
    cout << "AC x " << ac << '\n';
    cout << "WA x " << wa << '\n';
    cout << "TLE x " << tle << '\n';
    cout << "RE x " << re << '\n';




    return 0;
}


Measured memory_bytes: 3636
def delta2lower_height(arg_num):
    height = 0
    for i in range(1, arg_num):
        height += i
    return height


lower_margin, higher_margin = map(int, input().split())

delta = higher_margin - lower_margin

lower_height = delta2lower_height(delta)
snow_height = lower_height - lower_margin

print(snow_height)

Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;


namespace AtC
{
    class Program
    {
        static void Main(string[] args)
        {
            var nk = ReadIntArray();
            int N = nk[0], K = nk[1];
            var A = ReadIntArray();
            var counter = new int[N];
            foreach (var a in A) counter[a - 1]++;

            var list = counter.OrderByDescending(val => val).ToList();
            long sum = 0;
            for (int i = K; i < list.Count; i++) sum += list[i];
            Out(sum);
        }

        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }

        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }

        static string ReadString()
        {
            return Console.ReadLine();
        }

        static void Out(object o)
        {
            Console.WriteLine(o);
        }
    }

    static class EnumerableExtension
    {
        public delegate void Function<in T>(T val);

        public static void ForEach<T>(this IEnumerable<T> enumerable, Function<T> function)
        {
            foreach (var x in enumerable)
            {
                function(x);
            }
        }
    }
}

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

#define ll long long
#define P pair<int, int>
#define F first
#define S second

const ll mod = 1000000007LL;
ll n, k;
ll dp[100005];  // True if current player will win

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

  for (int stones = 0; stones <= k; stones++) {
    for (ll x : a) {
      if (stones >= x && !dp[stones - x]) {
        dp[stones] = true;
      }
    }
  }

  cout << (dp[k] ? "First" : "Second");
}

int main(int argc, char const *argv[]) {

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

  int T = 1;
  while (T--) {
    solve();
  }

  return 0;
}

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


int main(){

	int n, k;
	cin >> n >> k;
	vector<int> x(n);
	for(int i = 0; i < n; i++)
	{
		cin >> x[i];
	}
	int ans =  1100000001;
	for(int i = 0; i < n-k+1; i++)
	{
		int r = i, l = i+k-1;
		ans = min(ans, x[l] - x[r] + min(abs(x[r]), abs(x[l])));
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <sstream>
#include <fstream>
#include <cmath>
#include <stack>
#include <queue>
#include <list>
#include <map>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;

#define MAX(x,y) ( (x) > (y) ? (x) : (y) )
#define MIN(x, y) ( (x) < (y) ? (x) : (y) )
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define IVFOR(p,a) for(vector<int>::iterator p = (a).begin(); p!=(a).end(); p++)
#define ILFOR(p,a) for(list<int>::iterator p = (a).begin(); p!=(a).end(); p++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define CHECK(x)  cout << #x << " = " << (x) << endl
#define FINA(y) cout << (y) << endl

int main(){

  int n, k, x, y;
  cin >> n >> k >> x >> y;
  int ans;
  if(n >= k)
    ans = k * x + (n-k) * y;
  else
    ans = n * x;
  FINA(ans);

 return 0;
}


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

struct query {
    int l, r, t;
};

int main() {
    int n, m; cin >> n >> m;
    vector<query> v;
    for (int i = 0; i < n; i++) {
        int l, r; cin >> l >> r;
        v.push_back({l, r, 0});
    }
    for (int d = 2; d <= m; d++)
        for (int k = 0; k * d < m; k++)
            v.push_back({k * d + 1, (k + 1) * d - 1, d});
    sort(v.begin(), v.end(), [](query lhs, query rhs) {
            return (lhs.r < rhs.r) || (lhs.r == rhs.r && lhs.t < rhs.t);
        });
    int ans[m+1], bit[m+1];
    fill(bit, bit+m+1, 0);
    fill(ans, ans+m+1, n);
    for (query q : v) {
        if (q.t == 0)
            for (int x = q.l; x > 0; x -= x&-x) bit[x]++;
        else {
            for (int x = q.l; x <= m; x += x&-x) ans[q.t] -= bit[x];
        }
    }
    for (int i = 1; i <= m; i++) cout << ans[i] << endl;
}


Measured memory_bytes: 26728
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    int n1,n2,n3;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>n1>>n2>>n3;
        if(n1*n1==n2*n2+n3*n3){
            cout<<"YES"<<endl;
        }else if(n2*n2==n1*n1+n3*n3){
            cout<<"YES"<<endl;
        }else if(n3*n3==n1*n1+n2*n2){
            cout<<"YES"<<endl;
        }else{
            cout<<"NO"<<endl;
        }
    }
    return 0;
}


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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  
  vector<int> ans(n);
  rep(i, n) ans[a[i]-1] = i+1;
  rep(i, n) cout << ans[i] << " " ;
  cout << endl;
  return 0;
}

Measured memory_bytes: 3912
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('c1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    X = read_int()
    n = 10 ** 6
    for i in range(X, n):
      is_prime = True     
      for d in range(2, X):
          if i % d == 0:
            is_prime = False
      if is_prime:
        print(i)
        break


main()


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


  
int main(){
  int n;
  cin>>n;
  int l=0,r=n-1;
  int m;
  string ls,rs,ms;
  cout<<0<<endl;
  cin>>ls;
  if(ls=="Vacant"){
    return 0;
  }
  cout<<n-1<<endl;
  cin>>rs;
  if(rs=="Vacant"){
    return 0;
  }
  while(r-l>0){
    m = (l+r)/2;
    cout<<m<<endl;
    cin>>ms;
    if(ms=="Vacant"){
      return 0;
    }
    if(((m-l)%2==1 && ms==ls) || ((m-l)%2==0 && ms!=ls)){
      r = m;
      rs = ms;
    }else{
      l = m;
      ls = ms;
    }
  } 
  return 0;
}


Measured memory_bytes: 852
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

template<typename T>
struct SegTree{
  const T e = numeric_limits<T>::max(); //単位元
  vector<T> dat;
  int n;
  SegTree(int n_): n(), dat(4*n_, e){
    int x = 1;
    while(n_ > x) x *= 2;
    n = x;
  }

  SegTree(vector<T> v): n(), dat(4*v.size(), e){
    int x = 1;
    int n_ = v.size();
    while(n_ > x) x *= 2;
    n = x;
    for(int i = 0; i < n_; i++) dat.at(i+n-1) = v.at(i);
    for(int i = n-2; i >= 0; i--) dat.at(i) = min(dat.at(2*i+1), dat.at(2*i+2)); //演算
  }

  void set(int i, T x){dat.at(i + n-1) = x;}
  void build(){
    for(int i = n-2; i >= 0; i--) dat.at(i) = min(dat.at(2*i+1), dat.at(2*i+2)); //演算
  }

  void update(int i, T x){
    i += n-1;
    dat.at(i) = x;
    while(i > 0){
      i = (i-1)/2;
      dat.at(i) = min(dat.at(2*i+1), dat.at(2*i+2)); //演算
    }
  }

  T query_sub(int a, int b, int k, int l, int r){
    if(r <= a || b <= l) return e;
    else if(a <= l && r <= b) return dat.at(k);
    else{
      T vl = query_sub(a, b, 2*k+1, l, (l+r)/2);
      T vr = query_sub(a, b, 2*k+2, (l+r)/2, r);
      return min(vl, vr); //演算
    }
  }
  T query(int a, int b){return query_sub(a, b, 0, 0, n);}

  T getval(int i){return dat.at(i+n-1);}
};

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, T;
  cin >> N >> T;
  vll A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  SegTree<ll> tree(A);
  tree.build();
  priority_queue<ll> que;
  for(int i = 0; i < N; i++){
    ll x = tree.query(0, i);
    que.push(A.at(i) - x);
  }
  ll p = que.top();
  ll counter = 0;
  while(!que.empty()){
    ll x = que.top(); que.pop();
    if(x < p) break;
    counter++;
  }
  cout << counter << endl;
}


Measured memory_bytes: 6000
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
using namespace std;

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

class State{
public:
	int cost,x,y;

	State(int _cost,int _x,int _y){
		cost = _cost;
		x = _x;
		y = _y;
	}
};

int dx[] = {-2,-2,-2,-1,-1,0,0,1,1,2,2,2};
int dy[] = {-1,0,1,-2,2,-2,2,-2,2,-1,0,1};

int main(void){
	int sx,sy;

	while(cin>>sx>>sy && (sx||sy)){
		int n;
		cin>>n;

		bool t[10][10][10];
		memset(t,0,sizeof(t));
		rep(i,n){
			int x,y;
			cin>>x>>y;
			REP(j,-1,2) REP(k,-1,2) {
				int nx = x + j;
				int ny = y + k;
				if(nx>=0 && nx<10 && ny>=0 && ny<10) t[i][ny][nx] = true;
			}
		}

		queue<State> open;
		open.push(State(-1,sx,sy));
		bool ans = false;

		if(n == 0){
			cout<<"NA\n";
			continue;
		}

		while(!open.empty()){
			State st = open.front(); open.pop();

			if(st.cost == n-1){
				ans = true;
				break;
			}

			rep(i,12){
				int nx = st.x + dx[i];
				int ny = st.y + dy[i];
				int nc = st.cost + 1;

				if(nx>=0 && nx<10 && ny>=0 && ny<10 && t[nc][ny][nx]){
					open.push(State(nc,nx,ny));
					t[nc][ny][nx] = false;
				}
			}
		}
		cout<<(ans?"OK":"NA")<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  vector<long long> s(N + 1);
  s[0] = 0;
  for (int i = 0; i < N; i++) s[i + 1] = s[i] + A[i];
  map<long long,long long> M;
  set<long long> S;
  for (int i = 0; i <= N; i++){
    if (!M.count(s[i])){
      M[s[i]] = 1;
      S.insert(s[i]);
    } else {
      M[s[i]]++;
    }
  }
  long long ans = 0;
  for (auto i : S){
    ans += M[i] * (M[i] - 1) / 2;
  }
  cout << ans;
}

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

int dist[60];

int main()
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	
	memset(dist, -1, sizeof(dist));
	int t = 0;
	for (int k = 0; k < 3600; k++){
		for (int i = 0; i < a; i++){
			if (dist[t % 60] == -1) dist[t % 60] = t;
			t++;
			if (dist[t % 60] == -1) dist[t % 60] = t;
		}
		t += b;
	}
	
	printf("%d\n", dist[c]);
}

Measured memory_bytes: 1188
N = int(input())

k = 0
while N != k*(k-1)//2:
    k += 1
    if k == 1000:
        break

if k == 1000:
    print("No")
else:
    ans = [[] for _ in range(k)]
    cnt = 0
    for i in range(k):
        for j in range(i+1,k):
            ans[i].append(cnt+1)
            ans[j].append(cnt+1)
            cnt += 1

    print("Yes")
    print(k)
    for a in ans:
        print(k-1, *a)

Measured memory_bytes: 12580
#include<stdio.h>

int main()
{	
	int i,j,k,num[3],flag,escape,data;
	
	scanf("%d",&data);
	
	for(i=0;i<data;i++)
	{
		scanf("%d %d %d",&num[0],&num[1],&num[2]);
			
		for(j=0;j<2;j++)
		{
			for(k=0;k<2;k++)
			{
				if(num[k]<num[k+1])
				{
					escape=num[k];
					num[k]=num[k+1];
					num[k+1]=escape;
				}
			}
		}
		
		if(num[0] * num[0] == num[1] * num[1] + num[2] * num[2])
		{
			printf("YES\n");
		}
		
		else
		{
			printf("NO\n");
		}
	}

	return 0;

}

Measured memory_bytes: 580
import java.io.*;
import java.util.Scanner;

class Main
{
	public static void main (String[] args) throws IOException
	{
		String W,H,X,Y,R;
		int w,h,x,y,r;
		
		Scanner in = new Scanner(System.in);
		
		W = in.next();
		H = in.next();
		X = in.next();
        Y = in.next();
		R = in.next();
		
		w = Integer.parseInt(W);
		h = Integer.parseInt(H);
		x = Integer.parseInt(X);
        y = Integer.parseInt(Y);
		r = Integer.parseInt(R);

		if((r <= x && (w - r) >= x) && (r <= y && (h - r) >= y)){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 17320
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;
#define mmst(a, b) memset(a, b, sizeof(a))
#define mmcp(a, b) memcpy(a, b, sizeof(b))

typedef long long LL;

const int N=800400;
const LL mo=924844033;

void read(int &hy)
{
	hy=0;
	char cc=getchar();
	while(cc<'0'||cc>'9')
	cc=getchar();
	while(cc>='0'&&cc<='9')
	{
		hy=(hy<<3)+(hy<<1)+cc-'0';
		cc=getchar();
	}
}

int nn;
int s[N];
int to[N],nex[N],head[N],cnt;
int n,rev[N];
LL num[N],I[N],jc[N],Ijc[N],ans[N];

void add(int u,int v)
{
	to[++cnt]=v;
	nex[cnt]=head[u];
	head[u]=cnt;
}

void dfs(int x)
{
	s[x]=1;
	for(int h=head[x];h;h=nex[h])
	if(!s[to[h]])
	{
		dfs(to[h]);
		s[x]+=s[to[h]];
		num[s[to[h]]]++;
		num[nn-s[to[h]]]++;
	}
}

LL cheng(LL a,LL b)
{
	LL res=1;
	for(;b;b>>=1,a=a*a%mo)
	if(b&1)
	res=res*a%mo;
	return res;
}

void Init(int lim)
{
	int k=-1;
	n=1;
	while(n<lim)
	n<<=1,k++;
	for(int i=1;i<n;i++)
	rev[i]=(rev[i>>1]>>1) | ((i&1)<<k); 
	
	I[1]=1;
	Ijc[0]=jc[0]=1;
	
	for(int i=2;i<=n;i++)
	I[i]=(mo-mo/i)*I[mo%i]%mo;
	for(int i=1;i<=n;i++)
	jc[i]=jc[i-1]*i%mo,Ijc[i]=Ijc[i-1]*I[i]%mo;
}

void ntt(LL *a,int ops)
{
	for(int i=0;i<n;i++)
	if(i<rev[i])
	swap(a[i],a[rev[i]]);
	
	for(int l=2;l<=n;l<<=1)
	{
		int m=l>>1;
		LL wn=(ops) ? cheng(5,(mo-1)/l) : cheng(5,mo-1-(mo-1)/l);
		for(int i=0;i<n;i+=l)
		{
			LL w=1;
			for(int k=0;k<m;k++)
			{
				LL t=a[i+k+m]*w%mo;
				a[i+k+m]=(a[i+k]-t+mo)%mo;
				a[i+k]=(a[i+k]+t)%mo;
				w=w*wn%mo;
			}
		}
	}
	if(!ops)
	for(int i=0;i<n;i++)
	a[i]=a[i]*I[n]%mo;
}

int main()
{
	cin>>nn;
	for(int i=1;i<nn;i++)
	{
		int u,v;
		read(u);
		read(v);
		add(u,v);
		add(v,u);
	}
	
	dfs(1);
	for(int i=1;i<nn;i++)
	num[i]=mo-num[i];
	num[nn]=nn;
	
	Init(2*nn+1);
	
	for(int i=0;i<=nn;i++)
	num[i]=num[i]*jc[i]%mo;
	
	for(int i=1;i<=nn;i++)
	ans[i]=Ijc[nn-i];
	
	ntt(num,1);	
	ntt(ans,1);
	
	for(int i=0;i<n;i++)
	ans[i]=num[i]*ans[i]%mo;
	ntt(ans,0);
	
	for(int i=1;i<=nn;i++)
	printf("%I64d\n",ans[nn+i]*Ijc[i]%mo);

	return 0;
}


Measured memory_bytes: 63232
/*
    Mbak Sana Dong
*/
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    int n,m,i,j,k,x,y,ans,curr,temp;
    int a,b,c,d;
    cin >> a >> b;
    cin >> c >> d;
    if(a == c) ans = 0;
    else ans = 1;
    printf("%d\n", ans);
    return 0;
}


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

#define watch(x) cout << (#x) << " is " << (x) << endl
#define fr(i,n) for(int i=0; i<n; i++)
#define rep(i, st, en) for(int i=st; i<=en; i++)
#define repn(i, st, en) for(int i=st; i>=en; i--)
#define sq(a) (a*a)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll mod = 1e9+7;

const int inf = INT_MAX;
const int nax = 12;
int n, m, x;
vector<int> dp;
vector<int> c;
vector<vector<int>> a;
int ans = inf;

void rec(int i, int mask, vector<int>& v, int cost){
    bool f = true;

    fr(i, m){
        if(v[i] < x) f = false;
    }

    if(f) {
        ans = min(ans, cost);
        return;
    }
    if(i == n) return;

    rec(i+1, mask, v, cost);

    fr(j, m){
        v[j] += a[i][j];
    }

    rec(i+1, mask^(1<<i), v, cost + c[i]);

    fr(j, m){
        v[j] -= a[i][j];
    }
}

void solve(){
    cin>>n>>m>>x;
    int z;
    // dp.resize((1<<n), inf);
    a.resize(n);
    c.resize(n);
    fr(i, n){
        cin>>c[i];
        fr(j, m){
            cin>>z;
            a[i].push_back(z);
        }
    }

    vector<int> v(m, 0);
    rec(0, 0, v, 0);

    if(ans == inf){
        cout<<-1;
    } else cout<<ans;
}

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

    ll t = 1;
    //  cin>>t;
    while(t--){
        solve();
    }

    return 0;
}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? 1e9:1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){int b=0;for(auto itr :a){if(b++!=0)cout << " "; cout << itr;} }
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
#define int ll
signed main(){
    int n; cin >> n;
    string s; cin >> s;
    int w = 0,e = 0;
    rep(i,n){
        if(s[i] == 'W')w++;
        else e++;
    }
    int ans = INF;
    int nw = 0, ne = 0;
    rep(i,n){
        if(s[i] == 'W'){
            cmin(ans,nw+e-ne);
            nw++;
        }else {
            cmin(ans,nw+e-ne-1);
            ne++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
#define LINF 1e18
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int a; cin >> a;
    string s, t;
    cin >> s;
    t = "red";
    if (a >= 3200) cout << s << endl;
    else cout << t << endl;
}

Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N, T;
    cin >> N >> T;

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

    int M[N];
    fill(M, M + N, 0);

    int mx = 0;
    for (int i = N - 1; i >= 0; i--) {
        M[i] = mx;
        mx = max(mx, A[i]);
    }

    map<int, int> m;
    map<int, int> :: iterator it;

    for (int i = 0; i < N; i++) {
        if (M[i] < A[i]) continue;
        m[M[i] - A[i]]++;
    }

    int max_cnt = -1;
    int max_val = -1;
    for (it = m.begin(); it != m.end(); it++) {
        if (it->first > max_val) {
            max_val = it->first;
            max_cnt = it->second;
        }
    }

    cout << max_cnt << endl;

    return 0;
}

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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std; 

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";} 
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}
template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

void binary(int &l, int &r, v_int & v, int u)
{
    while(r-l>1) {
        int mid = (r+l)/2;
        if(v[mid] > u) {
            r = mid;
        } else {
            l = mid;
        }
    }
}

void binary2(int &l, int &r, v_int & v, int u)
{
    while(r-l>1) {
        int mid = (r+l)/2;
        if(v[mid] >= u) {
            r = mid;
        } else {
            l = mid;
        }
    }
}

int main(void)
{
    int n;
    cin >> n;

    v_int a(n), b(n), c(n);
    cin >> a >> b >> c;
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    ll ans = 0;

    irep(i, n) {
        int la = -1, ra = n;
        binary2(la, ra, a, b[i]);
        if(la == -1) { continue; }

        int lc = -1, rc = n;
        binary(lc, rc, c, b[i]);
        if(rc == n) { continue; }

        ans += (ll)(la+1) * (n-rc);
    }
    cout << ans << endl;
    return 0;
}

/*atcoder*/



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

using namespace std;


#define PI 3.14159265
#define int long long


main(){


	int n, q; cin >> n >> q;


	string s; cin >> s;


	vector <int> v;


	for(int i = 0; i < n - 1; i++){
		if(s.substr(i, 2) == "AC"){
			v.push_back(i);
		}
	}

	int l, r;
	for(int i = 0; i < q; i++){
		cin >> l >> r;

		int it = lower_bound(v.begin(), v.end(), l - 1) - v.begin();
		int jt = upper_bound(v.begin(), v.end(), r - 2) - v.begin();

		cout << jt - it << endl;
	}


	return 0;
}

Measured memory_bytes: 1528