akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using  ll = long long;
#define rep(i,n) for (int i = 1; i <= (n); ++i)

int main(){
  int n;
  std::cin >> n;

  std::map<int, int> m;
  rep(x,110)rep(y,110)rep(z,110){
    ll temp=x*x + y*y + z*z + x*y + y*z + z*x;
    // ll temp=(x+y+z)*(x+y+z)-x*y-y*z-z*y;
    if(temp==20)std::cout << x<<y<<z << '\n';
    m[temp]++;
  }

  rep(i,n){
    std::cout << m[i] << '\n';
  }

  return 0;
}


Measured memory_bytes: 5852
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define range(i,l,h) for(int i=l;i<h;i++)
#define endl '\n'
#define I INT_MAX
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define vt vector
using namespace std;
using std::ios;
constexpr int MOD=1e9+7;
constexpr int mod=998244353;
template<typename T> T power(T a,T b){T r=1;while(b){if(b&1)r*=a;b/=2;a*=a;}return r;}


int main()
{
  fastio;
  

 int n;
 cin>>n;
 int c=0;
 bool ok=0;
 range(i,0,n)
 {
    int a,b;
    cin>>a>>b;
    if(a==b)c++;
    else c=0;
    if(c>=3)ok=1;
 }
 cout<<(ok?"Yes":"No");
  

}

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

int main() {
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    printf("%d\n", ((n+(a-1))/a)*b < ((n+(c-1))/c)*d ? ((n+(a-1))/a)*b : ((n+(c-1))/c)*d);
    return 0;
}



Measured memory_bytes: 3200
#include<stdio.h>
#include<string.h>
int main(void)
{
	int n,i,j;
	char moji[10000][6],buf[6];
	int p,len[10000],suu[10000];
	int wk;
	scanf("%d",&n);
	p=0;
	for(i=0;i<n;i++)	{
		scanf("%s",moji[i]);
		len[i]=strlen(moji[i]);
		scanf("%d",&suu[i]);
	}
	for(i=0;i<n-1;i++)	{
		for(j=i+1;j<n;j++)	{
			if(len[i]>len[j] || (len[i]==len[j] && strcmp(moji[i],moji[j])>0))	{
				wk=len[i];
				len[i]=len[j];
				len[j]=wk;
				wk=suu[i];
				suu[i]=suu[j];
				suu[j]=wk;
				strcpy(buf,moji[i]);
				strcpy(moji[i],moji[j]);
				strcpy(moji[j],buf);
			}
		}
	}
	strcpy(buf,moji[0]);
	wk=suu[0];
	for(i=1;i<n;i++)	{
		if(strcmp(buf,moji[i])!=0)	{
			printf("%s %d\n",buf,wk);
			strcpy(buf,moji[i]);
			wk=suu[i];
		}
		else {
			wk+=suu[i];
		}
	}
	printf("%s %d\n",buf,wk);
	return 0;
}


Measured memory_bytes: 768
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll h[100005];
int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    int active = 0;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (active < h[i]) {
            ans += h[i]-active;
            active = h[i];
        }
        else {
            active = h[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)
if a.select{|a|a<0}.size.odd? # 負の数が奇数個
  p a.map(&:abs).inject(&:+) - a.map(&:abs).min*2
else
  p a.map(&:abs).inject(&:+)
end


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

using Int = long long;
const char newl = '\n';

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
template<typename T=int>
vector<T> read(size_t n){
  vector<T> ts(n);
  for(size_t i=0;i<n;i++) cin>>ts[i];
  return ts;
}

template<typename T,T MOD,T B>
struct RollingHash{
  using ll = long long;
  vector<T> hash,po;
  RollingHash(){}
  RollingHash(vector<T> vs){init(vs);}
  RollingHash(string &s){
    vector<T> vs;
    for(char c:s) vs.emplace_back(c);
    init(vs);
  }
  void init(vector<T> vs){
    int n=vs.size();
    hash.assign(n+1,0);
    po.assign(n+1,1);
    for(int i=0;i<n;i++){
      hash[i+1]=((ll)hash[i]*B+vs[i])%MOD;
      po[i+1]=(ll)po[i]*B%MOD;
    }
  }
  //S[l, r)
  T find(int l,int r){
    T res=(ll)hash[r]+MOD-(ll)hash[l]*po[r-l]%MOD;
    return res>=MOD?res-MOD:res;
  }
};

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n;
  cin>>n;
  auto ss=read<string>(n);

  auto cmp=[](string a,string b){return a.size()<b.size();};
  sort(ss.begin(),ss.end(),cmp);

  using ll = long long;
  const int MOD1 = 987678253;
  const int MOD2 = 998244353;
  const int B1 = 1777771;
  const int B2 = 1775777;

  unordered_map<ll, int> cnt;
  cnt.reserve(1e6+1000);
  auto P=[&](ll x,ll y)->ll{return (x<<31)|y;};

  ll ans=0;
  for(string s:ss){
    RollingHash<int, MOD1, B1> rh1(s);
    RollingHash<int, MOD2, B2> rh2(s);
    int n=s.size();
    vector<int> occ(26,n);
    for(int i=0;i<n;i++)
      chmin(occ[s[i]-'a'],i);

    // [i, n)
    for(int i=n;i>0;i--){
      ll hsh=P(rh1.find(i,n),rh2.find(i,n));
      if(!cnt.count(hsh)) continue;
      int bit=cnt[hsh];
      // cerr<<"bit:"<<bit<<endl;
      // cerr<<occ[2]<<' '<<i<<endl;
      for(int j=0;j<26;j++){
        if((~bit>>j)&1) continue;
        if(occ[j]<i) ans++;
      }
    }
    ll hsh=P(rh1.find(1,n),rh2.find(1,n));
    cnt[hsh]|=1<<(s[0]-'a');
    // cerr<<hsh<<endl;
  }

  cout<<ans<<newl;
  return 0;
}


