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

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

    vector<long long int> pow2(32,1);// pow2[j] = 2^j
    for(int j=0; j<31; j++){
        pow2[j+1] = pow2[j] * 2;
    }

    vector<vector<long long int>> a(30, vector<long long int>(n)), b(30, vector<long long int>(n));
    for(int i=0; i<n; i++){
        cin >> a[29][i];
        for(int j=28; j>=0; j--){
            a[j][i] = a[j+1][i] % pow2[j+1];
        }
    }
    for(int i=0; i<n; i++){
        cin >> b[29][i];
        for(int j=28; j>=0; j--){
            b[j][i] = b[j+1][i] % pow2[j+1];
        }
    }
    for(int j=29; j>=0; j--){
        sort(b[j].begin(), b[j].end());
    }

    long long int ans = 0;// total XOR
    for(int j=0; j<30; j++){// each bit
        long long int bit = 0;
        for(int i=0; i<n; i++){
            bit += lower_bound(b[j].begin(), b[j].end(), pow2[j+1] - a[j][i]) // 0 11...1 ~
                 - lower_bound(b[j].begin(), b[j].end(), pow2[j]   - a[j][i]);// 0 10...0
            if(j+2 < 31){
            bit += lower_bound(b[j].begin(), b[j].end(), pow2[j+2]           - a[j][i]) // 1 11...1 ~
                 - lower_bound(b[j].begin(), b[j].end(), pow2[j+1] + pow2[j] - a[j][i]);// 1 10...0   
            }         
        }
        ans += (bit % 2) * pow2[j];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 98644
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

int H, W, D;

int A[305][305];
int sum[300*300 + 10];
pii pos[300*300 + 10];

int distance(pii p, pii q)
{
	return abs(p.fst - q.fst) + abs(p.scd - q.scd);
}

signed main()
{
	cin >> H >> W >> D;

	rep(i, H) rep(j, W) {
		A[i][j] = read();
		pos[A[i][j]] = pii(i, j);
	}

	rep1(i, D) {
		int start = i;
		pii cur = pos[start];

		while (start <= H * W) {
			if (start - D > 0) {
				sum[start] = sum[start - D] + distance(pos[start - D], pos[start]);
			}

			cur = pos[start + D];
			start += D;
		}
	}

	int Q; cin >> Q;

	rep(_, Q) {
		int l = read(), r = read();

		printf("%lld\n", sum[r] - sum[l]);
	}
}




Measured memory_bytes: 3968
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;

int const MAX = 100005;
long long const MOD = 1000000007;
long long x[MAX], y[MAX];

long long mod_p(long long a, long long b) {
	return (a + b + 2 * MOD) % MOD;
}

long long mod_m(long long a, long long b) {
	return (a%MOD)*(b%MOD) % MOD;
}

long long func(long long p[], long long n) {
	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		long long value = mod_m(n + 1 - 2 * i,p[i]);
		ans = mod_p(value, ans);
	}
	return ans;
}

int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cin >> x[i];
	}
	for (int j = 1; j <= m; j++) {
		cin >> y[j];
	}
	cout << (func(x, n) * func(y, m)) % MOD << endl;
}


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

#define za ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod %1000000007
#define moz 1000000007
#define nl "\n"
#define S second
#define F first
#define PB push_back
#define MP make_pair
#define V vector
#define P pair
#define LEN length()
#define SZ size()
#define loop(i,a,b) for(int i=(a);i<=(b);i++)
typedef long long ll;
typedef complex<ll> C;
#define X real()
#define Y imag()

ll fpb(ll m , ll n)
{
    ll r = m % n;
    while(r != 0)
    {
        m = n;
        n = r;
        r = m % n;
    }
    return n;
}


int main()
{
    za;
    ll n,a,b;
    cin >> n;
    loop(i,0,n-1)
    {
        cin >> a;
        if(i==0)
        {
            b=a;
        }
        else
        {
            ll c=fpb(a,b);
            b=a*(b/c);
        }
    }
    cout << b << nl;
}


Measured memory_bytes: 256
/* Author: Dhruv Rastogi */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);

void solve(){  
    int m,d;
    cin>>m>>d;
    int cnt=0;
    rep(i,1,m+1){
        rep(j,10,d+1){
            if((j/10)*(j%10)==i and j%10>=2 and j/10>=2){
                //cout<<i<<' '<<j<<endl;
                ++cnt;
            }
        }
    }  
    cout<<cnt<<endl;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
  vector<int> result;
  int num[100] = {0};
  int tmp;
  while (cin >> tmp)
    num[tmp-1]++;

  int max = 0;
  for (int i = 0; i < 100; i++)
    if (max < num[i]) {
      max = num[i];
      result.clear();
      result.push_back(i+1);
    } else if (max == num[i]) {
      result.push_back(i+1);
    }

  for (int i = 0; i < result.size(); i++)
    cout << result[i] << endl;
  return 0;
}

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

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

class Potential_UnionFind {
public:
    vector <LL> par;
    vector <LL> siz;
    vector <LL> diff_weight;

