akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 100001;
int n, m, a, b, k;
vi e[N], v[2];
bool z[N];
void dfs(int i, int p){
  for(int j: e[i])if(!z[j]){
    z[j] = true;
    v[k].pb(j);
    dfs(j, i);
    return;
  }
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  FOR(i, 0, m){
    cin >> a >> b;
    e[a].pb(b);
    e[b].pb(a);
  }
  z[a] = true;
  z[b] = true;
  dfs(a, b);
  k++;
  dfs(b, a);
  cout << sz(v[0]) + sz(v[1]) + 2 << endl;
  reverse(rng(v[0]));
  for(int i: v[0]) cout << i << " ";
  cout << a << " " << b;
  for(int i: v[1]) cout << " " << i;
  cout << endl;
  return 0;
}

Measured memory_bytes: 9464
import java.io.*;
import java.util.*;
import java.math.*;
public class Main{

     public static void main(String []args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       
        String line1 = br.readLine();
        String[] strs = line1.trim().split("\\s+");
        int n = Integer.parseInt(strs[0]);
        int x = Integer.parseInt(strs[1]);
        String li = br.readLine();
        String[] st = li.trim().split("\\s+");
       int[] sum = new int[n+1];
       sum[0] = 0;
       for(int i=1;i<n+1;i++) { sum[i] = sum[i-1] + Integer.parseInt(st[i-1]); }
       int ans = n+1;
       for(int i=0;i<=n;i++){ if(sum[i]>x) { ans=i; break;} }
       
       System.out.println(ans);
       
}  

}





Measured memory_bytes: 21332
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7;
ll GCD(ll x, ll y) {if (x % y == 0) return y;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x * y / GCD(x, y);}

int main(){
 ll ans=0,n,m; cin>>n>>m;
  vector<vector<ll>>v(m);
  vector<ll>p(m);
  rep(i,m){
  ll k; cin>>k;
    rep(l,k){
      ll s; cin>>s; s--;
    v[i].push_back(s);
    }
  }
  rep(i,m) cin>>p[i];
  for(ll bit=0; bit<(1<<n); bit++){
  bool ok=true;
    rep(i,m){
       ll sum=0;
      for(ll l=0;l<v[i].size();l++){
        if(bit&(1<<v[i][l])) sum++;
      }
       if(sum%2!=p[i]){
        ok=false; break;
       }
    }
   if(ok) ans++;  
  }
  cout<<ans<<endl;
}

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

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

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

    sort(a.begin(),a.end());
    int g=0;
    for(int i=0; i<n; i++)
    {
        g=__gcd(g,a[i]);
        if (g==1)break;
    }
    if(g!=1)
    {
        cout<<"not coprime"<<endl;
    }
    else
    {
        vector<int>d(a[n-1]+1);
        for(int i=1; i<=a[n-1]; i++)d[i]=i;

        for(int i=4; i<=a[n-1]; i+=2)d[i]=2;

        for(int i=3; (long long)i*i<=a[n-1]; i++)
        {
            if(d[i]==i)
            {
                for(int j=i*i; j<=a[n-1]; j+=i)
                {
                    if(d[j]==j)d[j]=i;
                }
            }
        }

        map<int,int>m;
        k=0;
        for(int i=n-1; i>=0; i--)
        {
            int t=a[i];
            if(d[t]==t)
            {
                if(t==1)continue;
                if(m[t])
                {
                    k=1;
                    break;
                }
                else m[t]++;
            }
            else
            {
                for(int j=d[t]; (long long)j*j<=t; j++)
                {
                    if(t%j==0)
                    {
                        if(m[j])
                        {
                            k=1;
                            break;
                        }
                        else m[j]++;
                        while(t%j==0)t/=j;
                    }
                }
                if(t>1)
                {
                    if(m[t])k=1;
                    else m[t]++;
                }
                if(k)break;
            }
        }
        //for(int i=1;i<=6;i++)cout<<d[i]<<endl;
        if(k)cout<<"setwise coprime"<<endl;
        else cout<<"pairwise coprime"<<endl;
    }

    return 0;
}





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

int main(){
  int N,Q;
  cin>>N>>Q;
  string S;
  cin >>S;
  int count[N];
  count[0]=0;
  for(int i=1;i<N;i++){
    if((S.at(i-1)=='A')&&(S.at(i)=='C')){
      count[i]=count[i-1]+1;
    }
    else count[i]=count[i-1];
  }
  int l,r;
  for (int i=0;i<Q;i++){
    cin>>l>>r;
    //cout<<count[r-1]<<" "<<count[l-1]<<endl;
    cout<<count[r-1]-count[l-1]<<endl;
  }
   return 0;
}


