akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VB=vector<bool>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define print(x) std::cout<<x<<"\n"
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SZ(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
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; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = lcm(a, v[i]);} return a;}
VI Bit2Vector(const ll bit, ll n) {	VI s;	rep(i,n) if (bit & (1 << i)) s.push_back(i); return s;}


void Main()
{
	ll n; ll res=0;
	ll h1,m1,h2,m2,k;
	cin>>h1>>m1>>h2>>m2>>k;

	ll h=h2-h1;
	ll m=m2-m1;

	ll sum=60*(h)+m;
	res=max(sum-k,(ll)0);

	cout << res << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 3656
main = do
    getLine
    as_ <- return . map read . words =<< getLine
    let
	countPart [] result = result
	countPart (i:is) (ev,od)
	  | even i			= countPart is (ev+1,od)
	  | otherwise			= countPart is (ev,od+1)
	(evCount, odCount) = countPart as_ (0,0)
    putStr $ if odd odCount
		then "NO"
		else "YES"

Measured memory_bytes: 36220
#include <stdio.h>

int main(){
	int n,m,l;
	long long int a[100][100], b[100][100], c[100][100];
	int i,t,s;
	scanf("%d %d %d", &n, &m, &l);
	for(i = 0;i < n; i++){
		for(t = 0;t < m; t++){
			scanf("%d", &a[i][t]);
		}
	}
	for(i = 0;i < m; i++){
		for(t = 0;t < l; t++){
			scanf("%d", &b[i][t]);
		}
	}
	for(i = 0;i < n; i++){
		for(t = 0;t < l; t++){
			c[i][t] = 0;
			for(s = 0;s < m; s++){
				c[i][t] += a[i][s] * b[s][t];
			}
		}
	}
	for(i = 0;i < n;i++){
		for(t = 0;t < l;t++){
			printf("%lld", c[i][t]);
			if(t==l-1)puts("");
			else printf(" ");
		}
	}

	return 0;
}

Measured memory_bytes: 852
N = input()
P = map(lambda x:int(x)-1, raw_input().split())

MAX = 10**9
A = [MAX/(N-1)*i for i in xrange(N)]
A[0] += 1
B = A[::-1]

t = 0
for p in P:
    if A[p] + B[p] > t:
        t = A[p] + B[p]
    elif p == N-1:
        B[p] += t+1-A[p]-B[p]
        t += 1
    else:
        A[p] += t+1-A[p]-B[p]
        t += 1
print ' '.join(map(str, A))
print ' '.join(map(str, B))


Measured memory_bytes: 5964
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  long double n,m,d;
  cin >> n >> m >> d;
  long double k=(n-d)*2/n/n;
  if(d==0)k/=2;
  cout << fixed << setprecision(13);
  cout << (m-1)*k << endl;
}  


Measured memory_bytes: 256
#include <stdio.h>
#define det(A) (A.a*A.d-A.b*A.c)

struct matrix{ double a, b, c, d; };
struct vector{ double a, b; };

struct vector multi(struct matrix x, struct vector y){
	struct vector res;
	res.a=x.a*y.a+x.b*y.b,
	res.b=x.c*y.a+x.d*y.b;
	return res;
}

struct matrix inv(struct matrix x){
	struct matrix res;
	res.a=x.d/det(x), res.b=-x.b/det(x),
	res.c=-x.c/det(x), res.d=x.a/det(x);
	return res;
}

int main(int argc, char *argv[]){
     struct vector a, p, x;
     struct matrix A;
     
     while(~scanf("%lf %lf %lf %lf %lf %lf %lf %lf",
		  &a.a,&a.b,&A.a,&A.c,&A.b,&A.d,&p.a,&p.b)){
	  p.a-=a.a, p.b-=a.b, A.a-=a.a, A.b-=a.a, A.c-=a.b, A.d-=a.b;
	  x = multi(inv(A),p);
	  
	  if(x.a<0 || x.b<0 || x.a+x.b>1) puts("NO");
	  else puts("YES");
     }

     return 0;
}

