akhauriyash/Code-Regression huggingface dataset:
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    char c;
    cin>>c;
    cout<<char(c+1)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, t;
	cin >> a >> b >> t;
	int d = 1;
	int ans = 0;
	while (a * d <= t) {
		ans += b;
		d++;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
def main():

    N, M, X = map(int, input().split())
    B = [[0 for _ in range(M+1)]]
    for _ in range(N):
        A = list(map(int, input().split()))
        temp = []
        for b in B:
            tmp = [0 for _ in range(M+1)]
            for i in range(M+1):
                tmp[i] = b[i] + A[i]
            temp.append(tmp)
        B += temp

    minC = float('inf')
    for b in B:
        if all(u >= X for u in b[1:]):
            minC = min(minC, b[0])
    if minC == float('inf'):
        return -1
    return minC



if __name__ == '__main__':
    print(main())

Measured memory_bytes: 11200
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    int K, A, B;
    cin >> K;
    cin >> A >> B;
    for ( int i = A; i <= B; i++ ){
        if ( i % K == 0 ){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>

std::string check_stable (int num, std::string ary_org[], std::string ary[]) {

  int i, j, indexA, indexB;
  std::string str;

  indexA = indexB = -1;

  for (i = 0; i <= num - 2; i++) {

    if (ary[i][1] == ary[i + 1][1]) {

      for (j = 1; j <= num - 1; j++) {

        if (ary_org[j] == ary[i])     indexA = j;
        if (ary_org[j] == ary[i + 1]) indexB = j;
      }

      if (indexA > indexB) {

        str = "Not stable";
        return str;
      }
      else indexA = indexB = -1;
    }
  }

  str = "Stable";
  return str;
}

int main () {

  //---------------------------------------------------------------------//
  //Initialize

  int i, j, num;
  int index_last;
  int min, min_index;

  std::string temp;

  std::string ary_original[110];
  std::string aryB[110]; //Array for Bubble Sort
  std::string aryS[110]; //Array for Selection Sort

  std::cin >> num;

  for (i = 0; i <= num - 1; i++) {

    std::cin >> ary_original[i];
    aryB[i] = aryS[i] = ary_original[i];
  }

  //---------------------------------------------------------------------//
  //Bubble Sort

  index_last = num - 2;

  while (index_last >= 0) {

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

      if (aryB[i][1] > aryB[i + 1][1]){

        temp        = aryB[i];
        aryB[i]     = aryB[i + 1];
        aryB[i + 1] = temp;
      }
    }

    index_last --;
  }

  //---------------------------------------------------------------------//
  //Selection Sort

  for (i = 0; i <= num - 2; i++) {

    min       = aryS[i][1];
    min_index = i;

    for (j = i; j <= num - 1; j++) {

      if (min > aryS[j][1]) {

        min       = aryS[j][1];
        min_index = j;

      }
    }

    if (aryS[i] != aryS[min_index]) {

      temp            = aryS[i];
      aryS[i]         = aryS[min_index];
      aryS[min_index] = temp;
    }
  }

  //---------------------------------------------------------------------//
  //Output

  for (i = 0; i <= num - 2; i++) std::cout << aryB[i] << " ";
  std::cout << aryB[num - 1] << std::endl;

  std::cout << check_stable(num, ary_original, aryB) << std::endl;

  for (i = 0; i <= num - 2; i++) std::cout << aryS[i] << " ";
  std::cout << aryS[num - 1] << std::endl;

  std::cout << check_stable(num, ary_original, aryS) << std::endl;

  return 0;
}



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

using namespace std;

void out(int* a, int n)
{
    for(int i=0; i<n; i++){
        cout << a[i];
        if(i != n-1) cout << " ";
    }
    cout << endl;
}
int main()
{
    int n;
    cin >> n;
    int a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }

    int cnt = 0;
    for(int i=0; i<n; i++){
        //cout << "---" << endl;
        for(int j=0; j<n-i-1; j++){
            if(a[j]>a[j+1]){
                //cout << "Swap " << a[j] << ":" << a[j+1] << endl;
                int tmp = a[j+1];
                a[j+1] = a[j];
                a[j] = tmp;
                cnt++;
                //out(a, n);
            }
        }
    }
    
    out(a, n);
    cout << cnt << endl;
}


Measured memory_bytes: 3100
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimize("02")
#define pb push_back
#define F first
#define S second
using namespace std;
using ll =long long;
const ll maxn=1e6+6,inf=1e18+18;
ll n,m,t,x,mark[maxn],a[maxn],ans;
vector <ll>  v[maxn];
int main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	for(int i=1;i<maxn-2;i++){
		for(int j=i;j<maxn;j+=i)v[j].pb(i);
	}
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		mark[a[i]]++;
	}
	for(int i=0;i<n;i++){
		ans++;
		for(int j:v[a[i]]){
			if(j==a[i]){
				if(mark[j]>1){
					ans--;
					break;
				}
			}
			else if(mark[j]){
				ans--;
				break;
			}
		}
	}
	cout<<ans;
}


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

int compare_int(const void *a, const void *b)
{
    return *(long int*)b - *(long int*)a;
}

