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

#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define sortv(v) sort(v.begin(),v.end());
#define sorta(a,n) sort(a,a+n);
#define arrayin(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define arrayout(a,n) for(int i=0;i<n;i++) cout<<" ";cout<<"\n";
#define whatIs(x) cout<<#x<<" is "<<x<<endl;
#define fillA(a,value) memset(a,value,sizeof(a));
#define len(s) s.length()
#define reached cout<<"reached "<<endl;
#define INF INT_MAX //Infinity
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define MOD 1000000007
#define fi first
#define se second
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define vi64 vector<lli>
#define viii vector<tuple<int,int,int>>
#define prq priority_queue<int>
#define mii map<int,int>
#define msi multiset<int>
#define nl "\n"
#define sii set<int,int>
#define sz size

typedef long long int lli;
typedef unsigned long long int ulli;
typedef double ld;

using namespace std;

int main()
{
	fio;
	/*int t;
	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
	}*/
	lli a,b;
	char c;
	cin>>a>>c>>b;
	if(c=='+') cout<<a+b<<endl;
	else cout<<a-b<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int n, m;
bool d(int x) {
    int s = max(x - n, (ll)0);
    int a = n, b = m;
    b -= 2 * s;
    if(x * 2 <= b) return true;
    else return false;
}

signed main() {
    cin >> n >> m;
    int ub = (int)1e13, lb = 0;
    while(ub - lb > 1) {
        int mid = (ub + lb) / 2;
        if(d(mid)) lb = mid;
        else ub = mid;
    }
    cout << lb << endl;
    return 0;
}

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

int lcs(char x[] ,char y[]){

int i,j;
int u=strlen(x);
int v=strlen(y);
int a[u+1][v+1];
for(i=0;i<=u;i++)
a[i][0] = 0;
for(i=0;i<=v;i++)
a[0][i] = 0;
for(i=1;i<=u;i++){
for(j=1;j<=v;j++){
if(x[i-1]==y[j-1])
a[i][j]=a[i-1][j-1]+1;
else if(a[i-1][j]>=a[i][j-1])
a[i][j]=a[i-1][j];
else
a[i][j]=a[i][j-1];}

}
return a[u][v];
}

int main(){
int n,i;
int x[1001],y[1001];
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%s %s",x,y);
printf("%d\n",lcs(x,y));
}
return 0;
}

Measured memory_bytes: 5696
def submit():
    n, m, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    a_sum = [0]
    b_sum = [0]

    for e in a:
        a_sum.append(a_sum[-1] + e)
    for e in b:
        b_sum.append(b_sum[-1] + e)

    
    def calc(x):
        """
        aの上からx読んだ場合に、トータル何冊読めるか？
        """
        if a_sum[x] > k:
            return -1

        rest = k - a_sum[x]
        l = 0
        r = m
        if rest >= b_sum[r]:
            return x + r
    
        while l + 1 < r:
            mid = (l + r) // 2
            if rest >= b_sum[mid]:
                l = mid
            else:
                r = mid
        return x + l

    ans = 0
    for i in range(0, n + 1):
        c = calc(i)
        if ans < c:
            ans = c

    print(ans)

        

submit()

Measured memory_bytes: 127352
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
	long n;
	cin >> n;
	string s;
	long num = 0;
	cout << num << endl;
	cin >> s;
	long start = 0;
	long end = n;
	string s0 = s;
			
	while( s != "Vacant"){
		num = ( (end - start) / 2 ) + start;
		cout << num << endl;
		cin >> s;

		if( (num - start) % 2 == 0 ){
			if( s == s0 )
				start = num;
			else
				end = num;
		}
		else{
			if( s == s0 )
				end = num;
			else
				start = num;

			s0 = s;
		}
			

	}


	ret 0;
}

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

string replace(string str, int a, int b, string p);
string reverse(string str, int a, int b);
void print(string str, int a, int b);

int main() {
    string str, order, p;
    int a, b, q;
    cin >> str;
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> order;
        if (order == "replace") {
            cin >> a >> b >> p;
            str = replace(str, a, b, p);
        }
        else if (order == "reverse") {
            cin >> a >> b;
            str = reverse(str, a, b);
        }
        else if (order == "print") {
            cin >> a >> b;
            print(str, a, b);
        }
    }
    return 0;
}

string replace(string str, int a, int b, string p) {
    string ret = str;
    for (int i = 0; i < b-a+1; i++) {
        ret[a+i] = p[i];
    }
    return ret;
}


string reverse(string str, int a, int b) {
    string ret = str;
    for (int i = 0; i < b-a+1; i++) {
        ret[a+i] = str[b-i];
    }
    return ret;
}

void print(string str, int a, int b) {
    string ret = str.substr(a, b-a+1);
    cout << ret << endl;
}

Measured memory_bytes: 1224
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
typedef pair<int, int> P;

vector<P> down[105000], up[105000];
vector<int> ans[105000], res, topo;
int dp[105000];
bool come[105000];
int longest, n, m, a, b;
void toposort(int x){
    if(come[x])return;
    come[x] = true;
    for(int i = 0;i < up[x].size();i++){
	toposort(up[x][i].first);
    }
    topo.push_back(x);
}