Measured memory_bytes: 0
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T& a, const T& b) {
	if (a < b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T& a, const T& b) {
	if (a > b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

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


/******************************************************************************************/



//ユークリッド互除法
template<typename T>
T gcd(T x, T y) {

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

/*最小公倍数*/
template<typename T>
T lcm(T x, T y) {
	T tmp = gcd(x, y);

	return x / tmp * y;
}

struct Combination {

	vector<ll> fact, rfact;

	Combination(ll sz) : fact(sz + 1), rfact(sz + 1) {

		fact[0] = 1;
		for (ll i = 1; i < fact.size(); i++) {
			fact[i] = fact[i - 1] * i % MOD;
		}
		//逆元
		rfact[sz] = inv(fact[sz]);
		for (ll i = sz - 1; i >= 0; i--) {
			rfact[i] = rfact[i + 1] * (i + 1) % MOD;
		}
	}

	ll inv(ll x) {
		return pow(x, MOD - 2);
	}
	ll pow(ll x, ll n) {
		ll ret = 1;
		while (n > 0) {
			if (n & 1) (ret *= x) %= MOD;
			(x *= x) %= MOD;
			n >>= 1;
		}
		return (ret);
	}
	ll P(ll n, ll r) {
		if (r < 0 || n < r) return (0);
		return (fact[n] * rfact[n - r] % MOD);
	}

	ll C(ll p, ll q) {
		if (q < 0 || p < q) return (0);
		return (fact[p] * rfact[q] % MOD * rfact[p - q] % MOD);
	}

	ll H(ll n, ll r) {
		if (n < 0 || r < 0) return (0);
		return (r == 0 ? 1 : C(n + r - 1, r));
	}
};


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);


	char c;
	cin >> c;
	string alpha = "abcdefghijklmnopqrstuvwxyz";
	
	for (int i = 0; i < alpha.size(); i++)
	{
		if (alpha[i] == c) {
			cout << alpha[i + 1] << endl;
			return 0;
		}
	}
	



	return 0;
}



Measured memory_bytes: 256
//
//  main.cpp
//  ABC160B
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    long long X;
    cin>>X;
    long long fb=X/500;
    long long fs=(X%500)/5;
    long long ans=fb*1000+fs*5;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>

using namespace std;

const long long MOD = 1000000007;

/*ここで宣言しとけば、int以外の関数内でも使える*/
long long factorial[200010];
long long fact_inv[200010];
long long inv[200010];

long long combi(long long n, int p) {
  if (n == 0) {
    return 1;
  }
  if (p > n || p < 0) {
    return 0;
  } else {
    return (((factorial[n] * fact_inv[p]) % MOD) * fact_inv[n-p]) % MOD;
  }
}

int main() {
  int i;
  int H, W, A, B;
  scanf("%d %d %d %d", &H, &W, &A, &B);
  inv[1] = 1;
  for (i = 2; i <= H+W; ++i) {
    inv[i] = MOD - (MOD / i) * inv[MOD % i] % MOD;
  }
  factorial[0] = fact_inv[0] = 1;
  for (i = 1; i <= H+W; ++i) {
    factorial[i] = (factorial[i - 1] * i) % MOD;
    fact_inv[i] = (fact_inv[i - 1] * inv[i]) % MOD;
  }
  long long ans;
  if (H > W) {
    ans = combi(H+W-2, W-1);
    for (i = B-1; i >= 0; i--) {
      ans += (MOD*MOD - combi(H-A+B-1, i)*combi(W-B+A-1, W-1-i));
      ans = ans % MOD;
    }
  } else {
    ans = combi(H+W-2, W-1);
    for (i = A-1; i >= 0; i--) {
      ans += (MOD*MOD - combi(H-A+B-1, H-1-i)*combi(W-B+A-1, i));
      ans = ans % MOD;
    }
  }
  printf("%lld", ans);
  return 0;
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
#include<cmath>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
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; }
#define print(x) cout << (x) << endl;
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};

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


const int mod = 1e9 + 7;


int main(void){
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll n,m;
    cin >> n >> m;
    vector<ll> p(m);
    vector<string> s(m);
    rep(i,m) cin >> p[i] >> s[i];
    map<ll, ll> ma;
    map<ll, ll> wa;
    ll ac = 0;
    ll sumwa = 0;
    rep(i,m){
      if(s[i] == "AC"){
        if(ma[p[i]] == 0) {
          sumwa += wa[p[i]];
          ac++;
        }
        ma[p[i]]++;
      }
      if(s[i] == "WA"){
        if(ma[p[i]] == 0) wa[p[i]]++;
      }
    }
    cout << ac << " " << sumwa << endl;
}

Measured memory_bytes: 19072
def resolve():
    N = int(input())
    L = [[] for i in range(N)]

    for i in range(N):
        A = int(input())
        for j in range(A):
            x, y = map(int,input().split())
            L[i].append((x, y))

    ans = 0
    for p in range(2**N):
        ok = True
        for i in range(N):
            for x, y in L[i]:
                if p & (1 << i):
                    if p & (1 << (x-1)) > 0 and y == 0:
                        ok = False
                        break
                    elif p & (1 << (x-1)) == 0 and y == 1:
                        ok = False
                        break

            if not ok:
                break

        if ok:
            ans = max(ans, bin(p).count('1'))

    print(ans)

if __name__ == '__main__':
    resolve()


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

const int inf = 1e9;
int SIZE = inf;

vector<int> ans;

bool edge[1010][1010];

signed main(void){ 
  int N,M; cin >> N >> M;
  vector<vector<int>> to(N);
  for(int i = 0; i < M; i++){ 
    int a,b; cin >> a >> b; a--; b--;
    to[a].push_back(b);
    edge[a][b] = true;
  }
  
  for(int i = 0; i < N; i++){ 
    //始点全探索
    vector<int> dist(N,inf);
    vector<int> par(N,-1);
    dist[i] = 0;
            
    queue<int> Q; Q.push(i);
    while(!Q.empty()){ 
      int p = Q.front(); Q.pop();
      for(auto q : to[p] ){ 
        if( dist[q] != inf ){ continue;}
        else{ 
          dist[q] = dist[p]+1;
          par[q] = p;
          Q.push(q);
        }
      }//for-auto
    }//while
    
    for(int j = 0; j < N; j++){ //終点探索
      if( j == i || dist[j] == inf ){ continue;} 
      
      if( edge[j][i] ){ //ループたりうる
        
        vector<int> vec;
        int pos = j;
        
        while( pos != i ){ 
          vec.push_back(pos);
          pos = par[pos];
        }
        vec.push_back(i);
        int m = vec.size();
        if( m < SIZE ){ ans = vec; SIZE = m;}
        
        
        //ans更新
      }
    }///for-j
    
    
  }//for-i
  
  if( SIZE == inf ){ cout << -1 << endl; return 0;}
  
  cout << SIZE << endl;
  
  for(auto ne : ans ){ cout << ne+1 << endl;}
  
  return 0;
}

Measured memory_bytes: 1280
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//																				NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 100000007
#define testcases() ll t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
 
//----------------------------------------------------------------------------------------------------------------------------------------------------

ll exp(ll n, ll k, ll m){
	if(k==1)
		return n%m;
	ll ans = exp(n,k/2,m);
	ans = (ans*ans)%m;
	if(k%2){
		ans = (ans * n)%m;
	}
	return ans;
}

ll func(ll n, ll r, ll m){
	ll maxx = max(r, n-r);
	ll ans = 1;
	for(ll i=maxx+1;i<=n;i++){
		ans = (ans*i)%m;
		ans = (ans*exp(i-maxx,m-2,m))%m;
	}
	return ans;
}

int main(){
	ll n,a,b;
	cin>>n>>a>>b;
    ll m = 1000000007;
	ll ans = ((func(n,a,m)+func(n,b,m)+1))%m;
	ans = (exp(2,n,m) - ans + m) % m;
	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod 1000000007
#define MOD 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 2e9
#define common cout << "Case #" << w+1 << ": "  


int main()
{
    int n;
    cin >> n;
    if(n%2==0 or n%5==0)
        cout << "-1" << endl;
    else
    {
        int ans,rem=0;
        for(int i=1;i<=1e8;i++)
        {
            rem=(rem*10+7)%n;
            if(rem%n==0)
            {
                ans=i;
                break;
            }
        }   
        cout << ans << endl;
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
const ll mod = 1e9 + 7;
const int M = 2e6 + 5;
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll expo(ll base,ll pow){ll ans = 1LL;
   if(pow < 0) return 0;
   base %= mod;
   while(pow!=0){if(pow&1LL==1LL){ans = ans*base;ans = ans%mod;}
   base *= base;base%=mod;pow/=2LL;}return ans;}
ll inv(ll x){return expo(x,mod-2);}
ll mult_mod(ll a , ll b){a = a%mod; b = b%mod;ll c = (a * b)%mod;return c;}
ll add_mod(ll a , ll b){a = (a + mod)%mod;b = (b + mod)%mod;ll c = (a + b)%mod;return c;}
ll fac[(int)(2e6 + 7)] , inv_fac[(int)(2e6 + 7)];
void precomp_factorial(){fac[0] = 1;for(ll i = 1 ; i <= M ; i++) fac[i] = mult_mod(i , fac[i - 1]);
    inv_fac[M] = inv(fac[M]);for(ll i = M - 1 ; i >= 0 ; i--) inv_fac[i] = mult_mod(i + 1 , inv_fac[i + 1]);}
ll nCk(ll n , ll k){ll ans = fac[n];ans = mult_mod(ans , inv_fac[n - k]);ans = mult_mod(ans , inv_fac[k]);return ans;}
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};    // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};

int main() {
    ll n;
    cin >> n;
    ll ans = n-1LL;
    for(ll i = 2LL; i*i <= n; i++){
        if(n%i == 0){
           ll val = n/i;
           ans = min(ans, val-1LL+i-1LL);
        }
    }
    cout << ans;
}


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

#define MAX 1000000000000000000

int main(void) {
	int n, i;
	long *a;
	long m=1;
	scanf("%d", &n);
	a = malloc(n * sizeof(long));
	for (i = 0; i < n; i++) {
		scanf("%ld", a+i);
		if (a[i] == 0) {
			printf("0\n");
			return 0;
		}
	}
	for (i = 0; i < n; i++) {
		if (MAX / a[i] < m) {
			printf("-1\n");
			return 0;
		}
		m *= a[i];
	}
	printf("%ld\n", m);
	return 0;
}


Measured memory_bytes: 2932
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vector<int> > vvi;
typedef vector<vector<double> > vvd;

int main(){

    int h, w;
    cin >> h >> w;

    vector<vector<char>> m(h, vector<char>(w, '.'));

    char tmp;
    int count_white = 0;
    for(int i=0; i<h; ++i){
        for(int j=0; j<w; ++j){
            cin >> tmp;
            if( tmp == '#' ) m[i][j] = '#';
            else count_white++;
        }
    }

    deque<vi> pos;
    pos.push_back( vi(3, 0) );
    vector<pii> d = { pii(1,0), pii(-1,0), pii(0,1), pii(0,-1) };
    bool isReach = false;
    vi res(3, -1);
    m[0][0] = '#';

    while( !pos.empty() ){

        vi p = pos.front();
        pos.pop_front();

        if( p[0] == h-1 and p[1] == w-1 ) { isReach = true; res=p; break; }

        p[2]++;

        for( auto _d : d ) {

            int x = p[0] + _d.first;
            int y = p[1] + _d.second;

            if( 0 <= x and x < h and 0 <= y and y < w and m[x][y] == '.' ){
                pos.push_back( vi{x,y,p[2]} );
                m[x][y] = '#';
            }

        }

    }

    if( isReach ) cout << count_white - res[2] - 1 << endl;
    else cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end());

    cout << A[N/2] - A[N/2 - 1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <tuple>
#include <math.h>
#include <deque>
#include <stack>
#include <queue>

using namespace std;

typedef long long ll;


int solve() {
  ll n;
  string s;
  cin >> n >> s;
  string t1, t2;
  t1 = "";
  t2 = "";
  for (ll i = 0;i < n / 2; i++){
    t1 += s[i];
  }
  for (ll i = n / 2; i < n; i++){
    t2 += s[i];
  }
  if (t1 == t2){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const long long MOD=1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    int N;cin>>N;
    vector<int> a;
    a.push_back(0);
    for(int i=0;i<N;i++){
      int aa; cin>>aa; a.push_back(aa);
    }
    a.push_back(0);
    int s = 0;
    for(int i=0;i<N+1;i++){
      s = s + abs(a[i+1]-a[i]);
    }
    for(int i=1;i<N+1;i++){
      int d=0;
      if(a[i-1]<=a[i] && a[i]<=a[i+1]) d=0;
      else if(a[i-1]<=a[i] && a[i+1]<=a[i]) d=abs(a[i]-a[i-1])+abs(a[i+1]-a[i])-abs(a[i+1]-a[i-1]);
      else if(a[i]<=a[i-1] && a[i]<=a[i+1]) d=abs(a[i]-a[i-1])+abs(a[i+1]-a[i])-abs(a[i+1]-a[i-1]);
      cout<<s-d<<endl;
    }
    return 0;
}


Measured memory_bytes: 1784
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> s(n);
    int sum=0;
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        sum+= x;
        s[i]=x;
    }
    sort(s.begin(),s.end());
    if(sum%10 != 0){
        cout << sum << endl;
    }else{
        int i=0;
        bool reg=0;
        int regi;
        while(1){
            if(s[i]%10 != 0){
              //  cout<<s[i]<<" "<<"入っていけない"<<endl;
                regi=s[i];
                reg=1;
                break;
            }
            i++;
            if(i==n){
                break;
            }
        }
        if(reg==0){
            cout << 0 <<endl;
        }else{
         //   cout<<"駄目だ！"<<endl;
            cout << sum-regi<<endl;
        }
        
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long
lli a[100005];

int main() 
{
    lli n,k;
    cin>>n>>k;
    
    
    lli mn=INT_MAX,ind;
    
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]<mn){
            mn=a[i];
            ind=i;
        }
    }
    
    lli ans=(n-1)/(k-1);
    
    if((n-1)%(k-1)!=0) ans++;
    
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  string s; cin >> s;
  if(s.at(2)==s.at(3)){
    if(s.at(4)==s.at(5)) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else cout << "No" << endl;
}
  


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
 
int main()
{
    int n, m;
    cin >> n >> m;
    for (int i = n; i <= m / 2; i++)
    {
        if (m % i == 0) {cout << m / i << endl; return 0;}
    }
    cout << 1 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(void){
  int an=0;
  int sum=0;
  for(int i=0;i<3;i++){
    scanf("%d",&an);
    sum+=an;
  }
  if(sum>=22)
    printf("bust");
  else
    printf("win");
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
int main() {
	int n;
	float x1, y1, x2, y2, x3, y3;
	float a1, b1, c1, a2, b2, c2;
	float x, y,r;
	scanf("%d",&n);
	while (n>0) {
		scanf("%f %f %f %f %f %f",&x1,&y1,&x2,&y2,&x3,&y3);
		a1 = 2 * (x2 - x1);
		b1 = 2 * (y1 - y2);
		c1 = x2*x2 - x1*x1 + y2*y2 - y1*y1;
		a2 = 2 * (x3 - x1);
		b2 = 2 * (y1 - y3);
		c2 = x3*x3 - x1*x1 + y3*y3 - y1*y1;
		x = (b2*c1 - b1*c2) / (a1*b2 - a2*b1);
		y = (a2*c1 - a1*c2) / (a1*b2 - a2*b1);
		r = sqrt((x-x1)*(x - x1)+(y-y1)*(y - y1));
		printf("%.3f %.3f %.3f\n", x, y,r);
		n--;
	}
}

Measured memory_bytes: 1712
module A = Array
module C = Char
module I = Int64
module L = List
module Q = Queue

let pf = Printf.printf
let sf = Scanf.scanf
let ssf = Scanf.sscanf

let read_int () = sf "%d " (fun x -> x)
let read_float () = sf "%f " (fun x -> x)
let read_array read n = A.init n (fun _ -> read ())
let err s = raise (Failure s)

let inf = int_of_float 1e18
let eps = 1e-11

module S = struct
  include String
  let of_array a = String.init (A.length a) (A.get a)
  let to_array s = A.init (String.length s) (String.get s)
end;;

let _ =
  let n = read_int () in
  let len = read_int () in
  let a = read_array read_int n in
  let (max_len, pos) = A.init (n - 1) (fun x -> x) |>
                         A.map (fun i -> (a.(i) + a.(i + 1), i)) |>
                         A.fold_left max (0, 0) in
  if max_len >= len
  then A.append (A.init pos (fun x -> x+1)) (A.init (n-pos-1) (fun x -> n-x-1)) |>
         ( print_endline "Possible";
           A.iter (fun x -> string_of_int x |> print_endline) )
  else print_endline "Impossible"


Measured memory_bytes: 9984
//A - Poor

#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    string s,t;
    int a, b;

    cin >> s >> t;
    cin >> a >> b;

    string u;

    cin >> u;

    if (u == s) {
        a--;
    }else if (u == t){
        b--;
    }

    cout << a << " " << b << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
using namespace std;
using ll = long long;

vector<vector<ll>> dp(105, vector<ll>(100005, 0));
//dp[i][j] := i番目までの品物を見た時に作れる、総重量がj以下の最大の価値


int main(void) {
  int n, W;
  cin >> n >> W;
  ll w[n + 1], v[n + 1];
  rep (i, n) cin >> w[i + 1] >> v[i + 1];

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= W; j++) {
      if (j - w[i] >= 0) {
        dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
      }
      else {
        dp[i][j] = dp[i - 1][j];
      }
    }
  }

  cout << dp[n][W] << endl;
  return 0;
}

Measured memory_bytes: 83328
i=[]
while True:
    try:
        i += input().lower()

    except Exception:
        break

letters = "a b c d e f g h i j k l m n o p q r s t u v w x y z"
list1 = letters.split()

for j in range(len(list1)):

    print("{0} : {1}".format(list1[j], i.count(list1[j])))



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

public class Main
{
	PrintWriter out = new PrintWriter(System.out);
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok = new StringTokenizer("");
    String next() throws IOException {
        if (!tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine()); }
        return tok.nextToken();
    }
    int ni() throws IOException { return Integer.parseInt(next()); }
    long nl() throws IOException { return Long.parseLong(next()); }
    
    void solve() throws IOException {
        for (int tc=1;tc>0;tc--) {
            String s=next();
            int ans=0;
            for (int i=0;i<s.length();i++) ans+=(int)(s.charAt(i)-'0');
            if (ans%9==0) out.println("Yes");
            else out.println("No");
        }
        out.flush();
    }
    
    public static void main(String[] args) throws IOException {
        new Main().solve();
    }
}

Measured memory_bytes: 36356
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D, w) for(auto vec : vec2D) { for (auto v : vec) cerr << setw(w) << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

const char en = '\n';

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

typedef vector<vector<int>> Graph;
void add_edge(Graph& g, int from, int to, bool isDirected) {
	g[from].push_back(to);
	if (!isDirected) g[to].push_back(from);
}

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


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

	ll n, x, t;
	cin >> n >> x >> t;
	
	
	cout << ((n-1)/x)*(t) + t << endl;
}



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

#define ll long long
#define all(x) (x).begin(), (x).end()

// ----- Tools ----- //
template <typename Key, typename Value, typename Arg>
bool containsKey(const unordered_map<Key, Value>& m, const Arg& value) {return m.find(value) != m.end();}
template <typename Key, typename Value, typename Arg>
bool containsKey_tm(const map<Key, Value>& m, const Arg& value) {return m.find(value) != m.end();}
bool startsWith(string str, string tar) {return (str.rfind(tar, 0) == 0);}
bool contains(string str, string tar) {return (str.find(tar) != std::string::npos);}
vector<string> split(string str, char ch) {vector<string> res; stringstream ss(str); string s; while (getline(ss, s, ch)) res.push_back(s); return res; }
char toLower(char& ch) {if ('A' <= ch && ch <= 'Z') return ch - 'A' + 'a'; else return ch;}
char toUpper(char& ch) {if ('a' <= ch && ch <= 'z') return ch - 'a' + 'A'; else return ch;}

// -------- Main Code -------- //

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

const int maxN = 3005;
ll mem[maxN][maxN][5];
vector<vector<ll>> arr;

ll row, col, K;
ll inf = INT_MAX;

ll dfs(int r, int c, int cnt) {
    if (r >= row || c >= col) return (ll)0;
    if (mem[r][c][cnt] != -1) return mem[r][c][cnt];

    ll res = 0;

    if (r+1 < row) {
        if (arr[r+1][c] > 0) {
            res = max(res, dfs(r+1, c, 1) + arr[r+1][c]);
            res = max(res, dfs(r+1, c, 0));
        } else {
            res = max(res, dfs(r+1, c, 0));
        }
        
    }
    
    if (c+1 < col) {
        if (arr[r][c+1] > 0) {
            res = max(res, dfs(r, c+1, cnt));
            if (cnt + 1 <= 3) 
                res = max(res, dfs(r, c+1, cnt+1) + arr[r][c+1]);
        } else {
            res = max(res, dfs(r, c+1, cnt));
        }
    }

    return mem[r][c][cnt] = res;
}

void runcase() {
    cin >> row >> col >> K;
    arr.resize(row, vector<ll>(col, 0));
    for (int i=0; i<maxN; i++) 
        for (int j=0; j<maxN; j++) 
            for (int k=0; k<5; k++) mem[i][j][k] = -1;

    for (int i=0; i<K; i++) {
        ll r, c, v;
        cin >> r >> c >> v;
        r--; c--;
        arr[r][c] = v;
    }

    ll res, a, b;
    if (arr[0][0] > 0) {
        a = dfs(0, 0, 1) + arr[0][0];
        b = dfs(0, 0, 0);
        res = max(a, b);
    } else {
        res = dfs(0, 0, 0);
    }

    cout << res << '\n';
}

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

    // int t;
    // cin >> t;
    // while (t-- > 0)
        runcase();

    return 0;
}


