akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
template<class itr, class itr2> bool next_sequence2(itr first, itr last, itr2 first2, itr2 last2){ itr now = last; itr2 now2 = last2; while(now != first){ now--, now2--; (*now)++; if((*now) == (*now2)){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    int K, X;
    cin >> K >> X;
    Yes(K * 500 >= X);
}


Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	int tmp;
	int n;
	cin >> n;
	vector<int> t(n+1);
	int sum = 0;
	REP1(i, n){
		cin >> t[i];
		sum += t[i];
	}
	int m, p, x;
	cin >> m;
	REP(i, m){
		cin >> p >> x;
		cout << sum - t[p] + x << endl;
	}
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>

using namespace std;

int main() {
    string str;

    cin >> str;

    int len = str.size()-1;

    if(len%2)   len--;

    while (str.substr(0,len/2) != str.substr(len/2, len/2)) {
        len -= 2;
    }

    cout << len << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,m,i,j=-1;bool ans = true;cin >> n;
  int d[n+1];d[n] = 1000000001;
  for(i=0;i<n;i++) cin >> d[i];
  cin >> m;int t[m];
  for(i=0;i<m;i++) cin >> t[i];
  sort(d,d+n);sort(t,t+m);
  for(i=0;i<m;i++){
    j += 1;
    while(d[j] != t[i]){
      if (j == n || d[j] > t[i]){
        ans = false;
        break;
      }
      j += 1;
    }
    if(ans == false) break;
  }
  cout << ((ans) ? "YES":"NO") << endl;
}

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

int main(){
    int N;
    cin >> N ;
    vector<int> W(N);
    for(int i=0; i < N; i++){
        cin >> W.at(i) ;
    }
    int S1,S2;
    int before=0 ;
  vector<int> after(N);
    for(int i=0; i < N; i++){
        before= before + W.at(i) ;
      
    }
//  cout << before <<endl;

    bool stop = false;
    int i=0;
    while(i<N){
        for(int j=0; j<i ; j++){
            S1 = S1 + W.at(j) ;
        }
      S2=before;
        for(int j=0 ; j<i ; j++){
            S2 = S2 - W.at(j) ;
        }
 //     cout << S1 << endl <<S2 <<endl ;
        after.at(i)= S2 - S1 ;
        if(after.at(i)<0){
            after.at(i) = 0 - after.at(i);
        }
/*        if(after >= before){
            stop = true;
            int ans = before;
        }
        
            before = after;
            after =0 ;
*/            S1=0;
            S2=0;
        
        i++ ;
    }
int ans = after.at(0);
  for(int i;i<N;i++){
 //   cout << after.at(i) << endl;
    if(after.at(i) < ans){
      ans = after.at(i) ;
    }
  }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using i64 = int64_t;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)
constexpr i64 INF = 1LL << 60;

int main() {
	i64 n, x; cin >> n >> x;
	i64* a = new i64[n];
	rep(i, 0, n) cin >> a[i];

	vector<vector<i64>> mind(n + 1, vector<i64>(n, INF));
	rep(i, 0, n) mind[0][i] = a[i];

	i64 ans = INF;
	rep(i, 0, n) {
		i64 cnt = x * i;
		rep(j, 0, n)
			cnt += mind[i][j];
		ans = min(ans, cnt);

		// update table
		rep(j, 0, n)
			mind[i + 1][j] = min(mind[i][j], a[(n + j - i - 1) % n]);
	}
	cout << ans << endl;
	delete[] a;
	return 0;
}

Measured memory_bytes: 34656
#include <iostream>
#include <string>

using namespace std;

int main()
{
	int n;
	string str;
	char tmp[1010];
	cin >> n;
	cin.ignore();
	while (n > 0){
		cin.getline(tmp, sizeof(tmp));
		str = tmp;
		int len = 0;
		while (1){
			len = str.find("Hoshino", len);
			if (len == -1)  break;
			str[len + 6] = 'a';
		}
		cout << str << endl;
		n--;
	}
	return (0);
}

Measured memory_bytes: 1200
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class A_167_Registration
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列配列の入力
            string a = Console.ReadLine();
            string b = Console.ReadLine();
            if (a == b.Substring(0, b.Length - 1))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 25844
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;
#define N (int)1e5
#define mod (int)(1e9 + 7)
typedef long long LL;
int n, k, ess;
int dp[5001][5001], a[5001];
int main()
{
	cin >> n >> k;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		a[i] *= -1;
	}
	sort(a, a + n);
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 0; j < k; j++)
		{
			if (dp[i - 1][j]) {
				int aa = -a[i - 1] + j > k ? k : -a[i - 1] + j;
				dp[i][aa] += dp[i - 1][j];
				if (aa == k)
					ess = i;
			}
		}
		for (int j = 0; j <= k; j++)
		{
			dp[i][j] += dp[i - 1][j];
		}
	}
	cout << n - ess << endl;
}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T, class ... Args> constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }

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

    int m = -1;
    for (int i = 1; i * (i + 1) / 2 <= n; ++i) if (i * (i + 1) / 2 == n) { m = i + 1; break; }

    if (m == -1) { cout << "No" << endn; return; }
    else cout << "Yes" << endn;
    cout << m << endn;

    vector<vector<int>> d(m, vector<int>(m, -1));
    int cnt = 1;
    rep(i, m) {
        cout << m - 1 << " ";
        rep(j, m) {
            if (i == j) continue;
            int ii = i, jj = j;
            if (ii > jj) swap(ii, jj);
            if (d[ii][jj] > 0) cout << d[ii][jj] << " ";
            else cout << (d[ii][jj] = cnt++) << " ";
        }
        cout << endn;
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    solve();

    cout << flush;

    return 0;
}


