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

using namespace std;

int64_t solve(int64_t n, int64_t k, const std::string& s) {
  std::vector<int> gs;
  gs.reserve(n);
  bool previous = false;
  int previousStart = 0;
  int i;
  for (i = 0; i < n; i++) {
    bool current = s[i] == '1';
    if (i == 0) {
      if (current) {
        gs.push_back(0);
      }
    } else {
      if ((!previous && current) || (previous && !current)) {
        gs.push_back(i - previousStart);
        previousStart = i;
      }
    }
    previous = current;
  }
  gs.push_back(i - previousStart);
  if (!previous) {
    gs.push_back(0);
  }
  assert(gs.size() % 2 == 0);
  int const gn = gs.size();
  int currentSum = 0;
  for (int i = 0; i < gn && i < 2 * k; i++) {
    currentSum += gs[i];
  }
  int ret = currentSum;
  for (int i = 2; i < gn && 2 * k + i - 1 < gn; i += 2) {
    if (i == 2) {
      currentSum -= gs[0];
      currentSum += gs[2 * k];
      currentSum += gs[2 * k + 1];
      ret = std::max(currentSum, ret);
    } else {
      currentSum -= gs[i - 3];
      currentSum -= gs[i - 2];
      currentSum += gs[i + 2 * k - 2];
      currentSum += gs[i + 2 * k - 1];
      ret = std::max(currentSum, ret);
    }
  }
  return ret;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int64_t n;
  std::cin >> n;
  int64_t k;
  std::cin >> k;
  std::string s;
  std::cin >> s;
  auto const res = solve(n, k, s);
  std::cout << res << std::endl;
  return 0;
}


Measured memory_bytes: 848
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
ll factorial(int i) {       //階乗
    if (i == 0) return 1;
    return (factorial(i - 1)) * i;
}

int main() {
    int n;
    cin >> n;
    vector<double> v(n);
    rep(i, n) cin >> v[i];
    sort(v.begin(), v.end());
    double p = (v[0] + v[1]) / 2;
    for(int i = 2; i < n; i++) p = (p + v[i]) / 2;
    cout << p << endl;
}