Measured memory_bytes: 426900
import sys,queue,math,copy,itertools,bisect,collections,heapq
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())

N,K = LI()
a = [0]+LI()
if K == 0:
    print(1)
    exit(0)
dp = [[1] * (K+1) for _ in range(N+1)]
ac = 0
for i in range(1,N+1):
    ac += a[i]
    s = 0
    for j in range(K+1):
        s += dp[i-1][j]
        if j-a[i]-1 >= 0: s -= dp[i-1][j-a[i]-1]
        dp[i][j] = s % MOD
print((dp[-1][K]-dp[-1][K-1])%MOD)


Measured memory_bytes: 119784
#include <iostream>

using namespace std;

int main() {
    int n, m, d = 0, a;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> a;
        d += a;
    }
    cout << (((n - d) < 0) ? -1 : (n - d)) << endl;
    return 0;
}

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

int main() {
  int A,B,C;
  cin>>A>>B>>C;
  if(A>=B&&A>=C){
    cout<<B+C<< endl;
    return 0;
  }
  if(B>=A&&B>=C){
    cout<<A+C<< endl;
    return 0;
  }
  if(C>=A&&C>=B){
    cout<<A+B<< endl;
  }
}

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

using namespace std;

string s;

map<char, int> mp;

int main() {
    cin >> s;
    for (auto it : s) {
        mp[it]++;
    }
    for (char it = 'a'; it <= 'z'; ++it) {
        if (!mp[it]) {
            cout << it;
            return 0;
        }
    }
    cout << "None";
}


Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SI(): return input().split()

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product
from heapq import heapify, heappush, heappop