Measured memory_bytes: 2176
N = $stdin.gets.chomp.to_i
A = $stdin.gets.chomp.split(" ").map{ |a| a.to_i }

s = 0
x = 0
$ps = [] # ps[i] = A_0 + ... + A_i
$px = [] # px[i] = A_0 ^ ... ^ A_i
A.each{ |a| 
  s += a
  x ^= a
  $ps << s
  $px << x
}

#p $ps
#p $px

def X(l,r)
  $px[r] ^ (l > 0 ? $px[l-1] : 0)
end

def S(l,r)
  $ps[r] - (l > 0 ? $ps[l-1] : 0)
end

#p S(1,N-1)
#p X(1,N-1)

ct = 0
R = N-1
(0...N).each { |l|
    r = R
    if X(l,r) == S(l,r)
      ct += r-l+1
      next
    end    
    ir = l
    sr = N
    r = (l+r)/2
    # search r: X(l,r) == S(l,r) and X(l,r+1) != X(l,r+1)
    while true
#      p "#{l} #{r}"
      if X(l,r) == S(l,r)
        if X(l,r+1) != S(l,r+1) 
          ct += r-l+1
          break
        end
        ir = r+1
      else
        sr = r
      end
      r = (sr+ir)/2
    end
}
puts ct


Measured memory_bytes: 21232
X, K, D = list(map(int, input().split()))

if X < 0:
    X = -X

if X - K*D > 0:
    print(X-K*D)
else:
    K_min = int(X/D)
    if (K - K_min)%2 == 0:
        print(X - K_min*D)
    else:
        print((K_min+1)*D -X)


Measured memory_bytes: 9180
/*
 ============================================================================
 Name        : ABC166-B.c
 Author      : soya
 Version     :
 Copyright   : Your copyright notice
 Description : Hello World in C, Ansi-style
 ============================================================================
 */

#include <stdio.h>
#include <stdlib.h>
int N,K,cnt;
int A[101][101];
int d[101], snuke[101];
int main(void) {
	scanf("%d %d", &N, &K);
	for(int j = 0; j < K; j++){
		scanf("%d", &d[j]);
		for(int i = 0; i < d[j]; i++){
			scanf("%d", &A[j][i]);
			int tmp = A[j][i];
			snuke[tmp]++;
		}
	}

	/*for(int j = 0; j < K; j++){
		for(int i = 0; i < d[j]; i++){
			int tmp = A[j][i];
			snuke[tmp]++;
		}

	}*/

	for(int l = 1; l <= N; l++){
		if(snuke[l] == 0){
			cnt++;
		}
	}

	printf("%d", cnt);

	return 0;
}


Measured memory_bytes: 1728
#include <iostream>

using namespace std;

int main(int argc, char **)
{
	int f;
	char a[3][4];
	
	while(scanf("%s", a[0])!=EOF){
		if(a[0][0] == '0'){
			break;
		}
		f = 0;
		scanf("%s", a[1]);
		scanf("%s", a[2]);
		for(int i = 0; i < 3; i++){
			if(a[0][i] == a[1][i] && a[0][i] == a[2][i] && (a[0][i] == 'w' || a[0][i] == 'b')){
				cout << a[0][i] << endl;
				f = 1;
				break;
			} else if(a[i][0] == a[i][1] && a[i][0] == a[i][2] && (a[i][0] == 'w' || a[i][0] == 'b')){
				cout << a[i][0] << endl;
				f = 1;
				break;
			}
		}
		if(f == 0){
			if(a[0][0] == a[1][1] && a[0][0] == a[2][2] && (a[0][0] == 'w' || a[0][0] == 'b')){
				cout << a[0][0] << endl;
			} else if(a[0][2] == a[1][1] && a[0][2] == a[2][0] && (a[1][1] == 'w' || a[1][1] == 'b')){
				cout << a[1][1] << endl;
			} else {
				cout << "NA" << endl;
			}
		}
	}
}

Measured memory_bytes: 0
#include <stdio.h>
int main () {
   int x[3000],y[3000];
   int i, j;

   for (i = 0; i<3000; i++) {

     scanf ("%d %d\n", &x[i], &y[i]);

     if (x[i] == 0 && y[i] == 0) {
       break;
     }
     j++;
   }

   for (i = 0; i < j; i++) {

     if (x[i] <= y[i]) {
      printf ("%d %d\n",x[i], y[i]);
     } else {
      printf ("%d %d\n",y[i], x[i]);
     }

   }

   return 0;
}

Measured memory_bytes: 624
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;


using ll=long long;