Measured memory_bytes: 1408
import sys
sys.setrecursionlimit(10 ** 9)
N = int(input())
h = list(map(int, input().split()))
INF = 10 ** 9
dp = [INF] * N

def func(i):
    if dp[i] < INF:
        return dp[i]
    if i == 0:
        return 0
    dp[i] = min(dp[i], func(i - 1) + abs(h[i] - h[i - 1]))
    if i > 1:
        dp[i] = min(dp[i], func(i - 2) + abs(h[i] - h[i - 2]))
    return dp[i]
  
print(func(N - 1))

Measured memory_bytes: 93708
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int main(){
    ll x;
    cin >> x;

    ll money = 100;
    ll ans = 0;
    while(money < x){
        money += money / 100;
        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3644
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const mod int = 1e9 + 7

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}

	ans := 0
	for i := uint(0); i <= 60; i++ {
		n0 := 0
		for j := 0; j < n; j++ {
			if (a[j]>>i)&1 == 0 {
				n0++
			}
		}

		x := n0 * (n - n0) % mod
		for k := 0; k < int(i); k++ {
			x = x * 2 % mod
		}

		ans = (ans + x) % mod
	}

	fmt.Println(ans)
}

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 8168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }

int main() {
  vector<int> h(10);
  for (int i = 0; i < (int)10; ++i) cin >> h[i];
  sort((h).begin(), (h).end());
  cout << h[9] << endl;
  cout << h[8] << endl;
  cout << h[7] << endl;
  return 0;
}



Measured memory_bytes: 3160
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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; }

string N;

int main(){
    cin>>N;
    if(N[0]==N[1] && N[1]==N[2]){
        out("Yes");
    }
    else if(N[3]==N[1] && N[1]==N[2]){
        out("Yes");
    }
    else out("No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,K;
  cin >> N >> K;
  vector<long long>A(N);
  for(long long i=0; i<N; i++){
    cin >> A[i];
  }
  for(long long i=0; i<N-K; i++){
    if(A[i] < A[i+K]){
      cout << "Yes" << endl;
    }
    else{
    cout << "No" << endl;
    }
  }
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)

using ll = long long;

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	int len = v.size();
    cout << '[';
	for (int i = 0; i < len; ++i) {
		s << v[i]; if (i < len-1) s << ", ";
	}
    cout << ']';
	return s;
}

int main(){

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

    string s;
	cin >> s;


	int ans = 0;
	int l = 0, r = s.size()-1;
	while(l <= r){
		if(s[l] == s[r]){
			++l; --r;
		}
		else{
			if(s[l] == 'x'){
				++ans;
				++l;
				continue;
			}
			else if(s[r] == 'x'){
				++ans;
				--r;
				continue;
			}
			else{
				ppp(-1);
				return 0;
			}
		}
	}


	ppp(ans);




    return 0;
}