    Potential_UnionFind(LL sz_): par(sz_), siz(sz_, 1LL), diff_weight(sz_) {
        for (LL i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(LL sz_, LL sum = 0) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (LL i = 0; i < sz_; ++i){
            par[i] = i;
            diff_weight[i] = sum;
        }
    }

    LL root(LL x) {
        if (par[x] == x) {
            return x;
        }
        else {
            LL r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    LL weight(LL x){
        root(x);
        return diff_weight[x];
    }

    bool unite(LL x, LL y, LL w) {
        w += weight(x); w -= weight(y);
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y), w = -w;
        siz[x] += siz[y];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    bool same(LL x, LL y) {
        return root(x) == root(y);
    }

    LL size(LL x) {
        return siz[root(x)];
    }

    LL diff(LL x, LL y){
        return weight(y) - weight(x);
    }
};

int main(){
	int N, M;
	cin >> N >> M;
	Potential_UnionFind tree(N);
	rep(i,M){
		int L, R, D;
		cin >> L >> R >> D;
		L--; R--;
		if(tree.same(L,R)){
			int d=tree.diff(L,R);
			if(d!=D){
				cout << "No" << endl;
				return 0;
			}
		}
		else tree.unite(L,R,D);
	}
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 2560
//<============ Author --> @venom ============>//
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fo(i,n)           for(int i=0;i<n;i++)
#define int               long long
#define pb                emplace_back
#define mp                make_pair
#define ff                first
#define ss                second
#define all(x)            x.begin(), x.end()
#define sortall(x)        sort(all(x))
#define sortrev(x)        sort(all(x), greater<int>())
#define w(x)              int x; cin>>x; while(x--)
#define trunc(x,y)        fixed<<setprecision(y)<<x
#define mk(arr, n, type)  type *arr=new type[n];
#define PI                3.1415926535897932384626
#define mod               1000000007
#define inf               1e9 + 5
#define FIO               ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef pair<int, int>    pi;
typedef vector<int>       vi;
typedef vector<pi>        vpi;
typedef vector<vi>        vvi;
typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update> indexed_set;
const int N = 3e5, M = N;
int mpow(int base, int exp);
int gcd(int a, int b) {if (a == 0) return b; return gcd(b % a, a);}
//<----------------------------------------------------------------------------->//
void fastIO()
{
  FIO;
#ifndef ONLINE_JUDGE
  // for getting input from input.txt
  freopen("input.txt", "r", stdin);
  // for writing output to output.txt
  freopen("output.txt", "w", stdout);
#endif
}

struct activity
{
  int A;
  int B;
  int C;
};

int solve(vector<activity> v, int n)
{
  int dp[n + 1][3];

  dp[1][0] = v[1].A;
  dp[1][1] = v[1].B;
  dp[1][2] = v[1].C;

  for (int i = 2; i <= n; i++)
  {
    dp[i][0] = v[i].A + max(dp[i - 1][1], dp[i - 1][2]);
    dp[i][1] = v[i].B + max(dp[i - 1][0], dp[i - 1][2]);
    dp[i][2] = v[i].C + max(dp[i - 1][1], dp[i - 1][0]);
  }

  return max(dp[n][0], max(dp[n][1], dp[n][2]));
}

int32_t main()
{
  FIO;

  int n; cin >> n;

  vector<activity> a(n + 1);

  for (int i = 1; i <= n; i++)
  {
    cin >> a[i].A;
    cin >> a[i].B;
    cin >> a[i].C;
  }

  cout << solve(a, n);

  return 0;
}

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

Measured memory_bytes: 7296
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define snuke(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)

typedef long long ll;
#define MOD 998244353ll

ll F[100010],inv[100010],Finv[100010];
ll G[100010];
int freq[100010];

int main(void){
	int i,j;
	
	inv[1] = 1;
	for(i=2;i<100010;i++) inv[i] = (MOD - MOD/i) * inv[MOD%i] % MOD;
	
	F[0] = Finv[0] = 1;
	for(i=1;i<100010;i++){
		F[i] = F[i-1] * i % MOD;
		Finv[i] = Finv[i-1] * inv[i] % MOD;
	}
	
	G[0] = 1;
	for(i=1;i<100010;i++) G[i] = G[i-1] * (2*i-1) % MOD;
	
	int N;
	cin >> N;
	
	int h;
	REP(i,2*N){
		scanf("%d", &h);
		freq[h]++;
	}
	
	deque <vector <ll> > P;
	
	REP(i,100010) if(freq[i] > 0){
		int n = freq[i];
		vector <ll> v(n/2+1);
		REP(j,n/2+1){
			ll tmp = F[n] * Finv[2*j] % MOD * Finv[n-2*j] % MOD * G[j] % MOD;
			if(j % 2 == 1) tmp = (MOD - tmp) % MOD;
			v[j] = tmp;
		}
		P.push_back(v);
	}
	
	while(P.size() > 1){
		vector <ll> v = convolution(P[0], P[1]);
		P.pop_front();
		P.pop_front();
		P.push_back(v);
	}
	
	ll ans = 0;
	REP(i,P[0].size()) ans = (ans + P[0][i] * G[N-i]) % MOD;
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 12696
#include <stdio.h>
int haha(int i,int m);
int n,a[20]={},q,m;
int main()
{
	scanf("%d",&n);

	for(int i = 0 ; i < n ; i++)
		scanf("%d",&a[i]);

	scanf("%d",&q);

	for(int i=0;i<q;i++){
		scanf("%d",&m);

		if(haha(0,m))
			printf("yes\n");

		else
			printf("no\n");
	}
	
	return 0;
}

int haha(int i,int m){

	if(m==0)
		return 1;
	if(i>=n)
		return 0;

	int eun= haha(i+1,m) || haha(i+1,m-a[i]);
	return eun;
}

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

#define itn int
#define vi vector<int>
#define pb push_back
#define srt sort(v.begin(), v.end())
#define retunr return

//int infiint = std::numeric_limits<int>::max();
//float infiflt = std::numeric_limits<float>::infinity();


int main() {
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.txt", "rt", stdin);

	string s1;
	cin >> s1;
	int gh = s1.size();
	for(int i = 0; i < gh; i++)
		cout << 'x';

	return 0;
}


Measured memory_bytes: 384
X,Y=map(int, input().split())
v1 = [300000, 200000, 100000]
v2 = [300000, 200000, 100000]
x = 0
y = 0
if X <= 3:
    x = int(v1[X-1])
if Y <= 3:
    y = int(v2[Y-1])
if ((X==1) & (Y==1)):
    print(int(x + y + 400000))
else:
    print(int(x + y))

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

using namespace std;

//#define FILE_IO

typedef long long LL;

LL N, L, T;
LL p[100005], d[100005], f[100005], r[100005], aux[100005];

LL getIntersections(LL x, LL y)
{
	if(x > y) y += L;
	if(2 * T <= y - x)  return 0;
	LL t = 2 * T - (y - x);
	LL cnt = t / L + 1;
	if(t % L == 0)  cnt--;
	return cnt;
}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%lld%lld%lld", &N, &L, &T);
    for(LL i = 0; i < N; i++)
    {
        scanf("%lld%lld", &p[i], &d[i]);
        if(d[i] == 2)   d[i] = -1;
    }

    LL add = T % L;
    for(LL i = 0; i < N; i++)
    {
        if(d[i] == 1)   f[i] = (p[i] + add) % L;
        else            f[i] = (p[i] - add + L) % L;
    }
    sort(f, f + N);
    LL pos0 = p[0];
    if(d[0] == 1)   pos0 = (p[0] + add) % L;
    else            pos0 = (p[0] - add + L) % L;

    for(LL i = 0; i < N; i++)  aux[i] = f[i];
    for(LL i = 0; i < N; i++)
        if(pos0 == f[i])
        {
            if(f[i] == f[i + 1] && d[0] == -1)   i++;
            for(LL j = 0; j < N; j++)
                f[j] = aux[(j + i) % N];
            break;
        }

    LL id = 0;
    for(LL i = 1; i < N; i++)
        if(d[i] != d[0])
        {
            LL cnt = 0;
            if(d[0] == 1)   cnt = getIntersections(p[0], p[i]);
            else            cnt = getIntersections(p[i], p[0]);
            if(d[0] == 1) (id += cnt) %= N;
            else (id += N - (cnt % N) ) %= N;
        }

    for(LL i = 0; i < N; i++)
        r[(id + i) % N] = f[i];

    for(LL i = 0; i < N; i++)
        printf("%lld\n", r[i]);

    return 0;
}


Measured memory_bytes: 5120
#include <stdio.h>

int main (void)
{
    char s[4] = "\0";
    int total = 700;

    scanf("%s", s);
    if (s[0] == 'o') {
        total += 100;
    }
    if (s[1] == 'o') {
        total += 100;
    }
    if (s[2] == 'o') {
        total += 100;
    }
    printf("%d\n", total);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long int
// #include "Template.cpp"
#define endl "\n"

void solve()
{
    int n; cin >> n;
    vector<int> arr(n, 0);
    for(int i = 0; i < n; i ++) {
        cin >> arr[i];
    }
    auto check = [&](int i , int j, int k) {
        if(arr[i] == arr[j] || arr[j] == arr[k] || arr[i] == arr[k]) return false;
        return (arr[i] + arr[j]) > arr[k];
    };
    int ans = 0;
    for(int i = 0; i < n; i ++) {
        for(int j = i + 1; j < n; j ++) {
            for(int k = j + 1; k < n; k ++) {
                if(check(i, j, k) && check(i, k, j) && check(j, k, i)) {
                    ans ++;
                }
            }
        }
    }
    cout << ans << endl;
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3660
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
/**
 *
 * @author Y
 */
public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String[] s = br.readLine().split(" ");
        int a = Integer.parseInt(s[0]);
        int b = Integer.parseInt(s[1]);
        
        System.out.println( (a>b) ? GCDivisor(a,b) : GCDivisor(b,a) );
        
    }
    
    static int GCDivisor(int x1, int x2){
        return x2 == 0 ? x1 : GCDivisor(x2, x1%x2);
    }
}

Measured memory_bytes: 24312
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller(char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;
int main() {
  int N,D,X;
  scanf("%d%d%d",&N,&D,&X);
  vi A(N);
  rep(i,N) cin>>A[i];
  int counter=X;
  rep(i,N) {
    counter+=(D-1)/A[i]+1;
  }
  printf("%d\n",counter);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    //freopen("input01.txt","r",stdin);
    //freopen("output01.txt","w",stdout);
    long long int a,b,c,d, max1=LLONG_MIN;
    cin>>a>>b>>c>>d;
    max1=max({a*c,b*d,b*c,a*d});
    cout<<max1;
    return 0;
}

Measured memory_bytes: 3632
package main

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

type AB [][]int

func (ab AB) Len() int {
	return len(ab)
}

func (ab AB) Less(i, j int) bool {
	return ab[i][1] < ab[j][1]
}

func (ab AB) Swap(i, j int) {
	ab[i], ab[j] = ab[j], ab[i]
}

func main() {
	var n int
	fmt.Scan(&n)

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	ab := make(AB, n)
	for i := 0; i < n; i++ {
		scanner.Scan()
		a, _ := strconv.Atoi(scanner.Text())
		scanner.Scan()
		b, _ := strconv.Atoi(scanner.Text())
		ab[i] = []int{a, b}
	}
	sort.Sort(ab)

	t := 0
	for i := 0; i < n; i++ {
		t += ab[i][0]
		// fmt.Println(ab[i][0], ab[i][1], t)
		if t > ab[i][1] {
			fmt.Println("No")
			return
		}
	}

	fmt.Println("Yes")
}


Measured memory_bytes: 10112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
  int a,b;
  cin >> a >> b;
  int c = a-b*2;

  if(c<0) cout << 0 << endl;
  else cout << c << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
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; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int n = size(s);
    for(int i = n - 1; i >= 0; i--) {
        string ss = s.substr(0, i);
        if(size(ss) & 1) continue;
        bool ok = true;
        for(int j = 0; j < size(ss) / 2; j++) {
            if(ss[j] != ss[j + size(ss) / 2]) ok = false;
        }
        if(ok) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3572
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;

int64_t gcd(int64_t a, int64_t b) {return b?gcd(b, a%b):a;}
int64_t lcm(int64_t a, int64_t b) {return a/gcd(a,b)*b;}
int64_t extgcd(int64_t a, int64_t b, int64_t &x, int64_t &y) { // ax+by=gcd(a, b)の解を与える
    int64_t d = a;
    if(b) {
        d = extgcd(b, a%b, y, x);
        y -= (a/b)*x;
    } else {
        x = 1; y = 0;
    }
    return d;
}

int main() {
    int n;
    cin >> n;
    vector<ll> t(n);
    rep(i, n) {
        cin >> t[i];
    }

    ll ans = 1;
    rep(i, n) {
        ans = lcm(ans, t[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100005
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define ll  long long
using namespace std;
ll a,b,c;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(); cout.tie();
   
    cin>>a>>b>>c;
    ll d=c-a-b;
    if (d>0 && d*d>4*a*b) cout<<"Yes"; else cout<<"No";

}


Measured memory_bytes: 256
import sys
import numpy as np

N = int(sys.stdin.readline().rstrip())
AList = list(map(int,sys.stdin.readline().split()))

odd=True
sumRes=0
for a in AList:
  if odd:
    sumRes+=a
    odd = False
  else:
    sumRes-=a
    odd = True

x1 = sumRes//2
ansList = [x1]
for i in range(N):
  ansList.append(AList[i]-ansList[i])
  
ansList=np.array(ansList)
ansList=ansList[0:len(ansList)-1] * 2
print(' '.join(map(str, ansList)))
  


Measured memory_bytes: 24920
#include<bits/stdc++.h>
//#include<boost/lexical_cast.hpp>
#define si(n) scanf("%d",&n)
#define pb push_back

using namespace std;

int main()
{
    int n, m;
    vector<int> start;
    vector<int> finish;
    si(n);
    si(m);
    while(m--)
    {
        int a,b;
        si(a);
        si(b);
        if(a==1)start.pb(b);
        else if(b==n)finish.pb(a);
    }
    sort(start.begin(),start.end());
    sort(finish.begin(),finish.end());
    int f=0;
    for(int i=0,j=0;i<start.size()&& j<finish.size();)
    {
        if(start[i]==finish[j])
        {
            f=1;
            break;
        }
        else if(start[i]>finish[j])j++;
        else i++;
    }
    if(f==1)printf("POSSIBLE\n");
    else printf("IMPOSSIBLE\n");

}


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

int main()
{
int size1=0,size2=0;
int num=0;
int mini=0;
vector<int>n;
int j=0;
cin>>size1>>size2;
for(int i=0;i<size1;i++){
  cin>>num;
    n.push_back(num);

}

 for(int i=1;i<size1;i++){
      int first=n[i];
    for (j=i ; j > 0&&first<n[j-1] ; j--){
        n[j] = n[j-1];}
        n[j] = first;

 }

for(int i=0;i<size2;i++){
        mini=mini+n[i];
}
cout<<mini;






    return 0;
}


Measured memory_bytes: 3628
function main(input) {
  var a = input[0].split(" ")[0]-0;
  var b = input[0].split(" ")[1]-0;
  if(b%a == 0) console.log(a+b);
  else console.log(b-a);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


Measured memory_bytes: 7372
#include <iostream>
#include <stack>
#include <vector>
 
using namespace std;
 
int main() {
    stack<int> S1;
    stack< pair<int, int> > S2;
    int *ans;
    char ch;
    int A = 0;
 
    int i = 0, j;
    while (cin >> ch) {
        if (ch == '_' || (ch == '/' && S1.empty() == true)) {
            ++i;
            continue;
        }
        else if (ch == '\\') {
            S1.push(i);
            ++i;
            continue;
        }
        else if (ch == '/') {
            j = S1.top();
            S1.pop();
            A += (i - j);
            if (S2.empty() == true) {
                S2.push(make_pair(j, i - j));
                ++i;
                continue;
            }
            else {
                int k = S2.top().first;
 
                if (k < j) {
                    S2.push(make_pair(j, i - j));
                    ++i;
                    continue;
                }
                else if (j < k) {
                    int tempArea = 0;
                    while (j < k && S2.empty() != true) {
                        tempArea += S2.top().second;
                        S2.pop();
                        if (S2.empty() != true) {
                            k = S2.top().first;
                        }
                    }
                    S2.push(make_pair(j, tempArea + (i - j)));
                    ++i;
                    continue;
                }
            }
        }
        else {
            ++i;
            continue;
        }
    }
 
    int size = S2.size();
    ans = new int[size];
    for (int i = 0; i < size; ++i) {
        ans[size - 1 - i] = S2.top().second;
        S2.pop();
    }
 
 
    cout << A << endl;
    cout << size;
    for (int i = 0; i < size; ++i) {
        cout << " " << ans[i];
    }
    cout << endl;
 
    return 0;
}

Measured memory_bytes: 3264
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
 
#define INFLL 2000000000000000000
#define INF 2000000000
#define MOD 1000000007
#define PI acos(-1.0)
 
using namespace std;
 
typedef pair <int, int> pii;

bool isGood[2000][2000];
bool board[2000][2000];
int up[2000][2000];
int n, m;
int ll[2000], rr[2000];
int curRow;

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		string str;
		cin >> str;
		for (int j = 0; j < str.length(); j++) {
			board[i][j] = (str[j] == '#');
		}
	}
	for (int i = 0; i < n - 1; i++) {
		for (int j = 0; j < m - 1; j++) {
			int cnt = 0;
			for (int x = 0; x < 2; x++)
				for (int y = 0; y < 2; y++)
					if (board[i + x][j + y])
						cnt++;
			if (cnt % 2 == 0)
				isGood[i][j] = true;
			else
				isGood[i][j] = false;
		}
	}
	m--;
	n--;
	for (int i = 0; i < m; i++) 
		if (isGood[0][i]) up[0][i] = 1;
		else up[0][i] = 0;
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (isGood[i][j])
				up[i][j] = up[i - 1][j] + 1;
			else
				up[i][j] = 0;
		}
	}
	int ans = max(n + 1, m + 1);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++)
			ll[j] = rr[j] = j;
		stack <int> st;
		st.push(-1);
		for (int j = 0; j < m; j++) {
			while (st.top() != -1 && up[i][st.top()] >= up[i][j]) st.pop();
			ll[j] = st.top();
			st.push(j);
		}
		st = stack <int>();
		st.push(m);
		for (int j = m - 1; j >= 0; j--) {
			while (st.top() != m && up[i][st.top()] >= up[i][j]) st.pop();
			rr[j] = st.top();
			st.push(j);
		}
		for (int j = 0; j < m; j++) {
			if (up[i][j] == 0)
				continue;
			ans = max(ans, (rr[j] - ll[j]) * (up[i][j] + 1));
			//cout << i << " " << j << " " << ll[j] << " " << rr[j] << endl;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 23680
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.size = [1 for _ in range(n+1)]

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)
    
    
def main():
    N, M = [int(_) for _ in input().split()]
    bridge = [tuple(map(int, input().split())) for _ in range(M)]

    last = []
    last.append(int(N * (N-1) * 0.5))

    ins = UnionFind(N)
    last_temp = 0

    for i in range(M-1):
        #print(ins.par)
        if ins.same_check(bridge[M-1-i][0],bridge[M-1-i][1]):
            last.append(last[-1])
            #ins.union(bridge[M-1-i][0],bridge[M-1-i][1])
        else:
            last_temp = last[-1] - (ins.size[ins.find(bridge[M-1-i][0])]) * (ins.size[ins.find(bridge[M-1-i][1])])
            #print(ins.size,i)
            last.append(last_temp)
            ins.union(bridge[M-1-i][0],bridge[M-1-i][1])
    
    [print(last[M-i-1]) for i in range(M)]
    exit()
    
main()

Measured memory_bytes: 24956
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const long long mod = (long long)1e9 + 7;
const double pi = acos(-1.0);

int main() {
	int n;
	while (cin >> n && n) {
		VI a(n), b(n), c(n);
		rep(i, n)cin >> a[i] >> b[i] >> c[i];
		int v = max(*max_element(all(a)), *max_element(all(b))) + 1;

		VVI d(v, VI(v, inf));
		rep(i, v)d[i][i] = 0;
		rep(i, n) { d[a[i]][b[i]] = c[i]; d[b[i]][a[i]] = c[i]; }
		rep(i, v)rep(j, v)rep(k, v)d[j][k] = min(d[j][k], d[j][i] + d[i][k]);

		int ans1 = -1, ans2 = inf;
		rep(i, v) {
			int sum = accumulate(all(d[i]), 0);
			if (ans2 > sum) { ans1 = i; ans2 = sum; }
		}
		cout << ans1 << " " << ans2 << endl;
	}
}


Measured memory_bytes: 3116
H,W=map(int,input().split())
N=int(input())
a=list(map(int,input().split()))

color=[]
for i in range(N):
    color+=[i+1]*a[i]

grid=[]
for g in range(H):
    grid.append(color[g*W:(g+1)*W])

for l in range(H):
    if l%2==0:
        print(*grid[l])
    else:
        print(*grid[l][::-1])

Measured memory_bytes: 42224
#include<bits/stdc++.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
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

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

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T &a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T &a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

int main() {
	makei(d);
	cout << "Christmas";
	rep(25 - d)cout << " Eve";
	cout << endl;
}

Measured memory_bytes: 256
import           Control.Applicative
import           Control.Arrow
import           Control.Monad
import           Data.Bits
import qualified Data.ByteString.Char8         as B
import           Data.Char
import           Data.List
import qualified Data.Vector.Unboxed           as V
import           Data.Maybe

main = do
  let readInt = fmap (second B.tail) . B.readInt
  a <- fst . fromJust . readInt <$> B.getLine
  putStrLn $ if a >= 30 then "Yes" else "No"


Measured memory_bytes: 3772
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 501

int a[SIZE], b[SIZE], c[SIZE], h[SIZE], r[SIZE];
int d[SIZE], passprice[1<<8];

bool solve(){
  vector<pair<int,int> > way[SIZE];
  int n, m, p, H, K;
  int s,t;
  
  scanf("%d%d%d%d", &n, &m, &H, &K);

  if(H == 0) return false;
  
  for(int i=0;i<m;i++){
    scanf("%d%d%d%d%d", a+i, b+i, c+i, h+i, r+i);
    a[i]--; b[i]--; r[i]--;
    way[a[i]].push_back({i, b[i]});
    way[b[i]].push_back({i, a[i]});
  }

  scanf("%d%d%d", &s, &t, &p);
  s--; t--;

  for(int i=0;i<(1<<K);i++) passprice[i] = INF;
  passprice[0] = 0;
  
  for(int i=0;i<p;i++){
    int l, b, q = 0, d;
    scanf("%d%d", &l, &d);
    for(int j=0;j<l;j++){
      scanf("%d", &b);
      b--;
      q |= 1 << b;
    }

    for(int j=(1<<K)-1;j>=0;j--){
      passprice[j|q] = min(passprice[j|q], passprice[j] + d);
    }
  }

  int ans = INF;
  
  for(int freepass=0;freepass<(1<<K);freepass++){
    if(passprice[freepass] == INF) continue;
    
    priority_queue<pair<int,int> > pq;
    bool visited[SIZE*25] = {};
    pq.push({0, s});

    while(pq.size()){
      int now = pq.top().second;
      int cost = -pq.top().first;
      pq.pop();

      if(visited[now]) continue;
      visited[now] = true;

      if (now%n == t){
        ans = min(ans, cost + passprice[freepass]);
        break;
      }

      for(int i=0;i<way[now%n].size();i++){
        int id = way[now%n][i].first;
        int to = (now / n + h[id]) * n + way[now%n][i].second;
        if(to / n > H) continue;
        int newcost = cost;
        if(!(freepass & (1 << r[id]))) newcost += c[id];
        
        pq.push({-newcost, to});
      }
    }

  }

  if(ans == INF) ans = -1;
  
  printf("%d\n", ans);
  
  return true;
}

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



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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using v = vector<T>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}

/* ----------- ANSWER ----------- */
/* ------------------------------ */

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        double w, h, x, y;
        cin >> w >> h >> x >> y;
        double ans = w * h / 2.0;
        cout << fixed << setprecision(10) << ans;
        cout << " " << (x == w / 2 && y == h / 2) << endl;

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fio ios_base::sync_with_stdio(false)
#define pdl cout << "*" << endl
#define MOD 1000000007
#define INF 1000000000
#define INFLL 1000000000000000000ll
#define ff first
#define ss second
#define long int64_t
using namespace std;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<> dis(0, INF<<1);
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char* name, Arg1&& arg1){ cerr << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args)
{ const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma+1, args...); }

const int N = 3001;
const int mod = 998244353;

int c[N][N], ps[N+1], mul[N][N], dp[2][N][N << 1];

int main()
{
	fio;
	for(int i=0; i<N; i++)
		c[i][0] = 1;
	for(int i=1; i<N; i++)
		for(int j=1; j<N; j++)
			c[i][j] = (c[i-1][j] + c[i-1][j-1]) % mod;
	int n, k;
	cin >> n >> k;
	for(int i=n; i>=0; i--)
		ps[i] = (ps[i+1] + c[n][i]) % mod;
	for(int l=1; l<=n; l++)
	{
		mul[l][0] = c[n][l];
		for(int y=1; l+y<=n; y++)
		{
			mul[l][y] = (mul[l][y-1] + ps[l+y] + 0ll + ps[l+y]) % mod;
			if(l + (y << 1) < n)
				mul[l][y] = ((mul[l][y] - ps[l + (y << 1)] - ps[l + (y << 1) + 1]) % mod + mod) % mod;
			else if(l + (y << 1) == n)
				mul[l][y] = (mul[l][y] - c[n][n] + mod) % mod;
		}
		for(int y=n-l+1; y<=n; y++)
			mul[l][y] = mul[l][y-1];
	}
	dp[0][1][1] = 1;
	for(int l=2; l<=n; l++)
		for(int x=2; x<=k; x++)
			for(int i=0; i<2; i++)
				dp[i][l][x] = (dp[0][l-1][x-1-i] + dp[1][l-1][x-1-i]) % mod;
	int ans = 1;
	for(int l=1; l<=n; l++)
		for(int x=1; x<=k; x++)
			if((x & 1) != (k & 1))
				ans = (ans + dp[0][l][x] * 1ll * mul[l][k-x-1 >> 1]) % mod;
	memset(dp, 0, sizeof dp);
	dp[0][0][0] = dp[0][1][1] = dp[0][1][2] = 1;
	for(int l=2; l<=n; l++)
		for(int x=2; x<k; x++)
			dp[0][l][x] = (dp[0][l-1][x-1] + dp[0][l-1][x-2]) % mod;
	for(int l=1; l<=n; l++)
		for(int x=1; x<k; x++)
			if((x & 1) == (k & 1))
				ans = (ans + dp[0][l][x] * 1ll * c[n][l]) % mod;
	if(k & 1)
	{
		for(int i=1; i<=n; i++)
			ans = (ans + c[n][i]) % mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 211328
import math

A,B,H,M = (int(a) for a in input().split())
h = H * 30 + M/2
m = 6 * M
a = abs(h-m)
x = min(a,360-a)
t = math.cos(x*(math.pi)/180)
print(math.sqrt(A**2 + B**2 - 2*A*B*t))

Measured memory_bytes: 9500
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>

using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vs = vector<string>;
using Vb = vector<bool>;
using the = pair<int, int>;

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };

int main()
{
	int n, m, x;
	cin >> n >> m >> x;
	Vi C(n);
	Vii A(n, Vi(m, 0));
	rep(i, n) {
		cin >> C[i];
		rep(j, m) {
			cin >> A[i][j];
		}
	}

	Vi T(m, 0);
	bool ans = true;
	int sum = 0;
	Vi Ans;
	for (int bit = 0; bit < (1 << n); ++bit)
	{
	
		for (int i = 0; i < n; ++i) {
			if (bit & (1 << i)) { 
				rep(j, m)  T[j] += A[i][j];
				sum += C[i];
			}
		}
		/*rep(j, m) {
			cout << T[j] << " ";
		}
		cout<<" "<<sum << endl;*/
		rep(j, m) {
			if (T[j] < x) {
				ans = false;
				break;
			}
		}
		if (ans) Ans.push_back(sum);
		sum = 0;
		ans = true;
		rep(j, m)  T[j] = 0;
	}

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


Measured memory_bytes: 3644
local N = io.read("*n")
local A = {}
for i = 1, N do
   A[i] = io.read("*n")
end

local counter = 0
local X = true
while X do
    for i = 1, N do
        if A[i]%2 == 0 then
            A[i] = A[i]/2
        else
            X = false
        end
    end
    counter = counter + 1
end

print(counter-1)

Measured memory_bytes: 760
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repi(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
typedef long long ll;
using namespace std; 
using P = pair<int,int>;
const ll mod = 1e9+7;
const int INF = 1001001001;

const int MAX_W = 500;
const int MAX_H = 500;

int main(){
  int k;
  string s;
  cin >> k >> s;
  if(k>=s.size()){
    cout << s << endl;
  }else{
    for(int i=0;i<k;i++){
      cout << s[i];
    }
    cout << "..." << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3628
eps = 1e-12
q = gets.to_i
q.times{
  x0, y0, x1, y1, x2, y2, x3, y3 = gets.split.map(&:to_f)
  v0x = x1 - x0
  v0y = y1 - y0
  v1x = x3 - x2
  v1y = y3 - y2
  ct = (v0x*v1x+v0y*v1y)/Math.sqrt(v0x**2+v0y**2)/Math.sqrt(v1x**2+v1y**2)
  if (ct.abs - 1.0).abs < eps
    puts 2
  elsif ct.abs < eps 
    puts 1
  else
    puts 0
  end
}

Measured memory_bytes: 8904
s = gets.chomp
len = s.length

len.times do |i|
  s.slice!(-1)
  len2 = s.length
  if len2.even?
    x = s.scan(/.{1,#{len2/2}}/)
    if x[0] == x[1]
      puts len2
      break
    end
  end
end

Measured memory_bytes: 1916
import math

N= int(input())
A = list(map(int, input().split()))
 
B=[0]*N
for i in range(N):
    B[i]=A[i]-(i+1)

B=sorted(B)
cnt=B[(N//2)]

s=0
for i in range(N):
    s+=abs(B[i]-cnt)

print(s)


Measured memory_bytes: 26832
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;

typedef unsigned long long ll;
typedef int                     integer;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<" "<<y<<endl
#define pl(x)                   out<<x
#define p2l(x,y)                out<<x<<" "<<y
#define p1d(a,n)                for(int ix=0;ix<n;ix++) out<<a[ix]<<" "; out<<endl
#define p2d(a,n,m)              for(int ix=0;ix<n;ix++){ for(int jx=0;jx<m;jx++) out<<a[ix][jx]<<" "; out<<endl;}
#define range(v)                v.begin(),v.end()
#define w(x)                    while(x--)
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

class AFallingAsleep {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n;
        s(n);
        vector<string> ss(n);
        vi t(n);
        f(i,0,n){
            s2(ss[i],t[i]);
        }
        string x;
        s(x);
        int found = 0;
        f(i,0,n){
            if(ss[i] == x){
                found = i+1;
                break;
            }
        }
        int total = 0;
        f(i,found, n){
            total += t[i];
        }
        out<<total<<endl;

	}
};


integer main() {
	AFallingAsleep solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
}


Measured memory_bytes: 764
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<
typedef struct {
	int h;
	int w;
}Point;

long nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string s;
	cin>>s;
	int size=s.length();
	s="L"+s+"R";
	//cout<<s<<endl;
	vector<long long>ans(size+2,0);
	for(int i=1;i<=size;i++){
		if(s[i]=='R'&&s[i+1]=='L'){
			//cout<<i<<endl;
			//between i i+1
			int j=0;
			while(s[i-j]!='L'){
				if(j%2==0)ans[i]++;
				else ans[i+1]++;
				j++;
			}
			j=1;
			while(s[i+j]!='R'){
				if(j%2==0)ans[i]++;
				else ans[i+1]++;
				j++;
			}
		}
	}
	
	for(int i=1;i<size;i++){
		cout<<ans[i]<<" ";
	}
	cout<<ans[size]<<endl;
	
}
	


Measured memory_bytes: 1388
#include <stdio.h>
#define num_element 130
int main(void)
{
	int i,n,m;
	char array[num_element];
	char a[2];
	char b[2];
	char input[2];
	while(1)
	{
		for(i=0;i<num_element;i++)
		{
			array[i] = i;
		}
		scanf("%d",&n);
		if(n == 0)return 0;
		for(i=0;i<n;i++)
		{
			scanf("%s %s",a,b);
			array[a[0]] = b[0];
		}
		scanf("%d",&m);
		for(i=0;i<m;i++)
		{
			scanf("%s",input);
			printf("%c",array[input[0]]);
		}
		printf("\n");
	}
	return 0;
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

typedef long long lint;
typedef pair< lint, lint > pll;

int n;
vector< lint > a, lb, ub;
set< pll > used;
set< lint > adjs[5];

void dfs(int i, vector< lint >& res, vector< lint >& cur, int max_size, int max_depth) {
	if ((int)cur.size() == max_size || i == max_depth) {
		if (res.size() < cur.size()) res = cur;
		return;
	}
	
	bool poyo = true;
	
	for (lint v : cur) poyo &= !adjs[i].count(v);
	
	if (poyo) {
		for (lint v = lb[i]; v < ub[i] && v < lb[i] + 5; ++v) {
			bool ok = true;
		
			for (lint u : cur) ok &= !used.count(pll(u, v));
		
			if (ok) {
				cur.push_back(v);
				dfs(i + 1, res, cur, max_size, max_depth);
				cur.pop_back();
			}
		}
	}
	
	dfs(i + 1, res, cur, max_size, max_depth);
}

lint calc() {
	used.clear();
	for_(i,0,n) adjs[i].clear();
	
	lb.assign(n, 0);
	ub.assign(n, 0);
	
	for_(i,0,n) {
		vector< lint > vc, cur;
		
		dfs(0, vc, cur, a[i], i);
		
		//cout << a[i] << " " << vc.size();// << endl;
		
		if (i > 0) lb[i] = ub[i - 1];
		ub[i] = lb[i] + a[i] - vc.size();
		
		//cout << " " << lb[i] << " " << ub[i] << endl;
		
		for (lint u : vc) { adjs[i].insert(u); /*cout << u << " ";*/ }
		//cout << endl;
		
		for (lint u : vc) for (lint v : vc) {
			if (u == v) continue;
			used.insert(pll(u, v));
			used.insert(pll(v, u));
		}
	}
	
	//cout << "-----" << endl;
	
	return ub[n - 1];
}

int main() {
	cin >> n;
	a.assign(n, 0);
	for_(i,0,n) cin >> a[i];
	
	sort(a.begin(), a.end());// greater< lint >());
	
	lint ans = accumulate(a.begin(), a.end(), lint());
	
	do {
		ans = min(ans, calc());
	} while(next_permutation(a.begin(), a.end()));
	
	cout << ans << endl;
}

Measured memory_bytes: 3180