int main(){

  int n,k,i;
  scanf("%d %d",&n,&k);

  long int h[n],m;
  
  for(i=0;i<n;i++)
    scanf("%ld",&h[i]);
  
  qsort(h, n, sizeof(long int), compare_int);
  
  for(i=0;i<n;i++){
    if(i==0)
      m=h[i]-h[i+k-1];
    if(i+k>n)
      break;
    if(m>h[i]-h[i+k-1])
      m=h[i]-h[i+k-1];
  }
  
  printf("%ld",m);
 
  
}

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

int d, g;
vector<int> p;
vector<int> c;

int rec(int i, int sum, int count, string bits) {
  // ベースケース
  if (sum >= g) {
    return count;
  }
  if (i == d) {
    int pos = bits.find_last_of('0');
    int score = (pos + 1) * 100;
    for (int j = 0; j < (int) p.at(pos); j++) {
      sum += score;
      count++;
      if (sum >= g) {
        break;
      }
    }
    if (sum >= g) {
      return count;
    } else {
      return 0;
    }
  }

  // 完全に解く場合
  int p1 = rec(i + 1,
               sum + ((i + 1) * 100 * p.at(i)) + c.at(i),
               count + p.at(i),
               bits + '1');
  // 全く解かない場合
  int p2 = rec(i + 1, sum, count, bits + '0');

  if (p1 == 0) {
    return p2;
  }
  if (p2 == 0) {
    return p1;
  }
  return min(p1, p2);
}

int main() {
  cin >> d >> g;
  p.resize(d);
  c.resize(d);
  for (int i = 0; i < d; i++) {
    cin >> p.at(i) >> c.at(i);
  }

  string bits = "";
  int ans = rec(0, 0, 0, bits);

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

int main(){
   int k,x;
   cin >> k >> x;
   for(int i=x-k+1;i<x+k;i++) cout << i << " ";
   cout << endl;
   return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int e=0;
    while(true){
        if(e==0){
            c-=b;
            if(c<=0){
                cout<<"Yes"<<endl;
                break;
            } 
        }else{
            a-=d;
            if(a<=0){
                cout<<"No"<<endl;
                break;
            } 
        }
        e^=1;
    }
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
(全探索できるなら全探索しろ)
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'\n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え(=でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
*/

Measured memory_bytes: 3640
def modinv(a, m):
    b = m
    u = 1
    v = 0
    while b:
        t = a // b
        a -= t * b
        a, b = b, a
        u -= t * v
        u, v = v, u
    u %= m
    if u < 0:
        u += m
    return u

def nCk(N, k, mod):
    ret_val = 1
    for i in range(k):
        ret_val *= (N - i)
        ret_val %= mod
        ret_val *= modinv(i + 1, mod)
        ret_val %= mod
    return ret_val


n, a, b = map(int, input().split())
MOD = 10 ** 9 + 7
all_cnt = pow(2, n, MOD) - 1
a_cnt = nCk(n, a, MOD)
b_cnt = nCk(n, b, MOD)
ans = all_cnt - a_cnt - b_cnt
print(ans % MOD)

Measured memory_bytes: 9140
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<vector>
using namespace std;

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//infinity
#define INTINF 2000000000
#define LONGINF 2000000000

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;


	int mw = 0;
	int ms = 0;
	REP(i, 31){
		REP(j, 31){
			REP(k, 101){
				REP(l, 101){
					int w = (100*a)*i + (100*b)*j;
					int s = c * k + d * l;
					if( w == 0 || w + s > f){
						break;
					}else if(w / 100 * e < s){
						break;
					}else{
						if(ms == 0 || s * ( mw + ms ) > ms * ( w + s ) ){
							mw = w;
							ms = s;
						}
					}
				}
			}
		}
	}

	cout << mw + ms << " " << ms << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main() {
    int w, h, x, y, r;
    scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
    int minXY, maxX, maxY;
    minXY = 0 + r;
    maxX = w - r;
    maxY = h - r;
    if (x >= minXY && y >= minXY && x <= maxX && y <= maxY) printf("Yes\n");
    else printf("No\n");

    return 0;
}


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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<piii> viii;

const int MAXN = 5000100, MAXK = 30;
const ll MOD = 998244353;
const int INF = 1e8;
const ld PI = asin(1) * 2;

void setIO () {
    FAST_IO;
}

void setIO (string s) {
    setIO();
 	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}



int main() {
	setIO();

    int n, m;
    cin >> n >> m;
    int a[n];
    FOR(i, 0, n-1) cin >> a[i];
    int cnt = 0;
    int s = 0;
    FOR(i, 0, n-1) s += a[i];
    int x = (s+4*m-1)/(4*m);
     cnt = 0;
    FOR(i, 0, n-1) if (a[i] >= x) cnt++;
    if (cnt >=m) cout << "Yes";
    else cout << "No";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define ppf pop_front
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)/2)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1ll<<(x))
#define inf 1000000000
#define MOD 1000000007
#define N 100005
#define M 10000001
#define LOG 16
#define KOK 650
#define EPS 0.00001
using namespace std;

int n,m,x[N],y[N];

int main() {

	//freopen("input.txt","r",stdin);

	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);

	cin>>n>>m;

	for(int i=1;i<=n;i++) cin>>x[i];

	for(int i=1;i<=m;i++) cin>>y[i];

	int ax=0,ay=0;
	int s=0;

	for(int i=1;i<=n;i++) {

		ax=(ax+(ll)(i-1)*x[i]-s)%MOD;

		s=(s+x[i])%MOD;

	}

	s=0;

	for(int i=1;i<=m;i++) {

		ay=(ay+(ll)(i-1)*y[i]-s)%MOD;

		s=(s+y[i])%MOD;

	}

	cout<<(ll)ax*ay%MOD;
}