Measured memory_bytes: 36708
#include<cstdio>
int main()
{
	int n,t[100005],m,p,x,sum,sum2;
	while(scanf("%d",&n)!=EOF)
	{
		sum=0;
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&t[i]);
			sum=sum+t[i];
		}
		scanf("%d",&m);
		for(int j=1;j<=m;j++)
		{
			scanf("%d",&p);
			scanf("%d",&x);
			sum2=sum+x-t[p];
			printf("%d\n",sum2);
		}
 
	}
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

class KnapsackBBSolver {
 private:
  using P = pair<ll, ll>;
  ll W, best;
  vector<P> ps;

 public:
  KnapsackBBSolver(ll W_) : W(W_) {}

  void addItem(ll v, ll w, ll m) {
    ll num = m;
    for (ll k = 1; num > 0; k <<= 1) {
      ll mul = min(num, k);
      if (mul * w > W) break;
      ps.emplace_back(mul * v, mul * w);
      num -= mul;
    }
  }

  ll solve() {
    optimize();
    best = 0;
    dfs(0, 0, W);
    return best;
  }

 private:
  void optimize() {
    sort(ps.begin(), ps.end(), [&](const P& a, const P& b) {
      auto x = __int128(a.fst) * b.snd;
      auto y = __int128(b.fst) * a.snd;
      return x > y;
    });
  }

  pair<ll, bool> upper_bound(int i, ll W) {
    ll res = 0;
    bool integer = true;
    for (; i < ps.size() && W > 0; i++) {
      if (ps[i].snd > W) {
        res += __int128(ps[i].fst) * W / ps[i].snd;
        integer = false;
      } else {
        res += ps[i].fst;
      }
      W -= ps[i].snd;
    }
    return make_pair(res, integer);
  }

  void dfs(int i, ll V, ll W) {
    if (W < 0) return;
    if (i >= ps.size()) {
      if (V > best) best = V;
      return;
    }
    auto ub = upper_bound(i, W);
    if (V + ub.fst <= best) return;
    if (ub.snd) {
      best = V + ub.fst;
      return;
    }
    dfs(i + 1, V + ps[i].fst, W - ps[i].snd);
    dfs(i + 1, V, W);
  }
};

int main() {
  int N;
  ll X, D;
  while (cin >> N >> X >> D) {
    vector<ll> m(N);
    cin >> m[0];
    vec<int, 2> G(N);
    for (int i = 1; i < N; i++) {
      int p;
      cin >> m[i] >> p;
      --p;
      G[p].push_back(i);
    }
    vector<int> sz(N);
    vector<ll> msum(N);
    function<void(int)> dfs = [&](int v) {
      sz[v] = 1;
      msum[v] = m[v];
      for (int u : G[v]) {
        dfs(u);
        sz[v] += sz[u];
        msum[v] += msum[u];
      }
    };
    dfs(0);
    KnapsackBBSolver solver(X);
    for (int i = 0; i < N; i++) {
      ll lim = D;
      if (i == 0) lim = X / msum[0];
      solver.addItem(sz[i], msum[i], lim);
    }
    cout << solver.solve() << endl;
  }
  return 0;
}


Measured memory_bytes: 384
import sys

import math
def gcd(a,b):
	if a == 0:
		return b
	return gcd(b%a,a)

def solve(n):
	return n%9

def main():
	n = int(input())
	res = solve(n)
	if res == 0:
		print("Yes")
	else:
		print("No")
if __name__ == "__main__":
	main()


	


Measured memory_bytes: 74128
N, K, S = map(int, input().split())

INF = 10 ** 9
ans = [0] * N
if S == INF:
    for i in range(N):
        if i < K:
            ans[i] = S
        else:
            ans[i] = S - 1
else:
    for i in range(N):
        if i < K:
            ans[i] = S
        else:
            ans[i] = INF
    
print(' '.join(map(str, ans)))