Measured memory_bytes: 512
#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>;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a == b && a != c){
  	cout << "Yes" << endl;
  }else if(a == c && a != b){
  	 cout << "Yes" << endl;
  }else if(b == c && a != b){
  	cout << "Yes" << endl;
  }else{
  	cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
/* 
   AOJ 1275
   And Then There Was One

*/
#include<stdio.h>
#include<stdlib.h>

struct node
{
  int val;
  struct node* next;
};


struct node* make_circle(int n)
{
  struct node* head = malloc(sizeof(struct node*));
  struct node* p;
  int i;

  head->val = 1;
  for(i = 2, p = head; i < n + 1; i++)
    {
      p->next = malloc(sizeof(struct node*));
      p = p->next;
      p->val = i;
    }
  p->next = head;
  return head;
}



int search_ans(struct node* head, int n, int k, int m)
{
  int i, j;
  struct node* p = head;
  struct node* prev = head;
  struct node* d;

  if(m == 1)
    {
      for(i = 0; i < n - 1; i++)
	{
	  prev = prev->next;
	}
    }
  else
    {
      for(i = 0; i < m - 1; i++)
	{
	  prev = p;
	  p = p->next;
	}
    }

  /* printf("p = %d, prev = %d\n", p->val, prev->val); */

  for(i = 0; i < n - 1; i++)
    {
      prev->next = p->next;
      d = p;
      for(j = 0; j < k; j++)
	{
	  prev = p;
	  p = p->next;
	}
      free(d);
      /* printf("p is %d, prev = %d\n", p->val, prev->val); */
    }
  return p->val;
}



int main(void)
{
  int n, k, m, ans;
  struct node* head;
  while(1)
    {
      scanf("%d %d %d", &n, &k, &m);
      if(n == 0 && k == 0 && m == 0)
	{
	  break;
	}

      head = make_circle(n);
      ans = search_ans(head, n, k, m);

      printf("%d\n", ans);
    }
  return 0;
}

Measured memory_bytes: 912
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  int D, N;
  cin >> D >> N;
  int S = 1;
  for (int i = 0; i < D; i++)
  {
    S *= 100;
  }
  if (N <= 99)
  {
    cout << S * N << endl;
  }
  else
  {
    cout << S * 101 << endl;
  }
  return 0;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long

typedef pair<lint, lint> P;
const lint MOD = 1e9+7;
const lint INF = MOD * MOD;

int main(){
    lint k; cin >> k;
    if(k == 0){
        cout << 2 << endl << "1 1" << endl;
        return 0;
    }
    if(k == 1){
        cout << 2 << endl << "2 0" << endl;
        return 0;
    }
    if(k <= 50){
        cout << k << endl;
        rep(i, k){
            cout << k << " ";
        }
        cout << endl;
        return 0;
    }
    lint x = (k/50) + 49;
    lint m = (k%50) / 3;
    lint l = (k%50) % 3;
    cout << 50 << endl;
    cout << (x + 48*m + 50*l) << " ";
    cout << (x + 48*m - l) << " " << (x + 48*m - l) << " ";
    rep(i, 47){
        cout << (x - 3*m - l) << " ";
    }
    cout << endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    int n=s.size();
    vector<bool> dp(n+1);
    dp[0]=true;
    rep(i,n)if(dp[i]){
        if (i+5<=n && s.substr(i,5)=="dream") dp[i+5]=true;
        if (i+7<=n && s.substr(i,7)=="dreamer") dp[i+7]=true;
        if (i+5<=n && s.substr(i,5)=="erase") dp[i+5]=true;
        if (i+6<=n && s.substr(i,6)=="eraser") dp[i+6]=true;
    }
    if (dp[n]){
        cout<<"YES\n";
    }else{
        cout<<"NO\n";
    }
    return 0;
}


Measured memory_bytes: 512
n,m=map(int,input().split())
S=list(map(int,input().split()))
T=list(map(int,input().split()))
p=[0]*m
for s in S:
  k=0
  d=[0]*(m+1)
  for i in range(m):
    if T[i]==s:
      k+=p[i-1]+1
    d[i]=(p[i]+k)%(10**9+7)
  p=d
print(p[-2]+1)

Measured memory_bytes: 41708
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
const ll mod=1e9+7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
 
 
map<char,vector<int>>m3;
string s,t;
int binarySearch(int i,int l, int r, int x)
{
    while (l <= r) {
        int m = l + (r - l) / 2;
 
        // Check if x is present at mid
       	if(m == m3[t[i]].size() - 1) return m;
        if ((m3[t[i]][m]<=x)&&(m3[t[i]][m+1]>x))
            return m+1;
 
        // If x greater, ignore left half
        if (m3[t[i]][m] < x)
            l = m + 1;
 
        // If x is smaller, ignore right half
        else
            r = m - 1;
    }
    return 0;
}
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>s>>t;
    int n=s.length();
    int m=t.length();
    map<char,int>m1,m2;
    for(int i=0;i<n;i++){
        m1[s[i]]=1;
    }
    for(int i=0;i<m;i++){
        m2[t[i]]=1;
    }
    map<char,int>::iterator it=m2.begin();
    for(it;it!=m2.end();it++){
        if(m1[it->first]!=1){cout<<-1<<endl;return 0;}
    }
    for(int i=0;i<n;i++){
        m3[s[i]].push_back(i);
    }
    map<char,vector<int>>::iterator it1=m3.begin();
    for(it1;it1!=m3.end();it1++){
        sort((it1->second).begin(),(it1->second).end());
    }
    ll res=0;
    int cnt=0;
    int last=0;
    for(int i=0;i<m;i++){
        if(i==0){res+=(1+m3[t[0]][0]);last=m3[t[0]][0];continue;}
        int taille=m3[t[i]].size();
        int el=0;
        if(last>=m3[t[i]][taille-1])el=m3[t[i]][0];
        else{el=m3[t[i]][binarySearch(i,0,taille-1,last)];}
        if(el>last){res+=(el-last);}
        else{res+=(el+1);res+=(n-last-1);}
        last=el;
    }
    cout<<res<<endl;
    return 0;
    }

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
#define _cTime (chrono::system_clock::now())
#define progress (chrono::duration_cast<chrono::milliseconds>(_cTime-_sTime).count())
#define reset _sTime=_cTime
auto reset;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	vi v(n);
	int a,b;
	rep(i,m){
		cin>>a>>b;
		a--;b--;
		v[a]++;v[b]++;
	}
	bool ans=true;
	rep(i,n)ans&=(v[i]%2==0);
	YN(ans);
}



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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, a, b;
	cin >> n >> a >> b;
	
	cout << min(a, b) << " ";
	if (a + b > n) {
		cout << a + b - n << endl;
	} else {
		cout << 0 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#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;};

vector<int> memo(100010);

signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	
	int n;
	cin >> n;
	int a[n], sum = 0;
	rep(i, n) {
		cin >> a[i];
		memo[a[i]]++;
		sum += a[i];
	}
	int q;
	cin >> q;
	int b[q], c[q];
	rep(i, q) cin >> b[i] >> c[i];

	rep(i, q) {
		int cur = c[i] - b[i];
		sum += cur * memo[b[i]];
		memo[c[i]] += memo[b[i]];
		memo[b[i]] = 0;
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 6364
#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>;

int main(){
    int n;
    cin >> n;
    rep(i, 9)
        rep(j, 9)
            if((i+1)*(j+1) == n){
                cout << "Yes" << endl;
                return 0;
            }
    cout << "No" << endl;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
	vector<int> AA = {
1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
	};
  int var;
cin >> var;
cout << AA.at(var-1) << endl;
  
}

Measured memory_bytes: 256
def ncr(n, r, p): 
    num = den = 1 
    for i in range(r): 
        num = (num * (n - i)) % p 
        den = (den * (i + 1)) % p 
    return (num * power(den,  
            p - 2, p)) % p 

def power(x, y, p) : 
    res = 1 
    x = x % p  
    while (y > 0) : 
        if ((y & 1) == 1) : 
            res = (res * x) % p 
        y = y >> 1  
        x = (x * x) % p 
    return res 
n,a,b=list(map(int,input().split()))
p=1000000007;
r=ncr(n,a,p)
s=ncr(n,b,p)
ans=power(2,n,p)-1
ans=ans-r-s
print(ans%p)

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

using namespace std;

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

	vector<int> t(n);
	vector<string> s(n);

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

	string title;
	cin >> title;

	bool is_sleep = false;

	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (is_sleep) {
			ans += t[i];
			continue;
		}
		if (title == s[i]) {
			is_sleep = true;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 888
N, Y = map(int, input().split())
# x:10000円, y;5000円, z:1000円
for x in range(N+1):
    for y in range(N-x+1):# 5000円の枚数をN-(10000円の枚数)までに制限
        z = N - (x + y)
        if 10000*x + 5000*y + 1000*z == Y:
            print(x, y, z)
            exit(0)
print(-1, -1, -1)


Measured memory_bytes: 2940
from collections import deque

def dfs(graph, start, goal):
    stack = deque()
    push, pop = stack.append, stack.pop
    push(start)
    visited = [False for i in range(N+1)]
    visited[start] = True
    
    while stack:
        a = pop()
        for b in graph[a].keys():
            if a in [start, goal] and b in [start, goal]:
                continue
            elif b == goal:
                return True
            elif not visited[b]:
                push(b)
                visited[b] = True
    return False

N,M = map(int, input().split())
graph = {}
bridge = []
for i in range(M):
    a,b = map(int, input().split())
    if a not in graph:
        graph[a] = {}
    if b not in graph:
        graph[b] = {}
    graph[a][b] = graph[b][a] = 1
    bridge.append([a,b])

ans = 0
for a,b in bridge:
    ans += not dfs(graph, a, b)
print(ans)

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

int main() {
  int N,M;
  cin >> N >> M;
  
  vector<vector<int>> city(M, vector<int>(2));
  for(int i=0;i<M;i++){
    for(int j=0;j<2;j++){
      cin >> city.at(i).at(j);
    }
  }
  vector<int> map(N);
  for(int i=0;i<M;i++){
    for(int j=0;j<2;j++){
      for(int k=0;k<N;k++){
        if(city.at(i).at(j) == k+1){
          map.at(k)++;
        }
      }
    }
  }
  for(int i=0;i<N;i++){
    cout << map.at(i) << endl;
  }
}
          

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstring>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<vector>
using namespace std;
int x[100000];
int L[100000], R[100000];
int main() {

	int n, k;
	cin >> n >> k;
	int i;
	int base = -1;//はじめてx[i]>=0となるi
	for (i = 0; i < n; i++) {

		cin >> x[i];
		if (x[i] >= 0 && base == -1)base = i;
	}
	if (base == -1)base = n;

	for (i = base; i < n; i++) {
		R[i - base] = x[i];
		//cout << "R[" << i - base << "]=" << R[i - base] << endl;
	}
	for (i = base - 1; i >= 0; i--) {
		L[base - 1 - i] = -x[i];
		//cout << "L[" << base - 1 - i << "]=" << L[base - 1 - i] << endl;
	}
	int MIN = 1000000000;

	if (n - 1 - base >= k - 1) {
		MIN = min(MIN, R[k - 1]);
		//cout << "MIN = min(MIN, R[k - 1]) = " << MIN << endl;
	}
	if (base - 1 >= k - 1) {
		MIN = min(MIN, L[k - 1]);
		//cout << "MIN = min(MIN, L[k - 1]) = " << MIN << endl;
	}
	for (i = 0; i < k; i++) {
		if (i <= base - 1 && k - i - 2 <= n - 1 - base) {
			MIN = min(MIN, L[i] * 2 + R[k - i - 2]);
			//cout << "MIN = min(MIN, L[i] * 2 + R[k - i - 2]) = " << MIN << endl;
		}
		if (i <= n - 1 - base && k - i - 2 <= base - 1) {
			MIN = min(MIN, R[i] * 2 + L[k - i - 2]);
			//cout << "MIN = min(MIN, R[i] * 2 + L[k - i - 2]) = " << MIN << endl;
		}
	}
	cout << MIN << endl;
	return 0;
}

Measured memory_bytes: 4404
#include <iostream>
using namespace std;
const int INF = 1001000;

int main() {
    int N, T;
    cin >> N >> T;
    int cost = INF;

    for(int i=0; i<N; ++i) {
        int c,t;
        cin >> c >> t;
        if(c < cost && t <= T) cost = c;
    }
    if(cost == INF) cout << "TLE" << endl;
    else cout << cost << endl;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))

A.sort(reverse=1)

R = [0, 0]
r_ind = 0
a_ind = 0
while r_ind < 2 and a_ind < n-1:
    if A[a_ind] == A[a_ind + 1]:
        R[r_ind] = A[a_ind]
        a_ind += 2
        r_ind += 1
    else:
        a_ind += 1

print(R[0] * R[1])

Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
ll solver(int N, int K, string S) { /*
   while (K >= 0) {
     int l = 0, r = S.size() - 1;
     while (S[l] == 'L') l++;
     while (S[r] == 'R') r--;
     if (r - l >= 0) break;
     K--;
     for(int l=i;i<=r;i++){

     }
   }*/
  ll ans = 0;
  REP(i, S.size()) {
    if (i != 0 && S[i] == 'L') {
      if (S[i - 1] == 'L') ans++;
    } else if (i != S.size() - 1 && S[i] == 'R') {
      if (S[i + 1] == 'R') ans++;
    }
  }
  ans += 2 * K;
  if (ans >= S.size() - 1) ans = S.size() - 1;
  return ans;
}
int main() {
  int N, K;
  string S;
  cin >> N >> K >> S;
  cout << solver(N, K, S) << endl;
}

Measured memory_bytes: 3820
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

#define rep(i, n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
int n,m;
while(true) {
    cin >> n >> m;
    if(n==0&&m==0)break;
    int nsum=0;int msum=0;
    vector<int> nk(n);
    vector<int> mk(m);
    rep(i,n){
        cin>>nk[i];
        nsum+=nk[i];
    }
    rep(i,m){
        cin>>mk[i];
        msum+=mk[i];
    }
    int ans1=0;int ans2=0;bool f=false;

    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(nsum-nk[i]+mk[j]==msum-mk[j]+nk[i]){
                cout<<nk[i]<<" "<<mk[j]<<endl;
                f=true;
                break;
            }
        }
        if(f)break;
    }
    if(!f){
        cout<<-1<<endl;
    }





}

    return 0;
}