void back(int x){
    if(come[x])return;
    come[x] = true;
    for(int i = 0;i < down[x].size();i++){
	int to = down[x][i].first;
	int tmp = down[x][i].second;
	if(dp[to] != dp[x] - 1)continue;
	ans[dp[x]].push_back(tmp);
	back(to);
    }
}

int main(){
    cin >> n >> m;
    for(int i = 0;i < m;i++){
	cin >> a >> b;
	up[a].push_back(P(b, i + 1));
	down[b].push_back(P(a, i + 1));
    }
    for(int i = 1;i <= n;i++)
	toposort(i);

    for(int i = n - 1;i >= 0;i--){
	int from = topo[i];
	longest = max(longest, dp[from]);
	for(int j = 0;j < up[from].size();j++){
	    int to = up[from][j].first;
	    dp[to] = max(dp[to], dp[from] + 1);	    
	}
    }
    fill(come, come + 105000, false);
    for(int i = 1;i <= n;i++)
	if(dp[i] == longest)back(i);

    for(int i = 1;i <= n;i++){
	if(ans[i].size() == 1){
	    res.push_back(ans[i][0]);
	}
    }

    sort(res.begin(), res.end());
    for(int i = 0;i < res.size();i++)
	cout << res[i] << endl;
    if(res.size() == 0)
	cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 25652
#include <bits/stdc++.h>
#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 rrep(i, n) for (int i=((int)(n)-1); i>=0; i--)
#define rreps(i, n) for (int i=((int)(n)-1); i>0; i--)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using lint = long long;
using p = pair<int, int>;
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; }

int main() {
  int N; cin >> N;
  vector<int> a(N);
  vector<int> b(N);
  vector<int> c(N);
  rep (i, N) {
    cin >> a[i];
    a[i]--;
  }
  rep (i, N) cin >> b[i];
  rep (i, N-1) cin >> c[i];
  int ans = 0;
  ans = accumulate(ALL(b), ans);
  rep (i, N-1) {
    if (a[i] + 1 == a[i+1]) {
      ans += c[a[i]];
          }
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  int p[N];
  for(int i=0;i<N;++i){
    cin >> p[i];
  }
  sort(p,p+N);
  int ans = 0;
  ans += p[N-1]/2;
  for(int i=0;i<N-1;i++){
    ans += p[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
#include <utility>
// #include <numeric>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define LLONG_MAX 9223372036854775807
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())


typedef struct{
  ll pos;
  ll depth;
} data;
//
// struct Node{
//
// }



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

// ll X,Y,Z,K;
// ll pmax = 30000000000;
// vint A,B,C;




// int binary_search(int key){
//  //isOKを満たす要素のうち最小のインデックスを返す。（要ソート）
//   int left = -1;
//   int right = N;
//
//   while(right - left > 1){
//     int mid = left + (right - left)/2;
//
//     if(isOK(mid, key)) right=mid;
//     else left=mid;
//   }
//
//   return right;
// }

// ll gcd(ll m, ll n){
//   if(m<n) swap(m,n);
//   if(n==0) return m;
//   return gcd(n, m%n);
// }



int main() {

  // ll N;
  // cin >> N;
  //



  ll R,G,B,N;
  cin>>R>>G>>B>>N;

  ll ans=0;

  // cout << N/R;

  rep(r, N/R+1){
    rep(g, (N-R*r)/G+1){
      if((N-R*r-G*g)%B==0) ans++;
      // rep(b, (N-R*r-G*g)/B+1){
      //   // cout << R*r+G*g+B*b<< endl;
      //   if(R*r+G*g+B*b==N){
      //     ans++;
      //   }
      // }
    }
  }


  cout << ans << endl;


}

















//


Measured memory_bytes: 256
n = STDIN.gets.chomp.to_i

char_map = ('a'..'z').map{|c| [c, 100] }.to_h

n.times do |i|
  tmp_char_map = ('a'..'z').map{|c| [c, 0] }.to_h

  STDIN.gets.chomp.split('').each do |c|
    tmp_char_map[c] += 1
  end

  ('a'..'z').each do |c|
    char_map[c] = [char_map[c], tmp_char_map[c]].min
  end
end

('a'..'z').each do |c|
  char_map[c].times{ print c }
end

puts ''


Measured memory_bytes: 2044
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

//vector出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){
  o<<"{";
  for(int i=0;i<(int)v.size();i++) o << (i>0?", ":"") << v[i];
  o<<"}"<<endl;
  return o;
}

//逆元　a/b の modをとるとき -> a*modinv(b)%mod
long long modinv(long long a, long long m = 1e9+7) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m; 
  if (u < 0) u += m;
  return u;
}
ll const mod = 1e9+7;

// combination
const int MAX = 510000;
const ll MOD = 1000000007;
 
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;
}