Measured memory_bytes: 3780
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

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() {
    string a, b;
    cin >> a >> b;
    string res;
    res = a + b;
    int ans = stoi(res);
    rep(i, 1, 1000) {
        if (i * i == ans) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main() {
  int w, h, n;
  scanf("%d %d %d", &w, &h, &n);
  int r[4] = {0, w, 0, h};
  for(int i = 0; i < n; i++) {
    int c[2], a;
    scanf("%d %d %d", &c[0], &c[1], &a);
    r[a - 1] = (a & 1 ? max(r[a - 1], c[a / 3]) : min(r[a - 1], c[a / 3]));
  }
  if(r[0] >= r[1] || r[2] >= r[3])
    printf("0\n");
  else
    printf("%d\n", (r[1] - r[0]) * (r[3] - r[2]));
}

Measured memory_bytes: 256
N=int(input())

from itertools import combinations
import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

d=make_divisors(N)

if math.sqrt(N) in d:
    d.append(int(math.sqrt(N)))

dist=float('inf')
for i in d:
    j = N//i
    if i * j ==N:
        dist = min(dist,i+j-2)

print(dist)
    

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

int main() {
  int N;
  cin>>N;
  int A=1;
  vector<int> point(N);
  for(int i=0;i<N;i++){
    cin>>point.at(i);
  }
  sort(point.begin(),point.end());
  for(int i=1;i<N;i++){
    if(point.at(i)>point.at(i-1)){
      A++;
    }
  }
  cout<<A<<endl;
}


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

/*
int nPk(int n,int k){
    k = n - k;
    int rst = 1;
    int i;
    for (i=n;i>=k+1;i--)rst*=i;
    return rst;
}
*/
int main() {
  long long N,K,rst;
  cin>>N>>K;
  rst=K;
  for(int i=1;i<N;i++)rst *=(K-1);
  cout<<rst<<endl;
  return 0;
}

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

long long int gcd(long long int m,long long int n){
	m=abs(m);
	n=abs(n);
	if(m*n==0){
		return max(m,n);
	}else {
		return gcd(min(m,n),max(m,n)%min(m,n));
	}
}

vector<long long int> pf(long long int n) {
	vector<long long int> res;
	for (long long int i = 2; i*i <= n; i++) if (n%i==0) {
		res.push_back(i);
		while (n%i==0) n /= i;
	}
	if (n!=1) res.push_back(n);
	return res;
}

int main(){
	long long int a,b;
	cin>>a>>b;
	cout<<pf(gcd(a,b)).size()+1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define repeat(i,a,b) for(int i=(a),i##__end=(b);i<i##__end;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,i##__end=(a);i>=i##__end;i--)
#define mst(a,x) memset((a),(x),sizeof(a))
#define pii pair<int,int>
#define N 500010
#define mod 2147483647
#define int ll
string s;
int a[N];
signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>s;
	int cnt,ans=0;
	cnt=0;
	repeat(i,0,s.length())a[i]=-1;
	repeat(i,0,s.length()+1){
		if(i!=s.length() && s[i]=='<'){
			a[i]=max(a[i],cnt);
			cnt++;
		}
		else{
			a[i]=max(a[i],cnt);
			cnt=0;
		}
	}
	cnt=0;
	repeat_back(i,-1,s.length()){
		if(i!=-1 && s[i]=='>'){
			a[i+1]=max(a[i+1],cnt);
			cnt++;
		}
		else{
			a[i+1]=max(a[i+1],cnt);
			cnt=0;
		}
	}
	
	repeat(i,0,s.length()+1){
		//cout<<a[i];
		//if(i!=s.length())cout<<s[i];
		ans+=a[i];
	}
	//cout<<endl;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4764
a,b,k=map(int,input().split())
tmp=0
cnt=0
for i in range(k):
    if a%2!=0:
        a=a-1
    else:
        pass
    tmp=a//2
    a=a//2
    b=b+tmp
    cnt+=1

    if cnt>=k:
        break
    if b%2!=0:
        b=b-1
    else:
        pass
    tmp=b//2
    b=b//2
    a+=tmp
    cnt+=1

    if cnt>=k:
        break

print('{} {}'.format(int(a),int(b)))


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using vec_b = vector<bool>;
using vec_str = vector<string>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back


int main()
{
    ll P, Q, R;
    cin >> P >> Q >> R;
    _PR(MIN(MIN(P+Q,Q+R),R+P));

    return 0;
}

/*



*/

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

int main(){

  int n,m,c=0,r=0;
  int a[1000],b[1000];

  cin >> n >> m;

  for(int i=0; i<m; ++i){
    cin >>a[i]>>b[i];
    if(a[i]>=b[i]) ++c;
  }

  if(c<m-1){
    for(int i=0;i<m-1;++i){
      for(int k=i+1;k<m;++k)
	if(a[i]<a[k]){
	  swap(a[i],a[k]);
	}
    }

    for(int i=0;i<m;++i){
      if(n>a[i]){
	r+=n-a[i];
	++c;
	if(c>=m-1) break;
      }
    }
  }

  cout << r << endl;
  
  
  
  return 0;
}



Measured memory_bytes: 3096
N = int(input())
p = list(map(int, input().split()))
sorted_p = sorted(p)
count = 0

for a, b in zip(p, sorted_p):
    if a != b:
        count += 1
    if count > 2:
        break

if count <= 2:
    print('YES')
else:
    print('NO')

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  ll P, Q, R;
  IN(P,Q,R);

  OUT(min(min(P+Q, Q+R), R+P));

  return 0;
}

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 drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

#define MAX_N 3000
#define INF 1001001001
struct edge{
    int from, to, cost;
};

int main() {
    int n,m,p;
    cin >> n >> m >> p;
    int d[MAX_N];
    int d2[MAX_N];
    vector<edge> edges;
    vector<edge> edges2;

    rep(i,m){
        edge e;
        cin >> e.from >> e.to >> e.cost;
        e.cost *= -1;
        e.cost += p;
        edges.push_back(e);
        edge e2;
        e2.to = e.from;
        e2.from = e.to;
        e.cost = 1;
        edges2.push_back(e2);
    }

    fill(d,d+MAX_N,INF);
    d[1] = 0;

    srep(i,1,n+1){
        rep(j,edges.size()){
            edge e = edges[j];
            if(d[e.to] > d[e.from] + e.cost){
                d[e.to] = d[e.from] + e.cost;
            }
        }
    }

    
    int tmp[n];
    rep(i,n+1){
        tmp[i] = d[i];
    }

    srep(i,1,n+1){
        rep(j,edges.size()){
            edge e = edges[j];
            if(d[e.to] > d[e.from] + e.cost){
                d[e.to] = d[e.from] + e.cost;
            }
        }
    }

    rep(i,n+1){
        if(d[i] < tmp[i] && d[i] < INF/2){
            tmp[i] = -INF;
        }
    }

    int ans = tmp[n];

    if(ans == -INF){
        cout << "-1" << endl;
        return 0;
    }

    fill(d2,d2+MAX_N,INF);
    d2[n] = 0;
    srep(i,1,n+1){
        rep(j,edges2.size()){
            edge e = edges2[j];
            if(d2[e.to] > d2[e.from] + e.cost){
                d2[e.to] = d2[e.from] + e.cost;
            }
        }
    }

    

    srep(i,1,n+1){
        if(tmp[i]==-INF && d2[i]<INF/2 && d[i]<INF/2){
            cout << "-1" << endl;
            return 0;
        }
    }

    if(ans>0){
        ans = 0;
    }else{
        ans = -ans;
    }
    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)

int main() {
  ll n; cin >> n;
  vector <ll> v(n);
  bitset <30> sum(0);
  rep(i, n) {
    cin >> v.at(i);
    bitset <30> tmp(v.at(i));
    sum = sum ^ tmp;
  }
  rep(i, n) {
    bitset <30> tmp = sum;
    bitset <30> a(v.at(i));
    tmp = tmp ^ a;
    ll res = 0;
    for (ll j = 0; j < 30; j++) {
      if (tmp.test(j)) {
        res += (ll)pow(2, j);
      }
    }
    if (i) cout << ' ' << res;
    else cout << res;
  }
  cout << endl;
}

Measured memory_bytes: 4736
#include<iostream>
#include <bits/stdc++.h>
#include<utility>
#include<algorithm>
#define int long long int
int mod=1e9+7;
#define p_b push_back
#define p_f push_front
#define P_f pop_front
#define P_b pop_back
#define m_p make_pair
#define m_t make_tuple
#define len() length()
#define sz() size()
#define u_b upper_bound
#define l_b lower_bound
#define ins insert
#define str string 
#define bitcount __builtin_popcount
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define ld long double
#define db double
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define F first
#define S second
#define T third
#define endl "\n"
#define done return 0;
#define Fill(a,n,x) fill(a,a+n,x);
// #define fill(a,val) memset(a,val,sizeof(a))
using namespace std;
typedef map<int,int> Map;
typedef pair<int,int> pr;
typedef vector<int> vec;
const int INF = 1e18;
const int MAX =2e5+10;
int power(int a,int b)
{   
    if(b==0)
    return 1;
    int num=1;
    int m=mod+2;
    while(b!=1)
    { 
        if(b%2==0)
        { 
            a*=a;
            a%=m;
            b/=2;
        }
        else
        { 
            num*=a;
            num%=m;
            b--;
        }
        
    }
    return (a*num)%m;
}
void solve()
{
	 int a,b;
     cin>>a>>b;
     cout<<a*b<<endl;

}
int32_t main()
{
    fio;
    int t;
    t=1;
    // cin>>t;
    while(t--)
    {
        solve();
    }
    done;
}

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


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

struct edge {int to; ll cost; };

int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int n;
  cin >> n;
  priority_queue<double, vector<double>, greater<double>> que;
  for(int i=0; i<n; i++){
    double v;
    cin >> v;
    que.push(v);
  }
  while(que.size()>1){
    double v1=que.top(); que.pop();
    double v2=que.top(); que.pop();
    que.push((v1+v2)/2.0);
  }
  double ans = que.top();
  cout << setprecision(15) <<  ans << endl;
  return 0;
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N, K; cin >> N >> K;
  long long H[N];
  for(int i=0; i<N; i++) cin >> H[i];
  sort(H, H+N);
  long long ans=0;
  for(int j=0; j<N-K; j++) ans+=H[j];
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define sort(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mk make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }



int main() {
	ll n;
	ll k;
	cin >> n >> k;
	vector<P> x(n);
	rep(i, n) {
		ll a, b;
		cin >> a >> b;
		x[i] = mk(a, b);
	}
	sort(x);
	rep(i, n) {
		if (k <= x[i].second) {
			cout << x[i].first << endl;
			return 0;
		}
		else {
			k -= x[i].second;
		}
	}
	return 0;
}



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

int main(){
    set<int> s;
    int q, op, x;
    cin >> q;

    while(q-- > 0){
        cin >> op >> x;
        if(op == 0){
            s.insert(x);
            cout << s.size() << endl;
        }else if(op == 1){
            cout << s.count(x) << endl;
        }else if(op == 2){
            s.erase(x);
        }
    }

    return 0;
}


Measured memory_bytes: 12432
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll unsigned long long 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main()
{
    fast;
    int t=1;
    //cin>>t;
    while(t--)
    {
      int k;
      cin>>k;
      int c=0;
      int ans=0;
      for(int i=0;i<(1000000);i++)
      {
        ans++;
        c+=7;
        //cout<<c<<endl;
        c%=k;
        c*=10;
        if(c==0)
        {
          break;
        }
      }
      if(c==0)
      {
        cout<<ans<<endl;
      }
      else
      {
        cout<<"-1"<<endl;
      }
    }
}

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

int main() {
    int a = 500 , b = 100 , c = 50;
    int x;
    int A , B , C;
    cin >> A >> B >> C;
    cin >> x;
    int ans = 0;
    for (int i = 0;i <= A; i++) {
        for (int j = 0;j <= B; j++) {
            for (int k = 0;k <= C; k++) {
                if (a*i + b*j + c*k == x) {
                    ans++;
                }
            } 
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h> 
#include<math.h>
char S[200];

 int main(){
		double A, B, H, M;
		double angle;
		double pi =acos(-1);
		double V=180;
		scanf("%lf%lf%lf%lf",&A,&B,&H,&M);
		angle=fabs(H*30-M*6+30*(M/60));
		if(angle>180)
		angle=360-angle;
		angle=angle/V;
		
		double lenth;
		lenth=A*A+B*B-2*A*B*cos(angle*pi);
		lenth=sqrt(lenth);
		printf("%.10f",lenth);
		
		
		      
 }

Measured memory_bytes: 2552
n = int(input())
a = [int(i) for i in input().split()]
x = 1
f = 0
a.sort()
for i in range(n):
    #print(a[i])
    x = x*a[i]
    if x == 0:
        print(0)
        f = 1
        break
    elif x > 1000000000000000000:
        print(-1)
        f = 1
        break
if f == 0:
    print(x)

Measured memory_bytes: 21668
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
typedef pair<int, bool> sP;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<ll> vec;

struct SegT {
private:
	int n; vector<int> node, lazy;
	const int init_c = mod;
public:
	SegT(int sz) {
		n = 1;
		while (n < sz)n <<= 1;
		node.resize(2 * n - 1, init_c);
		lazy.resize(2 * n - 1, 0);
	}
	int f(int a, int b) {
		return min(a, b);
	}
	void eval(int k, int l, int r) {
		node[k] += lazy[k];
		if (r - l > 1) {
			lazy[2 * k + 1] += lazy[k];
			lazy[2 * k + 2] += lazy[k];
		}
		lazy[k] = 0;
	}
	void add(int x, int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0)r = n;
		eval(k, l, r);
		if (r <= a || b <= l)return;
		if (a <= l && r <= b) {
			lazy[k] += x; eval(k, l, r);
		}
		else {
			add(x, a, b, k * 2 + 1, l, (l + r) / 2);
			add(x, a, b, k * 2 + 2, (l + r) / 2, r);
			node[k] = f(node[k * 2 + 1], node[k * 2 + 2]);
		}
	}
	void add(int a, int b) {
		add(1, a, b);
	}
	int query(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0)r = n;
		eval(k, l, r);
		if (r <= a || b <= l)return init_c;
		if (a <= l && r <= b)return node[k];
		else {
			int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
			int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
			return f(vl, vr);
		}
	}
	void update(int k, ll x) {
		ll z = query(k, k + 1);
		add(x - z, k, k + 1);
	}
};


void solve() {
	int n, k; cin >> n >> k;
	string s, t; cin >> s >> t;
	SegT st(n + 1);
	st.update(0, 3);
	vector<int> memo(n + 1, mod);
	if (s[0] == t[0]) {
		memo[1] = 0;
	}
	rep1(i, n - 1) {
		int val = st.query(max(i - k, 0), i);
		val = min(val, memo[i]);
		st.update(i, 2*(val/2)+3);
		if (t[i - 1] != t[i]) {
			st.add(0, i);
		}
		if (s[i] == t[i]) {
			memo[i + 1] = val;
		}
	}
	int ans = min(memo[n], st.query(n - k, n));
	cout << ans/2 << endl;
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init();
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 14696
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>

using namespace std;

#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}


int main() {

    int N;
    cin >> N;

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

    int maxV = *max_element(a.begin(), a.end());
    sort(a.begin(), a.end(), [maxV](const int &a, const int &b) {
        int s = min(a, maxV - a);
        int t = min(b, maxV - b);
        return s < t;
    });

    cout << maxV << " " << a.back() << endl;

    return 0;
}








































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

using namespace std;

constexpr int MAXN = 200000;

int A[MAXN + 2];

int main() {
	int N;
	cin >> N;
	for(int i = 0; i < N; i++) cin >> A[i];
	sort(A, A + N);
	for(int i = 1; i < N; i++)
		if(A[i - 1] == A[i])
			goto no;
	cout << "YES" << '\n';
	return 0;
no:
	cout << "NO" << '\n';
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    string s;
    cin >> s;
    sort(all(s));
    if(s[0] == s[1] && s[1] != s[2] && s[2] == s[3]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

long long dp[110][100202];
const long long INF=1LL<<60;
int h[100202][2];
int N;
long long W,weight[111],value[111];



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


rep(i,N){
cin >>weight[i] >> value[i];
}

for(int i=0;i<N;i++){
for(int sum_w=0;sum_w<=W;sum_w++){
if(sum_w-weight[i]>=0){
dp[i+1][sum_w]=max(dp[i+1][sum_w],dp[i][sum_w-weight[i]]+value[i]);
}
dp[i+1][sum_w]=max(dp[i+1][sum_w],dp[i][sum_w]);
}
}
cout << dp[N][W];

return 0;
}

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

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
	string sep = " ";
	if(v.size()) os << v[0];
	for(int i=1; i<v.size(); i++) os << sep << v[i];
	return os;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__);
#else
#define dbg(...) 
#endif

int main() {
	ios_base::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<vector<int>> graph(n);
	for(int i=0; i<m; i++){
		int u, v;
		cin >> u >> v;
		u--; v--;
		graph[v].push_back(u);
		graph[u].push_back(v);
	}

	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> que;
	que.push({0, 0});
	vector<int> dist(n, 1e9);
	while(!que.empty()){
		int d = que.top().first;
		int u = que.top().second;
		que.pop();
		if(d>=dist[u]) continue;
		dist[u] = d;

		for(int v: graph[u]){
			int nd = d+1;
			que.push({nd, v});
		}
	}

	cout << "Yes" << endl;
	for(int i=1; i<n; i++){
		int ans = -1;
		for(int v: graph[i]){
			if(dist[v]+1==dist[i]){
				ans = v;
			}
		}
		cout << ans+1 << endl;
	}

	return 0;
}


Measured memory_bytes: 13912
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <set>
#include <queue>
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)

int main() {
    int s, w;
    cin >> s >> w;
    if(w >= s) {
        cout << "unsafe" << endl;
    }
    else cout << "safe" << endl;
    return 0;
}

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

int main(){
    int n;cin >> n;
    int x[n],cnt=0;
    for(int i=0;i<n;i++){
        cin >> x[i];
    }
    for(int i=2;i<n;i++){
        if(x[i-2]==min(min(x[i-2],x[i-1]),x[i]) &&
            x[i]==max(max(x[i-2],x[i-1]),x[i]) ||
            x[i-2]==max(max(x[i-2],x[i-1]),x[i]) &&
            x[i]==min(min(x[i-2],x[i-1]),x[i]))
            cnt++;
            }
    cout << cnt << endl;
    

}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

const int INF = (int)10e9;

int main(){
  int n, m;
  while(scanf("%d%d", &n, &m) && (n|m)){
    vector<int> C(m);
    for(int i=0; i<m; i++) scanf("%d", &C[i]);
    
    vector<int> dp(256, INF);
    dp[128] = 0;
    while(n--) {
      vector<int> next(256, INF);
      int in; scanf("%d", &in);
      for(int i=0; i<256; i++){
	if(dp[i] == INF) continue;
	for(int j=0; j<m; j++){
	  int conv = i + C[j];
	  conv = min(max(conv, 0), 255);
	  int diff = (in - conv) * (in - conv);
	  next[conv] = min(next[conv], dp[i] + diff);
	}
      }
      dp = next;
    }
    
    printf("%d\n", *min_element(dp.begin(), dp.end()));
  }
  return 0;
}

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p){
    return o << "(" << p.first << ", " << p.second << ")";
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n; cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));

    for(int i=0; i<n-1; i+=2){
        if(a[i]+a[i+1] < 0){
            a[i] = -a[i];
            a[i+1] = -a[i+1];
        }
    }
    ll ans = accumulate(all(a), 0ll);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};



signed main() {
	cin.tie(nullptr);
	cout.tie(nullptr);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	
	int n;
	cin >> n;
	int a[n];
	rep(i, n) cin >> a[i];
	int ans = 0;
	sort(a, a + n);
	for(int i = 0; i < n; i++) {
		for(int j = i+1; j < n; j++) {
			for(int k = j+1; k < n; k++) {
				if(a[i] != a[j] && a[j] != a[k] && a[i]+a[j]>a[k]) ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main() {
	int n;
	cin >> n;
	int ans = 0;
	vector<int>s(n);
	rep(i, n) {
		cin >> s[i];
		ans += s[i];
	}
	if (ans % 10 != 0) {
		cout << ans << endl;
	}
	else {
		sort(all(s));
		bool flag = false;
		rep(i, n) {
			if (s[i] % 10 != 0) {
				ans -= s[i];
				flag = true;
				break;
			}
		}
		if (flag) {
			cout << ans << endl;
		}
		else {
			cout << 0 << endl;
		}
	}


}

Measured memory_bytes: 256
// cpp_console.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include <string>
#include <iostream>

using namespace std;

int main()
{
	string s;
	char h;
	int cnt = 0;
	cin >> s;
	for(int i = 0; i < s.length() - 1; ++i){
		if(s[i] != s[i +1]){
			++cnt;
		}
	}
	cout << cnt << endl;
	return 0;
}



Measured memory_bytes: 512
/*
AuThOr Gwj
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int N;
LL x;
string X;
vector<int> divisor[200000+2];
const int MOD=998244353;
LL f[200000+2];
int main(){
	fastio;
	cin>>N>>X;
	rb(i,1,N){
		for(int j=i*2;j<=N;j+=i){
			divisor[j].PB(i); 
		}
	}
	//枚举i次操作后回到k的数的个数 
	rb(i,1,N-1){
		if(2*N%i==0&&N%i!=0){
			LL mid=i/2;
			if((N/mid)%2==1){
				string t1,t2;
				t1=t2="";
				rep(j,mid){
					t1+=X[j];
					if(X[j]=='0'){
						t2+='1';
						
					}
					else{
						t2+='0';	
					}
				}
				string t3="";
				rep(j,N/i){
					t3+=t1+t2;
				}
				t3+=t1;
					int flag=0;
				if(t3>X){
//					cout<<t1<<endl;
					rl(j,mid-1,0){
						if(t1[j]=='1'){
							t1[j]--;
							t2[j]++;
							flag=1;
							break;
						}
						else{
							t1[j]++;
							t2[j]--;
						}
					}
				}	else flag=1;
//				cout<<t1<<" "<<flag<<endl;
				if(!flag) continue;
				reverse(ALL(t1));
				LL base=1;
				rep(j,t1.length()){
					f[i]+=(t1[j]-'0')*base;
					f[i]%=MOD;
					base<<=1;
					base%=MOD;
				}
				for(auto it:divisor[i]){
					f[i]-=f[it];
					f[i]+=MOD;
					f[i]%=MOD;
				}
				f[i]++;
				f[i]%=MOD;	
//				cout<<i<<" "<<f[i]<<endl;
			}
		}
	}
	reverse(ALL(X));
	LL base=1;
	x=0;
	rep(i,X.length()){
//		x<<=1;
		x+=(X[i]-'0')*base;
		x%=MOD;
		base<<=1;
		base%=MOD;
	}	
	rb(i,1,N-1){
		x-=f[i];
		x+=MOD;
		x%=MOD;
	}
	x++;
//	cout<<x<<endl;
	LL res=0;
	rb(i,1,N-1)
		res+=(LL)i*f[i],res%=MOD;
	res+=x*(N+N);
	res%=MOD;
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 22520
s=input()
n=len(s)
pattern=[]
ans=0
for i in range(2**(n-1)):
  tmp=[""]*(n-1)
  for j in range(n-1):
    if (i >> j & 1):
      tmp[j]="+"
  num=s[0]
  for k in range(n-1):
    num+=tmp[k]+s[k+1]
  ans+=eval(num)
print(ans)

Measured memory_bytes: 39536
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
	
int main(){
	string O, E;
	cin >> O >> E;
	int N = O.size() + E.size();
	rep(i, N){
		if(i % 2 == 1) cout << E[i / 2];
		else cout << O[i / 2];
	}
	cout << endl;
}

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

ll mod = 1000000007;


// Sieve of Eratosthenes
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

int main() {
  Sieve s(1000);
  vector<int> facs(1000 + 1);
  ll n;

  ll ans = 1;

  cin >> n;
  for(int i=2;i<=n;i++) {
    auto factors = s.factor(i);
    for(auto p : factors) {
      facs[p.first] += p.second;
    }
  }

  for(auto fac : facs) {
    ans *= fac + 1;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


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

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

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

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

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

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

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

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

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  while(cin >> n && n){
    ll y,b,r,t;
    cin >> y;
    vector<pair<double,ll>> v(n);
    rep(i,n){
      cin >> b >> r >> t;
      v[i].se = b;
      if(t == 1){
        v[i].fi = (1 + 1.0*y * r/100);
      }
      else{
        v[i].fi = pow((1 + 1.0 * r/100),y);
      }
    }
    sort(all(v));
    cout << v[n-1].se << endl;
  }
  return 0;
}

Measured memory_bytes: 3380
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

    int ans = 0;

    for(int i=1; i <= N; i++) {
        if(i % 2 == 1) {
            int tmp = 0;
            for(int j=1; j <= i; j++) {
                if(i % j == 0) tmp++;
            }
            if(tmp == 8) ans++;
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP2(i, a, b) for(int i = a;i <= b;i++)
#define REPR(i, a, b) for(int i = a; i >= b; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define PI 3.14159265358979323846
#define vi vector<int>
#define vll vector<ll>
#define vi2 vector<vector<int>>
#define eb emplace_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
using P = pair<ll,ll>;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
#define INT(name) int name;cin >> name;
#define VEC(type,name,n) vector<type> name(n);REP(i,n) cin >> name[i];

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()
{
  string S;
  cin >> S;
  if(S[sz(S)-1]=='s'){
    S+="es";
  }else{
    S+="s";
  }

  cout << S << endl;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

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

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

string s,t;
void input(){
    fast_io();
    cin >> s >> t;
}

int solve(){
    int ans = 0;
    for (int i = 0; i < s.length(); i++)
    {
        if(s[i]!=t[i]) ans++;
    }
    cout << ans << endl;

    return 0;
}   

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

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

int main(){
   int N, K;
   cin >> N >> K;
   vector<int> h(N);
   for (int i=0; i<N; i++)
      cin >> h.at(i);

   int cnt = 0;
   for (int hp : h)
      if (hp >= K)
         cnt++;

   cout << cnt << endl;
}



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

const int DEPTH = 17;
const int INTMAX = (1LL << 31) - 1;

struct SegTree {
	int lazyV[1 << DEPTH + 1];
	int lazyT[1 << DEPTH + 1];	//null is -1
	int segMin[1 << DEPTH + 1];

	SegTree() {
		for (int i = 0; i < 1 << DEPTH + 1; i++) {
			lazyV[i] = 0;
			lazyT[i] = -1;
			segMin[i] = INTMAX;
		}
	};
	
	void lazy_evaluate(int id) {
		if (lazyT[id] == -1) return;
		
		segMin[id] = lazyV[id];
		
		if (id < (1 << DEPTH) - 1) {
			//if (lazyT[2 * id + 1] < lazyT[id]) {
				lazyT[2 * id + 1] = lazyT[id];
				lazyV[2 * id + 1] = lazyV[id];
			//}
			//if (lazyT[2 * id + 2] < lazyT[id]) {
				lazyT[2 * id + 2] = lazyT[id];
				lazyV[2 * id + 2] = lazyV[id];
			//}
		}
		
		lazyT[id] = -1;
	}
	
	//[l, r)
	void update(int l, int r, int x, int Time, int a = 0, int b = (1 <<DEPTH), int id = 0) {
		lazy_evaluate(id);
		
		if (a >= r || b <= l) return;
		if (l <= a && b <= r) {
			lazyT[id] = Time;
			lazyV[id] = x;
			lazy_evaluate(id);
			return;
		}
		
		update(l, r, x, Time, a, (a + b) / 2, id * 2 + 1);
		update(l, r, x, Time, (a + b) / 2, b, id * 2 + 2);
		segMin[id] = min(segMin[id * 2 + 1], segMin[id * 2 + 2]);
	}
	
	int find(int l, int r, int a = 0, int b = (1 << DEPTH), int id = 0) {
		if (a >= r || b <= l) return INTMAX;
		
		lazy_evaluate(id);
		if (l <= a && b <= r) {
			return segMin[id];
		}
		
		int u = find(l, r, a, (a + b) / 2, id * 2 + 1);
		int v = find(l, r, (a + b) / 2, b, id * 2 + 2);
		return min(u, v);
	}
};

SegTree seg;

int main() {
	int n, q;
	cin >> n >> q;
	
	for (int i = 0; i < q; i++) {
		int type;
		cin >> type;
		
		if (type == 0) {
			int s, t, x;
			cin >> s >> t >> x;
			seg.update(s, t + 1, x, i);
		}
		else {
			int s, t;
			cin >> s >> t;
			cout << seg.find(s, t + 1) << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 6220
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;
 
#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
 
const ll MAX_N = 100000;
ll S[MAX_N];
ll n_types[MAX_N];

int main(void){
    ll N, K;
    vector<pair<ll, ll>> s;
    ll answer = 0;
    ll l, r;
    
    cin >> N >> K;
    
    rep(i, N){
        ll t, d;
        cin >> t >> d;
        s.push_back(make_pair(d, t - 1));
        n_types[i] = 0;
        }
    
    sort(rall(s));
    ll sum0 = 0;
    ll cnt = -1;
    l = K - 1;
    r = K;

    rep(i, K){
        sum0 += s[i].first;
        if (n_types[s[i].second] == 0) cnt ++;
        n_types[s[i].second] ++;
    }

    ll cnt_min = cnt;
    S[cnt] = sum0;
    
    while(0 <= l && r < N && cnt < K - 1){
        if (n_types[s[r].second] == 0) {
            n_types[s[r].second] = 1;
            for(ll i = l; l >= 0; i --){
                if (n_types[s[i].second] > 1) {
                    n_types[s[i].second] --;
                    cnt ++;
                    S[cnt] = S[cnt - 1] - s[i].first + s[r].first;
                    l = i - 1;
                    break;
                }
            }
        }
        r ++;
    }

    For(i, cnt_min, cnt + 1) answer = max(S[i] + (i + 1) * (i + 1), answer);

    cout << answer << endl;
 
    return 0;
}

Measured memory_bytes: 2932
import collections
N=int(input())
A=list(map(int,input().split()))
counter=collections.Counter(A)
count=list(counter.values())
s=0
for i in range(len(count)):
    k=count[i]
    s+=k*(k-1)//2
for i in range(N):
    l=counter[A[i]]
    print(s-(l-1))

Measured memory_bytes: 26780
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;

public class Main {
	public static void main(final String[] args){
    
    final Scanner sc = new Scanner(System.in);
    final List<Integer> list = new ArrayList<>();
    //final List<Long> list2 = new ArrayList<>();

    int bigh = sc.nextInt();
    int bigw = sc.nextInt();
    int h = sc.nextInt();
    int w = sc.nextInt();

    System.out.println(bigh * bigw - bigw * h - (bigh - h) * w);






}
}

Measured memory_bytes: 35808
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int a,b;
    cin >> a >> b;
    cout << max(a,b) + max(max(a,b)-1,min(a,b)) << endl;
    return 0;
}

Measured memory_bytes: 3620
fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    val arr = IntArray(N)
    
    for (i in 0 until N) {
        arr[i] = readInputLine().toInt()
    }
    
    var ans = 0L
    
    for (i in 0 until N) {
        ans += (arr[i] / 2).toLong()
        arr[i] %= 2
        if (i != N - 1 && arr[i] == 1 && arr[i + 1] > 0) {
            ans++
            arr[i] = 0
            arr[i + 1]--
        }
    }
    
    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 39160
#include<cstdio>
typedef long long ll;
const int MAX=100010,mod=998244353;
int N,M,cA,cB,cC,cD,ans;
ll fac[MAX*4],ifac[MAX*4];
ll inv(int a,int p=mod){return a==1?1:(1+p*(a-inv(p%a,a)))/a%p;}
void init(int n){
	for(int i=*fac=1;i<=n;i++)fac[i]=fac[i-1]*i%mod;
	ifac[n]=inv(fac[n]);
	for(int i=n;i;i--)ifac[i-1]=ifac[i]*i%mod;
}
ll cho(int n,int m){return!m?1:m>n?0:fac[n]*ifac[m]%mod*ifac[n-m]%mod;}
char A[MAX],B[MAX],C[MAX],D[MAX];
void stat(char*s,int&c){
	for(;*s;s++)*s=='1'?c++:1;
}
void calc(int n,char*A,char*B,int cA,int cB,int cC,int cD){
	int f=0,up=cA+cB,dn=0;
	for(int i=n;i--;){
		int c=int(A[i]=='1')+int(B[i]=='1');
		if(c){
			f=c*(f+cho(cD-1+dn,dn))%mod;
			up-=c;dn+=c;
			ans=(ans+f*cho(cC-1+up,up))%mod;
		}
	}
}
int main(){
	scanf("%d%d%s%s%s%s",&N,&M,A,B,C,D);
	stat(A,cA);stat(B,cB);
	stat(C,cC);stat(D,cD);
	init(cA+cB+cC+cD);
	if(cA+cB)calc(N,A,B,cA,cB,cC,cD);
	if(cC+cD)calc(M,C,D,cC,cD,cA,cB);
	if(!cA&&!cB&&!cC&&!cD)(ans+=1)%=mod;
	printf("%d\n",ans);
}

Measured memory_bytes: 6784