akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string.h>

using namespace std;
typedef long long int ll;

int main(){

    int N;
    cin >> N;
    string name[N];
    int char_count[5];
    memset(char_count, 0, sizeof char_count);
    for(int i=0; i<N; i++){
        cin >> name[i];
        char first = name[i][0];
        if(first == 'M'){
            char_count[0] ++;
        }else if(first == 'A'){
            char_count[1] ++;
        }else if(first == 'R'){
            char_count[2] ++;
        }else if(first == 'C'){
            char_count[3] ++;
        }else if(first == 'H'){
            char_count[4] ++;
        }
    }

    ll total = 0;

    for(int i=0; i<5; i++){
        for(int j=i+1; j<5; j++){
            for(int k = j+1; k<5; k++){
                total += (ll)char_count[i] * char_count[j] * char_count[k];
            }
        }
    }

    cout << total << endl;

    return 0;
}

Measured memory_bytes: 6144
<?php
  

while ($line = fgets(STDIN)) {
   $tmp[] = trim($line);
}
array_shift($tmp);
$array_count =array_count_values($tmp);

$max = array_keys($array_count, max($array_count));
asort($max);
foreach($max as $items){
	echo $items."\n";
}

Measured memory_bytes: 107732
#define DEBUG 0

/**
 * File    : C2.cpp
 * Author  : Kazune Takahashi
 * Created : 2019-6-3 00:42:00
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <random>
#include <chrono>
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

/*
void Yes()
{
  cout << "Yes" << endl;
  exit(0);
}

void No()
{
  cout << "No" << endl;
  exit(0);
}
*/

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

// const ll MOD = 1000000007;

ll N, X;
ll b[100010], l[100010], u[100010];
ll base = 0;
typedef tuple<ll, ll, ll, ll> test;
vector<test> V;
ll sum[100010];

bool solve(ll T)
{
  ll cnt = T / X;
  ll x = T % X;
  ll ans = -1000000000000000;
  if (x == 0)
  {
    return (sum[cnt] >= 0);
  }
  for (auto i = 0; i < N; i++)
  {
    ll t, b, l, u;
    tie(t, b, l, u) = V[i];
    ll tmp = 0;
    if (x >= b)
    {
      tmp = l * b + u * (x - b);
    }
    else
    {
      tmp = l * x;
    }
    if (i < cnt)
    {
      ans = max(ans, sum[cnt + 1] - t + tmp);
    }
    else
    {
      ans = max(ans, sum[cnt] + tmp);
    }
  }
  return (ans >= 0);
}

int main()
{
  cin >> N >> X;
  for (auto i = 0; i < N; i++)
  {
    cin >> b[i] >> l[i] >> u[i];
  }
  for (auto i = 0; i < N; i++)
  {
    base -= l[i] * b[i];
  }
  for (auto i = 0; i < N; i++)
  {
    ll t = l[i] * b[i] + u[i] * (X - b[i]);
    V.emplace_back(t, b[i], l[i], u[i]);
  }
  sort(V.begin(), V.end());
  reverse(V.begin(), V.end());
  sum[0] = base;
  for (auto i = 0; i < N; i++)
  {
    sum[i + 1] = sum[i] + get<0>(V[i]);
  }
  sum[N + 1] = sum[N];
  ll ok = N * X + 1;
  ll ng = -1;
  while (abs(ok - ng) > 1)
  {
    ll t = (ok + ng) / 2;
    if (solve(t))
    {
      ok = t;
    }
    else
    {
      ng = t;
    }
  }
  cout << ok << endl;
}

Measured memory_bytes: 8688
// includes
#include <stdio.h>
#include <string.h>

// defines
#define LEN 100005


// Process
typedef struct {
    char name[10];
    int time;
} Process;


// deque target
int head;
// enqueue target
// tail is Queue length.
int tail;
// process count
int N;
// quontum time
int qms;

// Queue
Process Q[LEN];


// enqueue process to Queue
void enqueue(Process p) {
    Q[tail] = p;
    tail = (tail + 1) % LEN;
}

// dequeue process to Queue
Process dequeue() {
    Process p = Q[head];
    head = (head + 1) % LEN;
    return p;
}


void runProcess() {
    // elapsed time
    int et = 0;

    while (head != tail) {
        Process p = dequeue();
        if (p.time > qms) {
            p.time -= qms;
            enqueue(p);
            et += qms;
        } else {
            et += p.time;
            printf("%s %d\n", p.name, et);
            p.time = 0;
        }
    }
}

