akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
int main()
{
    int n,k;
    map<int,int> ns;
    scanf("%d%d",&n,&k);
    int i;
    for(i=0;i<n;i++)
    {
        int a;
        scanf("%d",&a);
        ns[a] ++;
    }
    map<int,int>::iterator it;
    vector<int> ss;
    for(it=ns.begin();it!=ns.end();it++)
        ss.push_back((*it).second);
    sort(ss.begin(),ss.end());
    int ans=0;
    for(i=0;i+k<ss.size();i++)
        ans += ss[i];
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 10748
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

#define ll long long
#define pii pair<int, int>

#define reps(i, s, n) for (int i = s; i < (n); i++)
#define rep(i, n) reps(i, 0, n)

using namespace std;

const int N = 222222;
const int M = 222222;

int n, m;
vector<int> load[M];

void init()
{
	cin >> n >> m;
	rep(i, m)
	{
		int a, b;
		cin >> a >> b;
		load[a].push_back(b);
		load[b].push_back(a);
	}
}

int visit[M];

void solve()
{
	queue<pii> que;
	que.push(pii(1, -1));

	while (que.empty() == false)
	{
		pii p = que.front();
		que.pop();

		if (visit[p.first] != 0)
		{
			continue;
		}
		visit[p.first] = p.second;

		rep(i, load[p.first].size())
		{
			que.push(pii(load[p.first][i], p.first));
		}
	}

	bool isOk = true;
	reps(i, 1, n + 1)
	{
		if (visit[i] == 0)
		{
			cout << "No" << endl;
		}
	}

	cout << "Yes" << endl;

	reps(i, 2, n + 1)
	{
		cout << visit[i] << endl;
	}
}

int main()
{
	init();
	solve();
}


Measured memory_bytes: 14588
#include<iostream>
#include<map>
#include<set>

using namespace std;

char answer[20];
int n;

void saiki(int x){
    if(n==x){
        for(int i=0;i<x;i++) cout << answer[i];
        cout << endl;
        return;
    }

    set<char> m;

    for(int i=0;i<x;i++){
        m.insert(answer[i]);
    }

    for(auto itr = m.begin(); itr != m.end(); itr++) {
        answer[x] = *itr;
        saiki(x+1);
    }
    answer[x]++;
    saiki(x+1);

    return;
}

int main(){
    cin >> n;
    answer[0] = 'a';
    saiki(1);
}

Measured memory_bytes: 1536
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n,x,num;
		while(true){
			n=sc.nextInt();
			x=sc.nextInt();
			if(n!=0||x!=0){
				num=0;
				for(int i=1;i<=n-2;i++){
					for(int j=i+1;j<=n-1;j++){
						for(int k=j+1;k<=n;k++){
							if(i+j+k==x){
								num++;
							}
						}
					}
				}
				System.out.println(num);
			}
			else{
				break;
			}
		}
	}
}


Measured memory_bytes: 26956
#include <stdio.h>
#include <string.h>

void reverse(char *string, int length)
{
  int i;
  for(i = 0; i < length/2; i++)
    {
      char tmp;
      tmp = string[i];
      string[i] = string[length - i - 1];
      string[length - i - 1] = tmp;
    }
}
int main(int argc, char *argv[])
{
  char buffer[32];

  memset(buffer, '\0', 32);
  scanf("%s", buffer);
  reverse(buffer, strlen(buffer));
  printf("%s\n", buffer);

  return 0;
}

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

int main(){
	int n;
	long long kc2;
	long long k;
	long long cnt = 0;
	long long t;
	cin >> n >> k;
	vector<long long> a(n);
	vector<long long> dp(2100);
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	for(int i=0; i<n; i++){
		dp[a[i]]++;
		t = 0;
		for(int j=a[i]+1; j<=2000; j++){
			t += dp[j];
		}
		cnt += t;
	}
	//cout << cnt << endl;
	for(int i=2000; i>=1; i--){
		dp[i-1] += dp[i];
	}
	for(int i=0; i<5; i++){
//		cout << "i: " << i << "  dp[i]" << dp[i] << " , ";
	}
//	cout << endl;

	t = 0;
	for(int i=0; i<n; i++){
		//cout << "a[i]+1: " << a[i]+1 << endl;
		t += dp[a[i]+1];
	}
	//cout << "t: " << t << endl;
	//cout << cnt << endl;
	cnt *= k;
	//cout << cnt << endl;
	cnt %= 1000000007;
	//cout << cnt << endl;
	kc2 = (k*(k-1))/2;
	kc2 %= 1000000007;
	//cout << "kc2 " <<kc2 << endl;
	t = t*kc2;
	//cout << "    "<<t << endl;
	t %= 1000000007;
	cnt += t;
	//cout << cnt << endl;
	cnt %= 1000000007;
	cout << cnt << endl;
	return 0;
}



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

using namespace std;

const int MOD=1e9+7;
const double PI=3.14159265359;


int main(){
    
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin>>n;
    
    vector<vector<int>> info(n,vector<int>(3));
    for(int i=0; i<n; i++){
        for(int&j:info[i]) cin>>j;
    }
    
    for(int x=0; x<=100; x++){
        for(int y=0; y<=100; y++){
            for(int h=max(1,info[0][2]-200); h<=info[0][2]+200;h++){
                bool works=1;
                for(auto& v:info){
                    if(v[2]!=max(0, h-abs(x-v[0])-abs(y-v[1]))){
                        works=0;
                        break;
                    }
                }
                if(works) cout<<x<<" "<<y<<" "<<h;
            }
        }
    }
    return 0;
    
}

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