class mod_ll
{
public:
	ll m_v;
	ll m_m; // prime value ex. 1000000009
	mod_ll(ll m=1000000007, ll v=0) : m_v(v), m_m(m)
	{
	}
	mod_ll operator = (ll rhs)
	{
		m_v=rhs%m_m;
		return *this;
	}
	mod_ll operator = (mod_ll rhs)
	{
		m_v=rhs.m_v;
		m_m=rhs.m_m;
		return *this;
	}
	mod_ll operator += (ll rhs)
	{
		m_v=(m_v+rhs)%m_m;
		return *this;
	}
	mod_ll operator += (mod_ll rhs)
	{
		if(m_m!=rhs.m_m) throw;
		m_v=(m_v+rhs.m_v)%m_m;
		return *this;
	}
	mod_ll operator + (mod_ll rhs)
	{
		auto ret=*this;
		return ret+=rhs;
	}
	mod_ll operator *= (ll rhs)
	{
		rhs%=m_m;
		m_v=(m_v*rhs)%m_m;
		return *this;
	}
	mod_ll operator *= (mod_ll rhs)
	{
		if(m_m!=rhs.m_m) throw;
		m_v=(m_v*rhs.m_v)%m_m;
		return *this;
	}
	mod_ll operator * (mod_ll rhs)
	{
		mod_ll ret=*this;
		return ret*=rhs;
	}
	mod_ll operator ^ (ll rhs)
	{
		mod_ll t=*this;
		mod_ll ret(m_m, 1LL);

		for(;rhs>0;rhs>>=1)
		{
			if(rhs&1) ret*=t;
			t*=t;
		}
		return ret;
	}
	mod_ll operator /= (mod_ll rhs)
	{
		if(m_m!=rhs.m_m) throw;
		return *this*=(rhs^(m_m-2));
	}
	mod_ll operator /= (ll rhs)
	{
		mod_ll t(m_m, rhs);
		return *this/=t;
	}
	mod_ll operator / (mod_ll rhs)
	{
		mod_ll ret=*this;
		return ret/=rhs;
	}
};

mod_ll mod_nCr(int n, int r, ll m)
{
	mod_ll bunsi(m, 1);
	mod_ll bunbo(m, 1);

	if(r*2>n) r=n-r;

	for(int i=0;i<r;i++)
	{
		bunsi*=(n-i);
		bunbo*=(i+1);
	}
	return bunsi/bunbo;
}


mod_ll mod_nPr(int n, int r, ll m)
{
	mod_ll ret(m, 1);

	for(int i=0;i<r;i++)
	{
		ret*=(n-i);
	}
	return ret;
}



int main(void)
{
	int n;
	while(scanf("%d", &n)==1)
	{
		vll a(n);
		for(int i=0;i<n;i++) scanf("%lld", &a[i]);

		vi b(61);
		int mb=0;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<61;j++)
			{
				if((a[i]>>j)&1)
				{
					b[j]++;
					mb=max(mb, j);
				}
			}
		}
//		for(int i=0;i<=mb;i++) printf(" %d", b[i]); printf("\n");

		mod_ll ans;
		mod_ll u;
		mod_ll t;
		u=1;
		for(int i=0;i<61;i++)
		{
			t=(ll)b[i]*(n-b[i]);
			ans+=u*t;
			u*=2;
		}
		printf("%lld\n", ans.m_v);
	}
	return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
#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, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    ll X,N,p[100];
    cin >> X >> N ;
    REP(i,N){
        cin >> p[i];
    }
    if(N==0){
        cout << X << endl;
        return 0;
    }
    REP(i,100){
        ll a = X+i;
        ll b = X-i;
        int af=0;
        int bf=0;
        REP(j,N){
            if(af==0&&p[j] == a){
                af=1;
            }
            if(bf==0&&p[j] == b){
                bf=1;
            }
            if(af==1 && bf==1){
                break;
            }
            if(j==N-1){
                if(bf==1){
                    cout << a << endl;
                    return 0;
                }
                cout << b<<endl;
                return 0;
            }
        }
    }
    return 0;    
}


Measured memory_bytes: 3624
using System;

class T1PBCD
{
	static public void Main(string[] args)
	{
		int N, K;
		string[] vals = Console.ReadLine().Split(' ');

		N = int.Parse(vals[0]);
		K = int.Parse(vals[1]);
		int[] A = new int[N];
		int[] B = new int[N];
		for(int i=0; i<N; i++)
		{
			vals = Console.ReadLine().Split(' ');
			A[i] = int.Parse(vals[0]);
			B[i] = int.Parse(vals[1]);
		}
		
		long ans = 0;
		long sum;
		int sht = 0;
		while(true)
		{
			//Console.WriteLine("K={0}", K);
			sum = 0;
			for(int i=0; i<N; i++)
			{
				if(((A[i] >> sht) & ~K) == 0)
				{
					sum += B[i];
					//Console.WriteLine("{0} is added", A[i]);
				}
			}
			//Console.WriteLine("sum={0}", sum);
			if(ans < sum)
				ans = sum;
			if(K == 0)
				break;

			while((K & 1) == 0)
			{
				K >>= 1;
				sht++;
				if(K == 0)
					break;
			}
			K &= 0x3ffffffe;
		}

		Console.WriteLine(ans);
	}
}


Measured memory_bytes: 17856
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
	
	ll n; cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	ll ans1 = a[n - 1];
	double m;
	m = (double) ans1 / 2;
	ll ans2;
	double tmpMin = 10000000000;
	for (int i = 0; i < n - 1; i++) {
		double tmp = abs(a[i] - m);
		if (chmin(tmpMin, tmp)) ans2 = a[i];
	}
	cout << ans1 << " " << ans2 << endl;
	return 0;
}

Measured memory_bytes: 3932
A, B, K = map(int, input().split())
for i in range(1, K+1):
  if(i%2==1):
    if(A%2 == 1):
      A = A-1
    B += A//2
    A = A//2
  else:
    if(B%2 == 1):
      B = B-1
    A += B//2
    B = B//2