int main() {
    // initialize head
    head = 0;

    // scan
    scanf("%d %d", &N, &qms);
    for (int i = 0; i < N; i++) { scanf("%s %d", Q[i].name, &Q[i].time); }

    // initialize tail
    tail = N;

    runProcess();

    return 0;
}



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

int n;
double dp[305][305][305];
int cnt[4];
int main()
{
    // freopen("j.in", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    int t;
    for (int i = 0; i < n; i++)
    {
        cin >> t;
        cnt[t]++;
    }
    dp[0][0][0] = 0;
    for (int n3 = 0; n3 <= cnt[3]; n3++)
    {
        for (int n2 = 0; n2 + n3 <= cnt[2] + cnt[3]; n2++)
        {
            for (int n1 = 0; n1 + n2 + n3 <= n - cnt[0]; n1++)
            {
                int s = n1 + n2 + n3;
                if (s != 0)
                {
                    double temp = double(n);
                    if (n1 != 0)
                        temp += double(n1) * dp[n1 - 1][n2][n3];
                    if (n2 != 0)
                        temp += double(n2) * dp[n1 + 1][n2 - 1][n3];
                    if (n3 != 0)
                        temp += double(n3) * dp[n1][n2 + 1][n3 - 1];
                    temp /= double(s);
                    dp[n1][n2][n3] = temp;
                }
            }
        }
    }
    cout.precision(16);
    cout << dp[cnt[1]][cnt[2]][cnt[3]] << endl;
}

Measured memory_bytes: 219392
#include <iostream>
#include <cmath>
#include <map>
#include <vector>
#include <iterator>
using namespace std;

vector<int> divisors;
void make_divisors(map<int, int>::iterator begin, map<int, int>::iterator end, int product) {
    if (begin == end)
        divisors.push_back(product);
    else
        for (int i = 0; i <= begin->second; i++)
            make_divisors(next(begin), end, product * pow(begin->first, i));
}

int main(void)
{
    int a, b, c;
    int cnt = 0;
    map<int, int> factors;

    cin >> a >> b >> c;

    for (int i = 2, e = c; e != 1 || i <= sqrt(c); i++)
        while (e % i == 0) {
            e /= i;
            if (factors.count(i))
                factors[i]++;
            else
                factors.insert(pair<int, int>(i, 1));
        }

    make_divisors(factors.begin(), factors.end(), 1);

    for (int i = 0; i < divisors.size(); i++)
        if (a <= divisors[i] && divisors[i] <= b)
            cnt++;

    cout << cnt << endl;
}



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

int main() {
  ll  n,f=0;
  cin>>n;
  for(ll i=1;i<=n;i++)
  {
    ll t,x,y,z;
    cin>>t>>x>>y;
    z=x+y;
    if(!(t%2==z%2&&t>=z))
    {
       f=1;
    }

  }
  if(f)
  {
    cout<<"No"<<endl;
  }
  else
  {
    cout<<"Yes"<<endl;
  }
}

Measured memory_bytes: 384
#include <stdio.h>
int main ()
{
	int A,N,T,P,S;
	1<N<10000;
	0<A<1000;
	scanf ("%d", &N);
	scanf ("%d", &A);
	T = N/500;
	P = T * 500;
	if (N>500 && 0<T<11){
		(S = N - P);
	} else if (N<500){
		(S = N);
		}
		if (A-S >= 0){
			printf ("Yes");
		} if (A-S < 0){
			printf ("No");
		}
		return 0;
	}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cstring>
using namespace std;
#define sci(n) scanf("%lld", &(n))
#define scd(n) scanf("%Ld", &(n))
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> pll;
int main(void)
{
	LL n; sci(n);
	cout << "Christmas ";
	for (int i = n; i < 25; i++) {
		cout << "Eve ";
	}
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(A, B, K):
    if K >= A:
        K -= A
        A = 0
    else:
        A -= K
        K = 0

    if K >= B:
        K -= B
        B = 0
    else:
        B -= K
        K = 0

    return '%d %d' % (A, B)


def main():
    A, B, K = read_int_n()
    print(slv(A, B, K))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6724
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))
Q = int(input())

d = defaultdict(int)
s = 0
for a in A:
    d[a] += 1
    s += a

B, C = [], []
for _ in range(Q):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)

for i in range(Q):
    b = B[i]
    c = C[i]
    now_b = d[b]
    d[c] += now_b
    d[b] = 0
    s += (c - b) * now_b
    print(s)


Measured memory_bytes: 30028
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 100000;
int N;
int u[MAX_N], v[MAX_N], w[MAX_N];

                            
struct edge { ll to, cost; };
const ll MAX_V = MAX_N, INF = INFLL;

// Vの初期化を忘れない。
int V;
vector<edge> G[MAX_V];
ll d[MAX_V];