int main() {
  int N;
  ll n;
  cin >> N;
  vector<ll> m(2*1e5+1,0);
  rep2(i,1,2*1e5+1) {
    n = __builtin_popcount(i);
    m[i] = m[i%n] + 1;
    // cout << m[i] << endl;
  }
  string X;
  cin >> X;
  n = 0;
  for (auto i:X) {
    if (i=='1') n++;
  }
  
  vector<ll> ans(N,0),P(N),P1(N);
  ll x=0,x1=0,p=1,p1=1;
  reverse(X.begin(),X.end());
  rep(i,N) {
    if (i>0) {
      p*=2;
      p1*=2;
    }

    p%=n+1;
    if (n-1>0) p1%=n-1;
    
    P[i]=p; P1[i]=p1;
    if (X[i]=='1') {
      x += p; //if (x>n+1) x%=n+1;
      x1 += p1; //if (x1>n-1&&n-1>0) x1%=n-1;
    }
  }
  
  rep(i,N) {
    ll t;
    if (X[i]=='0') {
      t =  (x+P[i]);
      if (t>n+1) t%=n+1;
      ans[i] = m[t]+1;
    }
    else {
      t = x1-P1[i];
      if (n-1==0) ans[i]=0;
      else {
        if (t>n-1) t%=n-1;
        ans[i] = m[t]+1;
      }
    }
  }
  reverse(ans.begin(),ans.end());
  rep(i,N) cout << ans[i] << endl;
}


Measured memory_bytes: 9972
/**
 * @author      : omgursocute
 * @created     : 12/02/2020
 * @task        : A
 */

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

int main() {
	// freopen("A.inp", "r", stdin);
	// freopen("A.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	
	string s, t;
	int a, b;
	string u;
	cin >> s >> t;
	cin >> a >> b;
	cin >> u;
	if(s == u) --a;
	else --b;
	cout << a << ' ' << b;

	return 0;
}



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

using namespace std;

int n ;
bool isprime(int a) {
    for (int i = 2; i <= sqrt(a) ; ++i) {
        if (a % i == 0) return false;

    }
    return true;

}
int main() {
    cin >> n;

    int sol = 0;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >>  a;
        if(isprime(a)) sol++;

    }
    cout << sol << endl;

    return 0;
}



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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<ll,int> P;
typedef pair<ll,P> PP;

//-----------------------------------------------------------------------------

struct BinaryIndexedTree {
	int bit[200010],n;
	BinaryIndexedTree(int N):n(N) {
		REP(i,n+1) bit[i]=0;
	}
	int sum(int i) {
		int s=0;
		while(i>0) s+=bit[i],i-=i&-i;
		return s;
	}
	void add(int i,int x) {
		while(i<=n) bit[i]+=x,i+=i&-i;
	}
};

int n;
ll k,a[200010],sum[200010];
vector<P> vec;
ll ans;

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

	cin>>n>>k;
	REP(i,n) {
		cin>>a[i];
		sum[i+1]=sum[i]+a[i]-k;
		vec.pb(P(sum[i+1],i+2));
	}
	vec.pb(P(0,1));
	sort(ALL(vec));
	BinaryIndexedTree tree(n+1);
	for(auto v:vec) {
		ans+=tree.sum(v.se-1);
		tree.add(v.se,1);
	}
	cout<<ans<<endl;

	return 0;
}


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



int main(){
    ll n;
    cin >> n;
    int phi;
    phi=n;
    ll lim=n;
    for(ll i=2; i*i<=lim; i++){
        if(n%i==0){
            phi=phi*(i-1)/i;
            while(n%i==0) n/=i;
        }
    }
    if(n!=1){
        phi=phi*(n-1)/n;
    }
    cout << phi << endl;
    return 0;
}


Measured memory_bytes: 3128
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <unordered_set>
#include <map>
#include <set>
#include <unordered_map>
#include <climits>
#include <cmath>
#include <stack>
#include <string>
using namespace std ;
#define ll long long int 
#define IOS ios::sync_with_stdio(false)  ; cin.tie(0) ; cout.tie()  
#define MOD  1000000007  

int main()
{ 
   
   ll n , m  , k  ;
   cin>>n>>m>> k ; 
   for(int   i  =  0 ;  i <=  n ; ++i)
   {
      for(int j  = 0 ;   j <= m  ; ++j)
      {
           if( i * m + j * (n - i) - j * i   == k)
           {
             // cout<<i<<" "<<j <<"\n"   ;
             cout<<"Yes\n" ; 
            return   0 ; 
           }
      }
   }
   cout<<"No\n"  ; 
return  0 ;  
}
  

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

using namespace std;

int main()
{
	int sum=0;
	string s;
	while(cin>>s){
		int n=0;
		bool bef=false;
		for(int i=0;i<s.length();i++){
			if(isdigit(s[i]))	n=n*10+s[i]-'0',bef=true;
			else{
				if(bef)	sum+=n,n=0,bef=false;
			}
		}
		if(bef)	sum+=n;
	}
	cout<<sum<<endl;

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define int long long
using vec_int = vector<int>;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int N;cin>>N;
    string S;cin>>S;

    if(N%2==1){
        cout<<"No"<<endl;
        return 0;
    } 

    int flag=1;
    for(int i=0;i<N/2;i++){
        if(S.at(i)!=S.at(i+N/2)){
            flag=0;
            break;
        }
    }
    if(flag==0){
        cout<<"No"<<endl;
        return 0;
    }

        cout<<"Yes"<<endl;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
int n,m,a[2005],b[2005];
long long dp[2005][2005];
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=m;i++)
        cin>>b[i];
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        {   
          dp[i][j]=(dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1])%mod;
          if(a[i]==b[j])
            dp[i][j]+=(dp[i-1][j-1]+1),dp[i][j]%=mod;
        }
    cout<<(dp[n][m]%mod+1+mod)%mod;
    return 0;
}


Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using LL = long long;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<long> VL;