def solve():
    n, m = MI()

    jobs = [[] for _ in range(m)]
    for i in range(n):
        a, b = MI()
        if m-a >= 0:
            jobs[m-a].append(b)

    # print(jobs)
    hp = []
    heapify(hp)
    ans = 0
    for i in range(m-1, -1, -1):
        js = jobs[i]
        for j in js:
            heappush(hp, -j)

        if len(hp) > 0:
            ans += -heappop(hp)
    print(ans)





if __name__ == '__main__':
    solve()


Measured memory_bytes: 18744
S = input()
lst = []
for s in S:
    if s in 'ACGT':
        lst.append(True)
    else:
        lst.append(False)

max_true = -1
k = 0
for b in lst:
    if b:
        k+=1
    else:
        if k > max_true:
            max_true = k
        k = 0
print(max(max_true, k))

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

using namespace std;

int main() {
  int A, B;
  cin >> A >> B;

  string ok = "Yay!";
  string no = ":(";

  if(A <= 8 && B <= 8) {
    cout << ok << endl;
  }else{
  	cout << no << endl;
  }
  return 0;
}





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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

    vector<int> A(N),B(N),C(N);
    rep(i,0,N) cin >> A[i];
    rep(i,0,N) cin >> B[i];
    rep(i,0,N) cin >> C[i];

    sort(begin(A),end(A));
    sort(begin(B),end(B));
    sort(begin(C),end(C));

    int ai=0,bi=0;
    i64 ans=0,bsum=0;
    rep(ci,0,N){
        while(bi<N and C[ci]>B[bi]){
            while(ai<N and B[bi]>A[ai]) ++ai;
            ++bi;
            bsum+=ai;
        }
        ans+=bsum;
    }

    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

