akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>

using namespace std;

typedef long long    ll;
typedef long double  ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;

template <typename T> bool chmax(T &a, T& b) {if (a < b) {a = b; return true;} return false;}
template <typename T> bool chmin(T &a, T& b) {if (a > b) {a = b; return true;} return false;}
#define rep(i, n)      for (int i = 0; i < (int)(n); ++i)
#define rep3(i, m, n)  for (int i = (m); i < (int)(n); ++i)
#define rrep(i, n)     for (int i = (int)(n)-1; i >= 0; --i)
#define rrep3(i, m, n) for (int i = (int)(n)-1; i >= (m); --i)
#define all(x) x.begin(), x.end()
#define rall(x) x.end(), x.begin()
#define mset(x, val) memset(x, (val), sizeof(x))
#define cons(a, b) make_pair((a), (b))
#define car first
#define cdr second

#define endl '\n'
#define INF  0x7f7f7f7f7f7f7f7f
#define INFi 0x7f7f7f7f


ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

char solve(char a) {
  if ('A' <= a && a <= 'Z') return 'A';
  else return 'a';
}

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

  char a;
  cin >> a;
  
  auto ans = solve(a);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3028
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define gcd __gcd
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define gcd __gcd
//SUNEET KUMAR -->  ਸੁਨੀਤ  
int power(int a,int n)//binary expo
{
    int r;
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
        r=power(a,n/2);
    if(n%2==0)
        return ((r)%mod)*((r)%mod)%mod;
    else
        return ((((r)%mod)*((r)%mod))%mod*((a)%mod))%mod;
}
int max(int a,int b)
{
    if(a>b)
        return a;
    else
        return b;
}
int maxot(int a,int b,int c)
{
    if(a>=b&&a>=c)
    {
        return a;
    }
    if(b>=a&&b>=c)
    {
        return b;
    }
    if(c>=b&&c>=a)
    {
        return c;
    }  
}
signed main()
{ 
      fastio;
      int n;
      cin>>n;
      int a[n+3],b[n+3],c[n+3];
      for(int i=1;i<=n;i++)
      {
          cin>>a[i]>>b[i]>>c[i];
      }
      int dp1[n+3],dp2[n+3],dp3[n+3];
      dp1[1]=a[1];dp2[1]=b[1];dp3[1]=c[1];
      for(int i=2;i<=n;i++)
      {
          dp1[i]=max(dp2[i-1]+a[i],dp3[i-1]+a[i]);
          dp2[i]=max(dp1[i-1]+b[i],dp3[i-1]+b[i]);
          dp3[i]=max(dp1[i-1]+c[i],dp2[i-1]+c[i]);
      }
    cout<<maxot(dp1[n],dp2[n],dp3[n])<<endl;
}

Measured memory_bytes: 4992
#include <algorithm>
#include <cstdio>
const int N=100005;
int a[N],fst[N],nxt[N],f[N],n,k,ans=0;
void addedge(int x,int y){
	nxt[y]=fst[x];fst[x]=y;
}
void dfs(int x){
	for (int i=fst[x];i;i=nxt[i]) dfs(i);
	if (++f[x]>=k && a[x]!=1) ans++,f[x]=0;
	f[a[x]]=std::max(f[a[x]],f[x]);
}
int main(){
	scanf("%d%d\n",&n,&k);f[1]=k;
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if (i!=1) addedge(a[i],i);
	}
	dfs(1);
	printf("%d\n",ans);
}

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

using namespace std;
typedef unsigned long long ll;
const int INF = 1e9;
const ll mod = 1e9 + 7;

void setup(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif	
}

int main(){
setup();
	ll T = 1;
	//cin >> T;	
	while (T--){
		ll n, x, t;
		cin >> n >> x >> t;
		ll ex = 0; 
		if (n%x != 0) ex = t;
		cout << (n/x)*t + ex << endl;
	}
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
	string s,t;
	cin>>s>>t;
	// cout<<s<<" "<<t<<endl;
	ll n=s.size(),m=t.size();
	ll dp[n+1][m+1];
	memset(dp,0,sizeof dp);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(s[i-1]==t[j-1])
			dp[i][j]=1+dp[i-1][j-1];
			else
			dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	// cout<<dp[n][m]<<endl;
	string ans="";
	for(int i=n,j=m;(i>0&&j>0); )
	{
		if(s[i-1]==t[j-1])
		{
			ans+=(s[i-1]);
			i--,j--;
			// cout<<s[i-1]<<endl;
		}
		else if(dp[i-1][j]>dp[i][j-1])
		i--;
		else
		j--;
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
}

Measured memory_bytes: 70656
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define FF first
#define SS second

using ll = long long;
using ld = long double;

template<typename T>
using vec = std::vector<T>;

template<typename T>
using uset = std::unordered_set<T>;

template<typename T1, typename T2>
using umap = std::unordered_map<T1, T2>;

constexpr ll INFL = 1'000'000'000'000'000'228;
constexpr int INFI = 1'000'000'228;
const ld PI = acos(-1);
std::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count());

vec<pair<int, int>> DD = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

#ifdef LOCAL
#else
#endif