int lcs(string x, string y) {
  // 二次元配列の初期化
  vector<vector<int>> memo(x.size()+1, vector<int>(y.size()+1));
  for (int i=1; i<x.size()+1; i++) {
    for (int j=1; j<y.size()+1; j++){
      if (x[i-1] == y[j-1]) {
        memo.at(i).at(j) = memo.at(i-1).at(j-1) + 1;
      } else {
        if (memo.at(i).at(j-1) > memo.at(i-1).at(j)) {
          memo.at(i).at(j) = memo.at(i).at(j-1);
        } else {
          memo.at(i).at(j)= memo.at(i-1).at(j);
        }
      }
    }
  }
  return memo.at(x.size()).at(y.size());
}

int main() {
  int n; cin >> n;
  rep(i, n) {
    string x, y; cin >> x >> y;
    cout << lcs(x, y) << endl;
  }
}



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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S, T;
    cin >> S >> T;
    int LS = S.length(), LT = T.length(), ans = LT;
    for (int i = 0; i + LT <= LS; ++i) {
        int count = 0;
        for (int j = 0; j < LT; ++j) {
            if (S[i + j] != T[j]) {
                ++count;
            }
        }
        ans = min(count, ans);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>

int main(void) {
  int Hiroshi, Kenjiro;
  int h1, h2;
  int k1, k2;
  int a, b, c, d;

  scanf("%d %d", &h1, &h2);
  scanf("%d %d", &k1, &k2);
  scanf("%d %d %d %d", &a, &b, &c, &d);

  Hiroshi = h1*a + h2*b + (h1/10)*c + (h2/20)*d;
  Kenjiro = k1*a + k2*b + (k1/10)*c + (h2/20)*d;

  if(Hiroshi > Kenjiro) {
    printf("hiroshi\n");
  }else if(Hiroshi < Kenjiro) {
    printf("kenjiro\n");
  }else {
    printf("even\n");
  }

  return 0;
}



Measured memory_bytes: 2120
//高知能系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 INF 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() {
	int ans = INF;
	int tmp;
	int n, m, x;
	cin >> n >> m >> x;
	vector<vector < int> > a(n, vector< int>(m));
	vector<int > c(n);
	REP(i, n){
		cin >> c[i];
		REP(j,m ) cin >> a[i][j];
	}
	vector<int > now(m);
	int nowc;
	REP(i, 1 << n){
		REP(j, m)now[j] = 0;
		nowc = 0;
		REP(j, n){
			if((1 << j) & i) {
				REP(k, m) now[k] += a[j][k];
				nowc += c[j];
			}
		}
		bool ch = true;
		REP(j, m) if(now[j] < x) ch = false;
		if(ch) ans = min(ans, nowc);
	}
	if(ans != INF)cout << ans << endl;
	else cout << -1 << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<int> A(N),B(N);
    rep(i,0,N)cin >> A[i];
    rep(i,0,N)cin >> B[i];
    vector<int> rem(N);
    ll sum = 0,cnt = 0;
    rep(i,0,N){
        rem[i] = A[i] - B[i];
        sum += min(0, A[i] - B[i]);
        cnt += A[i] < B[i] ? 1 : 0;
    }
    if(sum == 0){
        cout << 0 << endl;
        return 0;
    }
    sort(rem.rbegin(), rem.rend());
    //cout << cnt << endl;
    rep(i,0,N){
        sum += rem[i];
        if(sum >= 0){
            cout << i + cnt + 1<< endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int r;
  cin >> r;
  if (r < 1200) { cout << "ABC" << endl; }
  else if (r < 2800) { cout << "ARC" << endl; }
  else { cout << "AGC" << endl; }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <utility>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cstdio>

using namespace std;

#define REP(i,n,m) for( long long int i = (n); i < (m); i++ )
#define ll long long
#define ALL(a) (a).begin(), (a).end()
#define SORT(v) sort( ALL(v) );
#define LAST(v) v[v.size()-1]
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,-1,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pi pair<int, int>
#define MP make_pair
#define PB push_back
#define IIN(a) int a; cin >> a;
#define LIN(a) ll a; cin >> a;
#define SIN(a) string a; cin >> a;
#define EPS (1e-10)
#define INF 1000000000000LL

int MOD=1000000007;
int dx[4] = {0, 0, -1, 1};
int dy[4] = {1, -1, 0, 0};
//I ASCII code: '0' = 48; 'A' = 65; 'a' = 97


signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    LIN(a)
    LIN(b)
    LIN(c)
    ll ans = 0;

    if( a + b + 1 >= c){
      ans = b + c;
    }else{
      ans = a + 2 * b + 1;
    }

    cout << ans << endl;

    return 0;
}


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


int main()
{
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        int ans = 0;
        int num = i;
        for(int x = 1; x*x < num; x++)
        {
            for(int y = 1; x*x + y*y + x*y < num; y++)
            {
                for(int z = 1; x*x + y*y + z*z + x*y + y*z + z*x <= num; z++)
                {
                    if(x*x + y*y + z*z + x*y + y*z + z*x == num)ans++;
                }
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
vector<int> V;
list<int> L;
stack<int> S;
queue<int> Q;
deque<int> dq;
#define INF (1<<30)
#define INFLL (1ll<<60)
#define EPS (1e-10)
static const int MAX=100000;
static const int NMAX=50;
static const int MMAX=50;
ll ans=1ll;
int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    
    int  N,M; cin>>N>>M;
    
    if(abs(N-M)>1){
        cout<<0<<"\n";
        return 0;
    }
    
    for(int i=1;i<=N;i++){
        ans=(ans*i)%((int)pow(10,9)+7);
    }
    for(int i=1;i<=M;i++){
        ans=(ans*i)%((int)pow(10,9)+7);
    }
    
    cout<<(N==M?(2*ans)%((int)pow(10,9)+7):ans)<<"\n";
    
    return 0;
}



Measured memory_bytes: 256
M, K = map(int, input().split())

if K == 0:
    for i in range(pow(2, M + 1)//2):
        print (i, i, end = '')
        if i != pow(2, M + 1)//2 - 1:
            print (' ', end = '')
    exit()

tmp = 0
for i in range(pow(2, M)):
    tmp ^= i

if K >= pow(2, M):
    print (-1)
    exit()

if tmp ^ K != K:
    print (-1)
    exit()
    
#出力部分
print (K, end = ' ')
for i in range(pow(2, M) - 1, -1, -1):
    if i != K:
        print (i, end = ' ')
print (K, end = ' ')
for i in range(pow(2, M)):
    if i != K:
        print (i, end = '')
        if K == pow(2, M) - 1:
            if i != pow(2, M) - 2:
                print (end = ' ')
        else:
            if i != pow(2, M) - 1:
                print (end = ' ')



Measured memory_bytes: 5020
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i) sort((i).begin(),(i).end(), greater<int>());
#define YES(i) cout << ((i) ? "Yes" : "No") << endl;
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

int main() {
    int n;
    cin >> n;
    vector<ll> x(n), y(n);
    FOR(i, n)cin >> x[i] >> y[i];
    set<pair<ll, ll>> s;
    map<pair<ll, ll>, int> m;
    FOR(i, n)FOR(j, n) {
        if (i == j)continue;
        s.insert({x[i] - x[j], y[i] - y[j]});
        m[{x[i] - x[j], y[i] - y[j]}]++;
    }
    auto itr = s.begin();
    int a = 0;
    FOR(i, s.size()) {
        chmax(a, m[*itr]);
        itr++;
    }
    cout << n - a << endl;
}


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

using namespace std;

using ll = long long;

struct Edge {
    const int next;
    const ll cost;

    Edge(int next, int cost)
        :next(next), cost(cost)
    {};
};

ll maxN = 100000;
vector<vector<Edge>> ajacencyList(maxN);
vector<ll> depthVec(maxN, -1);

void dfs(int v, int p, ll cost) {
    depthVec[v] = cost;

    for (auto& elem : ajacencyList[v]) {
        if (elem.next == p) continue;
        dfs(elem.next, v, cost + elem.cost);
    }

    return;
}

int main() {
    ll N;
    cin >> N;

    for (ll n = 0; n < N - 1; n++) {
        ll a, b, c;
        cin >> a >> b >> c;
        ajacencyList[a].push_back(Edge(b, c));
        ajacencyList[b].push_back(Edge(a, c));
    }

    ll Q, K;
    cin >> Q >> K;

    dfs(K, K, 0);

    for (ll q = 0; q < Q; q++) {
        ll x, y;
        cin >> x >> y;
        cout << depthVec[x] + depthVec[y] << endl;
    }

    return 0;
}

Measured memory_bytes: 14336
#include <iostream>
#include <cstring>
#include <cstdio>

#define Maxn 110

using namespace std;

inline int read() {
    int x = 0, f = 1;
    char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while('0' <= c && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}

int n, m, a[Maxn], sum;

int main() {
    n = read(); m = read();
    for(int i = 1; i <= n; ++i) a[i] = read(), sum += a[i];
    int cnt = 0;
    for(int i = 1; i <= n; ++i) {
        int score = a[i] * 4 * m;
        if(score >= sum) ++cnt;
    }
    if(cnt >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#define pai 3.1415926535


int main(void) {

	int N;
	scanf("%d", &N);
	int A[200];
	int a = 0;
	int count = 0;
	for (int i = 0; i <2*N; i++) {
		scanf("%d", &A[i]);
	}
	for (int i = 0; i <2*N; i++) {
		for (int j = 0; j < 2*N - 1 - i; j++) {
			if (A[j] > A[j + 1]) {
				a = A[j];
				A[j] = A[j + 1];
				A[j + 1] = a;
			}
		}
	}
	for (int i = 0; i <2*N; i++) {
		if (i % 2 == 0) {
			count += A[i];
		}
	}
	printf("%d", count);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void)
{
	int n,m,b,max=0,sp=0;
	int a[1000]={0},v[1000]={0};
	
	cin >> n >> m ;
	for(int i = 0;i < n;i++){
		cin >> a[i] ;
	}
	for(int i = 0;i < m;i++){
		cin >> b ;
		for(int j = 0;j < n;j++){
			if(b >= a[j]){
				v[j]++;
				break;
			}
		}
	}
	for(int i = 0;i < n;i++){
		if(max < v[i] && v[i] != 0){
			max = v[i];
			sp = i + 1;
		}
	}
	cout << sp << endl;
	
	return 0;
}

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

const ll INF = 1LL << 60;

vector<vector<int>> to, ot;
vector<bool> from_1, from_n;

void dfs(int v) {
	if (from_1[v]) return;
	from_1[v] = true;
	for (int nv : to[v]) {
		dfs(nv);
	}
}

void rdfs(int v) {
	if (from_n[v]) return;
	from_n[v] = true;
	for (int nv : ot[v]) {
		rdfs(nv);
	}
}

int main() {
  int n, m, p;
	cin >> n >> m >> p;
	vector<tuple<int, int, int>> edge;
	to.assign(n, vector<int>());
	ot.assign(n, vector<int>());
	rep(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		a--, b--;
		edge.emplace_back(a, b, p - c);
		to[a].push_back(b);
		ot[b].push_back(a);
	}
	from_1.assign(n, false);
	from_n.assign(n, false);
	dfs(0), rdfs(n - 1);
	vector<bool> ok(n, false);
	rep(i, n) ok[i] = from_1[i] & from_n[i];
	vector<ll> ans(n, INF);
	ans[0] = 0;
	rep(i, n) rep(j, m) {
		int a, b, c;
		tie(a, b, c) = edge[j];
		if (!ok[a] || !ok[b]) continue;
		if (ans[a] + c < ans[b]) {
			ans[b] = ans[a] + c;
			if (i == n - 1) {
				cout << -1 << endl;
				return 0;
			}
		}
	}
	if (ans[n - 1] < 0) cout << -ans[n - 1] << endl;
	else cout << 0 << endl;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define X real()
#define Y imag()
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using comd = complex<double>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

double CalcDist(comd p1, comd p2){
  return sqrt(pow(p1.X - p2.X,2.0) + pow(p1.Y -p2.Y,2.0));
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(all(v),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

double EPS = 1e-10;
double add(double a, double b){
  if(abs(a+b) < EPS* (abs(a) + abs(b))) return 0;
  return a+b;
}
struct P{
  double x,y;
  P(){}
  P(double _x,double _y):x(_x),y(_y){}
  P operator + (P p){
    return P(add(x,p.x) ,add(y,p.y));
  }
  P operator - (P p){
    return P(add(x,-p.x) ,add(y,-p.y));
  }
  P operator * (double d){
    return P(x * d,y * d);
  }
  double norm(){
    return x*x + y*y;
  }
  double dot(P p){
    return add(x * p.x,y*p.y);
  }
  double det(P p){
    return add(x*p.y,-y*p.x);
  }
  double dist2(P p){
    return ((*this-p).x * (*this-p).x) + ((*this-p).y * (*this-p).y);
  }
  double GetSlope(P &p){
    P tmp = *this - p;
    return tmp.y/tmp.x;
  }
};
//???????????????????????¨?????????
bool on_seg(P p1,P p2,P q){
  return (p1-q).det(p2-q) == 0 && (p1-q).dot(p2-q) <= 0;
}

int check(P p1,P p2,P p3){
  P a = p2-p1,b = p3 - p1;
  if(a.det(b) > EPS) return 1;
  else if(a.det(b) < -EPS) return -1;
  return 0;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  double a,b,c,d,e,f,xp,yp;
  while(cin >> a >> b >> c >> d >> e >> f >> xp >> yp){
    bool flag = true;
//     double acx = c-a,abx = e-a,acy = d-b,aby = f-b,apx = xp-a,apy = yp - b;
    P p1 = P(a,b),p2 = P(c,d),p3 = P(e,f),p4 = P(xp,yp);
    int A = check(p1,p2,p4);
    int B = check(p2,p3,p4);
    int C = check(p3,p1,p4);
    if(A == B && B == C && (B == 1 || B == -1)){
      cout << "YES"<<endl;
    }
    else{
      cout << "NO"<<endl;
    }
  }
  return 0;
}

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol result{0};
    lol n, m; cin >> n >> m;
    lol k; cin >> k;
    vector<lol> a[n+1];
    vector<lol> b[n+1];
    vector<lol> group(n+1, 0);
    REP(i, m)
    {
        lol ai, bi; cin >> ai >> bi;
        a[ai].push_back(bi);
        a[bi].push_back(ai);
    }
    REP(i, k)
    {
        lol ai, bi; cin >> ai >> bi;
        b[ai].push_back(bi);
        b[bi].push_back(ai);
    }
    lol count{0};
    vector<int> groupnum(n+1, 0);
    FOR(i, 1, n)
    {
        if(group[i])
            continue;
        queue<int> que; count++;
        que.push(i);
        group[i] = count;
        groupnum[count]++;
        while(!que.empty())
        {
            lol cur = que.front(); que.pop();
            REP(j, a[cur].size())
            {
                if(group[a[cur][j]] == 0)
                {
                    group[a[cur][j]] = count;
                    groupnum[count]++;
                    que.push(a[cur][j]);
                }
            }
        }
        
    }
    FOR(i, 1, n)
    {
        lol groupofi = group[i];
        lol groupofinum = groupnum[groupofi];
        lol tekitai{0};
        REP(j, b[i].size())
        {
            if(group[b[i][j]] == groupofi)
                tekitai++;
        }
        cout << groupofinum - a[i].size() - tekitai - 1 << " ";
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 16796
import java.util.*;

class Main{
	public static void main(String args[]){
		Solve s = new Solve();
		s.solve();
	}
}

class Solve{
	Scanner in = new Scanner(System.in);

	void solve(){
		while(in.hasNext()){
			int n = in.nextInt();
			if(n == 0) return;
			int[] a = new int[n];
			for(int i = 0; i < n; i++) a[i] = in.nextInt();
			int s = 0;
			boolean f = false;
			for(int i = 1; i < n; i++){
				if(a[i] - a[i - 1] != 1){
					if(f) System.out.print(" ");
					f = true;
					if(s != i -1) System.out.print(a[s] + "-" + a[i - 1]);
					else System.out.print(a[s]);
					s = i;
				}
			}
			if(f) System.out.print(" ");
			if(s != n - 1) System.out.print(a[s] + "-" + a[n - 1]);
			else System.out.print(a[s]);
			System.out.println();
		}
	}
}

Measured memory_bytes: 33360
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> v(n, 0);
  for(int i = 0; i < n; i++){
    cin >> v[i];
  }
  bool f = true;
  int count = 0;
  while(f){
    f = false;
    for(int i = n - 1; i > 0; i--){
      if(v[i] < v[i - 1]){
        swap(v[i], v[i - 1]);
        count++;
        f = true;
      }
    }
  }
  
  for(int i = 0; i < n; i++){
    if(i != n - 1){
      cout << v[i] << " ";
    }
    else{
      cout << v[i] << endl;
    }
  }
  cout << count << endl;
} 


Measured memory_bytes: 3096
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class D
{
	public static void Main()
	{
		Console.WriteLine((new Solver()).Solve());
	}
}


public class Solver
{
	public int N { get; private set; }
	public long A { get; private set; }
	public long B { get; private set; }
	public long[] h { get; private set; }

	public Solver()
	{
		N = GetInt();
		A = GetLong();
		B = GetLong();
		h = new long[N];
		for(int i = 0; i < N; i++)
			h[i] = GetLong();
	}
	
	public long Solve()
	{
		long lb = 0;
		long ub = 1000000000;
		while(lb < ub)
		{
			long mid = (lb + ub) >> 1;
			if(enough(mid))
				ub = mid;
			else
				lb = mid + 1;
		}
		return lb;
	}

	private bool enough(long T)
	{
		long sum = 0;
		for(int i = 0; i < N; i++)
		{
			if(h[i] <= B * T)
				continue;

			sum += (h[i] - B * T + (A - B - 1))/(A - B);
		}
		return (sum <= T);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 15824
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
set<string> st;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		st.insert(s);
	}
	cout<<st.size()<<endl;
}

Measured memory_bytes: 19216
using System;
using System.Collections.Generic;
using System.Linq;
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Long() + add;
        }
        return Array;
    }
}
class Program {
    static Scanner cin = new Scanner();
    static void Main() {
        long N = cin.Long();
        long K = cin.Long();
        
        if(N % 2 == 0) {
            if (K <= N / 2) Console.WriteLine("YES");
            else Console.WriteLine("NO");
        }
        else {
            if (K <= N / 2 + 1) Console.WriteLine("YES");
            else Console.WriteLine("NO");
        }
        Console.ReadLine();
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/


signed main() {
	int n, m;
	cin >> n >> m;
	if (m >= (1 << n)) {
		cout << -1 << endl; return 0;
	}
	if (!m) {
		rep(i, 1 << n) {
			cout << i << " " << i << " ";
		}
		cout << endl; return 0;
	}
	int cnt = 0;
	rep(i, 1 << n) {
		if (i != m)cnt ^= i;
	}
	if (cnt != m)cout << -1 << endl;
	else {
		cout << 0 << " " << m << " " << 0 << " ";
		for (int i = (1 << n) - 1; i > 0; i--) {
			if (i != m)cout << i << " ";
		}
		cout << m << " ";
		REP(i, 1 << n) {
			if (i != m)cout << i << " ";
		}
		cout << endl;
	}
}

Measured memory_bytes: 1792
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		
		out.close();
	}
	
	static class TaskA
	{
		void solve(int TestCase, InputReader in, PrintWriter out)
		{
			String s = in.next();
			String t = in.next();
			int cnt = 0;
			for(int i = 0; i < 3; i++)
			{
				if(s.charAt(i) == t.charAt(i))
					cnt++;
			}
			
			out.println(cnt);
		}
	}
	
	static class InputReader
	{
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		
		public InputReader(InputStream stream)
		{
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}
		
		public String next()
		{
			while(tokenizer == null || !tokenizer.hasMoreTokens())
			{
				try
				{
					tokenizer = new StringTokenizer(reader.readLine());
				}
				catch(IOException e)
				{
					throw new RuntimeException(e);
				}
			}
			
			return tokenizer.nextToken();
		}
		
		public int nextInt()
		{
			return Integer.parseInt(next());
		}
	}
}

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

int main() {
  int n, k, sum;
  cin >> n >> k;
  sum = 0;
  
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    
    if (x <= k-x)
      sum += 2*x;
    else
      sum += 2*(k-x);
  }
  cout << sum << endl;
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;

int main()
{
  int n = 0;
  fscanf(stdin, "%d", &n);
  vector<int> w(n);
  int smallest = INF;
  for (int i = 0; i < n; ++i) {
    fscanf(stdin, "%d", &w[i]);
    smallest = min(smallest, w[i]);
  }
  vector<int> seen(n, 0);
  vector<int> v(w);
  sort(v.begin(), v.end());
  vector<int> pos(10005, -1);
  int ans = 0;
  for (int i = 0; i < n; ++i) { pos[v[i]] = i; }
  for (int i = 0; i < n; ++i) {
    if (seen[i]) { continue; }
    int next_pos = i;
    int cur = w[i];
    int least = w[i], sum = 0, len = 0;
    while (!seen[next_pos]) {
      // fprintf(stderr, "DEBUG: cur=%d\n", cur);
      seen[next_pos] = 1;
      ++len;
      sum += cur;
      least = min(least, cur);
      next_pos = pos[cur];
      cur = w[next_pos];
    }
    int cost = sum - least + (len - 1) * least;
    cost = min(cost, sum + least + (len + 1) * smallest);
    ans += cost;
  }
  fprintf(stdout, "%d\n", ans);
  return 0;
}

Measured memory_bytes: 1260
#include <stdio.h>

int main(void)
{
	int a, b;
	
	scanf("%d %d", &a, &b);
	
	if(a == 1)
		a += 13;
	if(b == 1)
		b += 13;
	
	if(a > b)
		puts("Alice");
	else if(a < b)
		puts("Bob");
	else
		puts("Draw");
	
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repbit(bit,n) for (int bit = 0; bit < (1<<n); bit++)
using namespace std;
typedef long long ll;

//const int INF = 1001001001;
//const ll INF = 1000000000000000000;

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

	string ans = s.substr(0, 3);
	cout << ans << endl;
	return 0;
}

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

int main() {
  string str;
  int joi,ioi;
  while(getline(cin,str)) {
    joi=0;ioi=0;
    for(int i=0;i<str.size()-2;i++) {

      if(str.substr(i,3) == "JOI") {
        joi++;
      }
      else if(str.substr(i,3) == "IOI") {
        ioi++;
      }
    }
    cout << joi << endl << ioi << endl;
  }
}

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

using namespace std;

#define ll long long
#define up(i,j,n)		for(int i=j;i<=n;i++)
#define down(i,j,n)	for(int i=j;i>=n;i--)
#define cmax(a,b)		a=max(a,b)
#define cmin(a,b)		a=min(a,b)

const int MAXN=5e3+5;
const int LIM=5e3;
const int oo=0x3f3f3f3f;

int N,fa[MAXN],f[MAXN],a[MAXN],g[MAXN][MAXN];
bool isleaf[MAXN],vis[MAXN];

namespace solution{
	void Prepare(){
		scanf("%d",&N);
		up(i,2,N)scanf("%d",&fa[i]);
		up(i,1,N)isleaf[i]=1;
		up(i,1,N)isleaf[fa[i]]=0;
		up(i,1,N)scanf("%d",&a[i]);
		up(i,1,N)f[i]=oo;
		up(i,1,N)up(j,0,5000)g[i][j]=oo;
		up(i,1,N)if(isleaf[i])g[i][0]=0;
	}
	void Solve(){
		down(node,N,1){
			up(i,0,a[node]){
				cmin(f[node],g[node][i]);
				if(g[node][i]<=a[node])cmin(f[node],i);
			}
			if(!vis[fa[node]]){
				vis[fa[node]]=1;
				if(f[node]<=a[fa[node]])cmin(g[fa[node]][f[node]],a[node]);
				if(a[node]<=a[fa[node]])cmin(g[fa[node]][a[node]],f[node]);
			}else{
				down(i,a[fa[node]],0){
					int cur=oo;
					if(a[node]<=i)cmin(cur,g[fa[node]][i-a[node]]+f[node]);
					if(f[node]<=i)cmin(cur,g[fa[node]][i-f[node]]+a[node]);
					g[fa[node]][i]=cur;
				}
			}
		}
		puts(f[1]==oo?"IMPOSSIBLE":"POSSIBLE");
	}
}

int main(){
//	freopen("input.in","r",stdin);
	using namespace solution;
	Prepare();
	Solve();
	return 0;
}


Measured memory_bytes: 20736