Measured memory_bytes: 1024
// Author : Nachiket Kanore
// Institute : PICT, Pune

/* It does not matter how slowly you go as long as you do not stop.*/

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define endl '\n'
#define rep(x,s,e) for(int x=s;x<=(e);x++)
#define repn for(int x=0;x<n;x++)
#define rep1n for(int x=1;x<=n;x++)
#define rep1m for(int y=1;y<=m;y++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define precise(x) cout << fixed << setprecision(x)
#define bits(x) __builtin_popcount(x)
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;


void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define see(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define see(x...)
#endif

const int inf = 1e18;
const int N = 1005;



int32_t main(){
    FAST;

    int a , b;  cin >> a >> b;
    int prod = a * b ;

    for(int x=1;x<=3;x++){
        if((x * prod) % 2 == 1)
            return cout << "Yes" , 0;
    }

    cout << "No";

    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

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

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

int n, m, a, b;
LL ans;

const int mod = 1000000007;

inline LL qpow(LL a, LL b)
{
	LL res = 1;
	while (b)
	{
		if (b & 1) res = (res * a) % mod;
		a = a * a % mod, b >>= 1;
	}
	return res % mod;
}

inline LL work(int x)
{
    LL s = 1, c = 1;
    for (int i = 1; i <= x; i+=1) 
        s = (s * i) % mod;
    for (int i = n - x + 1; i <= n; i+=1)
        c = (c * i) % mod;
    return (c * qpow(s, mod - 2)) % mod;
}

int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	cin >> n >> a >> b;
	ans = (((qpow(2, n) - 1) % mod - work(a) % mod - work(b) % mod) % mod + mod) % mod;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  int ans = 0;
  rep(i, s.length() / 2) {
    if (s[i] != s[s.length() - 1 - i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() 
{
	int a, b, tmp, count;
    while (1) {
    	cin >> a >> b;
        if (a == 0 && b == 0) {
            break;
        }
        if(a < b) { 
                    tmp = b; 
                    b = a; 
                    a = tmp; 
                    } 
        count = 0; 
        do {
            a = a % b;
            tmp = b;
            b = a;
            a = tmp;
            count++;
        } while (b != 0);
        cout << a << " " << count << endl;
    }
	return 0;
}


Measured memory_bytes: 3012
#include <stdio.h>
#define N 10100
int main()
{
    char a[N], b[N];
    int c[N], d[N];
    int i, j;
    int la, lb, l;
    scanf("%s%s", a, b);
    la = strlen(a);
    lb = strlen(b);
    if(la >lb)
       printf("GREATER");
    else if(la<lb)
        printf("LESS");
    else
    {
    for(i=0;i<la;i++)
    {
        c[i]=a[i]-'0';
        d[i]=b[i]-'0';
    }
     for(i=0;i<la;i++)
    {
        if(c[i]!=d[i])
         {
             break;
             l=i;
         }
    }
    if(c[l]>d[l])
        printf("GREATER");
    if(c[l]<d[l])
        printf("LESS");
    if(l=la&&c[l]==d[l])
        printf("EQUAL");
    }
    return 0;
}


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

#define COUT(x) cout << #x << " = " << (x) << ", "
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
typedef long long ll;
const int MOD = 1000000007;

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  if((A == B && B == C) || (A != B && A != C && B != C)){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		int n = s.length();

		if (s.substring(0, n / 2).equals(s.substring((n + 3) / 2-1, n))) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		sc.close();

	}
}

Measured memory_bytes: 35624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<pair<int,ll>> G[150000];
vector<pair<int,int>> Q;
vector<int> QV[150000];
ll sum[150000];
int par[18][150000],dep[150000],ordl[150000],ordr[150000];
int N;
void dfs(int prev,int cur,ll val,ll add){
    sum[cur]=val;
    for(const auto p : QV[cur])
        add+=p;
    for(auto& p: G[cur]){
        if(p.first==prev)continue;
        p.second+=add;
        dfs(cur,p.first,val+p.second,add);
    }
    QV[cur].clear();
}
void efs(int prev,int cur,int d,int& ord){
    dep[cur]=d;
    par[0][cur]=prev;
    ordl[cur]=ord++;
    for(const auto p: G[cur]){
        if(p.first==prev)continue;
        efs(cur,p.first,d+1,ord);
        ord++;
    }
    ordr[cur]=ord;

}
void init(){
    for(int i=0;i<18;i++)
        for(int j=0;j<N;j++)par[i][j]=-1;
    int ord=0;
    efs(-1,0,0,ord);
    for(int i=1;i<18;i++)
        for(int j=0;j<N;j++){
            if(par[i-1][j]==-1)par[i][j]=-1;
            else par[i][j]=par[i-1][par[i-1][j]];
        }
}
int getLCA(int a,int b) {
   if (dep[a] > dep[b]) swap(a, b);
   for(int i=0;i<18;i++)
       if ((dep[b] - dep[a]) >> i & 1)
           b = par[i][b];
   if (a == b) return a;
   for(int i=17;i>=0;i--)
       if (par[i][a] != par[i][b])a = par[i][a], b = par[i][b];
   return par[0][a];
}

ll get(int v){
    ll ret=sum[v];
    for(const auto p : Q){
        int u=p.first,x=p.second;
        if(ordl[v]<ordl[u]||ordr[u]<ordl[v])continue;
        if(dep[u]<=dep[v])ret+=1LL*x*(dep[v]-dep[u]);
    }
    return ret;
}

int main(){
    cin>>N;
    int M;
    cin>>M;
    for(int i=0;i<N-1;i++){
        int a,b;
        cin>>a>>b;
        G[a].emplace_back(b,0);
        G[b].emplace_back(a,0);
    }

    init();
    for(int i=0;i<M;i++){
        if(i%2000==0){
            Q.clear();
            dfs(-1,0,0,0);
        }
        int t;
        cin>>t;
        if(t==1){
            int u,x;
            cin>>u>>x;
            Q.emplace_back(u,x);
            QV[u].emplace_back(x);

        }else{
            int u,v,lca;
            cin>>u>>v;
            lca=getLCA(u,v);
            //cout<<u<<" "<<v<<" "<<lca;
            cout<<get(u)+get(v)-2*get(lca)<<'\n';
        }
    }
}


Measured memory_bytes: 44196
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
int main()
{
    long long N, P;
    cin >> N >> P;
    string S;
    cin >> S;
    const long long len = S.size();
    long long ans = 0;
    if (P == 2 || P == 5)
    {
        for (long long i = 0; i < len; ++i)
        {
            int num = S[i] - '0';
            if (num % P == 0)
            {
                ans += i + 1;
            }
        }
        cout << ans << endl;
        return 0;
    }

    // あまりが等しい値を分類する
    vector<long long> cnts(P, 0);
    long long num = 0;
    cnts[0] = 1;
    long long digit = 1;
    for (long long i = 0; i < len; ++i)
    {
         num = (num + (S[len - 1 - i] - '0') * digit ) % P;
         digit = (digit * 10) % P;
         ++cnts[num];
    }
    // ペアの組み合わせの総和
    for (long long i = 0; i < P; ++i)
    {
        ans += cnts[i] * (cnts[i] - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
#define rep1(i,N) for(int i=1;i<=(int)N;i++)
#define pb push_back
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> mat;
ll mod=1e9+7;
void add(ll &x,ll y){
	x+=y;
	x%=mod;
}
mat pro(mat a,mat b){
	int N=a.size();
	mat c(N,vi(N,0));
	rep(i,N) rep(j,N) rep(k,N) add(c[i][j],a[i][k]*b[k][j]);
	return c;
}
mat ex(mat x,int p){
	int N=x.size();
	mat a(N,vi(N,0));
	rep(i,N) a[i][i]=1;
	while(p){
		if(p%2) a=pro(a,x);
		x=pro(x,x);
		p/=2;
	}
	return a;
}
int N,K,C,T,t[1600],to[1600][40];
int main(){
	cin>>N>>K>>C>>T;
	rep(i,K){
		int a,b;
		cin>>a>>b>>t[i];
		a--;
		rep(j,N){
			if(a<=j&&j<a+b) to[i][j]=j-a;
			if(j<a) to[i][j]=j+b;
			if(j>=a+b) to[i][j]=j;
		}
	}
	int s=5*N;
	mat M(s,vi(s,0));
	rep(i,4*N) M[i][i+N]=1;
	rep(i,K){
		rep(j,N){
			int nj=to[i][j];
			int x=(5-t[i])*N+j;
			int nx=4*N+nj;
			M[nx][x]++;
		}
	}
	ll dp[5][40]={};
	dp[0][C-1]=1;
	rep(i,4){
		rep(j,K){
			if(i+t[j]>=5) continue;
			rep(k,N){
				add(dp[i+t[j]][to[j][k]],dp[i][k]);
			}
		}
	}
	if(T<=4){
		cout<<dp[T][0]<<endl;
		return 0;
	}
	vi v(5*N,0);
	rep(i,5) rep(j,N) v[i*N+j]=dp[i][j];
	mat e=ex(M,T-4);
	ll ans=0;
	rep(j,5*N) add(ans,e[4*N][j]*v[j]);
	cout<<ans<<endl;
}

Measured memory_bytes: 4988
#include <iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	string a;
	cin>>a;
	int se[n],sw[n];
	for(int i=0;i<n;i++)
	{
		se[i]=0;
		sw[i]=0;
	}
	if(a[0]=='E') se[0]=1;
	else sw[0]=1;
	for(int i=1;i<n;i++)
		if(a[i]=='E')
		{
			se[i]=se[i-1]+1;
			sw[i]=sw[i-1];
		}
		else
		{
			sw[i]=sw[i-1]+1;
			se[i]=se[i-1];
		}
	int minv=300005;
	for (int i=0;i<n;i++)
	{
		int sum=0;
		if (i==0)  sum=se[n-1]-se[0];
		else if(i==n-1)  sum=sw[n-2];
		else sum=sw[i-1]+(se[n-1]-se[i]);
		minv=min(minv,sum);
	}
	cout<<minv<<endl;
	return 0;
}

Measured memory_bytes: 2948
def solve(x,y,maxm):
    for i in xrange(y):
        for j in xrange(maxm+1):
            if dp[i][j]==0:continue
            for k in xrange(int(x)):

                if event[min(y,i+v[k])][0]==0:
                    dp[min(y,i+v[k])][j]+=dp[i][j]/x

                elif event[i+v[k]][0]==1:
                    skip=event[i+v[k]][1]
                    dp[min(y,i+v[k]+skip)][j]+=dp[i][j]/x

                elif event[i+v[k]][0]==2:
                    m=event[i+v[k]][1]
                    dp[i+v[k]][j+m]+=dp[i][j]/x

                else:
                    m=event[i+v[k]][1]
                    dp[i+v[k]][max(0,j-m)]+=dp[i][j]/x
    return dp

while 1:
    x,y,z=map(int,raw_input().split())
    if x==0 and y==0 and z==0:break
    v=map(int,raw_input().split())
    event=[[0]*2 for _ in xrange(y+1)]
    maxm=0
    for i in xrange(z):
        n,e,a=map(int,raw_input().split())
        event[n][0]=e
        event[n][1]=a
        if e==2:
            maxm+=a

    dp=[[0]*(5005) for _ in xrange(y+1)]
    dp[0][0]=1
    x=float(x)
    dp=solve(x,y,maxm)
    ans=0.0
    for i in xrange(maxm+1):
        ans+=dp[y][i]*i
    print(int(ans))

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

#define All(a) (a).begin(),(a).end()
#define ll long long int
ll A[51][51][2501];

int a;
ll ans=0;

void solve(){
  int n;
  scanf("%d %d",&n,&a);
  vector<int> v(n);
  for (int i = 0; i < n; i++)
  {
    scanf("%d",&v[i]);
  }
  
  A[0][0][0]=1;
  
  for (int i = 0; i < n; i++)
  {
    for (int k = 0; k <=50*n; k++)
    {
      for (int j = 0; j <n; j++)
      {
        //printf("%lld ",A[i][j][k]);;
        if(A[i][j][k]==0)continue;
        A[i+1][j][k]+=A[i][j][k];
        A[i+1][j+1][k+v[i]]+=A[i][j][k];
      }
      //printf("\n");
    }
    //printf("\n");
  }
  
  for (int k = 1; k <= n; k++)
  {
    ans+=A[n][k][a*k];
  }
  
  printf("%lld",ans);
}
int main(){
  /*
  int q;
  scanf("%d",&q);
  while(--q)solve();
  */
  solve();

  return 0;
}

Measured memory_bytes: 13068
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define NIL -1
typedef long long ll;
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll MOD = 1000000007;


int main() {
    int N, K;
    cin >> N >> K;
    if (N >= 10) cout << K << endl;
    else cout << K + 100 * (10 - N) << endl;
    return 0;

}

Measured memory_bytes: 256
local insert = table.insert

local s = io.read()
local n = s:len()

local s_byte_t = {}
for i = 1, n do
	s_byte_t[i] = s:byte(i);
end

local L, R = string.byte("LR", 1, 2)
-- 例の場所に入ったとき偶数回目の移動だったならその場

local next_different_t = {}
local current = R
for i = 1, n do
	if s_byte_t[i] ~= current then
		insert(next_different_t, i - 1)
		if current == R then
			current = L
		else
			current = R
		end
	end
end

local ans_t = {}
for i = 1, n do
	ans_t[i] = 0
end

local next_different_t_len = #next_different_t
current = R
for i = 1, next_different_t_len + 1 do
	local front = (i ~= next_different_t_len + 1) and next_different_t[i] or n
	local front_before = (i - 1 ~= 0) and next_different_t[i - 1] or 0

	if current == R then
		if current == R and (front - front_before) % 2 == 0 then
			ans_t[front]     = ans_t[front] 
				+ (front - front_before) // 2
			ans_t[front + 1] = ans_t[front + 1]
				+ (front - front_before) // 2
		else
			ans_t[front]     = ans_t[front]
				+ (front - front_before) // 2 + 1
			ans_t[front + 1] = ans_t[front + 1]
				+ (front - front_before) // 2
		end
		current = L
	elseif current == L then
		if (front - front_before) % 2 == 0 then
			ans_t[front_before]     = ans_t[front_before]
				+ (front - front_before) // 2
			ans_t[front_before + 1] = ans_t[front_before + 1]
				+ (front - front_before) // 2
		else
			ans_t[front_before]     = ans_t[front_before]
				+ (front - front_before) // 2
			ans_t[front_before + 1] = ans_t[front_before + 1]
				+ (front - front_before) // 2 + 1
		end
		current = R
	end
end

print(table.concat(ans_t, " "))


Measured memory_bytes: 8912
unittest
{
	assert( [ "103" ].parse.expand.solve == 3 );
	assert( [ "1000000000000000000" ].parse.expand.solve == 3760 );
	assert( [ "1333333333" ].parse.expand.solve == 1706 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto x = input.front.to!( long );
	return tuple( x );
}

auto solve( long x )
{
	auto t = 100L;
	for( auto i = 1L;; i++ )
	{
		t += t / 100;
		if( x <= t ) return i;
	}
}


Measured memory_bytes: 2788
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int main(void) {
    int N;
    vector<int> P(200010);
    cin >> N;
    for (int i=0;i<N;i++) cin >> P[i];
    
    int m = P[0], res = 1;
    for (int i=1;i<N;i++) {
        if (P[i] <= m) {
            m = P[i];
            res++;
        }
    }
    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000 + 10;
int main(){
    ll n,m; cin>>n>>m;
    if(n>m) swap(n,m);
    if(n==1){
        cout<<1<<endl;
        return 0;
    }
    ll ans = 0;
    if(n%2==1&&m%2==1){
        ans += m / 2 + 1;
        n--;
    }
    ans += (n*m)/2;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();

        int ans = 0;
        int[] acgt = new int[s.length];
        for(int i=0; i<s.length; i++) {
            if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
                acgt[i] = 1;
            }
        }
        int cnt = 0;
        for(int i=0; i<acgt.length; i++) {
            if(acgt[i] == 1) {
                cnt += 1;
            } else {
                cnt = 0;
            }
            ans = Math.max(cnt,ans);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35576
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=2000010,Mo=1000000007;
int fac[N],rev[N];
inline int Pow(int x,int y) {
    int ret=1;
    for(;y;x=1LL*x*x%Mo,y>>=1)
	if(y&1) ret=1LL*ret*x%Mo;
    return ret;
}
inline void pre(int n) {
    for(int i=fac[0]=1;i<=n;i++) fac[i]=1LL*fac[i-1]*i%Mo;
    rev[n]=Pow(fac[n],Mo-2);
    for(int i=n;i;i--) rev[i-1]=1LL*rev[i]*i%Mo;
}
inline int calc(int n,int m) {
    return 1LL*fac[n]*rev[m]%Mo*rev[n-m]%Mo;
}
inline int G(int n,int m) {return calc(n+m,n);}
inline int S(int x,int y,int X,int Y) {
    return (1LL*G(X+1,Y+1)-G(X+1,y)-G(x,Y+1)+G(x,y))%Mo;
}
int main() {
    pre(2000000);
    int a,b,c,d,e,f,A,B,C,D,E,F,ans=0;
    cin>>a>>b>>c>>d>>e>>f>>A>>B>>C>>D>>E>>F;
    for(int i=C,j=c;i<=D;i++)
	ans=(ans-1LL*(i+j)*S(i-B,j-b-1,i-A,j-a-1)%Mo*S(E-i,e-j,F-i,f-j))%Mo;
    for(int i=C,j=c;j<=d;j++)
	ans=(ans-1LL*(i+j)*S(i-B-1,j-b,i-A-1,j-a)%Mo*S(E-i,e-j,F-i,f-j))%Mo;
    for(int i=D,j=c;j<=d;j++)
	ans=(ans+1LL*(i+j+1)*S(i-B,j-b,i-A,j-a)%Mo*S(E-i-1,e-j,F-i-1,f-j))%Mo;
    for(int i=C,j=d;i<=D;i++)
	ans=(ans+1LL*(i+j+1)*S(i-B,j-b,i-A,j-a)%Mo*S(E-i,e-j-1,F-i,f-j-1))%Mo;
    cout<<(ans+Mo)%Mo;
    return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;

const int MOD=1000000007;
int INF=100100100100100;

int hen[550][550];
int f(int a,int b){
  int res=1;
  while(1){
    if(a%2!=b%2)return res;
    a/=2,b/=2;
    res++;
  }
}
signed main(){
  int n;cin>>n;
  rep(i,n){
    for(int j=i+1;j<n;j++){
      cout<<f(i,j)<<" ";
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 512
import math
n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
x = 0
y = 0
cnt=0
for i in range(n):
  for l in range(i):
    if p[i] > p[l]:
      cnt += 1
  x += (p[i] - 1 - cnt)*(int(math.factorial(n - 1 - i)))
  cnt = 0
for i in range(n):
  for l in range(i):
    if q[i] > q[l]:
      cnt += 1
  y += (q[i] - 1 - cnt)*(int(math.factorial(n - 1 - i)))
  cnt = 0
print(abs(x-y))

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

int main(){
  int n; cin >>n;
  vector<int> a(n);
  rep(i,n) cin >>a[i];
  const int M = 1000005;
  vector<int> cnt(M);
  for(int x : a){
    if(cnt[x]!=0){
      cnt[x] = 2;
      continue;
    }
    for(int i = x; i<M; i+=x) cnt[i]++;
  }
  int ans = 0;
  for(int x : a){
    if(cnt[x]==1) ans++;
  }
  cout << ans << endl;
  return 0; 
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const ll MOD = 998244353;
const int MAX_N = 3005;
const int MAX_S = 3005;

ll dp[MAX_N][MAX_S];
int A[MAX_N];

int main2() {
  CLR(dp, 0);
  int N = nextInt();
  int S = nextInt();
  REP(i, N) A[i] = nextInt();

  ll ans = 0;
  for (int i = 0; i < N; i++) {
    dp[i][0] += 1;
    for (int s = 0; s <= S; s++) {
      (dp[i+1][s] += dp[i][s]) %= MOD;
      if (s + A[i] <= S) {
        (dp[i+1][s + A[i]] += dp[i][s]) %= MOD;
      }
    }
    ans += dp[i+1][S];
    ans %= MOD;
  }
  ans %= MOD;
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 70784
// cout << "Case #" << test << ": ";
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; ++i)
        cin >> A[i];

    int res = 0;
    for(int i = 0; i < N; ++i) {
        // same を抜ける
        while(i + 1 < N && A[i] == A[i + 1])
            ++i;

        // up
        if(i + 1 < N && A[i] < A[i + 1]) {
            while(i + 1 < N && A[i] <= A[i + 1])
                ++i;
        }
        // down
        else if(i + 1 < N && A[i] > A[i + 1]) {
            while(i + 1 < N && A[i] >= A[i + 1])
                ++i;
        }
        ++res;
    }
    cout << res << endl;
}


Measured memory_bytes: 640
import java.io.*;
public class Main {
	void run(){
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);
		String str = "";
		try{
		str = br.readLine();
		}catch(IOException e){
			System.out.println(e);
		}
		char c[] = str.toCharArray();
		for(int i = 0;i < c.length;i++){
			if(Character.isUpperCase(c[i])){
				c[i] = Character.toLowerCase(c[i]);
			}else if(Character.isLowerCase(c[i])){
				c[i] = Character.toUpperCase(c[i]);
			}
			System.out.print(c[i]);
		}
		System.out.println("");
	}
	public static void main(String args[]){
		Main m = new Main();
		m.run();
	}
}

Measured memory_bytes: 24912
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
	int a,b,c,d,ans;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	ans=min(b,d)-max(a,c);
	if(ans<0)ans=0;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n, k;
    string s;
    cin >> n >> k >> s;
    int score = 0;
    rep(i, n-1) if (s[i] == s[i+1]) score++;
    int ans = min(score+2*k, n-1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
n, m = map(int, input().split())
array = [[int(x) for x in input().split()] for x in range(m)]
p_array = [int(x) for x in input().split()]

s_array = [x[1:] for x in array]
k_array = [x[0] for x in array]

res = 0
bit = 2 ** n
for bit_tmp in range(bit):
    flags = [False for x in range(n)]
    light_flag = True
    for shift in range(n):
        if 1 & bit_tmp >> shift:
            flags[shift] = True
    for index, s in enumerate(s_array):
        tmp = 0
        for ss in s:
            if flags[ss - 1]:
                tmp += 1
        if tmp % 2 != p_array[index]:
            light_flag = False
    if light_flag:
        res += 1
print(res)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long int
#define ii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
#define output(x) for (auto a:x) cout<<a<<" ";cout<<endl;
#define output2(x) for (auto a:x) cout<<a.fi<<" "<<a.se<<endl;
#define PI 3.14159265
#define rall(x) x.rbegin(),x.rend()
#define all(x) x.begin(),x.end()
#define sz(x) (int) x.size()
// DEBUG TEMPLATE
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
  *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
  
// DEBUG TEMPLATE ENDS

#define MOD 1000000007
int power(int x,int y,int mod = MOD) 
{ 
  int ret = 1;
  x = x % mod;
  while (y){
    if(y&1) ret = (ret*x)%mod;
    y = y>>1;
    x = (x*x)%mod;
    } 
    return ret%mod; 
}
int r,c;


int solve2(int x ,int y,int row , vector<vector<int>>&grid,vector<vector<vector<int>>>&dp){
  int ret = 0;
  if (x == r or y == c) return 0;
  if (dp[x][y][row]!=-1) return dp[x][y][row];
  if (grid[x][y] == 0){
    ret = max(ret,solve2(x+1,y,3,grid,dp));
    ret = max(ret,solve2(x,y+1,row,grid,dp));
  } else {
    if (row == 0){
      ret = max(ret,solve2(x+1,y,3,grid,dp));
    } else {
      ret = max(ret,max(solve2(x,y+1,row,grid,dp) , solve2(x,y+1,row-1,grid,dp) + grid[x][y]));
      ret = max(ret,solve2(x+1,y,3,grid,dp) + grid[x][y]);
    }
  }
  // if (x == 0 and y == 1)
  // debug() << imie(x) imie(y) imie(row) imie(ret);
  dp[x][y][row] = ret;
  return ret;;
}

void solve()
{ 
    int k;
    cin>>r>>c>>k;
    vector<vector<int>> grid(r,vector<int> (c,0));
    vector<vector<vector<int>>> dp(r,vector<vector<int>> (c,vector<int>(4,-1)));
    for (int i = 0 ; i < k ; i ++){
      int x,y,v;
      cin>>x>>y>>v;
      grid[--x][--y] += v;
    }
    debug() << imie(grid);
    // debug() << imie(solve2(0,3,3,grid));
    int ans = solve2(0,0,3,grid,dp);
    cout<<ans<<endl;
}


/*
  
*/
signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  // cin>>t;
  while (t--)
  solve();
}
// Check MOD values plox :(


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

const int MN = 200010;

int N, X, Y;
vector<int> adj1[MN], adj2[MN];
int par[20][MN], dep[MN], tin[MN], tout[MN], timer;

void dfs0(int u, int p) {
    tin[u] = timer++;

    par[0][u] = p;
    for(int i = 1; i < 20; i++) {
        int t = par[i - 1][u];
        if(t == -1) break;
        par[i][u] = par[i - 1][t];
    }

    for(int i = 0; i < adj2[u].size(); i++) {
        int v = adj2[u][i];
        if(v == p) continue;
        dep[v] = dep[u] + 1;
        dfs0(v, u);
    }

    tout[u] = timer;
}

int lca(int a, int b) {
    if(dep[a] < dep[b]) swap(a, b);
    int diff = dep[a] - dep[b];
    for(int i = 0; i < 20; i++) {
        if(diff & (1 << i)) a = par[i][a];
    }
    if(a == b) return a;
    for(int i = 20; i--;) {
        if(par[i][a] != par[i][b]) {
            a = par[i][a];
            b = par[i][b];
        }
    }
    return par[0][a];
}

int dist(int u, int v) {
    return dep[u] + dep[v] - 2 * dep[ lca(u, v) ];
}

int dep2[MN], mn, mnp;

int ans;
void dfs1(int u, int p) {
    if(dep[u] <= dep2[u]) return;
    ans = max(ans, dep[u]);

    for(int i = 0; i < adj1[u].size(); i++) {
        int v = adj1[u][i];
        if(v == p) continue;
        if(dist(u, v) >= 3) {
            printf("-1");
            exit(0);
        }
        dep2[v] = dep2[u] + 1;
        dfs1(v, u);
    }
}

int main() {
    scanf("%d %d %d", &N, &X, &Y);
    X--; Y--;

    for(int i = 0; i < N - 1; i++) {
        int a, b; scanf("%d %d", &a, &b);
        a--; b--;

        adj1[a].push_back(b);
        adj1[b].push_back(a);
    }
    for(int i = 0; i < N - 1; i++) {
        int a, b; scanf("%d %d", &a, &b);
        a--; b--;

        adj2[a].push_back(b);
        adj2[b].push_back(a);
    }

    dfs0(Y, -1);
    dfs1(X, -1);
    printf("%d", 2 * ans);
}


Measured memory_bytes: 52348
(let ((a (read))
      (b (read))
      (c (read))
      (flag nil))

  (loop named foo
        for i from a to (* a 100) by a
        if (= (mod i b) c) do (progn (setq flag t)
                                     (return-from foo)))

  (format t "~A~%"
          (if flag 'yes 'no)))


Measured memory_bytes: 7016
<?php /*atcoder.php*/

$at = new Atcoder();
$at->main();
unset($at);

class Atcoder{
	private function arrayIn(){
		$buf = explode(" ", fgets(STDIN));
		return $this->killNewLine($buf);
	}
	private function killNewLine($buf = null){
		$buf = str_replace("\r\n", "", $buf);
		$buf = str_replace("\n", "", $buf);
		$buf = str_replace("\r", "", $buf);
		return $buf;
	}

	public function main(){
		$s = $this->arrayIn();
	
		$n = $s[0];
		$m = $s[1];
		$x = $s[2];
		$y = $s[3];
	
		$xmap = $this->arrayIn();
		$ymap = $this->arrayIn();

		rsort($xmap);

		$z = -999;

		if($x > $xmap[0]){
			$z = $x + 1;
		}else{
			$z = $xmap[0] + 1;
		}

		sort($ymap);

		if($z > $y){
			echo "War\n";
			return false;
		}
		
		if($z > $ymap[0]){
			echo "War\n";
			return false;
		}
		echo "No War\n";
		return true;
	}
}
?>

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

const int MOD = 1000000007;
struct modint {
  long long val;
  modint(long long val=0) : val((val % MOD + MOD) % MOD){}
  modint operator-() const { return modint(-val); }
  modint& operator+=(const modint a) { if ((val += a.val)     >= MOD) val -= MOD; return *this; }
  modint& operator-=(const modint a) { if ((val += MOD-a.val) >= MOD) val -= MOD; return *this; }
  modint& operator*=(const modint a) { (val *= a.val) %= MOD; return *this; }
  modint operator+(const modint a) const { return (modint)*this += a; }
  modint operator-(const modint a) const { return (modint)*this -= a; }
  modint operator*(const modint a) const { return (modint)*this *= a; }
  modint pow(long long n) const { modint r(1), m(val); while (n > 0) { if (n & 1) {r *= m;} m *= m; n >>= 1; } return r; }
  modint inv() const { return pow(MOD-2); }
  modint& operator/=(const modint a) { return (*this) *= a.inv(); }
  modint operator/(const modint a) const { return (modint)*this /= a; }
  bool operator==(const modint &p) const { return val == p.val; }
  bool operator!=(const modint &p) const { return val != p.val; }
  friend ostream &operator<<(ostream &os, const modint &p) { return os << p.val; }
  friend istream &operator>>(istream &is, modint &a) { long long t; is >> t; a = modint(t); return (is); }
};

string S;
modint dp[100001][13];

signed main() {
  cin >> S;
  reverse(S.begin(), S.end());
  int n = S.size();
  dp[0][0] = 1;
  int p10 = 1;
  for(int i=0; i<n; i++) {
    if(S[i] == '?') {
      for(int d=0; d<=9; d++) {
        int dd = d * p10;
        for(int j=0; j<13; j++) {
          dp[i+1][(j+dd)%13] += dp[i][j];
        }
      }
    }
    else {
      int d = S[i] - '0';
      int dd = d * p10;
      for(int j=0; j<13; j++) {
        dp[i+1][(j+dd)%13] += dp[i][j];
      }
    }
    p10 = (p10 * 10) % 13;
  }

  cout << dp[n][5] << endl;
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a + b > c + d) {
    cout << "Left" << endl;
  } else if (a + b < c + d){
    cout << "Right" << endl;
  } else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256