void run() {
  ll h, w, k;
  cin >> h >> w >> k;
  ll x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  vec<vec<char>> field(h + 2, vec<char>(w + 2, '@'));
  for (ll i = 1; i <= h; i++) {
    for (ll j = 1; j <= w; j++) {
      cin >> field[i][j];
    }
  }
  vec<vec<vec<ll>>> dist(h + 2, vec<vec<ll>>(w + 2, vec<ll>(4, INFL)));
  set<tuple<ll, ll, ll, ll>> st;
  for (ll i = 0; i < 4; i++) {
    st.emplace(0, x1, y1, i);
  }
  while (st.size()) {
    auto [cur_dist, x, y, dir] = *st.begin();
    st.erase(st.begin());
    if (cur_dist >= dist[x][y][dir]) continue;
    dist[x][y][dir] = cur_dist;
    if (field[x + DD[dir].first][y + DD[dir].second] == '.') {
      st.emplace(cur_dist + 1, x + DD[dir].first, y + DD[dir].second, dir);
    }
    for (ll chg_dir = 0; chg_dir < 4; chg_dir++) {
      if (dir == chg_dir) continue;
      if (field[x + DD[chg_dir].first][y + DD[chg_dir].second] == '.') {
        st.emplace((cur_dist + k - 1) / k * k + 1, x + DD[chg_dir].first, y + DD[chg_dir].second, chg_dir);
      }
    }
  }
  ll ans = INFL;
  for (int dir = 0; dir < 4; dir++) {
    ans = min(ans, dist[x2][y2][dir]);
  }
  cout << (ans == INFL ? -1 : (ans + k - 1) / k) << '\n';
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/

signed main() {
#ifdef LOCAL
  std::freopen("input.txt", "r", stdin);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
#endif
  int t = 1;
  //cin >> t;
  while (t--) {
    run();
  }
  return 0;
}



Measured memory_bytes: 287472
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  int t,a,n;
  cin>>n>>t>>a;
  int ans=1e10;
  int p;
 
  for(int i=1;i<=n;i++){
    int h;
    cin>>h;
    int sum=( t *1000 - h *6) - a *1000;
    if(ans>abs(sum)){
      ans=abs(sum);
      p=i;
    }
  }
  cout<<p;
  return 0;
}

Measured memory_bytes: 256
// Created by  Ambesh kumar
#include "bits/stdc++.h"

//I already compile this file in my computer system to save the time
//if get the compiler error then you should change this header to
// #include "bits/stdc++.h"  ---> #include <bits/stdc++.h>

using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1000000007;
const int N = 3e5, M = N;
//=================================================================================================================================//

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

void solve() {
  int i, j, n, m;

  cin>>n;

  if(n<30)
  	cout<<"No" <<'\n' ;
  else
  	cout<<"Yes" <<'\n' ;
}







int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

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

    return 0;
}







Measured memory_bytes: 10672
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int h,w;
  cin >> h>>w;
  vector <char> a(h*w);
  
  for(int i=0;i<h*w;i++){
    cin >> a.at(i);
  }
  
  for(int i=0;i<w+2;i++){
    cout<<"#";
  }
  
  cout<<endl;
  
  for(int i=0;i<h*w;i++){
    if(i%w==0&&(i+1)%w==0){
      cout << "#"<<a.at(i)<<"#"<<endl;
    }
    else if(i%w==0&&(i+1)%w!=0){
      cout<< "#"<< a.at(i);
    }
    
    else if(i%w!=0&&(i+1)%w==0){
      cout << a.at(i)<<"#"<<endl;
    }
    else{
      cout << a.at(i);
    }
  }
  
  for(int i=0;i<w+2;i++){
    cout<<"#";
  }
  
  cout<<endl;
  
}
  
  

Measured memory_bytes: 3628
n,k = [int(_) for _ in input().split()]
a = [int(_) for _ in input().split()]


for i in range(len(a)):
    a[i] = '{:040b}'.format(a[i])
p = len(bin(k))-2
k = '{:040b}'.format(k)
t = True
ans = 0
for i in range(0,40):
    num_1 = 0
    num_0 = 0
    if t:
        if k[i] == '1':
            for j in range(n):
                if a[j][i] == '1':
                    num_1 += 1
                elif a[j][i] == '0':
                    num_0 += 1
            if num_0 > num_1:
                num = num_0
                ans += (2**(39-i))*num
            else:
                t = False
                num = num_1
                ans += (2**(39-i))*num
        elif k[i] == '0':
            for j in range(n):
                if a[j][i] == '1':
                    num_1 += 1
                elif a[j][i] == '0':
                    num_0 += 1
            num = num_1
            ans += (2**(39-i))*num
    else:
        for j in range(n):
            if a[j][i] == '1':
                num_1 += 1
            elif a[j][i] == '0':
                num_0 += 1
        if num_0 > num_1:
            num = num_0
            ans += (2**(39-i))*num
        else:
            num = num_1
            ans += (2**(39-i))*num
print(ans)

Measured memory_bytes: 16104
N = int(input())
a = list(map(int, input().split()))

ans = 1

up = False
down = False
ok = True

t = a[0]
i = 1
while i < N:
    if ok:
        if a[i] > t:
            up = True
            down = False
            ok = False
        elif a[i] == t:
            up = False
            down = False
            ok = True
        else:
            up = False
            down = True
            ok = False
    elif up:
        if a[i] >= t:
            up = True
            down = False
            ok = False
        else:
            up = False
            down = False
            ok = True
            ans += 1
    elif down:
        if a[i] <= t:
            up = False
            down = True
            ok = False
        else:
            up = False
            down = False
            ok = True
            ans += 1
    t = a[i]
    i += 1