int main(){
	int n;
	cin >> n;
	int a[n];
	
	for (int i=0; i<n; i++)  cin >> a[i];
	
	int cnt=0, i;
	
	do{
	   for (i=0; i<n; i++)
	      if (a[i]%2==1) {
		     cout << cnt;
		     return 0;
	      }
	      else
	         a[i]=a[i]/2;
	    
	   cnt++;
	} while (1);
	
}

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

using namespace std;

ostream& operator<<(ostream &os, const vector<uint64_t> &a)
{
  for (uint64_t n = 0; n < a.size(); ++n) {
    os << a[n];
    if (n + 1 < a.size()) { os << ' '; }
  }
  return os;
}

int main()
{
  uint64_t M, K;
  cin >> M >> K;
  
  uint64_t N = 1 << M;
  
  if (K >= N) {
    cout << -1 << endl;
  } else {
    if (K == 0) {
      vector<uint64_t> a(N << 1, 0);
      
      for (uint64_t n = 0; n < N; ++n) {
        a[(n << 1) + 0] = n;
        a[(n << 1) + 1] = n;
      }
      
      cout << a << endl;
    } else {
      if (M <= 1) {
        cout << -1 << endl;
      } else {
        vector<uint64_t> a(N << 1, 0);
        
        uint64_t x = 0;
        for (uint64_t n = 0; n < N - 1; ++n) {
          if (x == K) { ++x; }
          a[n] = x;
          ++x;
        }
        a[N - 1] = K;
        
        uint64_t y = N - 1;
        for (uint64_t n = N; n < (N << 1); ++n) {
          if (y == K) { --y; }
          a[n] = y;
          --y;
        }
        a[(N << 1) - 1] = K;
        
        cout << a << endl;
      }
    }
  }
  
  return 0;
}

Measured memory_bytes: 3840
//
//  main.cpp
//  ABC170D

