akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>

using namespace std;

int main(){
	int N;
	while(cin>>N, N){
		map<int, int> m;
		map<int, int>::iterator it;
		m.insert( make_pair(0, -1) );
		m.insert( make_pair(1000000001, -2) );
		while(N--){
			char com;
			int I, S, P, ans=-1;
			cin >> com;
			switch(com){
			case 'W':
				cin >> I >> S;
				for(it = m.begin(); it!=m.end() && S;){
					if(it->second == -1){
						it->second = I;
						int st = it->first;
						it++;
						int ls = it->first;
						if( ls-st > S ){
							m.insert( make_pair(st+S, -1) );
							break;
						}else{
							S -= ls-st;
						}
					}else it++;
				}
				break;
			case 'D':
				cin >> I;
				for(it = m.begin(); it!=m.end(); it++){
					if( it->second == I ){
						it->second = -1;
					}
				}
				break;
			case 'R':
				cin >> P;
				for(it = m.begin(); it!=m.end(); it++){
					if( it->first > P ){
						break;
					}else{
						ans = it->second;
					}
				}
				cout << ans << endl;
				break;
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;

int main(){
int A;
cin>>A;
if((A/100%10==7) || (A/10%10==7) || (A%10==7)){
  cout<<"Yes"<<endl;
}else{
  cout<<"No"<<endl;
}



}

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

using namespace std;

void solve()
{
	int a, b, c, d;
	string s;
	cin >> a >> b >> c >> d;
	//cin >> s;

	cout << (a-c)*(b-d) << endl;
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
l,r=map(int,input().split())
L=[]
ans=2019
mod=0
for i in range(r-l+1):
    L.append((l+i)%2019)
    if L.count((l+i)%2019)>1:
            break
for i in range(len(L)):
    for j in range(len(L)):
        if i!=j:
            mod=L[i]*L[j]%2019
            ans=min(ans,mod)
    if ans==0:
        break
print(ans)

Measured memory_bytes: 40172
#include <stdio.h>
int main(void){
    char a[200010] = {};
    scanf("%s",a);
    int i,j;
    for(i = 0; a[i] != 'A'; i++);
    for(j = 200005; a[j] != 'Z'; j--);
    printf("%d\n",j-i+1);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int x, a, b; cin >> x >> a >> b;
    if(a >= b) cout << "delicious" << endl;
    else if(a+x >= b) cout << "safe" << endl;
    else cout << "dangerous" << endl;  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,mx=0; cin>>n;
	string s;
	map<string,int>mp;
	for(int i=0;i<n;i++){
		cin>>s; mp[s]++;
		mx=max(mp[s],mx);
	}
	for(const auto& x:mp){
		if(x.second==mx)
			cout<<x.first<<'\n';
	}
	return 0;
}

Measured memory_bytes: 23808
"use strict";
function main(input) {
  let k = input[0].split(" ");
  k = k[1];
  let n = input[1].split(" ");
  
  //期待値の前計算
  let exp = [];
  for(let i=0;i<n.length;i++){
    exp[i] = (1 + parseInt(n[i],10)) / 2;
  }

  //累積和の計算
  let sum = [0];
  for(let i=0;i<n.length;i++){
    sum[i+1] = sum [i] + exp[i];
  }
  
  //隣接するk項の和の計算
  let max = 0;
  for(let i=k;i<=n.length;i++){
    let max_n = sum[i] - sum[i-k];
    max = (max<max_n)?max_n:max;
  }
  console.log(max);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

Measured memory_bytes: 38048
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int n;
    cin >> n;
    cout << (100000 - n) % 1000 << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long ago=0;
  int N,K; cin>>K>>N;
  for(int i=0;i<=K;i++){
    for(int j=0;j<=K;j++){
      if(N-i-j>=0&&N-i-j<=K)ago++;
    }
  }
  cout<<ago<<endl;
}

Measured memory_bytes: 3596
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define debug(v) cout << #v<< ": " << v <<endl;
#define fst first
#define snd second
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;

bool ps(const vll &l, ll n, ll k){
    ll c = 0;
    rep(i, 0, sz(l)){
        if(l[i] > n){
            c += l[i]/n;
            if(l[i]%n == 0){
                c--;
            }
        }
    }
    return c <= k;
}

int main(){
    ll n, k; cin >> n >> k;
    vll l(n);
    rep(i, 0, n){
        cin >>l[i];
    }
    ll mn = 0, mx = INF, md = (mn+mx)/2;
    while(mx - mn > 3){
        if(ps(l, md, k)){
            mx = md;
            md = (mn+mx)/2;
        }else{
            mn = md;
            md = (mn+mx)/2;
        }
    }
    ll t = 1;
    ll s = max(mn-2, t);
    rep(i, s, mx+2){
        if(ps(l, i, k)){
            prtl(i);
            return 0;
        }
    }
}


Measured memory_bytes: 4740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
const long long INF = 1LL << 60;

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

int main()
{   
    int n; cin >> n;
    int res=0;
    for(int i=1;i<=n;i++){
        if(i%2)res++;
    }
    printf("%.6lf\n",res*1.0/n);
}

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


int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    
    for(int i = 0;i<N;i++){
        cin >> a[i];
    }
    
    sort(a.begin(),a.end());
    int minX = a[0];
    int maxX = a[N-1];

    vector<int> num(maxX+1);//num[i]はiの個数
    for(int i = 0;i<N;i++){
        num[a[i]]++;
    }
    num.push_back(0);

    int ans = 0;
    for(int X = minX;X<=maxX;X++){//Xを決めると,X-1,X,X+1がX化できる要素なのでその数をカウント

        int c = 0;
        c += num[X-1];
        c += num[X];
        c += num[X+1];
        ans = max(ans,c);
    }
  cout << ans << endl;

}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm> 
#include <functional>	
using namespace std;

int main() {
	int n;
	cin >> n;
	if (n < 1000) {
		cout << "ABC" << endl;
	}
	else {
		cout << "ABD" << endl;
	}


	return 0;
}

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

int main()
{
int N;
int A;

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

	cin >> N;
	cin >> A;

	if( A >= 499 )
		cout << "Yes" << endl;
	else if( N % 500 <= A )
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}






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

using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 
 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define zeroes(x) memset(x,0,sizeof(x))
typedef long long int ll;
 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn=100000;



long long fe[32];
long long k; 
void decToBinary(long long n) 
{ 
    
    memset(fe,-1,sizeof(fe));
    long long i = 0; 
    while (n > 0) { 
  
        fe[i] = n % 2; 
        n = n / 2; 
        i++; 
    } 
} 

/*int main()
{
    long long n,q,m,b1,ans=0,a1,s,cntn=0,cntp=0,cntz=0,max1=-1,max2=-1;
    cin>>n;
    vector< pair <int,int> >a;
    long long p[n];
    for (int i = 0; i < n; ++i)
    {
        cin>>p[i];
    }
}*/

int main()
{
    long long n,a,b,c,k,flag=0,i=0;
    string s;
    cin>>s;
    n=s.length();
    //cout<<n<<endl;
    long long cntr=0,cntl=0,ind[n],o;
    memset(ind,0,sizeof(ind));
    //cout<<2<<endl;
    while(i<n-1)
    {
        //a=!(s[i]=='L' && s[i+1]=='R');
        //cout<<a<<endl;
        while (!(s[i]=='L' && s[i+1]=='R') && (i<n-1))
        {
            //cout<<i<<endl;
            if(s[i]=='R' && s[i+1]=='L')
                o=i;
            if(s[i]=='R')
                cntr+=1;
            if(s[i]=='L')
                cntl+=1;
            i++;
        }
        cntl+=1;
        if ((cntr+cntl)%2==0)
        {
            ind[o]=(cntr+cntl)/2;
            ind[o+1]=(cntr+cntl)/2;
        }
        else
        {
            if(cntr%2==1)
            {
                ind[o]=ceil(float(cntl+cntr)/2);
                ind[o+1]=ind[o]-1;
            }
            else
            {
                ind[o+1]=ceil(float(cntl+cntr)/2);
                ind[o]=ind[o+1]-1;
            }
        }
        cntr=0;
        cntl=0;
        i++;
    }
    for (int i = 0; i < n; ++i)
    {
        cout<<ind[i]<<" ";
    }

}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm(a, b) (a)/__gcd((a),(b))*(b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

vector<int> Div(int n) {
    vector<int> ret;
    for(int i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);

            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    string s, t;
    cin >> s >> t;
    int ssum[SIZE] = {}, tsum[SIZE] = {};
    for(int i = 0; i < s.size(); ++i) {
        int tmp;
        if(s[i] == 'A') {
            tmp = 1;

        } else {
            tmp = 2;

        }
        ssum[i + 1] = ssum[i] + tmp;
    }

    for(int j = 0; j < t.size(); ++j) {
        int tmp;
        if(t[j] == 'A') {
            tmp = 1;

        } else {
            tmp = 2;

        }
        tsum[j + 1] = tsum[j] + tmp;

    }

    int q;
    cin >> q;
    while(q--) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        if((ssum[b] - ssum[a - 1]) % 3 == (tsum[d] - tsum[c - 1]) % 3) {
            cout << "YES";

        } else {
            cout << "NO";

        }
        cout << endl;

    }
    return 0;
}



Measured memory_bytes: 2512
n=int(input())
a=[list(input()) for i in range(n)]
for i in range(n):
    a[i]=sorted(a[i])
import collections
import math
d=collections.defaultdict(int)
for i in a:
    d[''.join(i)]+=1
ans=0
for i in d.values():
    if i>2:
        ans+=math.factorial(i)//(math.factorial(i-2)*math.factorial(2))
    elif i==2:
        ans+=1
print(ans)

Measured memory_bytes: 39428
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,i,j,k,l,a,b,c,d;
    cin>>n;
    ll arr[n+10];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    a=b=0;
    sort(arr+0,arr+n,greater<ll>() );
    for(i=0;i<n;i++)
    {
        if(i%2==0)
        {
            a+=arr[i];
        }
        else
        {
            b+=arr[i];
        }

    }
    cout<<abs(a-b)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long       ll;
#define MOD ((int)1e9+7)
#define N ((int)2e5+123)
void reads(string& x){ char kk[N]; scanf("%s",kk); x = kk;}

int ans, a,b,c;

void solve(){
    scanf("%d%d%d", &a,&b,&c);
    swap(a,b);
    swap(a,c);
    printf("%d %d %d\n", a,b,c);
}

int main(){
    ios_base::sync_with_stdio(0);
    int t = 1; //scanf("%d",&t);
    for(int caso=1;caso<=t;caso++){
        solve();
    }
}

Measured memory_bytes: 3848
h, w = [int(i) for i in input().split()]
s = [list(input()) for _ in range(h)]
flg = True

for i in range(1, h - 1):
    for j in range(1, w - 1):
        if s[i][j] == "#" and s[i - 1][j] == "." and s[i + 1][j] == "." and s[i][j - 1] == "." and s[i][j + 1] == ".":
            flg = False

print('Yes' if flg else 'No')


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

using namespace std;

const int inf = (int)(1e9) + 100;
const int mod = (int)(1e9) + 100;
const int maxn = (int)(2e5) + 100;

#define pb push_back
#define mp make_pair
#define sz(a) (int)(a.size())
#define all(a) a.begin(), a.end()
#define ff first
#define ss second
#define ll long long
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vll vector <ll>
#define vpi vector <pii>
#define vpl vector <pll>
#define sc1(a) scanf("%d", &a)
#define sc2(a, b) scanf("%d%d", &a, &b)
#define frw(i, p, n) for(int i = p; i <= n; i++)
#define bck(i, n, p) for(int i = n; i >= p; i--)
#define mem(a) memset(a, 0, sizeof(a))

string s;
stack <char> st;
int main(){
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        if(st.empty()){
            st.push(s[i]);
        }
        else{
            if(st.top() == 'S' && s[i] == 'T'){
                st.pop();
            }
            else st.push(s[i]);
        }
    }
    cout << st.size() << endl;

	#ifndef ONLINE_JUDGE
        fprintf(stderr, "Time: %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC));
    #endif
	return 0;
}


Measured memory_bytes: 1152
MOD = 10**9 + 7

# 1 <= k <= n <= 10^7 程度
MAX = 510000
fac = [0] * MAX
finv = [0] * MAX
inv = [0] * MAX

fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1
for i in range(2, MAX):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = -inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD


def com(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD

from collections import defaultdict
n, m = map(int, input().split())

d = defaultdict(int)

i = 2
while m > 1:
    if m % i == 0:
        d[i] += 1
        m = m // i
    else:
        i += 1

for i in range(2, 10**5):
    if m % i == 0:
        d[i] += 1
        m = m // i

ans = 1
for k in d.keys():
    ans *= com(n-1+d[k], d[k])
    ans = (ans % MOD)
print(ans)

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

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

    sort(a, a + N, greater<int>());
    int Alice = 0;
    int Bob = 0;
    for (int i = 0; i < N; i++)
    {
        if (i % 2 == 0)
        {
            Alice += a[i];
        }
        else
        {
            Bob += a[i];
        }
    }

    cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
if (b-a)<=k and (c-a)<=k and (d-a)<=k and (e-a)<=k and (c-b)<=k and (d-b)<=k and (e-b)<=k and (d-c)<=k and (e-c)<=k and (e-d)<=k:
  print("Yay!")
else:
  print(":(")

Measured memory_bytes: 3064
while n=gets.to_i
  if n==0 then break end
  a=[]
  for i in 0..n-1
    a.push(gets.to_i)
  end
  a.sort!
  o=0
  for i in 0.. n-1
    o+=(n-1-i)*a[i]
  end
  puts o
end

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

using namespace std;
using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e9+7;
const ll mod = 1e9+7;

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

    if(a<=c&&c<=b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

using namespace std;

typedef long long llint;

int main() {
  llint a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;
  llint p = abs(a - b);
  llint q = (v - w) * t;
  if (p <= q) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, x[200001], s[200001];
vector<LL> v;

int main() {
	cin >> n;
	inc(i, n) { cin >> x[i] >> s[i]; }
	x[n] = 1e16;
	s[n] = 0;
	n++;
	
	inc(i, n) {
		v.PB(s[i]);
		v.PB(x[i] - x[i + 1]);
	}
	
	LL mi = 0, ma = 0, sum = 0;
	inc(i, v.size() - 1) {
		sum += v[i];
		setmin(mi, sum);
		setmax(ma, sum - mi);
	}
	
	cout << ma << endl;
	
	return 0;
}


Measured memory_bytes: 9692
n = int(input())
dp = [[0]*(4) for _ in range(n)]
for i in range(n):
    a,b,c = map(int,input().split())
    if i == 0:
        dp[0][1] = a
        dp[0][2] = b
        dp[0][3] = c
    else:
        dp[i][1] = max(dp[i-1][2]+a,dp[i-1][3]+a)
        dp[i][2] = max(dp[i-1][1]+b,dp[i-1][3]+b)
        dp[i][3] = max(dp[i-1][1]+c,dp[i-1][2]+c)
print(max(dp[-1][1],dp[-1][2],dp[-1][3]))


Measured memory_bytes: 60908
#include <iostream>
#include <string>
#include <string.h>
using namespace std;

class Dice{
private:
  int right,wrong;
  int N,E,W,S;
  int tmp1,tmp2;
public:
  Dice(int ri,int wr,int n,int e,int w,int s):right(ri),wrong(wr),N(n),E(e),W(w),S(s){};
  int ShowRight(){return right;}
  int ShowWrong(){return wrong;}
  int ShowN(){return N;}
  int ShowE(){return E;}
  int ShowW(){return W;}
  int ShowS(){return S;}
  void goN();
  void goE();
  void goW();
  void goS();
};

void Dice::goN(){
  tmp1=N; tmp2=S;
  N=wrong; S=right;
  right=tmp1; wrong=tmp2;
}
void Dice::goE(){
  tmp1=E; tmp2=W;
  E=wrong; W=right;
  right=tmp1; wrong=tmp2;
}
void Dice::goW(){
  tmp1=W; tmp2=E;
  W=wrong; E=right;
  right=tmp1; wrong=tmp2;
}
void Dice::goS(){
  tmp1=S; tmp2=N;
  S=wrong; N=right;
  right=tmp1; wrong=tmp2;
}

int main()
{
  int label1[6];
  int label2[6];
  int a,b;
  int flag=0;
  int OK_flag=0;

  for(int i=0;i<6;i++)
    cin >> label1[i];
  for(int i=0;i<6;i++)
    cin >> label2[i];

  Dice dice1(label1[0],label1[5],label1[1],label1[3],label1[2],label1[4]);
  Dice dice2(label2[0],label2[5],label2[1],label2[3],label2[2],label2[4]);


  a=dice1.ShowRight();
  if(a==dice2.ShowWrong()){ dice2.goN();dice2.goN();}
  else if(a==dice2.ShowN()) dice2.goN();
  else if(a==dice2.ShowE()) dice2.goE();
  else if(a==dice2.ShowW()) dice2.goW();
  else if(a==dice2.ShowS()) dice2.goS(); 
  if(dice1.ShowWrong()!=dice2.ShowWrong()){dice2.goN();dice2.goN();}
  {
    a=dice1.ShowRight();
    if(a==dice2.ShowWrong()){ dice2.goN();dice2.goN();}
    else if(a==dice2.ShowN()) dice2.goN();
    else if(a==dice2.ShowE()) dice2.goE();
    else if(a==dice2.ShowW()) dice2.goW();
    else if(a==dice2.ShowS()) dice2.goS(); 
  }
  
  b=dice1.ShowN();
  if(b==dice2.ShowS()){dice2.goS();dice2.goE();dice2.goE();dice2.goN();}
  else if(b==dice2.ShowW()){dice2.goS();dice2.goE();dice2.goN();}
  else if(b==dice2.ShowE()){dice2.goS();dice2.goW();dice2.goN();}
  
  for(int j=0;j<6;j++)
    {
      for(int i=0;i<4;i++)
	{
	  flag=0;
	  if(dice1.ShowRight()!=dice2.ShowRight())flag=1;
	  if(dice1.ShowRight()!=dice2.ShowRight())flag=1;
	  if(dice1.ShowN()!=dice2.ShowN())flag=1;
	  if(dice1.ShowE()!=dice2.ShowE())flag=1;
	  if(dice1.ShowW()!=dice2.ShowW())flag=1;
	  if(dice1.ShowS()!=dice2.ShowS())flag=1;
	  if(flag==0) OK_flag=1;
	  dice2.goS();dice2.goW();dice2.goN();
	}
      if(0<=j&&j<=2)dice2.goN();
      else dice2.goE();
    }

  if(OK_flag==1)cout << "Yes\n";
  else       cout << "No\n";

  return 0;
}

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

typedef long long ll;

int main() {

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

    int n = 0;
    int temp = 0;
    cin >> n;
    int ans = 1;

    for(int i = 0; i < n; i++) {
        cin >> temp;
        if(temp % 2 == 0) {
            if(temp % 3 != 0 && temp % 5 != 0) ans = 0;
        }
    }

    if(ans) cout << "APPROVED\n";
    else cout << "DENIED\n";

    return 0;
}

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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var ab = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var a = ab[0];
        var b = ab[1];

        for (int i = 1; i <= 1100; ++i)
        {
            var x8 = i * 8 / 100;
            var x10 = i * 10 / 100;
            if (x8 > a || x10 > b)
            {
                break;
            }
            else if (x8 < a || x10 < b)
            {
                continue;
            }

            Console.Error.WriteLine(x8 == x10);
            Console.WriteLine(i);
            return;
        }

        Console.WriteLine(-1);
    }
}


Measured memory_bytes: 13396
R, G, B, N = map(int, input().split())
ans = 0
for r in range(0, 3001):
    r_ = r*R
    for g in range(0, 3001):
        b = N - r_ - g*G
        if b < 0:
            continue
        if b%B==0:
            ans+=1
print(ans)


Measured memory_bytes: 41180
# coding: utf-8
# Your code here!

while True:
   try:
      a, b, c, d, e, f = map(float, input().split())
      x = (c * e - b * f) / (a * e - b * d)
      y = (c - a * x) / b
      
      if x == 0:
         print('{:.3f}'.format(abs(x)), '{:.3f}'.format(y))
      elif y == 0:
         print('{:.3f}'.format(x), '{:.3f}'.format(abs(y)))
      else:
         print('{:.3f}'.format(x), '{:.3f}'.format(y))
   except EOFError:
      break


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    for(int i=1;i<10;i++){
        if(n%i==0) if(n/i<10){
            cout<<"Yes"<<endl; 
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
 
int count_honor(int syogen[15][15], int N, int bit)
{
    int honor_count = 0;
    for (int i = 0; i < N; i++)
    {
        if (bit & (1 << i))
        {
            for (int j = 0; j < N; j++)
            {
                if (syogen[i][j] >= 0)
                {
                    bool me_honor = syogen[i][j] != 0;
                    bool real_honor = (bit & (1 << j)) != 0;
                    if (me_honor != real_honor)
                    {
                        return -1;
                    }                
                }
            }
            ++honor_count;
        }
    }
    return honor_count;
}

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

    int syogen[15][15];
    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
            syogen[i][j] = -1;

    for (int i = 0; i < N; i++)
    {
        int A;
        std::cin >> A;
        for (int a = 0; a < A; a++)
        {
            int x, y;
            std::cin >> x >> y;
            syogen[i][x-1] = y;
        }
    }
    
    int max_honor = 0;
    for (int bit = 0; bit < (1<<N); ++bit)
    {
        int ch = count_honor(syogen, N, bit);
        if (max_honor < ch) max_honor = ch;;
    }

    std::cout << max_honor << std::endl;
}

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

	int n;
	cin >> n;

	vector<int> b(n - 1);
	rep (i, 0, n - 1)
		cin >> b[i];

	ll res = b[0] + b[n - 2];
	rep (i, 0, n - 2)
		res += min(b[i], b[i + 1]);

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;

int main() {
    int N, K; cin >> N >> K;
    vector<int> P(N), C(N);
    for (int i = 0; i < N; i++) { cin >> P[i]; P[i]--; }
    for (int i = 0; i < N; i++) cin >> C[i];
    
    ll ans = -INF;
    for (int i = 0; i < N; i++) {
        int x = i;
        vector<int> S;
        ll sum = 0;
        while (true) {
            x = P[x];
            S.push_back(C[x]);
            sum += C[x];
            if (x == i) break;
        }
        int n = S.size();
        ll t = 0;
        for (int j = 0; j < n; j++) {
            t += S[j];
            if (j + 1 > K) break;
            ll now = t; 
            if (sum > 0) {
                ll cnt = (K - (j + 1) ) / n;
                now += sum * cnt;
            }
            ans = max(ans, now);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3700
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  n <- getInt
  let solve n m res | odd n = 0
                    | n < m  = res
                    | otherwise = solve n (m*5) (res + n `div` m)
  print $ solve n 10 0

Measured memory_bytes: 3772
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

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

char mp[4][4];
bool used[4][4];

vector<string> v;
string cur;


void dfs(int x,int y) {
	v.push_back(cur);
	if (cur.length() == 8)return;
	rep(k, 8) {
		int nx = x + dx[k], ny = y + dy[k];
		if (nx < 0 || ny < 0 || nx >= 4 || ny >= 4)continue;
		if (used[nx][ny])continue;
		cur.push_back(mp[nx][ny]);
		used[nx][ny] = true;
		dfs(nx, ny);
		used[nx][ny] = false;
		cur.pop_back();
	}
}

int dp[10001];

void solve() {
	sort(v.begin(), v.end());
	int n; cin >> n;
	vector<string> s(n); vector<int> c(n);
	rep(i, n) {
		cin >> s[i] >> c[i];
	}
	rep(i, 4) {
		rep(j, 4)cin >> mp[i][j];
	}
	rep(i, 4) {
		rep(j, 4) {
			cur.push_back(mp[i][j]);
			used[i][j] = true;
			dfs(i, j);
			used[i][j] = false;
			cur.pop_back();
		}
	}
	sort(v.begin(), v.end());
	int t; cin >> t;
	rep(i, n) {
		int num = upper_bound(v.begin(), v.end(), s[i]) - lower_bound(v.begin(), v.end(), s[i]);
		int len = s[i].length();
		per(k, t + 1) {
			
			rep1(j, num) {
				int ni = k + j * len;
				if (ni > t)break;
				dp[ni] = max(dp[ni], dp[k] + j * c[i]);
			}
		}
	}
	int ans = 0;
	rep(i, t + 1)ans = max(ans, dp[i]);
	cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 19256
using System;

namespace ABC141_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            if (s == "Sunny")
            {
                Console.WriteLine("Cloudy");
            }
            else if (s == "Cloudy")
            {
                Console.WriteLine("Rainy");
            }
            else
            {
                Console.WriteLine("Sunny");
            }
        }
    }
}


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

using namespace std;
typedef long long ll;
typedef pair< int , int > P;
typedef tuple<int, int, int> T;


int main(){
    int k;
    string s;

    cin>>k>>s;
    //cout<<s.size();
    if(s.size()<=k) {cout<<s;}
    else{
        rep(i,k){
            cout<<s[i];
        }
        cout<<"...";
    }
}



Measured memory_bytes: 3624
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e5 + 10;

int main() {
	fast_cin();
	ll a, b, c;
	cin >> a >> b >> c;
	ll ans = b;
	a += b;
	ans += min(c, a + 1);
	cout << ans << endl;
}

Measured memory_bytes: 256
<?php
$input = array_map('intval', explode(' ', trim(fgets(STDIN))));
$Ki = $input[0];
$S = $input[1];
$cnt = 0;

for ($i=0; $i<=$Ki; $i++){
    for ($j=0; $j<=$Ki; $j++){
        
        if (($i+$j)>$S){
            $k = 0;
        } else {
          $k = $S-$i-$j;
          if ($k>$Ki){
            $k = $Ki;
          }
        }
        if (($i+$j+$k)===$S){
            $cnt++;
        }
    }
}
print $cnt;

Measured memory_bytes: 4604
import java.util.Scanner;


public class Main{

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int arrayCnt = new Integer(s.nextLine()).intValue();
		String[][] arrayQuick = new String[arrayCnt][2];
		String[][] arrayMerge = new String[arrayCnt][2];
		for(int i=0 ; i<arrayCnt ; i++) {
			arrayQuick[i] = s.nextLine().split(" ");
			arrayMerge[i] = arrayQuick[i];
		}
		boolean flg = false;
		quickSort(arrayQuick, 0, arrayCnt-1);
		sort(arrayMerge, 0 , arrayCnt-1);
		for(int i=0 ; i<arrayCnt ; i++) {
			if(arrayQuick[i][0]!=arrayMerge[i][0])
				flg = true;
		}
		if(flg)
			System.out.println("Not stable");
		else
			System.out.println("Stable");

		for(int i=0 ; i<arrayQuick.length ; i++) {
			System.out.println(arrayQuick[i][0] + " " + arrayQuick[i][1]);
		}
	}

	public static void quickSort(String[][] array, int start, int end) {
		if(start < end) {
			int mid = partition(array, start ,end);
			quickSort(array, start, mid-1);
			quickSort(array, mid+1, end);
		}
	}

	public static int partition(String[][] array, int start ,int end) {
		if(start >= end)
			return -1;
		int index = start;
		for(int i=start ; i<end ; i++) {
			if(new Integer(array[i][1]).intValue() <= new Integer(array[end][1]).intValue()) {
				String[] tmp = array[index];
				array[index] = array[i];
				array[i] = tmp;
				index++;
			}else {

			}
		}
		String[] tmp = array[index];
		array[index] = array[end];
		array[end] = tmp;
		return index;
	}

	public static int sort(String[][] array, int start, int end) {
		int c = 0;
		if(start < end){
			int mid = (start+end)/2;
			c += sort(array, start, mid);
			c += sort(array, mid+1, end);
			c += merge(array, start, end);
		}
		return c;
	}

	public static int merge(String[][] array, int start, int end) {
		int cnt = 0;
		int mid = (start+end) / 2;
		String[][] left = new String[mid-start+2][2];
		String[][] right = new String[end-mid+1][2];
		for(int i=0 ; i<left.length-1 ; i++) {
			left[i] = array[start+i];
		}
		for(int j=0 ; j<right.length-1 ; j++) {
			right[j] = array[mid+j+1];
		}
		int l = 0;
		int n = 0;
		left[mid-start+1][0] = "S";
		left[mid-start+1][1] = Integer.MAX_VALUE+"";
		right[end-mid][0] = "S";
		right[end-mid][1] = Integer.MAX_VALUE+"";
		for(int k=0 ; k<left.length+right.length-2 ; k++) {
			if(new Integer(left[l][1]).intValue() > new Integer(right[n][1]).intValue()) {
				array[start] = right[n];
				n++;
			}else{
				array[start] = left[l];
				l++;
			}
			cnt++;
			start++;
		}
		return cnt;
	}
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

struct T{
  int dep;
  bool fin;
  T* chd[2];
  T(int d, bool f){
	dep = d;
	fin = f;
	REP(i,2) chd[i] = nullptr;
  }
};

void ins(const string& s, int i, T* rt){
  if(i == SZ(s)){
	rt->fin = true;
	return;
  }

  int ix = s[i] - '0';
  if(rt->chd[ix] == nullptr){
	rt->chd[ix] = new T(rt->dep+1, false);
  }
  ins(s, i+1, rt->chd[ix]);
}

LL N, L;
LL g(LL x){
  return x&-x;
}
LL dfs(T* rt){
  if(rt->fin){
	return 0;
  }
  LL res = 0;
  REP(i,2){
	if(rt->chd[i] == nullptr)
	  res ^= g(L-rt->dep);
	else
	  res ^= dfs(rt->chd[i]);
  }
  return res;
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  /*
  VI gr(300);
  gr[0] = 0;
  FOR(i,1,300){
	set<int> s;
	s.insert(0);
	int acc = 0;
	for(int j=i-1;j>0;--j){
	  acc ^= gr[j];
	  s.insert(acc);
	}

	for(int x=1;;++x){
	  if(!s.count(x)){
		gr[i] = x;
		break;
	  }
	}
  }
  REP(i,300) cout<<bitset<16>(i)<<":"<<gr[i]<<","<<g(i)<<endl;
  return 0;
  */
  cin >> N >> L;
  T* rt = new T(0, false);
  REP(i,N){
	string S;
	cin >> S;
	ins(S, 0, rt);
  }
  
  LL gg = dfs(rt);
  //cout<<gr<<endl;
  cout << (gg==0? "Bob": "Alice") << endl;
  
  return 0;
}


Measured memory_bytes: 8044
# ARC066C - Lining Up (ABC050C)
from collections import Counter


def main():
    n = int(input())
    a = tuple(map(int, input().rstrip().split()))
    MOD = 10 ** 9 + 7
    s = (n // 2) * 2
    l = (n + 1) // 2
    p = l if n % 2 == 0 else l - 1
    if sum(a) == s * l:
        print(2 ** p % MOD)
    else:
        print(0)


if __name__ == "__main__":
    main()

Measured memory_bytes: 14324
/*
{By GWj

*/
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define R(a) cin>>a
#define R2(a,b) cin>>a>>b
#define check_min(a,b) a=min(a,b)
#define check_max(a,b) a=max(a,b)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
/*}
*/
int n;
int c,k,t[100000+20];

int main(){
	fastio;
	R(n);
	R2(c,k);
	rb(i,1,n){
		R(t[i]);
	}
	sort(t+1,t+1+n);
	int l=1;
	int rest=0;
	rb(i,1,n){
		if(t[i]-t[l]>k||i-l+1>c){
			l=i;
			rest++;
		}
	}
	rest++;
	cout<<rest<<endl;
	return 0;
}

Measured memory_bytes: 3964
import java.util.Arrays;
import java.util.Scanner;

/**
 * Created by Reopard on 2014/06/04.
 */
public class Main{
    static Scanner sc = new Scanner(System.in);

    public static void main(String args[]){
        int n, count;
        boolean[] prime = new boolean[300000];
        Arrays.fill(prime, true);
        prime[0] = false;
        prime[1] = false;
        for(int i = 0; i < prime.length; i++){
            if(prime[i]){
                for(int j = i + i; j < prime.length; j += i) prime[j] = false;
            }
        }
        while((n = sc.nextInt()) != 0){
            count = 0;
            for(int i = n + 1; i <= 2*n; i++)
                if(prime[i]) count++;
            System.out.println(count);
        }
    }
}

Measured memory_bytes: 22864
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var n = int.Parse(spl[0]);
        var m = int.Parse(spl[1]);
        var x = int.Parse(spl[2]);

        var ca = new int[n][];

        for(int i=0; i<n; i++) {
            ca[i] = ToIntArray(input.ReadLine(), m + 1);
        }

        //var score = new long[m+1];

        long bmax = Pow(2, n);
        long b = 0;

        long min = long.MaxValue;

        while (b <= bmax) {
            var sum = 0L;
            var score = new long[m + 1];

            for(int i=0; i<n; i++) {
                var on = (b >> i) & 0x01;
                if (on == 1) { 
                    for(int j=1; j<=m; j++) {
                        score[j] += ca[i][j];
                    }
                    sum += ca[i][0];
                }
            }
            var ok = true;
            for (int j = 1; j <= m; j++) {
                ok &= score[j] >= x;
            }
            if (ok) {
                min = Math.Min(sum, min);
            }

            b += 1;
        }

        if (min == long.MaxValue) return -1;

        return min;
    }

    static long Pow(long x, long n) {
        long ans = 1;
        while (n > 0) {
            if (n % 2 == 1) {
                ans = ans * x;
            }
            x = x * x;
            n /= 2;
        }
        return ans;
    }

    /*
    static long min;

    static void f(int n, int m, int x, int[][] ca, long[] score, HashSet<int> subs, long sum) {
        if (sum >= min) return;

        var ok = true;
        for (int i = 1; i <= m; i++) {
            ok &= score[i] >= x;
        }
        if (ok) {
            min = Math.Min(sum, min);
            return;
        }

        for (int i=0; i<n; i++) {
            if (!subs.Contains(i)) {
                var hash = new HashSet<int>(subs);
                hash.Add(i);

                var sco = new long[m + 1];
                for (int j = 1; j <= m; j++) sco[j] = score[j] + ca[i][j];
                
                f(n, m, x, ca, sco, hash, sum + ca[i][0]);
            }
        }
    }*/


    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


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

int divisor = 1000000007;

int main() {
    int n, m;
    cin >> n >> m;
    vector<bool> broken(n);
    vector<int> dp(n+2);
    for (int i = 0; i < m; i++) {
        int a;
        cin >> a;
        broken[a-1] = true;
    }
    dp[0] = 0;
    dp[1] = 1;
    for (int i = 0; i < n; i++) {
        if (broken[i]) {
            dp[i+2] = 0;
        }
        else {
            dp[i+2] = (dp[i+1] + dp[i]) % divisor;
        }
    }
    int ans = dp[n+1];
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

struct Data {
    long long a, b, diff;
};
int main() {
    int n;
    cin >> n;
    vector<Data> val(n);
    for (int i = 0; i < n; i++) {
        cin >> val[i].a >> val[i].b;
        val[i].diff = val[i].a + val[i].b;
    }
    sort(val.begin(), val.end(), [](const Data& lhs, const Data& rhs) {
        return lhs.diff > rhs.diff;
    });
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0)
            ans += val[i].a;
        else
            ans -= val[i].b;
    }
    cout << ans << endl;
    return 0;
    
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>
#include <cstdlib>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

int main()
{
    int N;
    cin >> N;
    vector<ll> A(N);
    for(auto& x: A) cin >> x;

    unordered_map<ll, ll> mp1, mp2;
    for(int i=0; i<N; i++){
        mp1[A[i]+i]++;
        mp2[A[i]-i]++;
    }

    ll ans = 0;
    for(auto& p: mp1){
        ans += p.second * mp2[-p.first];
    }

    cout << ans << endl;
}

Measured memory_bytes: 27908
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
void fp(bool flag, string s, string t){
    if(flag)cout << s << endl;
    else cout << t << endl;
}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl digit10(intl a){
    if(!a)return 1;
    intl b = 0;
    while(a){
        a /= 10;
        b++;
    }
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n;
    cin >> n;
    intl a[n];
    cin(i,a);
    intl g = a[0];
    rep(i,n){
        g = gcd(g,a[i]);
    }
    cout << g << endl;
    return 0;
}

Measured memory_bytes: 1024