print(A, B)

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

using namespace std;

#define INF 1000000000
#define INFLL 0x3f3f3f3f3f3f3f3fLL 
#define EPS 10e-9
#define MOD 998244353
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define st first
#define nd second
#define sz(v) int(v.size())
#define all(X) (X).begin(), (X).end()
#define FOR(I, A, B) for(int I = A; I < B; I++)
#define RFOR(I, A, B) for(int I = A; I >= B; I--)

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<iii> viii;
typedef vector<ll> vll;

int n;
ll s;

int a[3030];
ll PD[3030][3030];

ll pd(int i, ll sum){
	if(sum < 0) return 0;
	if(i == n){
		if(sum == 0) return 1;
		else return 0;
	}
	ll &mem = PD[i][sum];
	if(mem != -1) return mem;
	mem = 2*pd(i+1, sum);
	mem %= MOD;
	mem += pd(i+1, sum - a[i]);
	mem %= MOD;
	return mem;
}

int main(){
	scanf("%d%lld", &n, &s);
	FOR(i,0,n){
		scanf("%d", &a[i]);
	}
	memset(PD, -1, sizeof(PD));
	cout << pd(0,s) << endl;
	return 0;
}



Measured memory_bytes: 75664
// Created by sz
#include <bits/stdc++.h>
using namespace std;

int N, A, B;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    
    cin>>N>>A>>B;
    cout<<min(A,B)<<" "<<max(A+B-N, 0)<<endl;
    

    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(){
int c1,c5,c10,c50,c100,c500,a,b,c,d,e,f;
	scanf("%d %d %d %d %d %d",&c1,&c5,&c10,&c50,&c100,&c500);
	
	a=c1;
	b=c5*5;
	c=c10*10;
	d=c50*50;
	e=c100*100;
	f=c500*500;
	
	if(a+b+c+d+e+f>=1000){
		printf("%d\n",1);
	}else{
		printf("%d\n",0);
	}
	
return 0;
}

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

const long long MAX = 200010;
const int MOD = 1000000007;

long long com[MAX], inv[MAX];

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// テーブルを作る前処理
void COMinit(int n) {
    com[0] = 1;
    com[1] = n % MOD;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        com[i] = ( com[i-1] * ( n - i + 1 ) % MOD ) * inv[i] % MOD;
    }
}


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

    COMinit(n);
    cout << (((modpow(2, n, MOD) - com[a] + MOD)) % MOD - com[b] - 1 + MOD ) % MOD << endl;
    return 0;
    
}


Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


ll dp[101010];

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

	int N, M;
	cin >> N >> M;
	vector<vector<ll>>dat(M);
	for (int i = 0; i < M; i++) {
		vector<ll>v(3);
		cin >> v[0] >> v[1] >> v[2];
		v[0]--; v[1]--;
		dat[i] = v;
	}
	sort(all(dat));
	for (int i = 0; i < 101010; i++)dp[i] = inf;

	min_priority_queue<pair<ll, ll>>p;
	int cur = 0;
	dp[0] = 0;
	for (int i = 0; i < N; i++) {
		if (i != 0) {
			if (p.size() == 0) {
				puts(-1);
				return 0;
			}
			while (p.size()) {
				if (p.top().second < i)p.pop();
				else {
					dp[i] = p.top().first;
					break;
				}
			}
		}
		if (dp[i] == inf) {
			puts(-1);
			return 0;
		}
		while (cur < M && dat[cur][0] <= i){
			if (dat[cur][0] == i)p.push({ dp[i] + dat[cur][2],dat[cur][1] });
			cur++;
		}
	}
	if (dp[N - 1] == inf)puts(-1);
	else puts(dp[N - 1]);
	

	return 0;
}

Measured memory_bytes: 8568
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<62;