print(ans)


Measured memory_bytes: 14432
let g,w=Bytes.map(fun c->if c>'@'&&c<'['then Char.chr(Char.code c+32)else c),read_line()open List;;let rec f n=match read_line()with"END_OF_TEXT"->Printf.printf"%d
"n|t->f(n+length(filter(fun s->s=(g w))(Str.split(Str.regexp" ")(g t))));;f 0

Measured memory_bytes: 2344
inputs = [0,0,0,0,0]
inputs[0] = int(input())

inputs[1] = int(input())

inputs[2] = int(input())

inputs[3] = int(input())

inputs[4] = int(input())


top = 10
top_i = 0

sum = 0

for i in range(5):
	if top > inputs[i] % 10 and inputs[i] % 10 != 0:
		top = inputs[i] % 10
		top_i = i

for i in range(5):
	if i != top_i:
		#print(sum)
		sum = sum + int(inputs[i] / 10) * 10
		if inputs[i] % 10 != 0:
			sum = sum + 10
sum = sum + inputs[top_i]

print(sum) 

Measured memory_bytes: 38256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            out.println(Math.min(b / a, c));
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
            this.bufPointer = 0;
            this.bufLength = 0;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int nextInt() {
            int n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

    }
}



Measured memory_bytes: 22356
# include <iostream>
# include <string>
using namespace std;
int main()
{
    string a, b;
    cin >> a >> b;
    if (a.size() > b.size())
    {
        cout << "GREATER";
    } else if (a.size() < b.size())
    {
        cout << "LESS";
    } else
    {
        for (int i = 0; i < a.size(); ++i)
        {
            if ((a[i] - '0') > (b[i] - '0'))
            {
                cout << "GREATER";
                return 0;
            } else if ((a[i] - '0') < (b[i] - '0'))
            {
                cout << "LESS";
                return 0;
            }
        }
        cout << "EQUAL";
    }
}

Measured memory_bytes: 256
import collections

n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))


if n < m :
    print("NO")
else :
    dic = collections.defaultdict(int)
    for dd in d :
        dic[dd] += 1
    
    for tt in t :
        dic[tt] -= 1
        if dic[tt] < 0 :
            print("NO")
            break
    else :
        print("YES")

Measured memory_bytes: 41700
#include <iostream>

using namespace std;

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



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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

template<class T> void gc (T& x) {
    char c;
    int s = 0;
    x = 0;
    c = getchar_unlocked();
    if (c == '-')
        s = 1;
    else if ('0' <= c && c <= '9')
        x = c - '0';
    while (true) {
        c = getchar_unlocked();
        if (c < '0' || '9' < c)
            break;
        x = x * 10 + (c - '0');
    }
    if (s)
        x = -x;
}

int main() {
    int N, M;
    gc (N);
    gc (M);
    int accum = 0;
    REP (i, M) {
        int Ai;
        gc (Ai);
        accum += Ai;
    }
    printf ("%d\n", N < accum ? -1 : N - accum);
    return 0;
}


Measured memory_bytes: 3784
# Segment tree (GCD)
from math import gcd


class SegmentTree:
    _f = None
    _data = None
    _offset = None
    _size = None

    def __init__(self, size, f):
        self._f = f
        self._size = size
        t = 1
        while t < size:
            t *= 2
        self._offset = t - 1
        self._data = [0] * (t * 2 - 1)

    def build(self, iterable):
        f = self._f
        data = self._data
        data[self._offset:self._offset + self._size] = iterable
        for i in range(self._offset - 1, -1, -1):
            data[i] = f(data[i * 2 + 1], data[i * 2 + 2])

    def query(self, start, stop):
        def iter_segments(data, l, r):
            while l < r:
                if l & 1 == 0:
                    yield data[l]
                if r & 1 == 0:
                    yield data[r - 1]
                l = l // 2
                r = (r - 1) // 2
        f = self._f
        it = iter_segments(self._data, start + self._offset,
                           stop + self._offset)
        result = next(it)
        for e in it:
            result = f(result, e)
        return result


N = int(input())
A = list(map(int, input().split()))

st = SegmentTree(N, gcd)
st.build(A)

result = st.query(1, N)
for i in range(1, N - 1):
    result = max(result, gcd(st.query(0, i), st.query(i + 1, N)))
result = max(result, st.query(0, N - 1))
print(result)


Measured memory_bytes: 20676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));


int main(){	
	long long N;
	scanf("%lld",&N);

	vector<long long> P(N-1+1), idx(N);
	for(ll i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&P[i]);
		P[i]--;
		idx[P[i]] = i;
	}

	vector<ll> dp(N, 1);
	repn(i, N-1) {
		if (idx[i]>idx[i-1]) dp[i] = dp[i-1]+1;
	}
	ll res = 0;
	rep(i, N) {
		res = max(res, dp[i]);
	}
	cout << N-res << endl;
	return 0;
}



Measured memory_bytes: 4992
#include<stdio.h>
using namespace std;