Measured memory_bytes: 3004
module IntSet = Set.Make (struct
  type t = int
  let compare = compare
end)

let () = Scanf.scanf "%d\n" @@ fun n ->
  let ps = Array.make n 0 in
  for i = 0 to n - 1 do
    Scanf.scanf "%d " @@ fun p ->
      ps.(p - 1) <- i
  done;
  let acc = Array.make n IntSet.empty in
  for i = n - 2 downto 0 do
    acc.(i) <- IntSet.add ps.(i + 1) acc.(i + 1)
  done;
  Printf.printf "%d\n" @@
  Array.fold_left ( + ) 0 @@ 
  Array.init n @@ fun p ->
    let ls, false, rs = IntSet.split ps.(p) acc.(p) in
    let l1, l2 = 
      match IntSet.max_elt ls with
      | exception Not_found -> -1, -1
      | l2 ->
          ( try IntSet.max_elt (IntSet.remove l2 ls)
            with Not_found -> -1 ),
          l2
    and r1, r2 =
      match IntSet.min_elt rs with
      | exception Not_found -> n, n
      | r1 ->
          r1,
          ( try IntSet.min_elt (IntSet.remove r1 rs)
      with Not_found -> n ) in
    (p + 1) * 
    ((r1 - ps.(p)) * (l2 - l1) + (ps.(p) - l2) * (r2 - r1))