int main(){
    int n,k,q;
    cin>>n>>k>>q;
    vector<int> a(q);
    for(auto & t : a) cin>>t;
    vector<int> v(n+1);
    for(int i=0;i<q;++i){
        v[a[i]]++;
    }
    for(int i=1;i<=n;++i){
        if(q - v[i] < k) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
inline int read(){
	register int x=0;
	register bool f=0;
	register char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-') f=1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<3)+(x<<1)+c-48;
		c=getchar();
	}
	return f?-x:x;
}
char cr[200];int tt;
inline void print(register int x,register char k='\n') {
    if(!x) putchar('0');
    if(x < 0) putchar('-'),x=-x;
    while(x) cr[++tt]=x%10+'0',x/=10;
    while(tt) putchar(cr[tt--]);
    putchar(k);
}
const int maxn=2e6+100;
const int inf=1234567890; 
int t[maxn<<2];
void pushup(int o){
	t[o]=min(t[o<<1],t[o<<1|1]);
	return;
}
void build(int o,int l,int r){
    if(l==r){
    	t[o]=inf;
    	return; 
	}
    int mid=l+r>>1;
    build(o<<1,l,mid);
    build(o<<1|1,mid+1,r);
    pushup(o);
    return;
}
void change(int o,int l,int r,int q,int v){
    if(l==r){
		t[o]=v;
		return;
	}
	int mid=l+r>>1;
    if(q<=mid) change(o<<1,l,mid,q,v);
    else change(o<<1|1,mid+1,r,q,v);
    pushup(o);
    return;
}
int query(int o,int l,int r,int ql,int qr){
    if(ql<=l&&r<=qr){
    	return t[o];
	}
	int mid=l+r>>1,res=inf;
    if(ql<=mid) res=min(res,query(o<<1,l,mid,ql,qr));
    if(qr>mid) res=min(res,query(o<<1|1,mid+1,r,ql,qr));
    return res;
}
struct edge{
	int to,nxt;
}e[maxn<<1];int h[maxn],cnt,n,in[maxn],k;
void add(int x,int y){
	e[++cnt].to=y;
	e[cnt].nxt=h[x];
	in[y]++;
	h[x]=cnt;
	return;
}
priority_queue<int>q;
int a[maxn],b[maxn],tot,p[maxn];
void topo(){
    for(int i=1;i<=n;i++)
		if(!in[i])q.push(i);
    while(!q.empty()){
        int u=q.top();q.pop();
		b[++tot]=u;
        for(int i=h[u];i;i=e[i].nxt){
        	int v=e[i].to;
			in[v]--;
        	if(!in[v])q.push(v);
		}
    }
    return;
}
signed main(){
	n=read();k=read();
    for(int i=1;i<=n;i++){
		a[read()]=i;
	}
	reverse(a+1,a+n+1);
    build(1,1,n);
    for(int i=n;i>=1;i--){
        int x=query(1,1,n,max(1,a[i]-k+1),a[i]);
        if(x>=1&&x<=n)add(a[i],a[x]);
        x=query(1,1,n,a[i],min(n,a[i]+k-1));
        if(x>=1&&x<=n)add(a[i],a[x]);
        change(1,1,n,a[i],i);
    }
    topo();
    reverse(b+1,b+n+1);
    for(int i=1;i<=n;i++)
		p[b[i]]=i;
    for(int i=1;i<=n;i++)print(p[i]);
	return 0;
}

Measured memory_bytes: 36604
import numpy as np
n=int(input())
a=np.array(list(map(int,input().split())))

ma=np.max(a)
pma=np.argmax(a)
mi=np.min(a)
pmi=np.argmin(a)
ans=[]

if ma*mi<0:
    if abs(ma)>abs(mi):
        for i in range(n):
            if i==pma:
                continue

            ans.append((pma+1,i+1))
            a[i]+=ma
        pos=1
    else:
        for i in range(n):
            if i==pmi:
                continue

            ans.append((pmi+1,i+1))
            a[i]+=mi
        pos=0
else:
    if ma>0:
        pos=1
    else:
        pos=0

if pos==1:
    for i in range(1,n):
        if a[i]>=a[i-1]:
            continue
        ans.append((i,i+1))
        a[i]+=a[i-1]
else:
    for i in range(n-2,-1,-1):
        if a[i+1]>=a[i]:
            continue
        ans.append((i+2,i+1))
        a[i]+=a[i+1]

print(len(ans))

for x,y in ans:
    print('{} {}'.format(x,y))


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_0 = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());

signed main()
{   
    gearup;
    int n; cin >> n;
    vl a(n+1);
    ll sum = 0;
    rep(i,n+1){
        cin >> a[i];
        sum += a[i];
    }
    auto solve = [&]() -> ll{
        if(n == 0){
            if(a[0] == 1)return 1;
            else return -1;
        }
        if(a[0] != 0)return -1;
        ll now = 1; //現在の深さのノード、最初はノード1個
        ll res = 1;
        //Greedyに残り葉の分だけ、葉を増やす
        rep(i,n){
            now -= a[i]; //高さiの葉分だけ消す
            sum -= a[i]; //残りの葉の総数
            if(now <= 0)return -1;
            if(now*2 <= sum)
                now *= 2;
            else if(now < sum)
                now += sum - now;
            res += now;
        }
        if(now < a[n])return -1;
        return res;
    };
    out(solve());
}



Measured memory_bytes: 3896
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

const int MAX_N = 100050;

long long A[MAX_N];
long long sgn1[MAX_N];
long long sgn2[MAX_N];
int N;

int main(int argc, char **argv) {
    std::cin >> N;

    for (int i = 1; i <= N; i++) {
        std::cin >> A[i];
    }

    for (int i = 1; i <= N; i++) {
        sgn1[i] = 0;
        sgn2[i] = 0;
    }

    for (int i = 2; i <= N; i++) {
        if (i % 2 == 0) {
            sgn1[i-1]++;
            sgn1[i]--;

            sgn2[i-1]--;
            sgn2[i]++;
        } else {
            sgn1[i-1]--;
            sgn1[i]++;

            sgn2[i-1]++;
            sgn2[i]--;
        }
    }

    std::vector<long long> vec, sgn1_vec, sgn2_vec;

    for (int i = 1; i <= N; i++) {
        vec.push_back(A[i]);
        sgn1_vec.push_back(sgn1[i]);
        sgn2_vec.push_back(sgn2[i]);
    }

    std::sort(vec.begin(), vec.end());
    std::sort(sgn1_vec.begin(), sgn1_vec.end());
    std::sort(sgn2_vec.begin(), sgn2_vec.end());

    long long ret1 = 0;
    long long ret2 = 0;
    for (int i = 0; i < N; i++) {
        ret1 += sgn1_vec[i]*vec[i];
        ret2 += sgn2_vec[i]*vec[i];
    }

    std::cout << std::max(ret1, ret2) << std::endl;

    return 0;
}