vector<vector<int>> roads;
vector<int> distances;

void snuke_move(int now, int back, int distance_all){
    distances[now] = distance_all;
    for(int i = 0; i < roads[now].size(); i++){
        if(roads[now][i] != back){
            snuke_move(roads[now][i], now, distance_all + 1);
        }
    }
}

int fennec_move(int now, int back){
    int ans = 1;
    for(int i = 0; i < roads[now].size(); i++){
        if(roads[now][i] != back && distances[roads[now][i]] * 2 >= distances[0]){
            ans += fennec_move(roads[now][i], now);
        }
    }
    return ans;
}

int main(){
    int N;
    cin >> N;
    roads.resize(N);
    for(int i = 0; i < N - 1; i++){
        int start, goal;
        cin >> start >> goal;
        roads[start - 1].push_back(goal - 1);
        roads[goal - 1].push_back(start - 1);
    }
    distances.resize(N);
    snuke_move(N - 1, -1, 0);
    if(fennec_move(0, -1) * 2 > N){
        cout << "Fennec" << endl;
    }else{
        cout << "Snuke" << endl;
    }
}


Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    string S,T;
    cin >> S >> T;
    cout << T << S << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
using ll = long long;
using pr = pair<ll, ll>;

int N;
map<pr, int> m;
pr A[200005];
ll ans, cnt, p[200005];

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