Measured memory_bytes: 75388
#include <iostream>
#include <vector>

using namespace std;
using ulli = unsigned long long int;
int main(void){
	int N;
	ulli T;
	
	cin >> N >> T;
	
	vector<ulli> v(N);
	for(int i = 0; i < N; ++i){
		cin >> v[i];
	}
	
	ulli sum = 0;
	for(int i = 0; i < N - 1; ++i){
		sum += min(v[i + 1] - v[i], T);
	}
	sum += T;
	cout << sum << endl;
	
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//
ll N;
vvc<pair<int,int>> G(100005);
int dist[100005];

void dfs(int now, int parent, int range){
    dist[now] = range;
    for(auto& e: G[now]){
        int to, cost;
        tie(to, cost) = e;
        if (to == parent) continue;
        dfs(to, now, range + cost);
    }
    return;
}
int main() {
    init();
    cin >> N;
    rep(i,N-1){
        ll a, b, c;
        cin >> a >> b >> c;
        G[a].eb(b, c);
        G[b].eb(a, c);
    }

    dfs(0, -1, 0);

    int start, r = 0;
    rep(i, N) if (chmax(r, dist[i])) start = i;

    fill(dist, dist + N, 0);

    dfs(start, -1, 0);

    cout << *max_element(dist, dist + N) << endl;
}


Measured memory_bytes: 13312
N = int(input())
T, A = map(int, input().split())
h_list = list(map(int,  input().split()))

temp_diff = 10000
tidx = -1

for i in range(N):
    x = h_list[i]
    temp = T - x*0.006
    abs_temp_diff = abs(A-temp)

    if abs_temp_diff <= temp_diff:
        temp_diff = abs_temp_diff
        tidx = i+1
print(tidx)


Measured memory_bytes: 3060
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;

int s_n(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }

    return sum;
}