#include <iostream>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
const int M=1000005;
int main(int argc, const char * argv[]) {
    int N;
    cin >>N;
    vector<int>a(N);
    vector<int>cnt(M);
    rep(i,N){
        cin>>a.at(i);
    }
    for(int x:a){
        if(cnt.at(x)!=0){
            cnt.at(x)=2; // 重複した時
            continue;
        }
        for (int i=x; i<M; i+=x) { // 倍数のところに１を加えていく
            cnt.at(i)++;
        }
    }
    int ans=0;
    for(int x:a){
        if(cnt.at(x)==1) ans++; // １回しか登場しないのが、割り切れないもの
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 7524
// https://atcoder.jp/contests/abc085/tasks/abc085_b
#include <bits/stdc++.h>
using namespace std;

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

int main() {
  int N, d;
  cin >> N;

  set<int> st;
  rep(i, N) {
    cin >> d;
    st.insert(d);
  }

  cout << st.size() << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
signed main()
{
    vector<int> a(9);
    rep(i, 9) cin >> a[i];
    
    int n;
    cin >> n;

    vector<int> b(n);
    rep(i, n) cin >> b[i];
    
    bool c[9];
    rep(i, 9) c[i] = false;
    rep(i, n) {
        rep(j, 9) {
            if (a[j] == b[i]) {
                c[j] = true;
            }
        }
    }

    rep(j, 3) {
        if (c[3 * j + 0] && c[3 * j + 1] && c[3 * j + 2]) {
            put("Yes")
            return 0;
        }
        if (c[0 + j] && c[3 + j] && c[6 + j]) {
            put("Yes")
            return 0;
        }
    }
    if (c[0] && c[4] && c[8]) {
        put("Yes");
        return 0;
    }
    if (c[2] && c[4] && c[6]) {
        put("Yes");
        return 0;
    }
        put("No");

    return 0;
}

Measured memory_bytes: 3604
a, b, c = map(int,input().split())

# 小さい順に並べるアルゴリズム
# a > b ならば、入れ替える
if a > b:
    a, b = b, a
# b > c ならば、入れ替える
if b > c:
    b, c = c, b
# a > b ならば、入れ替える
if a > b:
    a, b = b, a
    
print(a, b, c)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
const int N=51;
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	ll ans = 0,w,k,u,ap;
	int l;
	cin >> s;
	l=s.size();
	w=pow(2,l-1);

	FOR(i,0,w){
		k = s[0] - '0';
		u=i;
		ap=0;
		FOR(j,0,l-1){
			if(u&1){
				ap+=k;
				k=s[j+1]-'0';
				u=u>>1;
			}else{
				k=k*10;
				k+=s[j+1]-'0';
				u=u>>1;
			}
		}
		ap+=k;
		ans += ap;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define rep_itr(it, M) for (auto it = M.begin(); it != M.end(); ++it)
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N, R;

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

  cin >> N >> R;
  if (N>=10) {
    cout << R << "\n";
    return 0;
  }

  cout << R+100*(10-N) << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sb __builtin_popcount
#define MOD (ll)1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a, b;
    cin >> a >> b;
    if (max(a, b) <= 9 && min(a, b) >= 1)
    {
        cout << a * b << endl;
    }
    else
    {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#pragma warning(disable: 4996)
using namespace std;

int main() {
	int M, N;
	int ans=0,a=0,b=0;

	cin >> M >> N;

	if (M > 1) {
		a += (M * (M - 1)) / 2;
	}
	if (N > 1) {
		b += (N * (N - 1)) / 2;
	}
	cout << a + b << endl;
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    int cnt=0;
    for(int i=0; i<s.size()/2; i++){
        if(s.at(i)!=s.at(s.size()-1-i)){
            cnt++;
        }
    }
    cout << cnt;
    return 0;
}

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

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

int main(){
    int N;
    cin >> N;
    vector<int> a(N+1, 0);
    //iの書かれた箱に入れるボールの個数（0 or 1）
    vector<int> b(N+1, 0);
    for(int i = 1; i < N+1; i++) cin >> a[i];

    for(int i = N; i >= 1; i--){
        //iの倍数の箱に入っているボールの総数
        int sum = 0;
        //自分(i)より大きなiの倍数が存在するならば、それらの箱に入っているボールの総数を見る
        for(int j = i+i; j <= N; j+=i){
            sum ^= b[j];
        }
        //sum = 0, a[i] = 1の場合にb[i] = 1が格納される。
        //sum = 1, a[i] = 0の場合は問題設定的に考えられない
        //sum = 1 && a[i] = 1 または、sum = 0, a[i] = 0の時にb[i] = 0が格納される
        b[i] = sum ^ a[i];
    }
    vector<int> ans;
    //b[i]に1が入っている場合は、その箱の番号(i)を答えを出力するための配列ansに格納
    for(int i = 1; i < N+1; i++){
        if(b[i]) ans.push_back(i);
    }
    //答えを出力
    cout << (int)ans.size() << endl;
    rep(i, (int)ans.size()) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 5392
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String ans = "";
    for (int i = 0; i < s.length(); i += 2) {
      ans += s.charAt(i);
    }
    System.out.println(ans);

  }
}

Measured memory_bytes: 58364
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int,int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
int main() {
	string a, b, c;
	while (cin >> a) {
		if (a == "0")break;
		cin >> b >> c;
		reverse(a.begin(), a.end());
		reverse(b.begin(), b.end());
		reverse(c.begin(), c.end());
		int len = a.length();
		ll cnt[51][2] = {};
		cnt[0][0] = 1;
		rep(i, len) {
			ll cnt1 = 0; ll cnt2 = 0;
			rep(x, 10) {
				rep(y, 10) {
					rep(z, 10) {
						if (a[i] != '?'&&a[i] - '0' != x)continue;
						if (b[i] != '?'&&b[i] - '0' != y)continue;
						if (c[i] != '?'&&c[i] - '0' != z)continue;
						if (i == len - 1 && (x == 0 || y == 0 || z == 0))continue;
						if (x + y == z)cnt1++;
						if (x + y == 10 + z)cnt2++;
					}
				}
			}
			cnt[i + 1][0] += cnt[i][0] * cnt1; cnt[i + 1][0] %= MOD;
			cnt[i + 1][1] += cnt[i][0] * cnt2; cnt[i + 1][1] %= MOD;
			cnt1 = 0; cnt2 = 0;
			rep(x, 10) {
				rep(y, 10) {
					rep(z, 10) {
						if (a[i] != '?'&&a[i] - '0' != x)continue;
						if (b[i] != '?'&&b[i] - '0' != y)continue;
						if (c[i] != '?'&&c[i] - '0' != z)continue;
						if (i == len - 1 && (x == 0 || y == 0 || z == 0))continue;
						if (x + y + 1== z)cnt1++;
						if (x + y + 1== 10 + z)cnt2++;
					}
				}
			}
			cnt[i + 1][0] += cnt[i][1] * cnt1; cnt[i + 1][0] %= MOD;
			cnt[i + 1][1] += cnt[i][1] * cnt2; cnt[i + 1][1] %= MOD;
		}
		cout << cnt[len][0] << endl;
	}
	return 0;
}


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

using namespace std;

#define MOD 998244353

long long mod_div(long long a,long long b){
	if(a % b == 0)return a/b;
	long long tmp = MOD - 2,c = b,ret = 1;
	while(tmp > 0){
		if(tmp & 1){
			ret *= c;ret %= MOD;
		}
		c *= c;c %= MOD;tmp >>= 1;
	}
	return a*ret%MOD;
}
 
#define MAX_K 333333
vector<long long> kaijo(MAX_K);
long long combination(long long n, long long r){
    if(n < r || n < 0 || r < 0)
        return 0;
	if(kaijo[0] != 1){
		kaijo[0] = 1;
		for(long long i = 1;i < MAX_K;i++)kaijo[i] = (kaijo[i-1] * i) % MOD;
	}
    long long ret = kaijo[n];
	long long tmp = (kaijo[r] * kaijo[n-r]) % MOD;
    return mod_div(ret,tmp);
}

int main()
{
  long long n,a,b,k;
  long long x,y,ax,ay;
  long long ans = 0;

  cin >> n >> a >> b >> k;

  for(long long i = 0;i <= n;i++){
    if((k - a * i) % b == 0){
      x = i;
      y = (k - a * i) / b;
      ax = combination(n,x);
      ay = combination(n,y);
      ans += (ax * ay) % MOD;
      ans %= MOD;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using st = string;
#define mrep(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) mrep(i, 0, n)
#define chmax(x, y) { x = max(x, y); }
#define chmin(x, y) { x = min(x, y); }

int main() {
    int n;
    cin >> n;
    ll ans;
    vector<ll> l(n + 1);
    l.at(0) = 2;
    l.at(1) = 1;
    mrep(i, 2, n + 1) l.at(i) = l.at(i - 1) + l.at(i - 2);
    ans = l.at(n);
    cout << ans << endl;
    return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    string s;
    cin >> s;
    if(s[s.length()-1] == 's')
    {
        s += 'e';
        s += 's';
    }
    else
        s += 's';
    cout << s;
}


Measured memory_bytes: 3552
#include<iostream>
using namespace std;
int main()
{
	int a[5];
	for(int i=0;i<5;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<5;i++)
	{
	if(a[i]==0)
	{
		cout<<i+1<<endl;
	}
}
}

Measured memory_bytes: 3624
// problem: "https://atcoder.jp/contests/abc141/tasks/abc141_c"

#include<bits/stdc++.h>

using namespace std;

int main()
{
    int n,k,q;
    cin>>n>>k>>q;

    int i;
    vector<int>V(n+1,0);

    for(i=0;i!=q;i++)
    {
        int x;
        cin>>x;
        V[x]++;
    }

    for(i=1;i!=n+1;i++)
    {
        if(k-(q-V[i]) <= 0)
            cout<<"No\n";
        else
            cout<<"Yes\n";
    }

    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(){
    long long int a,b,c,k;

    scanf("%lld %lld %lld %lld",&a,&b,&c,&k);

    int total = a + b + c;

    long long int z = a*1 + b*0 + c*(-1);

    if(k<a){
        printf("%lld",k);
    }else if(k < a + b){
        printf("%lld",a);

    }else{
        printf("%lld",2*a + b - k);


    }

return 0;
}


Measured memory_bytes: 1696
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

int main() {
    int n;
    cin >> n;
    double a[n];
    double sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    sort(a, a + n);
    printf("%.0f %.0f %.0f\n", a[0], a[n-1], sum);
}

Measured memory_bytes: 1336
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int r = stdIn.nextInt();
		int c = stdIn.nextInt();
		
		int[][] h = new int[r+1][c+1];
		
		for(int i = 0; i < r; i++) {
			int rsum = 0;
			for(int j = 0; j < c; j++) {
				int tmp = stdIn.nextInt();
				rsum += tmp;
				h[i][j] = tmp;
			}
			h[i][c] = rsum;
		}
		
		for(int i = 0; i < c+1; i++) {
			int rsum = 0;
			for(int j = 0; j < r; j++) {
				rsum += h[j][i];
			}
			h[r][i] = rsum;
		}
		
		for(int i = 0; i < r+1; i++) {
			for(int j = 0; j < c; j++) {
				System.out.print(h[i][j] + " ");
			}
			System.out.println(h[i][c]);
		}
	}
}


Measured memory_bytes: 40952
N,M,X,Y = map(int, input().split())

x = list(map(int, input().split()))
y = list(map(int, input().split()))
x.sort()
y.sort()
x_tmp = max(x[-1], X)
y_tmp = min(y[0], Y)
print('No War' if x_tmp < y_tmp else 'War')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) //printf(f,##__VA_ARGS__),fflush(stdout)

typedef long long ll;

const int N=305;

int qk,f[N][N][N],n;
char s[N];

int dp(int l,int r,int k){
	if(l>r)return 0;
	if(l==r)return 1;
	if(f[l][r][k]!=-1)return f[l][r][k];
	int &res=f[l][r][k];
	res=0;
	if(s[l]==s[r])res=max(res,dp(l+1,r-1,k)+2);
	res=max(res,dp(l+1,r,k));
	res=max(res,dp(l,r-1,k));
	if(k)res=max(res,dp(l+1,r-1,k-1)+2);
	Pr("f(%d,%d,%d)=%d\n",l,r,k,f[l][r][k]);
	return res;
}

int main(int argc,char *argv[]){
	scanf("%s",s+1);
	n=strlen(s+1);
	scanf("%d",&qk);
	memset(f,-1,sizeof(f));
	cout<<dp(1,n,qk)<<endl;
	return 0;
}


Measured memory_bytes: 111232
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <climits>
#include <functional>

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

using namespace std;
typedef long long ll;
const int INF = INT_MAX / 4;

const int max_n = 1e3;
const int d = (int)(1e9 + 7);

ll fact(ll n) {
  ll r = 1;
  for(ll i = 2;i <= n;i++) {
    r = (r * i) % d;
  }
  return r;
}


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

  int N, M;
  cin >> N >> M;
  if (abs(N - M) >= 2){
    cout << 0 << "\n";
    return 0;
  }

  ll cnt = (fact(N) * fact(M)) % d;
  if (N == M)
    cnt = (cnt * 2) % d;

  cout << cnt << "\n";
  return 0;
}


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

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  if(n%2==0){
    for(int i=n-1;i>=0;i-=2){
      cout << a[i] << " ";
    }
    for(int i=0;i<n;i+=2){
      cout << a[i] << " ";
    }
  }
  else{
    for(int i=n-1;i>=0;i-=2){
      cout << a[i] << " ";
    }
    for(int i=1;i<n;i+=2){
      cout << a[i] << " ";
    }
  }
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main(){
    string s;
    cin >> s;

    rep(i,s.size()){
        cout << 'x';
    }

    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    ll x; cin >> x;
    ll now = 100;
    for(ll i=1;;i++) {
        now = (ll)now*1.01;
        //cout << now << endl;
        if(x <= now) {
            cout << i;
            return 0;
        }
    }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using ll = long long;
constexpr int MOD = 998244353;
constexpr int DEBUG = 0;
using namespace std;

ll powMod(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
  int n;
  cin >> n;
  int maxD = 0;
  vector<int> num(n, 0);
  for (int i = 0; i < n; i++) {
    int di;
    cin >> di;
    num[di]++;
    if (maxD <= di)
      maxD = di;
    
    if (i != 0 && di == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  if (num[0] != 1) {
    cout << 0 << endl;
    return 0;
  }
  ll total = 1;
  for (int i = 0; i < maxD; i++) {
    total *= powMod(num[i], num[i+1], MOD);
    total %= MOD;
    if (DEBUG == 1) {
      ll k = powMod(num[i], num[i+1], MOD) % MOD;
      cout << total << ":" << num[i] << "^" << num[i+1] << "=" <<  k << endl;
    }
  }
  cout << total << endl;

  return 0;
}


Measured memory_bytes: 768
#include <stdio.h>
int main(void)
{
  int a,b,x;
  scanf("%d%d%d",&a,&b,&x);
  if(x-a<=b && x>=a)
  {
    printf("YES\n");
  }
  else
  {
    printf("NO\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#define INF 10000000000
using namespace std;
typedef long long ll;
int main(){
  string s,t;
  ll n,is,it;
  vector<vector<ll>> dp(3001,vector<ll>(3001,0));
  vector<char> ans;
  cin >> s >> t;
  for(int i=0;i<s.size();i++){
    for(int j=0;j<t.size();j++){
      if(s[i]==t[j]){
        dp[i+1][j+1] = dp[i][j]+1;
      }else{
        dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j]);
      }
    }
  }
  n = dp[s.size()][t.size()];
  is=s.size();
  it=t.size();
  while(n>0){
    if(s[is-1]==t[it-1]){
      ans.push_back(s[is-1]);
      is--;
      it--;
      n--;
    }else if(dp[is][it]==dp[is-1][it]){
      is--;
    }else{
      it--;
    }
  }
  reverse(ans.begin(),ans.end());
  for(int i=0;i<ans.size();i++) cout << ans[i];
  cout << endl;
}


Measured memory_bytes: 70784
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <limits.h>
#include <bitset>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 1000000007;
const int INF = LLONG_MAX/3;
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
signed main(){
    COMinit();
    int h,w,a,b;
    cin>>h>>w>>a>>b;
    int ans=0;
    for(int i=b;i<w;i++){
        ans+=(COM(h-a-1+i,h-a-1)*COM(a-1+w-1-i,a-1))%MOD;
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 12160
h,w,m = map(int, input().split())
hw = [list(map(int, input().split())) for i in range(m)]
bomb = set()
h_list = [0] * (h+1)
w_list = [0] * (w+1)
for H,W in hw:
  h_list[H] += 1
  w_list[W] += 1
  bomb.add((H,W))
max_h = max(h_list)
max_w = max(w_list)
maxh_list = []
maxw_list = []
for k,v in enumerate(h_list):
  if v == max_h:
    maxh_list.append(k)
for k,v in enumerate(w_list):
  if v == max_w:
    maxw_list.append(k)
if len(maxh_list) * len(maxw_list) > m:
  ans = max_h + max_w
else:
  ans = max_h + max_w - 1
  for i in maxh_list:
    for j in maxw_list:
      if (i,j) not in bomb:
        ans = max_h + max_w
        break
print(ans)

Measured memory_bytes: 118996
#include <bits/stdc++.h>
using namespace std;
#define CP complex<long double>

#define X real()
#define Y imag()
const long double PI = acos(-1.0L);
const long double EPS = 1e-10;
// conj(x) : complex conjugate,(0,1)->(0,-1)
// abs(x) : dist between(0,0) and x
// norm(x) : abs(x) * abs(x)
// arg(x) : argment
long double dot(CP a, CP b) { return (a * conj(b)).X; }
long double cross(CP a, CP b) { return (a * conj(b)).Y; }
long double corner(CP a, CP b) {
  //[0,pi]
  return acos(dot(a, b) / (abs(a) * abs(b)));
}

CP intersection(CP a, CP b, CP c, CP d) {
  return a + (b - a) * (cross(d - c, c - a) /
                        cross(d - c, b - a));
}

bool on_seg(CP a, CP b, CP p) {
  // if not use end point, dot(a - p, b - p) < 0
  return abs(cross(a - p, b - p)) <= 1e-10 &&
         dot(a - p, b - p) <= 0;
}

// crossing lines? (a,b) and (c,d)
bool iscross(CP a, CP b, CP c, CP d) {
  // parallel
  if(abs(cross(a - b, c - d)) <= 1e-10) {
    return on_seg(a, b, c) || on_seg(a, b, d) ||
           on_seg(c, d, a) || on_seg(c, d, b);
  }
  CP isp = intersection(a, b, c, d);
  return on_seg(a, b, isp) && on_seg(c, d, isp);
}

long double distLP(CP a, CP b, CP p) {
  return abs(cross(b - a, p - a) / abs(b - a));
}

// segmentver.
long double distSP(CP a, CP b, CP p) {
  if(dot(b - a, p - a) < 0) return abs(p - a);
  if(dot(a - b, p - b) < 0) return abs(p - b);
  return distLP(a, b, p);
}

// segment and segment
long double distSS(CP a, CP b, CP c, CP d) {
  long double res = 1e18;
  res = min(res, distSP(a, b, c));
  res = min(res, distSP(a, b, d));
  res = min(res, distSP(c, d, a));
  res = min(res, distSP(c, d, b));
  return res;
}

long long q;

int main() {
  cin >> q;
  while(q--) {
    int a, b, c, d, e, f, g, h;
    cin >> a >> b >> c >> d >> e >> f >> g >> h;
    CP xs(a, b), xt(c, d), ys(e, f), yt(g, h);
    cout << iscross(xs, xt, ys, yt) << endl;
  }

  return 0;
}


Measured memory_bytes: 3104
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 998244353;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll c(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
ll dp[3001][3001];
int main(void) {
	int n, s;
	cin >> n >> s;
	vector<int> a(n);
	rep(i, 0, n)cin >> a[i];
	dp[0][0] = mpower(2, n);
	ll inv2 = mpower(2, mod - 2);
		for (int i = 0; i < n; ++i) {
	for (int j = 0; j <= s; ++j) {
			dp[i + 1][j] += dp[i][j];
			dp[i + 1][j] %= mod;
			if (j >= a[i])dp[i + 1][j] += dp[i][j - a[i]] * inv2;
			dp[i + 1][j] %= mod;
		}
	}
	printf("%lld\n", dp[n][s]);
	return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



i64 x,y;
void solve(){
	cin >> x >> y;
	
	i64 a = 0;
	while(x <= y){
		x += x;
		a++;
	}
	cout << a << endl;
}

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


Measured memory_bytes: 256
N = int(input())
S = ["0"+input() for _ in range(2)]

mod = 10**9 + 7
dp = [0]*(N+1)

if S[0][1] == S[1][1]:
    dp[1] = 3
    i = 1
else:
    dp[1] = 6
    dp[2] = 6
    i = 2

while i <= N-1:
    if S[0][i] == S[1][i]:#pattern1
        if S[0][i+1] == S[1][i+1]:
            dp[i+1] = (dp[i]*2)%mod
            i += 1
        else:
            dp[i+1] = (dp[i]*2) %mod
            dp[i+2] = dp[i+1]
            i += 2
    else:
        if S[0][i+1] == S[1][i+1]:
            dp[i+1] = dp[i]
            i += 1
        else:
            dp[i+1] = (dp[i]*3)%mod
            dp[i+2] = dp[i+1]
            i += 2

print(dp[N])        


Measured memory_bytes: 3064
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pii pair<long long,long long>
#define ppii pair<long long,pair<long long,long long>>
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define mod 1000000007
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define pyes cout << "Yes" << endl
#define pno cout << "No" << endl
typedef vector<vector<long long>> vii;
typedef long long lint;
typedef long long ll;
lint qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
lint qp(int a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
lint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1e14;
const int MAX_N = 1 << 17;
const int cf = 100010;
///////////////////////////////////////////////////////////////////////////////

int main() {
	lint n; cin >> n;
	vector<pair<ll, ll>> t(n);
	rep(n) cin >> t[i].second >> t[i].first;
	sort(all(t));
	reverse(all(t));
	lint sc = t[0].first;
	for (int i = 0; i < n; i++) {
		sc = min(sc - t[i].second, t[i].first - t[i].second);
		//debug(sc);
	}
	
	(sc < 0) ? pno : pyes;
	return 0;

}

Measured memory_bytes: 3328
N,P=map(int,input().split())
A=list(map(int,input().split()))
f=0
for i in range(N):
  if A[i]%2==1:
    f=1
if f==0:
  if P==0:
    print(2**N)
  else:
    print(0)
else:
  print(2**(N-1))

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

class gfg 
{ 
public : long long int gcd(long long int a, long long int b){ 
	if (a == 0) 
		return b; 
	return gcd(b % a, a); 
} 


long long int lcm(long long int a, long long int b) 
{ 
	return (a*b)/gcd(a, b); 
} 
} ; 

int main() 
{ 
	gfg g; 
	long long int a,b;
	cin>>a>>b;
	cout<<g.lcm(a, b); 
	return 0; 
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int> v;
#define PI acos(-1)
const int maxn = 5e5+400;
typedef long long ll;

int main(){
    double a,b,x;
    cin>>a>>b>>x;
    double ans;
    bool ok=false;
    if(x-a*b/2>0){
        double tmp=(x-a*a*b/2)/(a*a/2);
        if(tmp>=0&&tmp<=b){
            ans=atan2(a,b-tmp);
            ok=true;
        }
    }
    if(!ok){
        double tmp=2*x/(a*b);
        ans=atan2(tmp,b);
    }
    ans=ans*180/PI;
    printf("%.10f",90-ans);
}


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

int main(){
    string s; cin>>s;
    map<char,int>mp;
    rep(i,s.size())mp[s[i]]++;
    int cnt=0;
    for(auto itr:mp){
        if(itr.second%2==0)continue;
        cnt++;
    }
    cout<<(s.size()%2?(cnt-1)/2:(cnt)/2)<<endl;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
int n,a[11],maxx=-1;
ll sum;
int main()
{
	cin>>n;
	for (int i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
		maxx=max(maxx,a[i]);
	}
	cout<<sum-maxx/2;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
            #pragma comment(linker, "/stack:200000000")
            #pragma GCC optimize("unroll-loops")
             
            #include <algorithm>
            #include <bitset>
            #include <cassert>
            #include <chrono>
            #include <cmath>
            #include <complex>
            #include <cstdio>
            #include <cstdlib>
            #include <cstring>
            #include <ctime>
            #include <deque>
            #include <functional>
            #include <iomanip>
            #include <iostream>
            #include <iterator>
            #include <limits>
            #include <climits>
            #include <list>
            #include <map>
            #include <numeric>
            #include <queue>
            #include <random>
            #include <ratio>
            #include <set>
            #include <sstream>
            #include <stack>
            #include <string>
            #include <unordered_map>
            #include <unordered_set>
            #include <utility>
            #include <vector>
            using namespace std;
             
            typedef long long ll;
            typedef long double LD;
            #define int ll
            #define double LD
            #define pb push_back
            #define mp make_pair
            #define REP(i,n) for (int i = 0; i < n; i++)
            #define loop(i,n) for (int i = 0; i < n; i++)
            #define FOR(i,a,b) for (int i = a; i < b; i++)
            #define REPD(i,n) for (int i = n-1; i >= 0; i--)
            #define FORD(i,a,b) for (int i = a; i >= b; i--)
            #define remax(a,b) a = max(a,b)
            #define remin(a,b) a = min(a,b)
            #define mem(a, b) memset(a, b, sizeof a)
            #define append push_back
            #define all(v) v.begin(),v.end()
            #define F first
            #define S second
            #define print(x) cout << (x) << endl
            #define PRECISION(x) cout << fixed << setprecision(x)
            #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
            #define N 505
            #define pb push_back
            const double PI=acos(-1);
            const int MOD = 1000000007;
            const int FMOD = 998244353;
            const double eps = 1e-9;
             
            mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
            
         
           signed main()
           {
           		int n,m;
           		cin>>n>>m;
           		int a[m];
           		loop(i,m)
           		cin>>a[i];
           		
           		int sum=0;
           		loop(i,m)
           		sum+=a[i];
           		
           		if(sum>n)
           		cout<<-1;
           		else
           		cout<<n-sum;
		   }

Measured memory_bytes: 3684
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=998244353;
const llint big=2.19e18+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A,B,C,D,E,F,i,j;cin>>A>>B>>C>>D>>E>>F;
	bool mizu[31]={0};
	bool sato[3001]={0};
	mizu[0]=1;sato[0]=1;
	for(i=0;i*A*100<=F;i++){
		for(j=0;i*A*100+j*B*100<=F;j++){mizu[i*A+j*B]=1;}
	}
	for(i=0;i*C<=F;i++){
		for(j=0;i*C+j*D<=F;j++){sato[i*C+j*D]=1;}
	}
	tuple<double,int,int>ans=mt(-1.2,0,0);
	for(i=1;i*100<=F;i++){
		if(!mizu[i]){continue;}
		for(j=0;i*100+j<=F;j++){
			if(!sato[j]){continue;}
			if(E*i<j){break;}
			maxeq(ans,mt((j+0.0)/(i*100+j),i*100+j,j));
		}
	}
	cout<<get<1>(ans)<<" "<<get<2>(ans)<<endl;
	return 0;
}


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

#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
//#define end endl
//#define endl() end()
#define f first
#define s second
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef pair<int, int> ii;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;

int n, m, x;

#define MAX 16

int a[MAX][MAX];
int c[MAX];
int at[MAX];

int resp = INF;

void bt(int p, int custo)
{
	//m algos
	//n livros
	if (p==n)
	{
		for (int i=0; i<m; i++)
		{
			//cout << "[" << i << "," << at[i] << endl;
			if (at[i] < x)
			{
				return;
			}
		}
		resp = min (resp, custo);
		return;
	}

	int mc[MAX];

	for (int i=0; i<m; i++)
	{
		mc[i] = at[i];
	}

	bt (p+1,custo);

	for (int i=0; i<m; i++)
	{
		at[i] = a[p][i]+at[i];
	}
	bt(p+1,custo+c[p]);
	for (int i=0; i<m; i++)
	{
		at[i] = mc[i];
	}

}

int main(){ _
	char end = '\n';

	cin >> n >> m >> x;

	for (int i=0; i<n; i++)
	{
		cin >> c[i];
		for (int j=0; j<m; j++)
		{
			cin >> a[i][j];
		}
		
	}
	for (int i=0; i<m; i++)
		at[i] = 0;



	bt (0,0);

	if (resp < INF)
	{
		cout << resp << endl;
	}
	else
		cout << -1 << endl;

	exit(0);
}


Measured memory_bytes: 3668
n, m = map(int, input().split())
dmg = []
cost = []

for i in range(m):
    a, b = map(int, input().split())
    dmg.append(a)
    cost.append(b)

inf = 10**9
dp = [inf] * 30000
dp[0] = 0

for i in range(m):
    for j in range(n):
        if dp[j] != inf:
            dp[j + dmg[i]] = min(dp[j + dmg[i]], dp[j] + cost[i])
print(min(dp[n:]))


Measured memory_bytes: 42076
#include <bits/stdc++.h>
using namespace std;
const int maxn = 23;
const int mod = 1e9+7;
typedef long long ll;
int N;
int memo[1 << 21][maxn];
int A[maxn][maxn];
int solve(int mask,int last){
    if (!mask && last == N)return 1;
    if(!mask || last == N)return 0;
    int &ans = memo[mask][last];
    if (ans != -1)return ans;
    ans = 0;
    for (int i = 0;i < N;i++){
        if (mask & (1 << i)&& A[last+1][i])
            ans =(ans+solve(mask^(1 << i),last+1))%mod;
    }
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> N;
    for (int i = 1; i <=N;i++){
        for (int j = 0; j < N;j++){
            cin >> A[i][j];
        }
    }
    memset(memo,-1,sizeof memo);
    cout << solve((1 << N)-1,0);
    return 0;
}


Measured memory_bytes: 188672
fun main(args: Array<String>) = abc157c()

fun abc157c() {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val scList = (1..m).map { readLine()!!.split(' ').map { it.toInt() }.let { Pair(it[0], it[1]) } }

    for (i in 0..999) {
        if (i.toString().length != n) continue
        if (scList.all {
                val (s, c) = it
                Character.getNumericValue(i.toString()[s - 1]) == c
            }) return println(i)
    }

    println(-1)
}


Measured memory_bytes: 37920
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

h,w = inpl()
s = [[0] * w for i in range(h)]
r = [[0] * w for i in range(h)]
l = [[0] * w for i in range(h)]
u = [[0] * w for i in range(h)]
d = [[0] * w for i in range(h)]

for i in range(h):
    s[i] = input()

# cal l
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            l[i][j] = 0
        elif j == 0:
            l[i][j] = 1
        else:
            l[i][j] = l[i][j-1] + 1
# cal r
for i in range(h):
    for j in range(w)[::-1]:
        if s[i][j] == '#':
            r[i][j] = 0
        elif j == w-1:
            r[i][j] = 1
        else:
            r[i][j] = r[i][j+1] + 1
# cal u
for i in range(w):
    for j in range(h):
        if s[j][i] == '#':
            u[j][i] = 0
        elif j == 0:
            u[j][i] = 1
        else:
            u[j][i] = u[j-1][i] + 1
# cal d
for i in range(w):
    for j in range(h)[::-1]:
        if s[j][i] == '#':
            d[j][i] = 0
        elif j == h-1:
            d[j][i] = 1
        else:
            d[j][i] = d[j+1][i] + 1
ans = 0
# print(l,r,u,d)
for i in range(h):
    for j in range(w):
        ans = max(ans, r[i][j] + l[i][j] + u[i][j] + d[i][j])
print(ans-3)


Measured memory_bytes: 204932
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [input() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    s = list(ST())
    t = list(ST())
    s.sort()
    t.sort(reverse=True)
    if s == t:
        print("No")
    else:
        if sorted([s, t])[0] == s:
            print("Yes")
        else:
            print("No")
if __name__ == '__main__':
    main()

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

constexpr int64_t mod = 998244353;

int main() {
  int n, s;
  cin >> n >> s;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  vector<vector<int64_t>> dp(n + 1, vector<int64_t>(s + 1));
  dp.at(0).at(0) = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= s; j++) {
      dp.at(i + 1).at(j) = 2 * dp.at(i).at(j) % mod;
      if (j >= a.at(i)) {
        dp.at(i + 1).at(j) += dp.at(i).at(j - a.at(i));
        dp.at(i + 1).at(j) %= mod;
      }
    }
  }
  cout << dp.at(n).at(s) << endl;
}


Measured memory_bytes: 73752
#include <bits/stdc++.h>
 
using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i< (int) n; i++)
#define PI  3.14159265358979323846264338327950
 
int main () {
    int N ,A;
    cin >> N >> A;

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




}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
using namespace std;
template <typename X, typename T> auto make_vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_vectors(X x, Y y, Z z, Zs... zs) { auto cont = make_vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

template <int32_t MOD>
struct mint {
    int32_t value;
    mint() : value() {}
    mint(int64_t value_) : value(value_ < 0 ? value_ % MOD + MOD : value_ >= MOD ? value_ % MOD : value_) {}
    inline mint<MOD> operator + (mint<MOD> other) const { int32_t c = this->value + other.value; return mint<MOD>(c >= MOD ? c - MOD : c); }
    inline mint<MOD> operator - (mint<MOD> other) const { int32_t c = this->value - other.value; return mint<MOD>(c <    0 ? c + MOD : c); }
    inline mint<MOD> operator * (mint<MOD> other) const { int32_t c = (int64_t)this->value * other.value % MOD; return mint<MOD>(c < 0 ? c + MOD : c); }
    inline mint<MOD> & operator += (mint<MOD> other) { this->value += other.value; if (this->value >= MOD) this->value -= MOD; return *this; }
    inline mint<MOD> & operator -= (mint<MOD> other) { this->value -= other.value; if (this->value <    0) this->value += MOD; return *this; }
    inline mint<MOD> & operator *= (mint<MOD> other) { this->value = (int64_t)this->value * other.value % MOD; if (this->value < 0) this->value += MOD; return *this; }
};
template <int32_t MOD> mint<MOD> operator * (int64_t value, mint<MOD> n) { return mint<MOD>(value) * n; }
template <int32_t MOD> std::ostream & operator << (std::ostream & out, mint<MOD> n) { return out << n.value; }


constexpr int MOD = 1e9 + 7;
mint<MOD> solve(int n, int m, const vector<int> & a, const vector<int> & b) {
    auto dp = make_vectors(n + 1, m + 1, mint<MOD>());
    auto sum = make_vectors(n + 1, m + 1, mint<MOD>());
    dp[0][0] = 1;
    REP (i, n + 1) {
        REP (j, m + 1) {
            if (i - 1 >= 0) sum[i][j] += sum[i - 1][j];
            if (j - 1 >= 0) sum[i][j] += sum[i][j - 1];
            if (i - 1 >= 0 and j - 1 >= 0) sum[i][j] -= sum[i - 1][j - 1];
            if (i - 1 >= 0 and j - 1 >= 0) sum[i][j] += dp[i - 1][j - 1];
            if (i - 1 >= 0 and j - 1 >= 0 and a[i - 1] == b[j - 1]) {
                dp[i][j] = sum[i][j];
            }
        }
    }
    mint<MOD> ans = 0;
    REP (i, n + 1) {
        REP (j, m + 1) {
            ans += dp[i][j];
        }
    }
    return ans;
}

int main() {
    int n, m; cin >> n >> m;
    vector<int> a(n);
    REP (i, n) {
        cin >> a[i];
    }
    vector<int> b(m);
    REP (j, m) {
        cin >> b[j];
    }
    cout << solve(n, m, a, b) << endl;
    return 0;
}


Measured memory_bytes: 31744