int main() {
	scanf("%d", &N);
	p[0] = 1LL;
	for(int i=1; i<=200000; i++) p[i] = p[i-1] * 2 % MOD;
	for(int i=1; i<=N; i++) {
		ll x, y;
		scanf("%lld %lld", &x, &y);
		if(x == 0 && y == 0) {
			N--, i--, cnt++;
			continue;
		}
		if(x < 0 || (x == 0 && y < 0)) x = -x, y = -y;
		ll g = gcd(x, abs(y));
		x /= g, y /= g;
		m[pr(x, y)]++;
		A[i] = pr(x, y);
	}
	ans = 1LL;
	for(auto it : m) {
		ll x = it.first.first, y = it.first.second;
		int c1 = it.second;
		int c2 = (m.find(pr(y, -x)) != m.end() ? m[pr(y, -x)] : 0);
		if(y <= 0 && m.find(pr(-y, x)) != m.end()) continue;
		ans = ans * (p[c1] + p[c2] - 1LL) % MOD;
	}
	printf("%lld\n", (ans + cnt + MOD - 1LL) % MOD);
}

Measured memory_bytes: 20868
// This amazing code is by Eric Sunli Chen.
#include<bits/stdc++.h>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

int n,k,dp[311][311][311];
char s[311];

int dfs(int l,int r,int k)
{
	if(dp[l][r][k]!=-1)return dp[l][r][k];
	if(l>r)return 0;if(l==r)return 1;
	int&ret=dp[l][r][k];
	ret=max(dfs(l,r-1,k),dfs(l+1,r,k));
	if(k||s[l]==s[r])ret=max(ret,dfs(l+1,r-1,k-(s[l]!=s[r]))+2);
	return ret;
}