Measured memory_bytes: 5216
#include <bits/stdc++.h>
using namespace std;
# define ll  long long  int
# define ld  long double
#define fin0(i,a,b,c) for(int i=a;i<b;i+=c)
#define fin1(i,a,b,c) for(int i=a;i<=b;i+=c)
#define fde0(i,a,b,c) for(int i=a;i>b;i-=c)
#define fde1(i,a,b,c) for(int i=a;i>=b;i-=c)
#define vi vector<int>
#define vll vector<ll>
#define vboo vector<bool>
#define all(a) a.begin(),a.end()
# define pb push_back
# define pp pop_back
# define ff first
# define ss second
# define mp make_pair
# define ac accumulate
# define mod 1000000007
# define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define t     \
    int t;    \
    cin >> t; \
    while (t--)
# define trace1(x)                cerr << #x << ": " << x << "\n";
# define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << "\n";
# define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << "\n";
# define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << "\n";
const ll INF= 1e18;


int main(){
  IOS;
  int n,x,T;
  cin>>n>>x>>T;
  float parts = n/(float)x;
  cout<<int(ceil(parts)*T);
  return 0;
}


Measured memory_bytes: 3688
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>
#include <cstdint>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef unsigned long long		SQWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int N;
	string S;
	cin >> N >> S;

	vector<int> sumE(N + 1, 0);
	vector<int> sumW(N + 1, 0);
	
	REP(i, N) {
		sumE[i + 1] = sumE[i];
		sumW[i + 1] = sumW[i];
		if (S[i] == 'E') {
			sumE[i + 1]++;
		} else {
			sumW[i + 1]++;
		}
	}

	int ans = INF;
	REP(i, N) {
		int lCnt = sumW[i] - sumW[0];
		int rCnt = sumE[N] - sumE[i + 1];
		ans = min(ans, lCnt + rCnt);
	}

	cout << ans << endl;
	return 0;
}



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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  ll N, M;
  cin >> N >> M;

  ll ans;
  if (N == 1 && M == 1) {
    ans = 1;
  } else if (N == 1) {
    ans = M - 2;
  } else if (M == 1) {
    ans = N - 2;
  } else {
    ans = (N - 2) * (M - 2);
  }
  
  // 解答
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x,n;
    cin >> x >> n;
    if(n==0)cout << x << endl;
    else{
    int p[n];
    for(int i=0;i<n;i++)cin >> p[i];
    int flag=0;
    for(int i=0;i<105;i++){
        if(i==0){
            for(int j=0;j<n;j++){
                if(p[j]==x){
                    flag++;
                    break;
                }
            }
            if(flag==0){
                cout << x << endl;
                return 0;
            }
            else flag=0;
        }
        else{
            for(int j=0;j<n;j++){
                if(p[j]==x-i){
                    flag++;
                    break;
                }
            }
            if(flag==0){
                cout << x-i << endl;
                return 0;
            }
            else flag=0;
            for(int j=0;j<n;j++){
                if(p[j]==x+i){
                    flag++;
                    break;
                }
            }
            if(flag==0){
                cout << x+i << endl;
                return 0;
            }
            else flag=0;  
        }
    }
}
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class M>
struct SegmentTree{
    using T = typename M::T;
    int sz;
    vector<T> seg;
    explicit SegmentTree(int n) {
        sz = 1;
        while(sz < n) sz <<= 1;
        seg.assign(2*sz, M::e());
    }

    void set(int k, const T &x){ seg[k + sz] = x; }

    void build(){
        for (int i = sz-1; i > 0; --i) seg[i] = M::f(seg[2*i], seg[2*i+1]);
    }

    void update(int k, const T &x){
        k += sz;
        seg[k] = x;
        while (k >>= 1) seg[k] = M::f(seg[2*k], seg[2*k+1]);
    }

    T query(int a, int b){
        T l = M::e(), r = M::e();
        for(a += sz, b += sz; a < b; a >>=1, b>>=1){
            if(a & 1) l = M::f(l, seg[a++]);
            if(b & 1) r = M::f(seg[--b], r);
        }
        return M::f(l, r);
    }

    T operator[](const int &k) const { return seg[k + sz]; }
};


struct Monoid{
    using T = int;
    static T f(T a, T b) { return min(a, b); }
    static T e() { return INT32_MAX; }
};

int main() {
    int n, q;
    cin >> n >> q;
    SegmentTree<Monoid> seg(n);
    for (int i = 0; i < q; ++i) {
        int c, x, y;
        scanf("%d %d %d", &c, &x, &y);
        if(c == 0) seg.update(x, y);
        else printf("%d\n", seg.query(x, y+1));
    }
    return 0;
}


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