Measured memory_bytes: 66284
#include <bits/stdc++.h>
using namespace std;
#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<n;i++)
int main(void){
    int n;
    cin>>n;
    rep(lp,n){
        string s; cin>>s;
        set<string> st;
        for(int i=1;i<s.length();i++){
            string a=s.substr(0,i);
            string b=s.substr(i);
            string ra=a; reverse(all(ra));
            string rb=b; reverse(all(rb));
            st.insert(a+b);
            st.insert(a+rb);
            st.insert(ra+b);
            st.insert(ra+rb);
            st.insert(b+a);
            st.insert(b+ra);
            st.insert(rb+a);
            st.insert(rb+ra);
        }
        cout<<st.size()<<endl;
    }
}

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

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    rep(i, n - 2)
    {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np
MOD = 10**9 + 7

def fft_convolve(f, g):
  Lf, Lg = f.shape[-1], g.shape[-1]
  L = Lf + Lg - 1
  fft_len = 1 << L.bit_length()
  fh, fl = f >> 15, f & (1 << 15) - 1
  gh, gl = g >> 15, g & (1 << 15) - 1
  def conv(f, g):
    Ff = np.fft.rfft(f, fft_len)
    Fg = np.fft.rfft(g, fft_len)
    h = np.fft.irfft(Ff * Fg)
    return np.rint(h)[..., :L].astype(np.int64) % MOD
  x = conv(fl, gl)
  z = conv(fh, gh)
  y = conv(fl + fh, gl + gh) - x - z
  return (x + (y << 15) + (z << 30)) % MOD

s = input()
x, y = map(int, input().split())

Rob = list(s.split("T"))

X = [len(r) for r in Rob[::2]]
Y = [len(r) for r in Rob[1::2]]

Xst = X[0]
X = X[1:]

if abs(x-Xst) <= sum(X) and abs(y) <= sum(Y):
  f = np.array([1], np.int64)
  for i in X:
    L = [0]*(2*i+1)
    L[0], L[-1] = 1, 1
    f = np.convolve(f, np.array(L, np.int64))
  FlagX = f[abs(x-Xst)+sum(X)]

  g = np.array([1], np.int64)
  for j in Y:
    L = [0]*(2*j+1)
    L[0], L[-1] = 1, 1
    g = np.convolve(g, np.array(L, np.int64))
  FlagY = g[abs(y)+sum(Y)]

  if FlagX and FlagY:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Measured memory_bytes: 27572
#include <stdio.h>

void REV_print(int n, int a[])
{
    int i;
    for (i=n-1; i>=0; i--)
    {
        printf("%d", a[i]);
        if(i==0)
        {
            printf("\n");
        }
        else
        {
            printf(" ");
        }
    }
}

int main()
{
	int i,n,a[100];

	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
	    scanf("%d", &a[i]);
	}

	REV_print(n, a);
	return 0;
}



Measured memory_bytes: 2068
def da(Y,M,D):
    day = (Y / 3) * 590
    if Y % 3 == 0:
        day = day - 200 + (M - 1)*20 + D
    else:
        day = day + (Y%3 - 1) * 195
        if M%2 == 1:
            day = day + (M/2 * 39) + D
        else:
            day = day + (M/2 - 1) * 39 + 20 + D
        
        
    return day
n = int(raw_input())
for i in range(n):
        l = map(int,raw_input().split())
        Y = l[0]
        M = l[1]
        D = l[2]
        print da(1000,1,1) - da(Y,M,D)

Measured memory_bytes: 6432
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;

    int reverse = 0;
    int tmp, remaind;

    tmp = n; 
    while (tmp != 0) {
        remaind = tmp % 10;
        reverse = reverse * 10 + remaind;
        tmp /= 10;
    }

    if (n == reverse) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
ll MOD=1000000007;
int inf=1000000000;
ll INF=10000000000000000;
int main(){
    int n;
    cin >> n;
    map<int,int> m;
    vector<int> a(n);
    rep(i,n){
        cin >> a.at(i);
        m[a.at(i)]++;
    }
    int k=pow(2,30);
    int ans=0;
    rep(i,31){
        rep(j,n){
            auto it=m.find(k-a.at(n-1-j));
            if (it!=m.end()){
                if (m[k-a.at(n-1-j)]!=0 && m[a.at(n-1-j)]!=0 && (a.at(n-1-j)!=k-a.at(n-1-j) || m[a.at(n-1-j)]>1)){
                m[k-a.at(n-1-j)]--;
                m[a.at(n-1-j)]--;
                ans++;
                //cout << a.at(j) << endl;
                }
            }
        }
        k/=2;
    }
    cout << ans << endl;
}

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

int a, b;
int n;

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

    for (int i = 1; i < 10; ++i) {
        if (n % i != 0) {
            continue;
        }
        b = n / i;
        if (b <= 9) {
            cout << "Yes" << endl;
            break;
        }
    }
    if (b >= 10) {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Z 15000000
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;int n,m,a,b,c[15],t,he,ta,an,v[Z],w[Z];bool vis[Z];void BFS(int x,int l){if(vis[x])return;if(l==m)return;if(x==0||x==t){an=l;return;}vis[x]=1;int d[3]={-1},e=x,f=0,g=1;while(1){d[e%3]=max(d[e%3],g);e/=3,f++,g*=3;if(f==n)break;}if(d[0]>d[1]){e=x+d[0];if(!vis[e])v[ta]=e,w[ta]=l+1,ta++;}if(d[0]<d[1]){e=x-d[1];if(!vis[e])v[ta]=e,w[ta]=l+1,ta++;}if(d[1]>d[2]){e=x+d[1];if(!vis[e])v[ta]=e,w[ta]=l+1,ta++;}if(d[1]<d[2]){e=x-d[2];if(!vis[e])v[ta]=e,w[ta]=l+1,ta++;}return;}int main(){while(1){cin>>n>>m;if(!n&&!m)break;rep(i,3){cin>>a;rep(j,a)cin>>b,c[b-1]=i;}int o=0,p=1;rep(i,n)o+=p*c[i],p*=3;t=p-1,he=0,ta=1,an=-1,v[0]=o,w[0]=0;rep(i,Z)vis[i]=false;while(true){if(ta==he)break;BFS(v[he],w[he]);if(an!=-1)break;he++;}cout<<an<<endl;}return 0;}

Measured memory_bytes: 37288
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807;
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
#define bool    _Bool
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }


int main() {
	int N;
	scanf("%d", &N);
	int *A = (int *)malloc(sizeof(int)*N + 1);
	A[N + 1] = 0;
	int i = 0, j = 0;
	for (i = i; i < N; i++) {
		scanf("%d", &A[i]);
	}
	qsort(A, N, sizeof(int), cmp);
	int cnt = 1, ans = 0;
	for (i = 0; i < N; i++) {
		//printf("%d\n", A[i]);
		if (A[i] == A[i + 1]) {
			cnt++;
		}
		else if (cnt % 2 == 1) {
			ans++;
			cnt = 1;
		}
		else {
			cnt = 1;
		}
	}
	printf("%d\n", ans);


#ifdef DEBUGF
	getch();
#endif
	return 0;
}

Measured memory_bytes: 892
/*Template by hemnath_d(Enlightened by chamow)*/
#include<bits/stdc++.h>
using namespace std;
/*--------------------------------------------------------------*/
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<int> vi;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
/*--------------------------------------------------------------*/
#define fastread ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fx first
#define sx second
#define forw(i,a,n) for(i=a;i<=n;i++)
#define rev(i,a,n) for(i=a;i>=n;i--)
#define For(i,a,n) for(i=a;i<n;i++)
#define Rev(i,a,n) for(i=a;i>n;i--)
#define inf 100000000000000
#define minf -100000000000000
/*--------------------------------------------------------------*/
//Function to add an edge for graph
//Undirected graph
void add_edge(vec adj[],ll a,ll b)
{
    adj[a].pb(b);
    adj[b].pb(a);
}
/*---------------------------------------------------------------*/
//Comparator class for min-heap using priority_queue
//Change the parameters before use
class myComparator
{
public:
    int operator() (/*Datatype*/int p1,/*Datatype*/int  p2)
    {
        return p1/*value*/ > p2/*value*/;
    }
};
/*----------------------------------------------------------------*/
//END OF TEMPLATE
/*----------------------------------------------------------------*/
int main()
{
    fastread;
    ll n;
    vec arr;
    cin>>n;
    ll i,val;
    For(i,0,n)
    {
        cin>>val;
        arr.pb(val);
    }
    bool flag=false;
    ll ans=0;
    while(1)
    {
        For(i,0,n)
        {
            if(arr[i]%2==1||arr[i]==0)
                flag=true;
            arr[i]/=2;
        }
        if(flag==true)
            break;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}


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

int dp[(int)2e5][3];

int main(){
    string s;
    cin >> s;
    if (s.size() == 1){
        cout << 1 << endl;
        return 0;
    }
    //分割後の大きさはたかだか3個になるはず

    //もらうdpをする
    //0番目までの選び方は、0番目のみを選ぶ方法のみ
    dp[0][0] = 1;
    //1番目までの選び方は、0番目と1番目が異なれば、2つに分割できる
    if (s[0] != s[1]) dp[1][0] = 2;
    dp[1][1] = 1;
    if (s.size() == 2){
        cout << max(dp[s.size() - 1][0], dp[s.size() - 1][1]) << endl;
        return 0;
    }
    //2番目までの選び方
    int i = 2;
    for (int j = 0; j < 2; j++){
        //i - j番目までの部分文字列の長さをk - 1とする
        for (int k = 0; k < 2; k++){
            if (j != k){
                if (dp[i - j - 1][k] != 0) dp[i][j] = max(dp[i][j], dp[i - j - 1][k] + 1);
            }
            else{
                bool flag = false;
                for (int l = 0; l <= k; l++) if (s[i - j - l - 1] != s[i - l]) flag = true;
                if (flag && dp[i - j - 1][k] != 0) dp[i][j] = max(dp[i][j], dp[i - j - 1][k] + 1);
            }
        }
    }
    dp[2][2] = 1;
    //dp[i]を更新する
    for (int i = 3; i < s.size(); i++){
        //i番目を終点とする部分文字列の長さをj - 1とする
        for (int j = 0; j < 3; j++){
            //i - j番目までの部分文字列の長さをk - 1とする
            for (int k = 0; k < 3; k++){
                if (j != k){
                    if (dp[i - j - 1][k] != 0) dp[i][j] = max(dp[i][j], dp[i - j - 1][k] + 1);
                }
                else{
                    bool flag = false;
                    for (int l = 0; l <= k; l++) if (s[i - j - l - 1] != s[i - l]) flag = true;
                    if (flag && dp[i - j - 1][k] != 0) dp[i][j] = max(dp[i][j], dp[i - j - 1][k] + 1);
                }
            }
        }
    }
    cout << max({dp[s.size() - 1][0], dp[s.size() - 1][1], dp[s.size() - 1][2]}) << endl;
}

Measured memory_bytes: 2948
#include <stdio.h>
#define INF 5300000

int main(){

  int t,i,n,p[500],m[500][500];
  int minm=INF,l=0,j=0,k=0,q=0;
 
 scanf("%d",&n);

   for( i = 0; i < n; i++){
    scanf("%d%d",&p[i],&p[i+1]);
  }
  for( i = 1; i <= n; i++){
    m[i][i] = 0;
     
  }
  for( l = 2; l < n+1; l++){
 
    for( i = 1; i<n-l+2; i++){
      j = i+l-1;
      m[i][j] = INF;
 
     for( k = i; k < j; k++){
    q = m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
      
    if(q <= m[i][j]){
      m[i][j] = q;
 
    }
      }
    }
}
  printf("%d\n",m[1][n]);
  return 0;
}



Measured memory_bytes: 2056
#include<iostream>
#include<algorithm>>
using namespace std;
static const int MAX = 200000;

int main(){
	int R[MAX], n;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> R[i];
	}

	int maxv = -2000000000;
	int minv = R[0];

	for (int i = 1; i < n; i++) {
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}
	cout << maxv << endl;
	return 0;
}