int main()
{
	scanf("%s",s+1);get1(k);n=strlen(s+1);
	
	memset(dp,-1,sizeof(dp));
	printf("%d\n",dfs(1,n,k));
	return 0;
}

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

int main(){
  int d,w,h;int n;
  while(true){
    cin>>d>>w>>h;
    if(d==0&&w==0&&h==0)break;
    if(d>w)swap(w,d);
    if(w>h)swap(h,w);
    cin>>n;
    int r;
    for(int i=0;i<n;i++){
      cin>>r;
      if(sqrt(d*d+w*w)<r*2)cout<<"OK"<<endl;
      else cout<<"NA"<<endl;
    }
  }
}

Measured memory_bytes: 3012
void main() {
	auto ip = readAs!(int[]), N = ip[0], x = ip[1];
	auto a = readAs!(int[]);
	
	ulong cnt;
	foreach(i; 0..N-1) {
		if(a[i] > x) {
			cnt += a[i] - x;
			a[i] = x;
		}
		if(a[i] + a[i+1] > x) {
			cnt += (a[i] + a[i+1]) - x;
			a[i+1] = x - a[i];
		}
	}
	cnt.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 4220
N = int(input())
W = []
w_dic = dict()
for i in range(N):
    a = input()
    W.append(a)

check = True
for i in range(N-1):
    s = W[i]
    s_1 = W[i+1]
    if s[-1] == s_1[0]:
        continue
    else:
        check = False
        break
for i in range(N):
    if W[i] in w_dic:
        check = False
        break
    else:
        w_dic[W[i]] = 1
if check:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




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

	int a[4];
	rep(i, 4)cin >> a[i];
	sort(a, a + 4);

	cout << (a[0] == 1 && a[1] == 4 && a[2] == 7 & a[3] == 9 ? "YES" : "NO") << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define Pr(a) (#a)<<"="<<(a)<<" "
#define pr1(a) cerr<<Pr(a)<<endl;
#define pr2(a,b) cerr<<Pr(a)<<Pr(b)<<endl;
#define pr3(a,b,c) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<endl;
#define pr4(a,b,c,d) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<endl;
#define pr5(a,b,c,d,e) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<endl;
#define pr6(a,b,c,d,e,f) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<Pr(f)<<endl;
#define int long long
#define double long double
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

vector<int> DP(vector<int> V, vector<int> W, vector<int> K){
  int n = V.size();
  int N = 51*51*51;
  vector<int> dp(N+1, INF);
  dp[0] = 0;
  
  for(int i=0;i<n;i++){
    int v = V[i];
    int w = W[i];
    int k = min(50LL,K[i]);
    for(int t=min(k, 1LL); k>0 ; k-=t, t = min(t*2, k)){    
      for(int j=N;j>=0;j--){
        if(j - v * t < 0) continue;
        Min(dp[j], dp[j - v * t] + w*t);
      }
    }    
  }
  return dp;
}

int calc(vector<int> &V,vector<int> &W, vector<int> &K, vector<int> &Idx,int X){
  int res = 0;
  for(int i:Idx){
    int v = V[i];
    int w = W[i];
    int k = K[i];
    int num = min(k, X/w);
    res += v * num;
    X -= w * num;
  }
  return res;
}
 
int solve(int W,vector<int> v,vector<int> w,vector<int> m){
  int n = v.size();
  auto dp = DP(v,w,m);

  for(int i=0;i<n;i++) m[i] = max(0LL,m[i] - 50);
  
  vector<int> Idx(n);
  for(int i=0;i<n;i++) Idx[i] = i;
  sort(Idx.begin(),Idx.end(), [&](int i,int j){
      double a = 1.0 * v[i]/w[i];
      double b = 1.0 * v[j]/w[j];
      if(a != b) return a > b;
      return w[i] > w[j];
    });
  
  int res = 0;
    const int N = 51 * 51 * 51;
    for(int i=0;i<N;i++){
      int cost = dp[i];
      if(cost > W) continue;
      Max(res, i + calc(v,w,m,Idx,W-cost));
    }
    return res;
}

signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n,W;
  cin>>n>>W;
  vector<int> v(n),w(n),m(n);
  for(int i=0;i<n;i++) cin>>v[i]>>w[i]>>m[i];

  int ans = solve(W,v,w,m);
  cout<<ans<<endl;

  return 0;
}



Measured memory_bytes: 3924
//abc176_e.cpp
//Sat Aug 22 20:51:52 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

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

int main(){
	int h,w,m;
	cin >> h >> w >> m;

	map<int,int> x,y;
	map<P,int> target;
	rep(i,m) {
		int tmpx,tmpy;
		cin >> tmpx >> tmpy;
		x[tmpx]++;
		y[tmpy]++;
		target[P(tmpx,tmpy)] = 1;
	}

	int xmax = 0;
	vector<int> xmaxpos;
	for (auto itr=x.begin();itr!=x.end();itr++){
		if (itr->second > xmax){
			xmaxpos.clear();
			xmax = itr->second;
			xmaxpos.push_back(itr->first);
		}else if (itr->second == xmax){
			xmaxpos.push_back(itr->first);
		}
	}

	int ymax = 0;
	vector<int> ymaxpos;
	for (auto itr=y.begin();itr!=y.end();itr++){
		if (itr->second > ymax){
			ymaxpos.clear();
			ymax = itr->second;
			ymaxpos.push_back(itr->first);
		}else if (itr->second == ymax){
			ymaxpos.push_back(itr->first);
		}
	}

//	cout << xmaxpos.size() << "  " << ymaxpos.size() << endl;

	int ans = xmax+ymax;
	int modify = 1;
	rep(i,xmaxpos.size()){
		rep(j,ymaxpos.size()){
			if (target[P(xmaxpos[i],ymaxpos[j])]==0){
				modify = 0;
				break;
			}
		}
		if (modify==0){
			break;
		}
	}

	cout << ans-modify << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 54260