int main()
{
	int N, K;

	cin >> N >> K;

	int h[N];
	int count = 0;

	for (int i = 0; i < N; i++)
	{
		cin >> h[i];
		if (h[i] >= K)
		{
			count++;
		}
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(void){
   int C1, C2, C3, i; 
   double p, G = 0, B = 0, k = 0;
   while ( scanf("%d %d %d", &C1, &C2, &C3) != EOF ) {
      for (i = 1; i <= 10; i++) {
         if ( i == C1 || i == C2 || i == C3) k++;
         else if ( C1 + C2 + i <= 20) G++;
         else if ( C1 + C2 + i >= 20) B++;
      }
      p = G / 7;
      if ( p >= 0.5 ) printf("YES\n");
      else printf("NO\n");
      k = G = B = p = 0;
   }
   return 0;
}

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

using namespace std;
using ll = long long;
constexpr int mod = 1e9+7;
constexpr int md = mod;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout << min({a+b,b+c,a+c}) << endl;
    return 0;
}



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

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
  string s;
  cin >> s;
  while(s.size() > 0){
    int n = s.size();
    if(n > 4 && s[n - 5] == 'd' && s[n - 4] == 'r' && s[n - 3] == 'e' && s[n - 2] == 'a' && s[n - 1] == 'm'){
      s = s.substr(0, n - 5);
    }else if(n > 4 && s[n - 5] == 'e' && s[n - 4] == 'r' && s[n - 3] == 'a' && s[n - 2] == 's' && s[n - 1] == 'e'){
      s = s.substr(0, n - 5);
    }else if(n > 6 && s[n - 7] == 'd' && s[n - 6] == 'r' && s[n - 5] == 'e' && s[n - 4] == 'a' && s[n - 3] == 'm' && s[n - 2] == 'e' && s[n - 1] == 'r'){
      s = s.substr(0, n - 7);
    }else if(n > 5 && s[n - 6] == 'e' && s[n - 5] == 'r' && s[n - 4] == 'a' && s[n - 3] == 's' && s[n - 2] == 'e' && s[n - 1] == 'r'){
      s = s.substr(0, n - 6);
    }else{
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 512
bitcount = [bin(i).count('1') for i in range(0x10000)]
def solve(a, b):
    global bitcount
    b = [65535 ^ bi for bi in b]
    pdp = {a[0]:0}
    ndp = {}
    for ai in a[1:] + [0]:
        for k, v in pdp.items():
            v += bitcount[k]
            for bi in b:
                bi &= k
                vb = v - bitcount[bi]
                bi |= ai
                try:
                    if ndp[bi] < vb:
                        ndp[bi] = vb
                except KeyError:
                    ndp[bi] = vb
        pdp, ndp = ndp, {}
        
    return max(pdp.values())

import sys
f = sys.stdin


while True:
    n, c = map(int, f.readline().split())
    if n == c == 0:
        break
    a = [int(''.join(f.readline().split()), 2) for i in range(n)]
    b = [int(''.join(f.readline().split()), 2) for i in range(c)]
    print(solve(a, b))

Measured memory_bytes: 16840
#include <stdio.h>
int Y, M, D;
bool is_leap(int y) {
	return y % 400 == 0 || (y % 4 == 0 && y % 100 != 0);
}
int count(int y, int m, int d) {
	int ret = 0;
	for(int i = 1; i < y; i++) {
		if(is_leap(i)) ret += 366;
		else ret += 365;
	}
	for(int i = 1; i < m; i++) {
		if(i == 2) ret += (is_leap(y) ? 29 : 28);
		else if(i == 4 || i == 6 || i == 9 || i == 11) ret += 30;
		else ret += 31;
	}
	return ret + d;
}
int main() {
	while(~scanf("%d%d%d", &Y, &M, &D)) {
		if(count(Y, M, D) >= count(1989,  1,  8)) printf("heisei %d %d %d\n", Y - 1988, M, D);
		else if(count(Y, M, D) >= count(1926, 12, 25)) printf("showa %d %d %d\n", Y - 1925, M, D);
		else if(count(Y, M, D) >= count(1912,  7, 30)) printf("taisho %d %d %d\n", Y - 1911, M, D);
		else if(count(Y, M, D) >= count(1868,  9,  8)) printf("meiji %d %d %d\n", Y - 1867, M, D);
		else printf("pre-meiji\n");
	}
}

Measured memory_bytes: 2592
#include <stdio.h>
int temp[500000],cnt;   
void MergeSort(int x[ ], int left, int right)
{
    int mid, i, j, k;
	if (left >= right)              
        return;                     
    mid = (left + right) / 2;       
    MergeSort(x, left, mid);        
    MergeSort(x, mid + 1, right);   
    for (i = left; i <= mid; i++)
        temp[i] = x[i];
    for (i = mid + 1, j = right; i <= right; i++, j--)
        temp[i] = x[j];
        i = left;         
        j = right;
      
    for (k = left; k <= right; k++) {
        if (temp[i] <= temp[j]) 
            x[k] = temp[i++];
        else 
    x[k] = temp[j--];
    cnt++;
    }
}

int main()
{
    int i,j,n;
    int x[500001];
    scanf("%d",&n);
   for (i = 0; i < n; i++){
        scanf("%d",&x[i]);
   }
    MergeSort(x, 0, n-1);
    printf("%d",x[0]);
    for (i = 1; i < n; i++){
        printf(" %d", x[i]);
    }
    printf("\n%d\n",cnt);
    return 0;
}



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

class UnionFind {
	vector<int>par, high;
public:
	vector<int>size;
	UnionFind(int n) {
		par = high = vector<int>(n);
		size = vector<int>(n, 1);
		for (int i = 0; i < n; i++)par[i] = i;
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (high[x] > high[y]) {
			par[y] = x;
			size[x] += size[y];
		}
		else {
			par[x] = y;
			size[y] += size[x];
			if (high[x] == high[y])high[y]++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};
unordered_map<int, int>E[200000];
int main() {
	int n, k, l; scanf("%d%d%d", &n, &k, &l);
	UnionFind road(n), rail(n);
	rep(i, k) {
		int p, q; scanf("%d%d", &p, &q); p--; q--;
		road.unite(p, q);
	}
	rep(i, l) {
		int r, s; scanf("%d%d", &r, &s); r--; s--;
		rail.unite(r, s);
	}
	rep(i, n) {
		E[road.find(i)][rail.find(i)]++;
	}
	rep(i, n) {
		int r = road.find(i), s = rail.find(i);
		printf("%d", E[r][s]);
		if (i == n - 1)printf("\n");
		else printf(" ");
	}
}

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

int main(){
  int H, W;
  cin >> H >> W;

  while(H != 0 || W != 0){
    for (int i = 0; i < H; i++){
      for (int j = 0; j < W; j++){
        if((i+j)%2 == 0){
          cout << "#";
        }else{
          cout << ".";
        }
      }
      cout << endl;
    }
    cout << endl;
    cin >> H >> W;
  }
}



Measured memory_bytes: 3096
import math

a, b, h, m = map(int, input().split())

t = h*60 + m
angle = abs(t*0.5 - t*6)
if angle != 0:
    angle %= 360

angle = math.radians(angle)
ans = (a**2 + b**2 - 2*a*b * math.cos(angle)) ** 0.5
print(ans)

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

#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,m,n) for(int i=(m) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1000000000;

int func(string s,string t){
   int cnt = 0;
   for(char c = 'a';c <= 'z';c++){
      bool left = false,right = false;
      for(int i=0;i<s.size();i++){
         if(s[i] == c)left = true;
      }
      for(int i=0;i<t.size();i++){
         if(t[i] == c)right = true;
      }
      if(left&&right)cnt++;
   }
   return cnt;
}
int main(){
   int n;string s;
   cin >> n >> s;

   int ans = 0;
   for(int i=1;i<n;i++){
      int tmp = func(s.substr(0,i),s.substr(i));
      if(tmp > ans)ans = tmp;
   }
   cout << ans << endl;
   return 0;
}



Measured memory_bytes: 256
def solve
  n, k = gets.split.map!(&:to_i)
  d = []
  a = []
  cnt = 0
  (0..(k - 1)).each do |i|
    d[i] = gets.to_i
    a[i] = gets.split.map!(&:to_i)
  end

  new_a = a.flatten

  (1..n).each do |j|
    cnt += 1 if new_a.include?(j) == false
  end

  print cnt
end
solve

Measured memory_bytes: 14420
//by Top1
#include <bits/stdc++.h>
          
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define cerr cout
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
      
const int inf = (1e9) + 1;
const int mod = 1e9 + 7;
const int maxn = 3e6 + 111;
        
using namespace std;          

int a, b, n, fac[maxn];

int binpow(int x, int y){
	if (y == 0)
		return 1;
	if (y % 2 == 1)
		return binpow(x, y - 1) * x % mod;
	else{
		int z = binpow(x, y / 2);
		return (z * z) % mod;
	}
}

int C (int n, int k) {
	int res = 1;
	for (int i=1; i<=k; ++i){
		res = res % mod * (n - k + i + mod + mod) % mod * binpow(i, mod - 2);
		res %= mod;
	}
	return res % mod;
}

void solve(){             
	cin >> n >> a >> b;

	int ans = binpow(2, n) - 1;
	int x = C(n, a) % mod;
	int y = C(n, b) % mod;

	cout << ((ans - x % mod + mod) % mod - y % mod + mod) % mod;
}                              
      
main(){
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

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

Measured memory_bytes: 384
#include <stdio.h>

int calc(int x,int y){
	if(y == 0){
		return x;
	}else{
		return calc(y,x%y);
	}
}

int main(){
	int x,y;
	scanf("%d %d",&x,&y);
	if(x >= y)
		printf("%d\n",calc(x,y));
	else{
		printf("%d\n",calc(y,x));
	}
}


Measured memory_bytes: 2732
#include<iostream>
#include<string>
using namespace std;
int main(){
	string a;
	int l[26];
	cin>>a;
	for(int i=0;i<26;i++){
		l[i]=0;
	}
	for(int i=0;i<a.size();i++){
		l[a[i]-'a']++;
//		cout<<"i:"<<i<<endl;
//		cout<<"a[i]-'a'"<<a[i]-'a'<<endl;
	}
	for(int i=0;i<26;i++){
		if(l[i]%2==1){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
//#include "stdc++.h"
#include<bits/stdc++.h>
#include<iostream>
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define pb push_back
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0) return 1;ll p=power(a,n/2,m);p=(p*p)%m;if(n%2) return (p*a)%m;else return p; }
#define flush fflush(stdout)
const ll MOD =998244353;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

int main()
{
    int k;
    cin>>k;
    bool visited[k];
    memset(visited,0,sizeof(visited));
    queue<int>q;
    int ans[k];
    q.push(1);
    ans[1]=0;int u,v1,v2;
    while(!q.empty())
    {
        u=q.front();
        q.pop();
        v1=(u*10)%k;
        v2=(u+1)%k;
        if(!visited[v1])
        {
            visited[v1]=1;
            ans[v1]=ans[u];
            q.push(v1);
        }
        else
        {
            if(ans[v1]>ans[u])
            {
                ans[v1]=ans[u];
                q.push(v1);
            }
        }
        if(!visited[v2])
        {
            ans[v2]=1+ans[u];
            visited[v2]=1;
            q.push(v2);
        }
        else
        {
            if(ans[v2]>1+ans[u])
            {
                ans[v2]=1+ans[u];
                q.push(v2);
            }
        }
    }
    cout<<ans[0]+1<<endl;
    return 0;
}


Measured memory_bytes: 896