int main(){
    int N, M;
    scanf("%d %d", &N, &M);
    int L[M+1],R[M+1];

    int ML=1, mR=N;
    for(int i=1;i<=M;i++){
        scanf("%d %d", &L[i],&R[i]);
        if(L[i]>ML){
            ML = L[i];
        }
        if(mR>R[i]){
            mR = R[i];
        }
    }
    if(mR-ML>=0){
        printf("%d\n", mR-ML+1);
    }else{
        printf("%d\n", 0);
    }
    return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>pii;
//#define int ll
const int maxn=20,inf=0x3f3f3f3f,mod=1000000007;
//#define DEBUG//#define lowbit(x) ((x) & -(x))//<<setiosflags(ios::fixed)<<setprecision(9)
void read(){}
template<typename T,typename... T2>inline void read(T &x,T2 &... oth) {
	x=0; int ch=getchar(),f=0;
	while(ch<'0'||ch>'9'){if (ch=='-') f=1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	if(f)x=-x;
	read(oth...);
}
int c[maxn],a[maxn][maxn];
signed main()
{
	std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	#ifdef DEBUG
		freopen("input.in", "r", stdin);
	//	freopen("output.out", "w", stdout);
	#endif
	int n,m,x,ans=inf;
	cin>>n>>m>>x;
	for(int i=1;i<=n;i++)
	{
		cin>>c[i];
		for(int j=1;j<=m;j++)
			cin>>a[i][j];
	}
	bool ok=1;
	for(int i=1;i<=m;i++)
	{
		int now=0;
		for(int j=1;j<=n;j++)
			now+=a[j][i];
		if(now<x)
			ok=0;
	}
	if(!ok)
		cout<<-1<<endl;
	else{//枚举n本书
		for(int i=0;i<=(1<<n)-1;i++)
		{
			int cost=0;
			vector<int>rec(m+1,0);
			for(int j=0;(1<<j-1)<=i;j++)
			{
				if(i&(1<<j-1))//要买第j本
				{
					cost+=c[j];
					for(int k=1;k<=m;k++)
						rec[k]+=a[j][k];
				}
			}
			bool flag=1;
			for(int j=1;j<=m;j++)
				if(rec[j]<x)
				{
					flag=0;
					break;
				}
			if(flag)
				ans=min(ans,cost);
		}
		cout<<ans<<endl;
	}
	return 0;
}




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

using namespace std;

typedef long long ll;

const int maxn = 3e5 + 10, mod = 998244353;
ll fact[maxn];

ll power(ll base, int e) {
	return e? power(base * base % mod, e >> 1) * (e & 1? base: 1) % mod: 1;
}

ll c(int k, int r) {
	return fact[k] * power(fact[r], mod - 2) % mod * power(fact[k - r], mod - 2) % mod;
}

int n, a, b, ans;
ll k;

int main(){
	fact[0] = 1;
	for (int i = 1; i < maxn; ++i)
		fact[i] = fact[i - 1] * i % mod;
	cin >> n >> a >> b >> k;
	if (1ll * n * (a + b) < k)
		return cout << "0\n", 0;
	if (a < b)
		swap(a, b);
	for (int i = 0; i <= n; ++i)
		if (1ll * i * a <= k) {
			ll j = k - 1ll * i * a;
			if (!(j % b) && j / b <= n) {
				j /= b;
				ans = (ans + c(n, i) * c(n, j)) % mod;
			}
		}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, ll>;

vector<vector<P>> g(100010);
vector<ll> dist(100010, -1);

#if 1
void dfs(int v, int p, ll d){
    dist.at(v) = d;
    for(auto &u: g.at(v)){
        if(dist.at(u.first)!=-1) continue;
        dfs(u.first, v, d+u.second);
    }
}

int main() {
    int n; cin >> n;
    
    rep(i, n-1){
        int a, b, c; cin >> a >> b >> c;
        g.at(a).push_back(make_pair(b, c));
        g.at(b).push_back(make_pair(a, c));
    }

    int q, k; cin >> q >> k;
    dfs(k, -1, 0);

    rep(i, q){
        int x, y; cin >> x >> y;
        cout << dist.at(x) + dist.at(y) << endl;
    }
    

    return 0;
}
#endif

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

using namespace std;

int main()
{
	vector<int> c(3);
	for (auto &x : c) cin >> x;
	sort(c.begin(), c.end());
	if (c[0] + c[1] == c[2]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


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

int a[10];
int fact[10]={1,1,2,6,24,120,720,5040,40320};

int dp[362880];
void swap(int i,int j){
	int t=a[i];
	a[i]=a[j];
	a[j]=t;
}

int f(){
	int ans=0,b=0;
	for(int i=8;i>=0;i--){
		ans+=__builtin_popcount(b&((1<<a[i])-1))*fact[8-i];
		b|=1<<a[i];
	}
	return ans;
}
void g(int n){
	int b=0;
	for(int i=0;i<9;i++)a[i]=i;
	for(int i=0;i<9;i++){
		int x=n/fact[8-i];
		n%=fact[8-i];
		for(int j=x;j>0;j--)swap(i+j,i+j-1);
	}
}

int que[363000],quecnt;
void check(int p,int k){
	int x=f();
	if(!dp[x]){
		dp[x]=k+1;
		que[quecnt++]=x*10+p;
	}
}
int calc(){
	for(int i=0;i<quecnt;i++){
		int x=que[i]/10;
		int p=que[i]%10;
		if(x==0)return dp[x]-1;
		g(x);
		if(p  <6)swap(p,p+3),check(p+3,dp[x]),swap(p,p+3);
		if(p  >2)swap(p,p-3),check(p-3,dp[x]),swap(p,p-3);
		if(p%3<2)swap(p,p+1),check(p+1,dp[x]),swap(p,p+1);
		if(p%3>0)swap(p,p-1),check(p-1,dp[x]),swap(p,p-1);
	}
	return -1;
}

int main(){
	int p;
	for(int i=0;i<9;i++){
		int t;
		scanf("%d",&t);
		if(t)a[i]=t-1;
		else{
			a[i]=8;
			p=i;
		}
	}
	check(p,0);
	printf("%d\n",calc());
}


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

int main() {
  int a, b;
  cin >> a >> b;
  
  if(a < 6)
    cout << '0' << endl;
  else if(a < 13)
    cout << b / 2 << endl;
  else
    cout << b << endl;
}

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

typedef long long ll;
typedef vector<int> vi;

int main()
{
	int l, r, d;
	cin >> l >> r >> d;

	int ans = 0;
	for (int i = l; i <= r; i++) {
		if (i % d == 0) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


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

int main(void)
{
  int N;
  cin >> N;
  
  int digits1st = N % 10;
  int hon_num[5] = {2,4,5,7,9};
  int pon_num[4] = {0,1,6,8};
  int bon_num[1] = {3};
  
  for(int i = 0; i < 5; i++)
  {
    if(hon_num[i] == digits1st)
    {
      cout << "hon" << endl;
      return 0;
    }
  }
  for(int i = 0; i < 4; i++)
  {
    if(pon_num[i] == digits1st) 
    {
      cout << "pon" << endl;
      return 0;
    }
  }
  for(int i = 0; i < 1; i++)
  {
    if(bon_num[i] == digits1st) 
      cout << "bon" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set>
using namespace std;
/*int p = 998244353;*/
int p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
signed main(){
	int w, h, n; cin >> w >> h >> n;
	if (h == 1 || w == 1) { cout << 0 << endl; return 0; }
	vvel pot(w);
	rep(i, n) {
		int x, y; cin >> x >> y;
		pot[x].push_back(y);
	}
	int ans = w-1;
	vel maxi(w,0); maxi[w - 1] = 0;
	for (int i = w - 2; i >= 0; i--) {
		maxi[i] = maxi[i + 1];
		for (auto x : pot[i + 1]) {
			mmax(maxi[i], x);
		}
		mmin(ans, maxi[i] + i);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define fi first
#define se second
#define pf push_front
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define debug(val) cerr << "Value of " << #val << " : " << val << '\n';
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll nax = 0;

int main(){
	IOS	
	int l, r, n, ans=0;
	cin >> l >> r >> n;
	for(int i=l;i<=r;++i){
		if(i%n==0){
			ans++;
		}
	}
	cout << ans << '\n';
}


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

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

  int a, b, k;
  cin >> a >> b >> k;

  for (int i = a; i <= min(b, a + k - 1); ++i) cout << i << "\n";
  for (int i = max(b - k + 1, a + k); i <= b; ++i) cout << i << "\n";
}


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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int n;
  cin >> n;
  int ans = 0;
  for(int i=0; i<n; i++){
    int a;
    cin >> a;
    while(true){
      if(a%2!=0) break;
      a /= 2;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

#define INF (int)1e09

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set; // insert erase find count
using std::queue;
using std::priority_queue;
using std::stack;

template <typename T> using Vec = vector<T>; // c++11
typedef pair<int, int> PII;
typedef pair<int, pair<int, int> > PIII;

int main(void) {
    int n;
    cin >> n;
    int times = 0;
    while (1) {
        times++;
        if (n <= 3) {
            break;
        } else {
            if (n % 3 != 0) {
                n += (3 - (n % 3));
            }
            n /= 3;
        }
    }
    cout << times << endl;
    return 0;
}

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

int main() {
    int N, T; cin >> N >> T;
    vector<int> a(N);
    for (int& ai : a) cin >> ai;
    vector<int> rangeMax(N);
    rangeMax[N - 1] = a[N - 1];
    for (int i = N - 2; i >= 0; i--) {
        rangeMax[i] = max(rangeMax[i + 1], a[i]);
    }
    map<int, int> cnt;
    for (int i = 0; i < N - 1; i++) {
        cnt[rangeMax[i + 1] - a[i]]++;
    }
    cout << (--cnt.end())->second << endl;
    return 0;
}

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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> vec(N,0);
  for(int i=0; i<M; i++) {
    int a,b;
    cin >> a >> b;
    vec[a-1]+=1;
    vec[b-1]+=1;
    }
 
    for(int i=0; i<N; i++){
        cout << vec[i] << endl;
    }
  return 0;
}
  

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

int main() {
  char c;
  cin >> c;

  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
    cout << "vowel" << endl;
  else 
    cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstring>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(0); cin.tie(0), cout.tie(0);
    int n, a, b; cin >> n >> a >> b;
    if(abs(a-b)%2) cout << "Borys";
    else cout << "Alice";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define cyes cout << "YES" << endl
#define cno cout << "NO" << endl
#define f(i, a, n) for(int i = a; i < n; i++)
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mod 1000000007
int gcd(int a, int b) { if (!b) return a; return gcd(b, a % b); }  
int lcm(int a, int b) { return (a * b) / gcd(a, b); }
using namespace std;



int32_t main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  
  int a,b,c;
  cin >> a >> b >> c;

  if((a+b+c)>=22)
  	cout << "bust";
  else
  	cout << "win";



  return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define int 		  long long
#define	pb 			  push_back
#define all(a)		  (a).begin(),(a).end()
#define sz(x)		  (int)x.size()
#define endl	 	  "\n"
#define inf 		  1000000007
#define FOR(i, a, b)  for(int i=a; i<b; i++)
//int dp[1000001] = {0};

bitset<101112> bs;
vector<int> primes;
void init(){
	bs.set();
	bs[0] = bs[1] = 0;
	for(int i=2;i<=101111;i++){
		if(bs[i]){
			for(int j=i*i;j<=101111;j+=i) bs[j]=0;
			primes.pb(i);
		}
	}
}
void solve(){
	init();
	int k, res;
	cin>>k;
	FOR(i, 0, sz(primes)){
		if(primes[i]>=k){
			cout<<primes[i];
			return;
		}
	}
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t=1;
	//cin>>t;
	FOR(i, 1, t+1){	
	//	cout<<"Case #"<<i<<":"<<endl;
		solve();
	}
	return 0;
 
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int maxn = 1e6 + 5;
int A,B,C,X;

int ans = 0;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cin>>A>>B>>C>>X;
  for (int a=0; a<=A; a++) {
    for (int b=0; b<=B; b++) {
      for (int c=0; c<=C; c++) {
	if (a*500 + b*100 + c*50 == X) {
	  ans++;
	}
      }
    }
  }


  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
a,b,c,x,y=map(int,input().split())

c1=a*x+b*y
if x>=y:
    c2=2*y*c+(x-y)*a
else:
    c2=2*x*c+(y-x)*b
c3=2*max(x,y)*c
print(min(c1,c2,c3))


Measured memory_bytes: 38256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let nl = read_vec::<i64>();
    let (n,l) = (nl[0],nl[1]);
    let mut sn : Vec<String>= Vec::new();
    for _ in 0..n {
        sn.push(read::<String>());
    }
    sn.sort();
    for s in &sn{
        print!("{}",s );
    }

}

Measured memory_bytes: 4352
import math
import sys
from collections import Counter
def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

n = int(arr_data[0][0])
m = int(arr_data[n+1][0])


#print(n,m)

arr_blue=[]
arr_red=[]
for v in range(1,1+n):
    
    arr_blue.append(arr_data[v][0])
    
for v in range(n+1+1,n+1+1+m):
    
    arr_red.append(arr_data[v][0])


list01=Counter(arr_blue)
list02=Counter(arr_red)

#print(arr_blue)    
#print(arr_red)    

maxdata=0
    
for k in list01:
    
#    print(k,list01[k],list02[k])    
    
    if maxdata<list01[k]-list02[k]:
        
        maxdata=list01[k]-list02[k]
        
print(maxdata)
    

Measured memory_bytes: 3316
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int a, b;
  cin >> a >> b;
  cout << (a <= 9 && b <= 9 ? a * b : -1);
}
#endif


Measured memory_bytes: 256
#include <iostream>

using namespace std;

bool CheckRightTriangle(int a,int b,int c);
int main(){
	int *a,*b,*c,datanum;
	cin>>datanum;
	a = new int[datanum];
	b = new int[datanum];
	c = new int[datanum];
	for( int i=0;i<datanum;i++ ){
		cin>>a[i]>>b[i]>>c[i];
	}
	for(int i=0;i<datanum;i++){
		if(CheckRightTriangle(a[i],b[i],c[i])){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}
	delete[] a;
	delete[] b;
	delete[] c;
	return 0;
}

bool CheckRightTriangle(int a,int b,int c){
	if( a*a+b*b==c*c ) return true;
	if( c*c+a*a==b*b ) return true;
	if( b*b+c*c==a*a ) return true;
	return false;
}

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

using ll = long long;
#define REP(i, n) for(int (i)=0; (i)< (n); ++i)
#define REPR(i, n) for(int (i)=(n); (i)>=0; --i)
#define FOR(i, n, m) for(int (i)=(n); (i)<(m); ++i)
constexpr int INF = 1e9;
//constexpr ll INF = 1LL << 61;
constexpr int mod = 1e9+7;

int main(){
  bool ans = false;
  int N;
  cin >> N;
  int cnt =0;
  REP(i, N){
    int d1, d2;
    cin >> d1 >> d2;
    if(d1 == d2){
      cnt++;
    }
    else{
      cnt = 0;
    }
    if(cnt == 3){
      ans = true;
    }
  }
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}


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

#define PI acos(-1)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define endl '\n'
#define io  ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define file freopen ("maxflow.in", "r", stdin),freopen ("maxflow.out", "w", stdout);
#define all(v) ((v).begin()), ((v).end())

using namespace std;

typedef pair<int, int> pii;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, int> pli;

bool e(ll x) {
  return x % 2 == 0;
}

int main () {
#ifndef ONLINE_JUDGE
  //freopen ("in.txt", "r", stdin);
#endif
  ll a, b, c;
  while(cin >> a >> b >> c){
  if(e(a) || e(b) || e(c)) {
    cout << 0 << endl;
  }else {
    cout << min({a * b, a * c, b * c}) << endl;
  }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<typename T> using v2 = vector<vector<T>>;
template<typename T> using v3 = vector<vector<vector<T>>>;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>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; }
const int MOD = 1e9 + 7;
const int INF = 1e9 + 200;
const ll INFLL = 2e18 + 200;

int main() {
    const int MAX = 1000 * 1000;
    ll K;
    cin >> K;
    bool check = true;
    ll add = 7, temp = 7;
    if (K == 7 || K == 1) {
        cout << 1 << endl;
        return 0;
    }
    for (int i = 1; i <= MAX; i++) {
        add *= 10;
        add %= K;
        temp += add;
        temp %= K;
        if (temp == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
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 total1 = 0;
  int total2 = 0;


  
  
  
  for(int i = 0;i<n;i++){
  if(i % 2 == 0){
    total1 += A[i];
  }else{
    total2 += A[i];
  }
  }
  cout << total1 - total2 << endl;
}


Measured memory_bytes: 3648
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
// #include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <stack>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <sstream>
#include <iomanip>
using namespace std;


#define int int64_t
#define vi vector<int>
#define vb vector<bool>
#define vbb vector< vector<bool> >
#define all(x) (x).begin(), (x).end()
#define vii vector< vector<int> >
#define rip(dp, n, m) vector< vector<int> > dp(n, vector<int>(m,0))
#define ff first
#define ss second
#define pii pair<int64_t, int64_t>
#define miv map<int, vector<int> >
#define mp make_pair
#define pb push_back
#define prr(x) cout << (#x) <<'	' << (x) << endl
#define pr(x) cout  << (x) << endl
#define f(i,n) for(i=0;i<n;i++)
#define pqb priority_queue<int>
#define pqs priority_queue<int,vi,greater<int> >
#define setbits(x)  __builtin_popcountll(x)
#define zrobits(x)  __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x) int x; cin>>x; while(x--)
#define FIO  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int32_t main()
{
  FIO;
  int i, n, j, m, k, l, t;
  string s1, s2;
  cin >> s1 >> s2;
  n = s1.length();
  m = s2.length();
  rip(dp, n+1, m+1);
  // f(i,n+1) 
  for(i=1;i<=n;i++)
  {
    for(j=1;j<=m;j++)
    {
      if(s1[i-1]==s2[j-1])  
        {
          // cout << "HII";
          dp[i][j] = dp[i-1][j-1]+1;}
      else
        dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
    }
  } 

  i=n,j=m;
  string s;
  while(i and j)
  {
    if(s1[i-1]==s2[j-1]) 
    {
      s = s + char(s1[i-1]);
      i--,j--;
    }

    else if(dp[i][j] ==dp[i][j-1]) j--;
    else if(dp[i][j] ==dp[i-1][j]) i--;
  } 

  k = dp[n][m];
  f(i,k) cout << s[k-i-1];
}

Measured memory_bytes: 74124
class Main
  def self.main lines
    n,m,c = lines.shift.split.map(&:to_i)
    p n, m, c
    bs = lines.shift.split.map(&:to_i)
    p bs
    cnt = 0
    n.times do |a|
      as = lines.shift.split.map(&:to_i)
      p as
      x = c
      m.times do |mm|
        x += as[mm]*bs[mm]
      end
      cnt += 1 if x > 0
    end
    cnt
  end
end

if $0 == __FILE__
  $stdout = open('/dev/null', 'w')
  r = Main.main STDIN.readlines
  $stdout = STDOUT
  puts r
end

Measured memory_bytes: 1788
K,N = list(map(int,input().split()))
A = list(map(int,input().split()))
r = 0
l = 0
ans = A[N-1] - A[0]

for i in range(len(A)):
    if A[i] != A[0]:
        r = A[i] - A[i-1]
    if A[i] != A[N-1]:
        l = A[i+1] - A[i]
    if ans > K - max(r,l):
        ans = K - max(r,l)
print(ans)

Measured memory_bytes: 26444
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
static const int INF (1<<30);

int main() {
  long long N, K;
  cin >> N >> K;

  long long ans;
  if (K % 2 == 1) {
    ans = pow(N / K, 3);
  } else {
    ans = pow(N / K, 3);
    ans += pow((N+K/2) / K, 3);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std ;
int main () {
string d;
getline (cin , d);
if (d=="SAT")
    cout<<"1"<<endl;
else if (d=="SUN")
    cout<<"7"<<endl;
else if (d=="MON")
    cout<<"6"<<endl;
    else if (d=="TUE")
    cout<<"5"<<endl;
    else if (d=="WED")
    cout<<"4"<<endl;
    else if (d=="THU")
    cout<<"3"<<endl;
    else if (d=="FRI")
    cout<<"2"<<endl;
return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vector<ll>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ld eps = 1e-9;
const ll MOD = 1000000007;
const ll INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(ll i=0;i<(ll)(s.size());++i) {
    cout << s[i];
    if(i == (ll)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
struct Edge {
  ll a, b, c, h, r;
};
bool operator< (Edge e1, Edge e2) {
  return e1.c > e2.c;
}
using Graph = vector<vector<Edge>>;
struct Elm {
  ll idx, time, cost;
};
bool operator< (Elm e1, Elm e2) {
  return e1.cost > e2.cost;
}
void solve(ll n, ll m, ll h, ll k) {
  Graph g(n);
  for(ll i=0;i<m;++i) {
    ll a, b, c, h, r; cin >> a >> b >> c >> h >> r;
    a--; b--, r--;;
    g[a].push_back({a, b, c, h, r});
    g[b].push_back({b, a, c, h, r});
  }
  ll s, t; cin >> s >> t;
  s--; t--;
  ll p; cin >> p;
  vector<ll> d(p);
  vector<bitset<8>> bs(p);
  for(ll i=0;i<p;++i) {
    ll l; cin >> l;
    cin >> d[i];
    for(ll j=0;j<l;++j) {
      ll a; cin >> a;
      a--;
      bs[i] |= 1<<a;
    }
  }
  vvi dp(p+1, vi(1<<k, INF));
  dp[0][0] = 0;
  for(ll i=0;i<p;++i) {
    for(ll j=0;j<1<<k;++j) {
      dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
      ll nxt = j | bs[i].to_ulong();
      dp[i+1][nxt] = min(dp[i+1][nxt], dp[i][j] + d[i]);
    }
  }
  vi pass(1<<k);
  for(ll j=0;j<1<<k;++j) {
    pass[j] = dp[p][j];
  }
  ll now = -1;
  ll ans = INF;
  while(now < (1<<k)) {
    now++;
    Graph g1(n);
    for(ll i=0;i<n;++i) {
      for(ll j=0;j<(ll)(g[i].size());++j) {
        g1[i].push_back(g[i][j]);
        if((now>>g[i][j].r)&1) {
          g1[i][j].c = 0;
        }
      }
    }
    vvi dp(n, vi(h+1, INF));
    priority_queue<Elm> pq;
    dp[s][0] = 0;
    pq.push({s, 0, 0});
    while(!pq.empty()) {
      auto nowe = pq.top(); pq.pop();
      ll idx = nowe.idx, time = nowe.time, cost = nowe.cost;
      if(dp[idx][time] < cost) continue;
      for(ll i=0;i<(ll)(g[idx].size());++i) {
        ll nxt = g[idx][i].b, w = g[idx][i].c, t = g[idx][i].h, r = g[idx][i].r;
        if((now>>r)&1) {
          if(time + t <= h && dp[nxt][time+t] > cost) {
            dp[nxt][time+t] = cost;
            pq.push({nxt, time+t, cost});
          }
        } else {
          if(time + t <= h && dp[nxt][time+t] > cost + w) {
            dp[nxt][time+t] = cost + w;
            pq.push({nxt, time+t, cost + w});
          }
        }
      }
    }
    ll mi = INF;
    for(ll i=0;i<=h;++i) {
      mi = min(mi, dp[t][i]);
    }
    if(mi != INF) {
      ans = min(ans, mi + pass[now]);
    }
  }
  cout << (ans == INF ? -1 : ans) << endl;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  while(1) {
    ll n, m, h, k; cin >> n >> m >> h >> k;
    if(n == 0) break;
    solve(n, m, h, k);
  }
}



Measured memory_bytes: 3688
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
#include<queue>
#include<deque>
using namespace std;
typedef pair<int, int>P;
typedef pair<int, pair<int, int>>PP;
typedef long long ll;
ll inf = -1;
ll mod = mod = pow(10, 9) + 7;
int main() {
	int n, m; cin >> n >> m;
	vector<int> a(m);
	vector<int>grid(n + 1, 0);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
		grid[a[i]] = 1;
	}
	for (int i = 1; i < m; i++) {
		if (a[i] - a[i - 1] == 1) {
			cout << 0 << endl;
			return 0;
		}
	}
	vector<ll>dp(n + 1,0);
	dp[0] = 1;
	if (grid[1] == 0 and grid[2] == 0) {
		dp[1] = 1;
		dp[2] = 2;
	}
	else if (grid[1] == 1 and grid[2] == 0) {
		dp[2] = 1;
	}
	else if (grid[1] == 0 and grid[2] == 1) {
		dp[1] = 1;
	}
	for (int i = 3; i <= n; i++) {
		if (grid[i] == 0) {
			dp[i] = (dp[i - 2] + dp[i - 1]) % mod;
		}
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 1664
// https://beta.atcoder.jp/contests/abc098/tasks/arc098_b
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

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

using namespace std;

int main(){
  int n;
  vector<int> v;
  long long sum = 0;
  long long ans = 0;

  cin >> n;
  for(int i = 0; i < n; i++){
    int work;
    cin >> work;
    v.push_back(work);
  }
  // sum = v[0];

  int r = 0;
  for(int l = 0; l < n; l++){
    while(r < n && (sum ^ v[r]) == (sum + v[r])){
      // if((sum ^ v[r]) != (sum + v[r])) break;
      // cout << "L:" << l << " R:" << r << endl;
      sum += v[r];
      r++;
    }
    ans += r - l;
    sum -= v[l];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1400