void add_edge(int v, int u, int cost) {
  G[v].push_back((edge){u, cost});
  G[u].push_back((edge){v, cost});
}

void dijkstra(int s) {
  fill(d, d+V, INF);
  priority_queue<Pll, vector<Pll>, greater<Pll> > pque;
  d[s] = 0;
  pque.push(Pll(0, s));


  while (!pque.empty()) {
    Pll p = pque.top(); pque.pop();
    ll v = p.second;
    if (d[v] < p.first) continue;
    for (int i = 0; i < (int)G[v].size(); ++i) {
      edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost; 
        pque.push(Pll(d[v]+ e.cost, e.to));
      }
    }
  }
}

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

  cin >> N;
  rep(i, N-1) cin >> u[i] >> v[i] >> w[i];
  V = N;
  rep(i, N-1) {
      add_edge(--u[i], --v[i], w[i]);
  }

  dijkstra(0);

  rep(i, N) cout << d[i]%2 << endl;

  return 0;
}


Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
int stage[100] = {0};
void showStage(){
	for (int i = 0; i < 10; ++i)
	{
		printf("%2d ",stage[i]);
	}
	printf("\n");
}
int main(){
	int n;
	int x[100100];
	int k[100100];
	long long ans = 1;
	scanf("%d",&n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%d",&x[i]);
	}
	//一個でもゴールできないものができると
	//その後ろは全員ゴールできない

	//ロボットのとりうる最高順位をkとする
	//ロボットは自分より前にいるロボットの最高順位kを超えることはできない。

	//ロボットの取りうる最高順位は変化するか？->変化しない
	
	//ゴールできる=マップ上のロボットがWの距離までにW/2+1個以下しかない
	//後ろのやつがゴールした後の状態だとそれより前のやつは全員ゴールできる

	//それぞれのロボットに関して最高順位kを求める


	int tmpk = 1;
	for (int i = 0; i < n; ++i)
	{
		//iは自分より前にいるロボットの個数
		k[i] = tmpk;
		ans *= tmpk;
		ans %= mod;
		//ロボットが抜かせれる個数tmpkとする
		if(x[i]>(i-(i-tmpk+1))*2){
		  tmpk++;
		  //とれる最高順位 i-tmpk
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
	int i=1,c=0;
	long long a,b;
	scanf("%lld %lld",&a,&b);
	while(i){
		if(a<=b){
			c=c+1;
		}
		if(a>b){
			i=0;
		}
		a=a*2;
	}
	printf("%d",c);
	return 0;
}

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

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct Init {
    Init() {
        cout << fixed << setprecision(20);
    };
} init;

int N;
string S;
int mod = 1e9 + 7;

// 拡張ユークリッドの互除法
int extgcd(int a, int b, int &x, int &y) {
    int d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1;
        y = 0;
    }
    return d;
}

// mod逆元
int mod_inverse(int a, int m) {
    int x, y;
    extgcd(a, m, x, y);
    return (m + x % m) % m;
}

pint f(pint ab, int i, int hash) {
    if (S[i] == '+') { return pint(ab.first, (ab.second + 1) % mod); }
    else if (S[i] == '-') { return pint(ab.first, (ab.second - 1 + mod) % mod); }
    else if (S[i] == '>') { return pint(ab.first * hash % mod, ab.second * hash % mod); }
    else if (S[i] == '<') {
        return pint(ab.first * mod_inverse(hash, mod) % mod,
                    ab.second * mod_inverse(hash, mod) % mod);
    }
}

pint finv(pint ab, int i, int hash) {
    if (S[i] == '-') { return pint(ab.first, (ab.second + 1) % mod); }
    else if (S[i] == '+') { return pint(ab.first, (ab.second - 1 + mod) % mod); }
    else if (S[i] == '<') { return pint(ab.first * hash % mod, ab.second * hash % mod); }
    else if (S[i] == '>') {
        return pint(ab.first * mod_inverse(hash, mod) % mod,
                    ab.second * mod_inverse(hash, mod) % mod);
    }
}
signed main() {
    cin >> N >> S;
    const int K = 3;
    vint hash = {114514, 1919, 810};
    map<int, int> mp[K];
    pint b[K], c[K];
    for (int i = 0; i < K; i++) {
        int h = hash[i];
        b[i] = c[i] = pint(1, 0);
        for (int j = N - 1; j >= 0; j--) { b[i] = f(b[i], j, h), mp[i][0] = 1; }
    }
    int ans = 0;
    for (int i = N - 1; i >= 0; i--) {
        int cur = LLONG_MAX;
        for (int j = 0; j < K; j++) {
            int h = hash[j];
            pint cc = finv(pint(1, 0), i, h);
            c[j] = pint(c[j].first * cc.first % mod, (c[j].first * cc.second + c[j].second) % mod);
            int fi = (c[j].first * b[j].second + c[j].second) % mod;
            chmin(cur, mp[j][fi]);
            mp[j][c[j].second]++;
        }
        ans += cur;
    }
    cout << ans << endl;
}

Measured memory_bytes: 94212
n,k=map(int,input().split())
A=sorted(list(map(int,input().split())))


mod=10**9+7

if A[-1]<0 and k%2==1:
    now=1
    for i in range(k):
        now*=A[-i-1]%mod
        now%=mod
    print(now) ;exit()

l=0 ; r=n-1
ans=1
if k%2==1:
    ans=A[-1]
    r-=1

for i in range(k//2):
    mi=A[l]*A[l+1]
    pl=A[r]*A[r-1]
    if mi>pl:
        ans*= mi%mod
        ans%=mod
        l+=2
    else:
        ans*= pl%mod
        ans%=mod
        r-=2
print(ans%mod)


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

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

int main(){
    int W,H,N;
    cin >> W >> H >> N;
    int u=H,d=0,r=W,l=0;
    int x,y,a;
    REP(i,N){
        cin >> x >> y >> a;
        if(a==1){
            l = max(l,x);
        }else if(a==2){
            r = min(r,x);
        }else if(a==3){
            d = max(d,y);
        }else{
            u = min(u,y);
        }
    }
    cout << max((u-d),0)*max((r-l),0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint         = long long;
constexpr lint inf = 1LL << 60;
constexpr lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n;
    cin >> n;
    vector<lint> f(n + 1, 0);
    for (int i = 1; i <= n; ++i) {
        for (int j = i; j <= n; j += i) {
            f[j]++;
        }
    }
    lint ret = 0;
    for (lint i = 1; i <= n; ++i) {
        ret += f[i] * i;
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 81340
def main():
    H, W = map(int, input().split())
    A = []
    for _ in range(H):
        A.append(list(map(int, input().split())))

    ope = []

    for i in range(H-1):
        for j in range(W):
            if A[i][j] % 2 == 1:
                A[i][j] -= 1
                A[i+1][j] += 1
                ope.append([i+1,j+1,i+2,j+1])
    for j in range(W-1):
        if A[H-1][j] % 2 == 1:
            A[H-1][j] -= 1
            A[H-1][j+1] += 1
            ope.append([H,j+1,H,j+2])
            

    print(len(ope))
    for o in ope:
        print(*o) 

main()

Measured memory_bytes: 70748
import java.util.*;

public class Main {    
    
  public static void main(String[] args) {
   
     Scanner sc = new Scanner(System.in);                                      
     
     int N = sc.nextInt();
     
     int M = sc.nextInt();
     
     HashSet<Integer> hashend = new HashSet();
     HashSet<Integer> hashstart = new HashSet();     

     for(int i = 0;i < M;i++){
         int a = sc.nextInt();
         int b = sc.nextInt();
         if(a == 1){
             hashend.add(b);                          
         }  
         if(b == N){
             hashstart.add(a);
         }         
     }
     
     for(Integer a : hashend){        
         if(hashstart.contains(a)){
             System.out.println("POSSIBLE");
             return;
         }
     }
     
     System.out.println("IMPOSSIBLE");
                  
  }   
}


Measured memory_bytes: 108436
N=int(input())
S=input()

def ans052(N:int, S:str):
    x=0
    x_list=[0]
    for i in range(N):
        if S[i]=="I":
            x+=1
            x_list.append(x)
        elif S[i]=="D":
            x-=1
            x_list.append(x)
    x_list.sort()
    return x_list[-1]

print(ans052(N,S))

Measured memory_bytes: 9028
/// Bismillahir Rahmanir Rahim
/* Mohammad Morsalin
   Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define int long long
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ms2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pi pair<int,int>
#define tc(t) int t;cin>>t;while(t--)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define fi first
#define se second
#define PI acos(-1)
#define sz(a) (int)a.size();
#define IOS ios::sync_with_stdio(false);
using namespace std;
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
double sq(double x) {return x*x;}
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
signed main()
{
    IOS
    string s;
    cin>>s;
    for(int i=0;i<3;i++)cout<<s[i];
    cout << endl;
    return 0;
}
///Alhamdulillah


Measured memory_bytes: 3640
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    int X, Y;
    cin >> X >> Y;
    bool good = Y % 2 == 0 && (Y >= 2 * X && Y <= 4 * X);
    cout << (good ? "Yes" : "No") << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


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

#define FOR(i, a, b) for (int i = a; i < (int) b; i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = a; i >= (int) b; i--)
#define R0F(i, a) ROF(i, a, 0)
#define GO(i, a) for (auto i : a)

#define f first
#define s second
#define eb emplace_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;
typedef long long i64;

const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int ms[] = {+31, +29, +31, 30, +31, +30, +31, +31, +30, +31, +30, +31};

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  vi a (3);
  F0R (i, 3) cin >> a[i];
  sort (all(a));
  a.erase (unique(all(a)), a.end());
  cout << (sz(a) == 2 ? "Yes" : "No") << '\n';
  return 0;
}



Measured memory_bytes: 256
#define s(a,b) t=a,a=b,b=t
f(int*a){*a=(*a&7)<<4|*a>>4;}k,m,a,b,c,t,r;main(n){while(scanf("%d",&n),n){r=1,a=97,b=82,c=67;while(n--){scanf(" %c%*s",&k);m=k-76;t=m%6==0?(s(b,c),f(m>0?&c:&b)):1<m&&m<8?(s(a,b),f(m^7?&b:&a)):(s(a,c),f(m>0?&c:&a));r+=a&7;}printf("%d\n",r);}}

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

int main() {
  int n, m, l;
  cin >> n >> m >> l;
  long matA[n][m], matB[m][l];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> matA[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < l; j++) {
      cin >> matB[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < l; j++) {
      long sum = 0;
      for (int k = 0; k < m; k++) {
        sum += matA[i][k] * matB[k][j];
      }
      cout << sum;
      cout << (j == l - 1 ? '\n' : ' ');
    }
  }
  return 0;
}



Measured memory_bytes: 3196
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        String ans = "NO";
        for(int i = 0;i < b;i++){
            int num = (i+1)*a%b;
            if(num == c){
                ans = "YES";
            }
        }
        System.out.println(ans);
    }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rep3(i, m, n) for(ll i=m;i<=(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000
#define LLINF 1000000000000000000

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T & a, const T & b) { if (b < a) { a = b; return 1; } return 0; }

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const ll mod = MOD;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

ll dp[100005];

void solve_abc_d() {
	ll n;
	ll l_ans = 0;

	cin >> n;
	V h(n+1);
	rep(i, n) cin >> h[i+1];

	rep1(i, n) dp[i] = INF;
	
	dp[1] = 0;
	rep1(i, n) {
		if (i == 1) continue;
		else if (i == 2) {
			chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
		}
		else {
			chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
			chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
		}
	}

	cout << dp[n] << "\n";

	return;
}

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

	solve_abc_d();

	return 0;
}


Measured memory_bytes: 4772
#include<bits/stdc++.h>
#define lowbit(x) (x&-x)
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
const int INF=0x3f3f3f3f;
const int MOD=20010905;
const int maxn=1e5+10;
int N,K,S,A[maxn];
int main()
{
    scanf("%d %d %d",&N,&K,&S);
    for(int i=1;i<=K;i++)
        A[i]=S;
    for(int i=K+1;i<=N;i++)
    {
        if(S<=1000000000/2)
            A[i]=2*S;
        else
            A[i]=1;
    }
    for(int i=1;i<=N;i++)
    {
        if(i>1)
            printf(" ");
        printf("%d",A[i]);
    }
    return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<string>
#include<cstdio>
#include<cctype>
#include<vector>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<queue>
#include<set>
#include<unordered_map>
#include<stack>
#include<map>
#include<bitset>
#include <cstdlib>
#include<cstring>
#define ll long long;
#define pb push_back
const int MOD = 1e9 + 7;
const int qq = 1e5 + 10;
const int INF = 1e9 + 10;
const double eps = 1e-11;
const double pi = acos(-1.0); 
using namespace std;
using uint = unsigned int;
using int64 = long long;
using uint64 = unsigned long long;
#define ma = 2147483647;
#define mi = -2147483647;
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	string s1, s2;
	cin >> s1 >> s2;
	int flag = 1;
	for (int i = 0; i < s1.length(); i++)
	{
		if (s1[i] == s2[i]);
		else {
			flag = 0;
			break;
		}
	}
	if (flag == 0)
		cout << "No";
	else cout << "Yes";






	return 0;
}

Measured memory_bytes: 3640
s = input()
n = int(input())
for i in range(n):
    c = input().split()
    a = int(c[1])
    b = int(c[2])
    if c[0] == 'replace':
        s = s[0:a] + c[3] + s[b+1:]
    elif c[0] == 'reverse':
        t = s[a:b+1]
        s = s[0:a] + t[::-1] + s[b+1:]
    elif c[0] == 'print':
        print(s[a:b+1])



Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

typedef struct Edge{
    int to;
    LL w;
}Edge;

vector<vector<Edge>> G;
vector<LL> d;

void DFS(int v,int p = -1,LL nd = 0){   // nd = 現在地までの根からの距離 を更新していく
    for(auto nv : G[v]){
        int a = nv.to;
        LL b = nv.w;
        if(a == p)continue;
        d[a] = nd + b;
        DFS(a,v,nd + b);
    }
}

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

    d.resize(N,0);
    G.resize(N,vector<Edge>());
    rep(i,N-1){
        int a,b;
        LL c;cin >> a >> b >> c;
        a--;b--;
        G[a].push_back((Edge){b,c});
        G[b].push_back((Edge){a,c});
    }

    int Q,K;cin >> Q >> K;
    vector<int> x(Q);
    vector<int> y(Q);
    rep(i,Q){
        int a,b;cin >> a >> b;
        a--;b--;
        x[i] = a;
        y[i] = b;
    }

    DFS(K-1);
    rep(i,Q){
        cout << d[x[i]] + d[y[i]] << endl;
    }

}


Measured memory_bytes: 15104
#include <iostream>
#include <vector>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <map>
#include <queue>

#define rep(i,x) for(int i = 0; i < x; i++)
#define rrep(i,x) for(int i = 1; i <= x; i++)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1002003004005006007;

const int mod = 998244353;


struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint dfs(int v, vector<vector<int>> &graph){
    mint v_num = 1;
    mint child_num = 1;
    for (int next_v : graph[v]){
        child_num *= dfs(next_v, graph);
    }
    return v_num + child_num;
}

int main(){
    int n; cin >> n;
    vector<pair<int, int>> xd_list(n);
    rep(i, n) cin >> xd_list[i].first >> xd_list[i].second;
    sort(xd_list.begin(), xd_list.end());
    vector<vector<int>> graph(n);
    priority_queue<P, vector<P>, greater<P>> que;
    for (int i = n - 1; i >= 0; i--){
        int x = xd_list[i].first;
        int d = xd_list[i].second;
        while (!que.empty() and que.top().first < x + d){
            graph[i].push_back(que.top().second);
            que.pop();
        }
        que.push(P{x, i});

    }
    mint ans = 1;
    while (!que.empty()){
        int v = que.top().second;
        ans *= dfs(v, graph);
        que.pop();
    }
    cout << ans << endl;
}


Measured memory_bytes: 22144
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <string>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int t;
	cin >> t;

	if (t >= 30) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}

	return 0;

}

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

int main(){
  string s;
  int maxLength=0;
  int positionA;

  cin >> s;

  int i=0;
  while(s[i]!='A')i++;
  positionA = i;

  i=s.length()-1;
  while(s[i]!='Z'){    
    i--;
  }

  cout << i-positionA+1 << endl;
      
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<math.h>
#include<stack>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;

int main(){
  int n, m, k, x, ans = 0;
  cin >> n >>m;
  int a[m];
  rep(i,m) a[i] = 0;
  rep(i, n){
      cin >> k;
      rep(j, k){
          cin >> x;
          a[x-1]++;
      }
    }
    rep(i, m) if(a[i] == n) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const int NINF = -1*INF;
const long long LLINF = 1ll << 60;
const long long LLNINF = -1*LLINF;

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef vector<vld> vvld;
 
#define mp make_pair
#define pb push_back
#define pf push_front
#define all(x) x.begin(), x.end()
#define revAll(x) x.rbegin(), x.rend()
#define gcd(a, b) __gcd(a, b)
#define popcount(x) __builtin_popcount(x)
#define isize(x) (int)(x.size())
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define umap unordered_map

const ll MOD = 1e9 + 7;

// points type 0, queries type 1
struct Event{
	int type, start, end, val;

	Event(int t, int s, int e, int v){
		type = t, start = s, end = e, val = v;
	}

	bool operator<(const Event& other){
		return mp(end, type) < mp(other.end, other.type);
	}

};

inline int lastbit(int x) {
  return x & (-x);
}

template <int... ArgsT> struct BIT {
  int val = 0;
  void update(int val) {
    this->val += val;
  }
  int query() {
    return val;
  }
};

template <int N, int... Ns>
struct BIT<N, Ns...> {
  BIT<Ns...> bit[N + 1];
  template<typename... Args>
  void update(int pos, Args... args) {
    for (; pos <= N; bit[pos].update(args...), pos += lastbit(pos));
  }
  template<typename... Args>
  int query(int l, int r, Args... args) {
    int ans = 0;
    for (; r >= 1; ans += bit[r].query(args...), r -= lastbit(r));
    for (--l; l >= 1; ans -= bit[l].query(args...), l -= lastbit(l));
    return ans;
  }
};

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	int n, q; cin >> n >> q;
	vector<Event> events = vector<Event>();
	vi ans = vi(q);
	rep(i, n){
		int x; cin >> x;
		events.pb(Event(0, i, i, x));
	}
	rep(orig_index, q){
		int l, r; cin >> l >> r;
		l--, r--;
		events.pb(Event(1, l, r, orig_index));
	}
	sort(all(events));
	BIT<5*100000+100> bit;
	umap<int, int> last = umap<int, int>();
	for(const Event& event : events){
		if (event.type == 0){
			if (last.find(event.val) != last.end()){
				bit.update(last[event.val] + 1, -1);
			}
			last[event.val] = event.start;
			bit.update(event.start + 1, 1);
		}else{
			int cnt = bit.query(event.start + 1, event.end + 1);
			ans[event.val] = cnt;
		}
	}
	rep(i, isize(ans)){
		cout << ans[i] << "\n";
	}
}

Measured memory_bytes: 43064
def linear_search(l, key):
    i = 0
    l.append(key)
    while l[i] != key:
        i += 1

    if i == len(l) - 1:
        return False
    else:
        return True

if __name__ == "__main__":
    import sys
    input = sys.stdin.readline # faster input

    n = int(input())
    S = list(map(int, input().split()))
    q = int(input())
    T = list(map(int, input().split()))

    c = 0
    for key in T:
        if linear_search(S, key):
            c += 1

    print(c)



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

typedef pair<int, int> ii;

long long dp[110][100010];
int main(){

    int n, w;
    cin >> n >> w;

    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= w; j++){
            dp[i][j] = 0;
        }
    }

    
    vector<ii> a(n);
    for(auto &x : a){
        cin >> x.first >> x.second;
    }


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

    cout << dp[n][w] << endl;

    return 0;
}



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

int main(){
  string A,B,C;
  cin >>A>>B>>C;
  
  char Al = A[A.size()-1];
  char Bf = B[0];
  char Bl = B[B.size()-1];
  char Cf = C[0];
  
  string ans;
  if(Al==Bf&&Bl==Cf) ans = "YES";
  else ans = "NO";
  
  cout <<ans<< endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  double d;
  cin >> n >>d;
  int ans = 0;
  for(int i = 0;i<n;i++)
  {
    double a,b;
    cin >> a >>b;
    double c =sqrt(a*a+b*b);
    if(c<=d)
    {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3836
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define all(v) (v).begin(),v.end()
#define fi first
#define se second
set<string> c;
map<ll,ll> mp;
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
ll dp[200000];
int main(){
int n,k;
cin>>n>>k;
string s;
cin>>s;
int cnt=0;
for(int i=0;i<n-1;i++)if(s[i]==s[i+1])cnt++;
cout<<min(n-1,cnt+2*k)<<endl;
}


Measured memory_bytes: 512
import sys,math,copy,queue,itertools
from fractions import gcd
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(0,1),(-1,0),(0,-1))
s = sys.stdin.readline()

if s[2] == s[3] and s[4] == s[5]:
    print ('Yes')
else:
    print ('No')

Measured memory_bytes: 65132
import java.util.Scanner;

/**
 * @author yoshizaki
 *
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner= new Scanner(System.in);
        long height = scanner.nextLong(); 
        long width  = scanner.nextLong();
        long field = height * width;
        long can = field / 2l;
        if (field % 2l ==1l) can++;
        if (height == 1l || width ==1l) can = 1;
        System.out.println(can);
    }
}


Measured memory_bytes: 23636
#include<iostream>
#include<iomanip>
using namespace std;
int main() {
	int a, b;
	double c, d;
	cin >> a >> b;
	c = a;
	d = b;
	cout << fixed << setprecision(6);
	cout << a / b << " " << a % b << " " << c / d << endl; 
	return 0;
}


Measured memory_bytes: 3276
#include <cstdio>
#include <cstring>
#include <vector>

int main()
{
  static char s[1000010];
  scanf("%s",s);
  int n=strlen(s);
  std::vector<int> down(n+1);
  down[n]=0;
  int c=0;
  for(int i=n-1;i>=0;i--){
    down[i]=(s[i]=='0'?down[i+1]-1:std::min(down[i+1]+1,0));
  }
  int m=down[0];
  int ans=n;
  for(int b=0;b<2;b++){
    int M=0,c=0;
    for(int i=0;i<n;i++){
      if(s[i]=='0'||(s[i]=='?'&&c-1+down[i+1]>=m-b)){
	c--;
      }
      else{
	c++;
      }
      M=std::max(M,c);
    }
    ans=std::min(ans,M-(m-b));
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 7532
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
///////////////////////////////////////

int main() {
	int N, M;
	vector<int>V;
	cin >> N >> M;
	ll A[100100];
	ll B[100100], C[100100];
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		V.push_back(A[i]);
	}
	vector<pii>key;
	for (int i = 0; i < M; ++i) {
		cin >> B[i] >> C[i];
		key.push_back({ C[i],B[i] });
	}
	sort(key.begin(), key.end(), greater<pii>());
	sort(V.begin(), V.end());
	int x = 0;
	for (int i = 0; i < M; ++i) {
		int count = 0;
		while (V[x]<key[i].first && count < key[i].second) {
			V[x] = key[i].first;
			count++;
			x++;
		}
		if (x >= N) {
			break;
		}
	}
	ll sum = 0;
	for (int i = 0; i < N; ++i) {
		sum += V[i];
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < n; ++i) 
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i) 
#define pb insert
#define F first
#define S second
#define mp make_pair
#define debug1(a) cout<<" a : "<<a<<"\n"
#define debug2(a,b) cout<<" a : "<<a<<" b : "<<b<<"\n"
#define debug3(a,b,c) cout<<" a : "<<a<<" b : "<<b<<" c : "<<c<<"\n"
#define M 1000000007

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
	int n;
	cin>>n;
	int a[n],dp[n]={0};
	rep(i,n) cin>>a[i];
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	REP(i,2,n-1)
	{
		dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
	}
	cout<<dp[n-1];
	return 0;
}




Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long n = long.Parse(Console.ReadLine());
            var ans = new long[n];

            foreach (var x in Enumerable.Range(1, 100))
            {
                foreach (var y in Enumerable.Range(1, 100))
                {
                    foreach (var z in Enumerable.Range(1, 100))
                    {
                        var tmp = x * x + y * y + z * z + x * y + y * z + z * x;
                        if (tmp <= n)
                        {
                            ans[tmp - 1]++;
                        }
                    }
                }
            }

            for (int i = 0; i < n; i++)
            {
                Console.WriteLine(ans[i]);
            }

            Console.Out.Flush();
        }
    }
}


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

typedef struct Node {
  int x;
  struct Node *prev;
  struct Node *next;
} Node;

Node *head, *tail;

void dump() {
  int l = 0;
  Node *p = head;
  while (p != NULL) {
    if (l == 0)  printf("%d",  p->x);
    else printf(" %d", p->x);
    ++l;
    p = p->next;
  }
  printf("\n");
}

void insert(int x) {
  Node *nod = malloc(sizeof(Node));;
  nod->x = x;
  nod->prev = NULL;
  nod->next = NULL;

  if (head == NULL) {
    head = nod;
    tail = nod;
  } else {
    nod->next = head;
    head->prev = nod;
    head = nod;
  }
}

void delete(int x) {
  Node *p = head;
  int flg = 0;

  while (flg == 0 && p != NULL) {
    if (p->x == x) {
      Node *c = p;
      if (c->prev != NULL) {
        p->prev->next = c->next;
      } else {
        head = c->next;
      }

      if (c->next != NULL) {
        p->next->prev = c->prev;
      } else {
        tail = c->prev;
      }
      flg = 1;
    } else {
      p = p->next;
    }
  }
}

void deleteFirst() {
  if (head == tail) {
    head = NULL;
    tail = NULL;
  } else if (head != NULL) {
    if (head->next != NULL) head->next->prev = NULL;
    head = head->next;
  }
}

void deleteLast() {
  if (head == tail) {
    head = NULL;
    tail = NULL;
  } else if (tail != NULL) {
    if (tail->prev != NULL) tail->prev->next = NULL;
    tail = tail->prev;
  }
}

int main(int argc, char **argv) {

  int n;
  scanf("%d\n", &n);

  int i;
  int x;
  char buf[256];
  char tmp[256];
  for (i = 0; i < n; ++i) {
    fgets(buf, 256, stdin);

    if (buf[0] == 'i' || buf[6] == ' ') {
      sscanf(buf, "%s %d", tmp, &x);

      if (buf[0] == 'i') insert(x);
      else               delete(x);
    } else if (buf[6] == 'F') {
      deleteFirst();
    } else if (buf[6] == 'L') {
      deleteLast();
    }
  }

  dump();

  return 0;
}



Measured memory_bytes: 36164