void main() {
    int n = readln.chomp.to!(int);

    writeln((n % s_n(n) == 0) ? "Yes" : "No");
}

Measured memory_bytes: 256
// Problem : D - Maze Master
// Contest : AtCoder - AtCoder Beginner Contest 151
// URL : https://atcoder.jp/contests/abc151/tasks/abc151_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

int n,m;

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

bool valid(int x, int y){
    return x>=0 && y>=0 && x<n && y<m;
}

void solve(){
    cin>>n>>m;
    vector<vector<char>> a(n,vector<char>(m));
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++) cin>>a[i][j];
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(a[i][j] == '#') continue;
            queue<pii> q;
            vector<vi> d(n,vi(m,inf));
            q.push({i,j});
            d[i][j] = 0;
            while(!q.empty()){
                pii p = q.front();
                q.pop();
                int x = p.fi, y = p.se;
                ans = max(ans,d[x][y]);
                for(int i=0;i<4;i++){
                    int nx = x+dx[i];
                    int ny = y+dy[i];
                    if(!valid(nx,ny) || a[nx][ny] == '#' || d[nx][ny] != inf) continue;
                    d[nx][ny] = d[x][y]+1;
                    q.push({nx,ny});
                }
            }
        }
    }
    cout<<ans;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3656
'use strict'
 