Measured memory_bytes: 3888
use proconio::{fastout, input};

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[fastout]
fn main() {
    input! {
        a: usize,
        b: usize,
        x: usize,
    }

    let mut ans = "";
    if a <= x && x <= a + b {
        ans = "YES"
    } else {
        ans = "NO"
    }
    println!("{}", ans);
}


Measured memory_bytes: 2188
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    summation = 0
    tallest = A[0]
    for a in A[1:]:
        if a > tallest:
            tallest = a
        else:
            diff = tallest - a
            summation += diff

    print(summation)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using edge = pair<ll, P>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
using Graph = vector<vector<ll>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

vector<ll> divisor(ll N) {
    vector<ll> res;
    for (ll i = 1L; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            ll j = N / i;
            if (j != i)  {
                res.push_back(j);
            }
        }
    }
    sort(res.begin(), res.end());
    return res;
}


void Main() {
    ll N;
    cin >> N;
    vector<ll> divisors = divisor(N);
    int n = (int) divisors.size();
    ll ans = N - 1;
    rep(i, n) {
        ll x = divisors[i];
        ll y = N / x;
        ans = min(ans, x + y - 2);
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds;
using namespace std;

typedef long long int lli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef vector<pii> vii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> OrderedSet;

const int MOD	= 1e9 + 7;
const double PI = acos(-1.0);

#define fastio			ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto &i : c)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define fill(a)  memset(a, 0, sizeof (a))
#define error(x) cerr << #x << " = " << (x) << endl
#define errorp(p) cerr << #p << " = " << (p.first) << ", " << (p.second) << endl

template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }
int mul(int a, int b, int c){lli res=(lli)a*b;return (int)(res>=c?res%c:res);}
template<typename T>T power(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}
template <class T>  inline void smax(T &x,T y){ x = max((x), (y));}
template <class T>  inline void smin(T &x,T y){ x = min((x), (y));}

int main(){
    // #ifndef ONLINE_JUDGE
	// 	freopen("test", "r", stdin);
	// #endif
    fastio;
    

    int N, K, C;
    string S;

    cin >> N >> K >> C;
    cin >> S;

    vi dpl(N, 0), dpr(N, 0);

    rep(i, N){
        if(S[i] == 'o'){
            dpl[i] = 1 + (i - C - 1 < 0 ? 0 : dpl[i - C - 1]);
        }else{
            dpl[i] = dpl[i - 1];
        }
    }

    repD(i, N - 1, 0){
        if(S[i] == 'o'){
            dpr[i] = 1 + (i + C + 1 >= N ? 0 : dpr[i + C + 1]);
        }else{
            dpr[i] = dpr[i + 1];
        }
    }

    // tr(dpl, c){
    //     cout << c << " ";
    // }
    // cout << endl;

    //  tr(dpr, c){
    //     cout << c << " ";
    // }
    // cout << endl;

    vi ans;
    rep(i, N){
        if(S[i] == 'o'){
            int work = 1;
            work += (i > 0 ? dpl[i - 1] : 0);
            work += (i < N - 1 ? dpr[i + 1] : 0);
            if(work == K){
                ans.pb(i + 1);
            }
        }
    }

    tr(ans, x){
        cout << x << endl;
    }

    return 0;
}


Measured memory_bytes: 4236
#include <iostream>
#include <vector>
#include<algorithm>
#define mod 998244353;
using namespace std;
typedef long long ll;
int main(void){
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    int size=*max_element(v.begin(), v.end());
    vector<int> index(size+1,0);
    for(int i=0; i<n; i++){
        index[v[i]]++;
    }
    if(v[0] !=0 || index[0] != 1){
        cout << "0";
        return 0;
    }
    ll sum = 1;
    for(int i = 2; i< index.size(); i++){
        for(int j = 0; j <index[i]; j++){
            sum *=index[i-1];
            sum%=mod;
        }
    }
    cout << sum << endl;
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    string S;
    cin >> S;
    REP(i, S.length() - 8)
    {
        cout << S[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int n, m;
  
  scanf("%d%d", &n, &m);
  if(n == 1 && m == 1){
    printf("0\n");
  }else if(m < 2){//偶数のみから２つ
  	printf("%d\n", n * (n - 1) / 2);
  }else if(n < 2){//奇数のみから２つ
    printf("%d\n", m * (m - 1) / 2);
  }else if(n > 1 && m > 1){//全てあり
    printf("%d\n", n * (n - 1) / 2 + m * (m - 1) / 2);
  }
  
  return 0;
}

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

int main(void)
{
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    int c = 0;
    for (int i = 0; i < n; i++) {
        if (p[i] != i+1) c++;
    }
    if (c <= 2) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}



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

using namespace std;

int N, K;
long long sum = 0;

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

    for (int b = 1; b <= N;b++)
    {
        int q = N / b;
        int r = N % b;
        sum += q * max(0, b - K);
        sum += max(0, r - K + 1);
    }

    if (K == 0)
    {
        sum -= N;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check();


bool cmp(pair<int,int>p,pair<int,int>q) {
    // return p.first>q.first;//descending by first
    // return p.first<q.first;//ascending by first
    // return p.second>q.second;//descending by second
    return p.second<q.second;//ascending by second
}

// bool cmp(int p,int q) {
    // return p>q;//descending
    // return p<q;//ascending
// }


int main() {

    int t;
    // cin>>t;
    t=1;
    while(t-->0) {
        clue();
    }

    return 0;
}
int clue() {

    int a[50]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    cout<<a[k-1]<<endl;

    // ()?cout<<"Yes"<<endl:cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//.\a.exe

int main(void){ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////////////////
int x,y,z;
cin >> x >> y >> z;
cout << (x-z)/(y+z) << endl;

////////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>
#include<bitset>
#include<string>
#include<iostream>
#include<vector>
#include<string.h>
#include<algorithm>
using namespace std;


int main()
{
    int ans=0,a,b,plag=1;
    cin>>a>>b;

    while(plag<b){
        plag+=a-1;
        ans++;
    }
    cout<<ans<<endl;
    
    return 0;
}


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

int top, S[1000];
void push(int);
int pop();

int main(){
  int x, y;
  char s[100];

  top = 0;

  while(scanf("%s", s) != EOF){
    if(s[0] ==  '+'){
      x = pop();
      y = pop();
      push(x + y);
    }else if(s[0] == '-'){
      y = pop();
      x = pop();
      push(x - y);
    }else if(s[0] == '*'){
      x = pop();
      y = pop();
      push(x * y);
    }else{
      push(atoi(s));
    }
  }
  printf("%d\n", pop());
  
  return 0;
}

void push(int x){
  top++;
  S[top] = x;
}

int pop()
{
  top--;
  return S[top+1];
}

Measured memory_bytes: 548
import heapq as hp
n = int(input())
X = list(map(int,input().split()))
min1=[]
a=min(X)
b=max(X)
for i in range(a,b+1):
    total=[]
    for j in X:
        total.append(abs(j-i)**2)
    else:
        ans=sum(total)
        hp.heappush(min1,ans)
print(hp.heappop(min1))


Measured memory_bytes: 3060
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

N = int(input())

A = []
for i in range(N):
    A.append(int(input()))

AA = Counter(A)

B = sorted(AA.items(), key=lambda x:x[0])

if B[-1][1] == 1:
    c = B[-2][0]
else:
    c = B[-1][0]

M = B[-1][0]

for i in range(N):
    if A[i] == M:
        print(c)
    else:
        print(M)




Measured memory_bytes: 111896
/*
********************
Author : Sahil Kundu
********************
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mod 1000000007
#define pb(i) push_back(i)
#define f first
#define s second
#define mk(l,r) make_pair(l,r)
#define vi vector<int>
#define vl vector<ll>
#define vch vector<char>
#define all(vc) vc.begin(),vc.end()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ms(i,j) memset(i,j,sizeof i)
#define w(t) while(t--)
#define len(s) s.length()
#define rep(i,n) for(ll i=0;i<(n);++i)
#define repA(i,a,n) for(ll i=a;i<=(n);++i)
#define repD(i,a,n) for(ll i=a;i>=(n);--i)
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
#define PI       3.14159265358979323846
#define fastIO ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
const ll MAX=1e5+5;
const ll INF=2e18;

#define INPUT_OUTPUT {\
	freopen("input.txt","r",stdin);\
	freopen("output.txt","w",stdout);\
}

// logical code of program starts here.
void solve()
{
    int n;
    cin>>n;
    int dp[n+1][3]={0};
    rep(i,n+1)
    {
        if(!i)continue;
        int a,b,c;
        cin>>a>>b>>c;
        dp[i][0]=max(dp[i-1][1]+b,dp[i-1][2]+c);
        dp[i][1]=max(dp[i-1][0]+a,dp[i-1][2]+c);
        dp[i][2]=max(dp[i-1][1]+b,dp[i-1][0]+a);
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;
}


// mian function 
int main()
{
    //INPUT_OUTPUT;//file handling
    fastIO;// fast input output
    clock_t start, end; 
    start = clock();
    int t;
    t=1;
    //cin>>t;
    w(t) solve();
    end = clock();   
    double time_taken = double(end - start)/double(CLOCKS_PER_SEC); 
    clog << "Time taken by program is : " << fixed 
    << time_taken << setprecision(5); 
    clog << " sec " << endl;
    return 0;
}

Measured memory_bytes: 4960
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iostream>
#include <set>
#include <string>
#include <unordered_map>

using namespace std;

void bubble_sort(deque<int> values, int n) {
  bool flag = true;
  int cnt = 0;

  while (flag) {
    flag = false;

    for (int i = n - 1; i >= 1; i--) {
      if (values[i] < values[i - 1]) {
        int tmp;

        tmp = values[i - 1];
        values[i - 1] = values[i];
        values[i] = tmp;

        flag = true;
        cnt++;
      }
    }
  }

  // print
  for (int i = 0; i < n - 1; i++) {
    cout << values[i] << " ";
  }
  cout << values[n - 1] << endl;

  cout << cnt << endl;
}

int main() {
  int n;
  deque<int> values;

  cin >> n;

  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    values.push_back(tmp);
  }

  bubble_sort(values, n);

  return 0;
}


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

using namespace std;

int main(void){
    vector<int> a;
    int N;
    int Alice=0;
    int Bob=0;

    cin>>N;

    

    for(int i=0;i<N;i++){
        int input;
        cin>>input;
        a.push_back(input);
    }

    sort(a.rbegin(),a.rend());

    for(int i=0;i<N;i++){
        if(i%2==0){
            Alice+=a[i];
        }else{
            Bob+=a[i];
        }
    }

    cout<<Alice-Bob;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<ctime>
#define INF 1e9
using namespace std;
const int maxn=110;
int n,x[maxn],minn=INF;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&x[i]);
	for(int p=1;p<=100;p++)
	{
		int sum=0;
		for(int i=1;i<=n;i++)
			sum+=(x[i]-p)*(x[i]-p);
		minn=min(minn,sum);
	}
	printf("%d",minn);
	return 0;
}

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

int main() {
  long long W, H, x, y;
  cin >> W >> H >> x >> y;
  double ans1 = (double)(W) * H / 2;
  cout << fixed << setprecision(10) << ans1 << " ";

  if (x * 2 == W && y * 2 == H) cout << 1 << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 256
#include <fstream>
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <cstdlib>

using namespace std;

int num[(1 << 26)];
int cur = 0;
signed main(){
    memset(num, -1, sizeof(num));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s;
    cin >> s;
    num[0] = 0;
    for (int i = 0; i < s.size(); i++){
        cur ^= 1 << (s[i] - 'a');
        for (int i = 0; i < 26; i++){
            int mask = cur ^ (1 << i);
            if (num[mask] == -1)
                continue;
            if (num[cur] == -1)
                num[cur] = num[mask] + 1;
            else
                num[cur] = min(num[cur], num[mask] + 1);
        }
    }
    if (cur == 0)
        cout << 1;
    else
        cout << num[cur];
}


Measured memory_bytes: 262864
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#include<iomanip>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll>P;

int main()
{
    int n;
    cin>>n;
    vector<P> ab(n);
    rep(i,n)
    {
        cin>>ab[i].first>>ab[i].second;
    }
    ll ans=0;
    ll total=0;
    for(ll i=n-1;i>=0;i--)
    {
        ll c=(ab[i].first+total)%ab[i].second;
        ll add=0;
        if(c==0)
        {
            add=0;
        }
        else
        {
            add=ab[i].second-c;
        }
        
        ans+=add;
        total+=add;
    }
    cout<<ans;


}

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

int main() {
  string s, t;
  cin >> s >> t;
  vector<vector<int>> dp(s.size()+1, vector<int>(t.size()+1, 0));
  for (int i = 0; i < s.size(); i++) {
    for (int j = 0; j < t.size(); j++) {
      if (s.at(i) == t.at(j)) {
        dp.at(i+1).at(j+1) = max(dp.at(i+1).at(j+1), dp.at(i).at(j) + 1);
      }
      dp.at(i+1).at(j+1) = max(dp.at(i+1).at(j+1), dp.at(i+1).at(j));
      dp.at(i+1).at(j+1) = max(dp.at(i+1).at(j+1), dp.at(i).at(j+1));
    }
  }
  string ans = "";
  int i = s.size();
  int j = t.size();
  while (i > 0 && j > 0) {
    if (dp.at(i).at(j) == dp.at(i-1).at(j)) i--;
    else if (dp.at(i).at(j) == dp.at(i).at(j-1)) j--;
    else {
      ans = s.at(i-1) + ans;
      i--;
      j--;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

#define INF (1<<(4*4-1))
#define MOD 1000000007

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

   int N;
   int A,B;
   cin>>N>>A>>B;
   vector<int>P(N);
   for(int i=0;i<N;i++)cin>>P[i];
   int one = 0;
   int two = 0;
   int three = 0;
   for(int i=0;i<N;i++){
      if(P[i]<=A)one++;
      else if(A<=P[i]&&P[i]<=B)two++;
      else if(B<P[i])three++;
   }
   cout<<min(min(one,three),two)<<endl;

   /*
   int H,W;
   cin>>H>>W;
   vector<>
   */
   return 0;
}


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

#define SENTINEL 1000000000000000000

void merge(long long A[], long long B[], long long left, long long mid, long long right){
  long long n1, n2, i, j, k;
  long long *L,*R, *Lb, *Rb;
  
  n1 = mid-left;
  n2 = right-mid;
  
  L = (long long*)malloc(sizeof(long long) *(n1 + 1));
  R = (long long*)malloc(sizeof(long long) *(n2 + 1));
  Lb = (long long*)malloc(sizeof(long long) *(n1 + 1));
  Rb = (long long*)malloc(sizeof(long long) *(n2 + 1));
  
  for(i = 0; i <= n1 - 1; i++){
    L[i] = A[left + i];
    Lb[i] = B[left + i];
  }
  for(j = 0; j <= n2 - 1; j++){
    R[j] = A[mid + j];
    Rb[j] = B[mid + j];
  }
  
  L[n1] = SENTINEL;
  R[n2] = SENTINEL;
  Lb[n1] = SENTINEL;
  Rb[n2] = SENTINEL;
  
  i = 0;
  j = 0;
  
  for(k = left; k <= right - 1; k++){
   if(L[i] <= R[j]){
      A[k] = L[i];
      B[k] = Lb[i];
      i++;
    }
    else{
      A[k] = R[j];
      B[k] = Rb[j];
      j++;
    }
  }
  free(L);
  free(R);
  free(Lb);
  free(Rb);
}

void mergeSort(long long A[], long long B[], long long left, long long right){
  long long mid;
  
  if(left + 1 < right){
    mid=(left + right)/2;
    mergeSort(A,B, left, mid);
    mergeSort(A,B, mid, right);
    merge(A,B, left, mid, right);
  }
}

int main(void){

    int N;

    scanf("%d", &N);

    long long X[N];
    long long n[N];

    for(int i = 0; i < N; i++){
        scanf("%lld", &X[i]);
        n[i] = i;
    }

    long long B[N];

    mergeSort(X, n, 0, N);

    for(int i = 0; i < N; i++){
        if(i <= N / 2 - 1){
            B[n[i]] = X[N / 2];
        }else{
            B[n[i]] = X[N / 2 - 1];
        }
    }

    for(int i = 0; i < N; i++){
        printf("%lld\n", B[i]);
    }

    return 0;
}

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

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

    int ans = 0;
    int nownum = 1;
    for(int i = 0; i < n; i++){
        if(a[i] == nownum){
            nownum++;
        }else{
            ans++;
        }
    }

    if(ans == n) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,max_a=0,cnt=0,h;
  cin >> n >> h;
  ll a[n],b[n];
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
    max_a=max(a[i],max_a);
  }
  sort(b,b+n,greater<ll>());
  for(int i=0;i<n;i++){
    if(h<=0){
      break;
    }
    if(max_a<=b[i]){
      cnt++;
      h-=b[i];
    }else{
      break;
    }
  }
  if(h>=0){
    cnt += (h+max_a-1)/max_a;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 1792
s=input()

mae=int(s[:2])
ushiro=int(s[2:])

if 1<=mae<=12:
    if 1<=ushiro<=12:
        ans="AMBIGUOUS"
    else:
        ans="MMYY"

elif 1<=ushiro<=12:
    ans="YYMM"

else:
    ans="NA"
    
print(ans)

Measured memory_bytes: 9080
s = list(map(int, input()))
ans = 0
for i in range(2):
    for j in range(2):
        for k in range(2):
            if i == 0:
                c = s[0] + s[1]
            else:
                c = s[0] - s[1]
            if j == 0:
                c += s[2]
            else:
                c -= s[2]
            if k == 0:
                c += s[3]
            else:
                c -= s[3]    
            if c == 7:
                ans = [i, j, k]
                
for i in range(3):
    print(str(s[i]), end = "")
    if ans[i] == 0:
        print("+", end = "")
    else:
        print("-", end = "")
print(str(s[3]) + "=7")

Measured memory_bytes: 3064
n,k=map(int,input().split())
l=[0]*(k+1)
a=0
mod=10**9+7
for i in range(1,k+1):
  l[i]+=i
  for j in range(i*2,k+1,i):
    l[j]-=l[i]
  a+=l[i]*pow(k//i,n,mod)
print(a%mod)


Measured memory_bytes: 12840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef complex <double> cp;
#define debug(a) cout<<#a<<":"<<a<<endl;
#define fr freopen("in.txt","r",stdin);
#define Fill(x,a) memset(x,a,sizeof(x))
#define cpy(a,b) memcpy(a,b,sizeof(a))
const double PI = acos(-1);
const ll INF=0x3f3f3f3f;
const ll N=1e6+7;
const ll mod=1e9+7;
ll maxn,minn;
ll T,n,m,q;
ll inv[N]; 
ll arr[N];

int main(){
	cin >> n;
	for(ll i = 1; i <= n; i ++ ){
		scanf("%lld", arr + i);
	}
	inv[1] = 1;
	for(ll i = 2; i <= n; i ++ ){
		inv[i] = (mod - mod / i) * inv[mod % i] % mod;
	}
	for(ll i = 2; i <= n; i ++ ){
		inv[i] = (inv[i] + inv[i - 1]) % mod;
	}
	ll ans = 0;
	for(ll i = 1; i < n; i ++ ){
		ans = ans + (arr[i + 1] - arr[i]) * inv[i] % mod;
	}
	for(ll i = 1; i < n ; i ++ ){
		ans = (ans * i ) % mod;
	}
	cout << ans << endl;
	
		
	
	


	return 0;
}



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

bool cmp(pair<long long,long long>a,pair<long long,long long>b)
{
    return a.second<b.second;
}

int main()
{
    long long n;
    cin>>n;
    vector<pair<int,int> >v;
    for(int i=0;i<n;i++)
    {
        long long a,b;
        cin>>a>>b;
        v.push_back(make_pair(a-b,a+b));
    }
    sort(v.begin(),v.end(),cmp);
    long long curr=v[0].second,ans=1;
    for(long long i=1;i<n;i++)
    {
        if(curr<=v[i].first)
        {
            ans++;
            curr=v[i].second;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1400
n=int(input())
a=[0]+list(map(int,input().split()))
a+=[0]

cost=0
pre=0
for i in range(n+2):
    cost+=abs(a[i]-pre)
    pre=a[i]
#print(a,cost)
for i in range(n):
    if (a[i]-a[i+1])*(a[i+1]-a[i+2])<0:
        print(cost-2*(min(abs(a[i]-a[i+1]),abs(a[i+1]-a[i+2]))))
    else:
        print(cost)
        


Measured memory_bytes: 63340