function Main(input) {
	const month = input.split(' ')[0];
	const day = input.split(' ')[1];
	if(month <= day){
		console.log(month);
	} else {
		console.log(month - 1);
	}


 
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9420
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
typedef long long ll;
using namespace std;
int main()
{
	ll N, A, B; 
  	cin >> N;
  	vector<pair<ll, ll>> jobs(N);
  	for (ll i = 0; i < N; i++) {
    	cin >> A >> B;
      	jobs[i] = make_pair(B, A);
    }
  	vsort(jobs);
  	ll deadline, task = 0;
  	for (ll i = 0; i < N; i++) {
      	deadline = jobs[i].first;
    	task += jobs[i].second;
      	if (task > deadline){
        	cout << "No" << endl;
          	return 0;
        }
    }
  	cout << "Yes" << endl;
}

Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<vector>
#include<assert.h>
using namespace std;

int const N = 2e5 + 41;
int const INF = 1e7 + 41;
int n, k, st[N], cnt[N], ans[N], f[N];
vector<int> e[N];

void prepare(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
}

void read(){
	scanf("%d",&n);
	for(int i=0;i<n-1;++i){
		int a, b;
		scanf("%d%d",&a,&b);
		--a;--b;
		e[a].push_back(b);
		e[b].push_back(a);
	}
	for(int i=0;i<n;++i){
		st[i] = -INF;
		cnt[i] = INF * 5;
	}
	scanf("%d",&k);
	for(int i=0;i<k;++i){
		int vi, pi;
		scanf("%d%d",&vi,&pi);
		--vi;
		st[vi] = pi;
		cnt[vi] = 1;
		f[vi] = 1;
		assert(pi <= 1e7);
	}
}

void bad(){
	printf("No\n");
	exit(0);
}

void check(int u){
	if(cnt[u] == 0){
		bad();
	}
}

void merge(int u, int to){
	if(!f[u] && !f[to]){
		return;
	}
	if(!f[u] || !f[to]){
		if(!f[u]){
			st[u] = st[to] - 1;
			cnt[u] = cnt[to] + 1;
			f[u] = 1;
		}
		return;
	}
	
	int le = (st[to] - 1);
	if(le % 2 != st[u] % 2){
		cnt[u] = 0;
		return;
	}
	int ri = (cnt[to]) * 2 + le;
	le = max(le, st[u]);
	ri = min(ri, st[u] + (cnt[u] - 1) * 2);
	if(le > ri){
		cnt[u] = 0;
		return;
	}
	st[u] = le;
	cnt[u] = (ri - le) / 2 + 1;
	f[u] = 1;
}

void dfs(int u, int p){
	for(int i=0;i<e[u].size();++i){
		int to = e[u][i];
		if(to == p){
			continue;
		}
		dfs(to, u);
		merge(u, to);
		check(u);
	}
}

void dfs1(int u, int p, int curV){
	ans[u] = curV;
	for(int i=0;i<e[u].size();++i){
		int to = e[u][i];
		if(to == p){
			continue;
		}
		if(st[to] <= curV - 1 && st[to] + (cnt[to] - 1) * 2 >= curV -1){
			dfs1(to, u, curV-1);
		}else{
			dfs1(to, u, curV+1);
		}
	}
}

void solve(){
	dfs(0, 0);
	dfs1(0, 0, st[0]);
	printf("Yes\n");
	for(int i=0;i<n;++i){
		printf("%d\n",ans[i]);
	}
}

int main(){
	prepare();
	read();
	solve();



	return 0;
}

Measured memory_bytes: 18176
s=input()
n=len(s)
t=int((n-1)/2)
a=s[:t]
b=s[int((n+3)/2)-1:]
check=False
if a==b:
    check=True
    if n%4==1:
        r=int((n-1)/4)
    else:
        r=int((n-3)/4)
    for i in range(r):
        if s[i]!=s[t-1-i]:
            check=False
            break
if check:
    print("Yes")
else:
    print("No")

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

using ll = long long;
template <typename T> constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (ll i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (ll i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define COMP(key) [](const auto& a, const auto& b) { return a.key < b.key; }

template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& a) { return is >> a.first >> a.second; }
template<typename T> istream& operator>>(istream& is, vector<T>& a) { for (T& x : a) is >> x; return is; }

template<typename T> using pop_max = std::priority_queue<T>;
template<typename T> using pop_min = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T> void LOG(const T& x) { cerr << x << "\n"; }
template<typename T> void LOG(const vector<T>& a) { for (const T& x : a) cerr << x << " "; cerr << "\n"; }
template<typename T> void LOG(const vector<vector<T>>& a) { for (const auto& x : a) LOG(x); }
template<typename T, std::size_t S> void LOG(const T (&a)[S]) { REP(i, S) cerr << a[i] << " "; cerr << "\n"; }
template<typename T, std::size_t S, std::size_t R> void LOG(const T (&a)[S][R]) { REP(i, S) { REP(j, R) cerr << a[i][j] << " "; cerr << "\n"; } }

ll ceil(ll a, ll b) { return a > 0 ? (a - 1) / b + 1 : a / b; }
ll gcd(ll a, ll b) { while (b != 0) { ll t = b; b = a % b; a = t; } return a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll gcd(const vector<ll>& v) { return accumulate(v.begin(), v.end(), 1LL, static_cast<ll(*)(ll, ll)>(gcd)); }
ll lcm(const vector<ll>& v) { return v.empty() ? 0LL : accumulate(v.begin() + 1, v.end(), v[0], static_cast<ll(*)(ll, ll)>(lcm)); }
ll pow(ll x, ll y, ll z) { ll a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }
ll inv(ll x, ll m) { return pow(x, m - 2, m); }

template<typename T> bool chmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<typename T> bool chmin(T& x, const T& y) { return x > y ? x = y, true : false; }

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_cpp;

const ll INF = inf<ll>;
using P = pair<ll, ll>;
const ll M = 1000000007;
signed main() {
    ll n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    ll a=0;
    ll b=0;
    REP(i,n-1){
        if(s[i]==s[i+1])a++;
        else b++;
    }
    a+=min(b,k*2);
    cout<<a<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

constexpr lint MOD = 1000000007;
lint N, M, K;

lint power(lint x,lint n, lint mod)
{
    lint ans = 1;
    while (n>0)
    {
        if (n & 1) ans = ans * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return ans;
}

vector<lint> factorial;
vector<lint> facInv;
void cPrecal(int n)
{
    factorial = facInv = vector<lint>(n+1, 1);
    for (int i=1; i<=n; i++)
    {
        factorial[i] = factorial[i-1] * i % MOD;
        facInv[i] = power(factorial[i], MOD-2, MOD);
    }
}

lint nCr(int n, int r)
{
    if (n<r || r<0) return 0;
    else return (factorial[n] * facInv[r] % MOD) * facInv[n-r] % MOD;
}

int main()
{
    cin >> N >> M >> K;
    if (K > M) swap(M, K);

    cPrecal(N+M+K);
    lint ans = 0;
    lint bcpattern;
    for (lint k=0; k<=M+K; k++)
    {
        if (k <= K) bcpattern = power(2, k, MOD);
        else if (k <= M) bcpattern = (bcpattern * 2 - nCr(k-1, K) + MOD) % MOD;
        else bcpattern = (bcpattern * 2 - nCr(k-1, K) - nCr(k-1, k-1-M) + 2 * MOD) % MOD;
        lint tmp = ((nCr(N-1+k, k) % MOD) * bcpattern % MOD) * power(3, M+K-k, MOD);
        ans  = (ans + tmp) % MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 14336
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1001001001;
const ll LONGINF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int main() {
    vector< pair<int, int> > RLE;
    int N, K; cin >> N >> K;
    string s; cin >> s;
    for(int i=0; i<N; i++) {
        if(RLE.empty() or RLE.back().first != s[i]) RLE.emplace_back(s[i], 1);
        else RLE.back().second++;
    }

    int ans = 0;
    for(auto e : RLE) ans += e.second - 1;

    int M = RLE.size();
    while(K > 0 and M > 1) {
        if(M >= 3) {
            ans += 2;
            M -= 2;
        }
        else {
            ans += 1;
            M -= 1;
        }
        K--;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
using ll = long long;

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> sides_candidate;

    for(ll i=0;i < n;i ++)
    {
        cin >> a[i];
    }
    sort(a.rbegin(),a.rend());
    for(ll i=0;i < n-1;i ++)
    {
                if(sides_candidate.size() == 2)
                {
                        break;
                }
                if(a[i] == a[i+1])
                {
                        sides_candidate.push_back(a[i]);
                        i ++;
                }
    }

    if(sides_candidate.size() == 2)
    {
        cout << sides_candidate[0] * sides_candidate[1] << endl;
    }
    else
    {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  string s; cin >> s;
  s[3] = '8';
  cout << s << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
import math
s = input()

n = len(s)

def is_kaibun(s):
    n = len(s)
    h = s[0:math.ceil((n-1)/2)]
    t =  s[(n+3)//2-1:n]
    #print(h,t)
    return h == t[::-1]

h = s[0:(n-1)//2]
t =  s[(n+3)//2-1:n]

if is_kaibun(s) and is_kaibun(h) and is_kaibun(t):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
string s;
int main() {
	cin>>s;
	if(s[0]==s[s.length()-1]) {
		if(s.length()%2==0) {
			cout<<"First"<<endl;
			return 0;
		} else {
			cout<<"Second"<<endl;
			return 0;
		}
	} else {
		if(s.length()%2==0) {
			cout<<"Second"<<endl;
			return 0;
		} else {
			cout<<"First"<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 512
from math import gcd 
N,K=map(int,input().split())

mod=10**9+7

A=[0]*K

for i in range(K,0,-1):
    a=K//i
    b=pow(a,N,mod)
    A[i-1]=b

for i in range(K,0,-1):
    for j in range(K//i-1):
        c=i*(j+2)
        A[i-1]-=A[c-1]
        A[i-1]%=mod

s=0
for i in range(K):
    s+=A[i]*(i+1)
    s%=mod

print(s)

Measured memory_bytes: 11284