akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
const int INF = 1e9;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007
//setprecision(15)

int main() {
	int N, K; cin >> N >> K;
	int ans = 0;
	rep(i, N) {
		int x; cin >> x;
		int m = min(x, K-x);
		ans += m * 2;
	}
	cout << ans << endl;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

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

  ll ans = 0;
  for (ll i = 0; i <= 60; i++) {  // 2進数で何桁目を見るか
    ll count = 0;                 // 1の回数
    for (int j = 0; j < n; j++) {
      count += (v[j] >> i) & 1;
    }
    ans += (1ll << i) % MOD * count % MOD * (n - count) % MOD;
    ans %= MOD;
  }

  cout << ans % MOD << endl;
}


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

typedef pair<int, int> P;
#define ll long long
#define ld long double
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;


int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> mp;
    rep(i, n)
    {
        cin >> a[i];
        mp[a[i]]++;
    }
    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());
    
    int ans = 0;
    for (auto s : a)
    {
        if (mp[s] >= s)
        {
            ans += mp[s]-s;
        }
        else
        {
            ans += mp[s];
        }
        //cout << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

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

    int ans = 1;
    for (int i = 0; i < S.size(); ++i) {
        if (i > 0) {
            if (S[i] != S[i-1]) ++ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>

using namespace std;
using boost::sort;
using boost::adaptors::reversed;

int main() {
    string s;
    cin >> s;
    int n = 0;
    for (auto c : s) {
        n = (n + (c - '0')) % 9;
    }
    cout << (n == 0 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    ll n; cin >> n;
    string s; cin >> s;
    ll cumW[n], cumE[n];
    ll cntW = 0, cntE = 0;
    REP(i, n){
        if(s[i] == 'W') cntW++;
        if(s[i] == 'E') cntE++;
        cumW[i] = cntW;
        cumE[i] = cntE;
    }

    ll res = 1000000000;
    REP(i, n){
        ll tmp = 0;
        if(i != 0) tmp += cumW[i-1];
        if(i != n-1) tmp += cumE[n-1] - cumE[i];
        res = min(res, tmp);
        //cout << tmp << endl;
    }
    cout << res << endl;
}

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

Measured memory_bytes: 5396
#include <stdio.h>
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

int ReadValue() {
    int value; 
    scanf("%d",&value); 
    return value;
}
void ReadArray(int R[],int n) {
    int i; 
    for (i=0; i<n; i++) {
        scanf("%d",&R[i]);
    } 
}
int main() {
    int n=ReadValue();
    int R[n]; ReadArray(R,n);
    int maxR=R[1]-R[0],minR=R[0];
    for (int i=1; i<n; i++) {
        maxR=max(maxR,R[i]-minR);
        minR=min(minR,R[i]);
    }
    printf("%d\n",maxR);
    return 0;
}


Measured memory_bytes: 2516
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
using namespace std;

#define INF INT_MAX / 3
#define LINF LLONG_MAX / 3

/*
 * ???????????§????????????????????????
 */

int main(){
    int N,W; cin>>N>>W;
    vector<int> v(N),w(N);
    for(int i=0;i<N;i++) cin>>v[i]>>w[i];
    int sumv = 0;
    for(int i=0;i<N;i++) sumv += v[i];
    vector<vector<int>> dp(N+1,vector<int>(sumv+1,INF));

    dp[0][0] = 0;

    for(int i=0;i<N;i++){
        for(int j=0;j<=sumv;j++){
            if(j<v[i]){
                dp[i+1][j] = dp[i][j];
            }else{
                dp[i+1][j] = min(dp[i][j],dp[i][j-v[i]]+w[i]);
            }
        }
    }

    int ans = 0;
    for(int i=0;i<=sumv;i++) if(dp[N][i]<=W) ans = i;
    cout << ans << endl;
}

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
ll LCM(int a, int b){
    return a*b/gcd(a,b);
}
int counterBit(int x){
    if(x==0)return 0;
    return counterBit(x>>1)+(x&1);
}
int main(void)
{
    int n;
    cin>>n;
    map<int,int> mp;
    rep(i,1,n+1){
        int x=i;
        for(int a=2;a<=x;a++){
            while(x%a==0){
                mp[a]++;
                x/=a;
            }
        }
    }

    ll ans=1;
    for(auto x : mp){
        ans = ans * (x.second+1)%INF;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#b
a,b,k=list(map(int,input().split()))
ans=[]
if k<=a:
    ans.append(a-k)
    ans.append(b)
elif (k-a)<=b:
    ans.append(0)
    ans.append(b-k+a)
else:
    ans.append(0)
    ans.append(0)
x=str(ans[0])+' '+str(ans[1])
print(x)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
#define fi first
#define se second
const ll inf = 9e18;
const ll mod = 1e9 + 7;

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

	ll n;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	ll dp[n+2] = {0};
	dp[0]  = 0;
	dp[1] = abs(a[1] - a[0]);
	for(int i=2;i<n;i++){
		dp[i] = min(dp[i-1] + abs(a[i-1] - a[i]), dp[i-2]+ abs(a[i] - a[i-2]));
	}
	cout<<dp[n-1]<<"\n";
	return 0;
}




Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <array>
#include <cmath>

int main()
{
    using namespace std;
    int n, i;
    array <int, 1000>score;
    double result, sum1, sum2;
    
    while (cin >> n) {
        if (n == 0) break;
        
        sum1 = sum2 = 0;
        for (i = 0; i < n; ++i) {
            cin >> score.at(i);
            sum1 += score.at(i);
            sum2 += score.at(i) * score.at(i);
        }

        result = sqrt(sum2 / n - (sum1 / n ) * (sum1 / n));

        printf("%.8f\n", result);

    }

    return 0;
}
        
        

Measured memory_bytes: 1184
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<55;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

int n;
vl a;

int main(){
	cin>>n;
	a=vl(n);
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=1;i<n;i++) a[i]+=a[i-1];
	ll ans=0,sum=a[n-1];
	for(int i=0;i<n;i++){
		int Im=lower_bound(a.begin(),a.end(),(a[i]+sum/3)%sum)-a.begin();
		int IM=lower_bound(a.begin(),a.end(),(a[i]+sum/3*2)%sum)-a.begin();
		for(int j=Im-1;j<Im+1;j++) for(int k=IM-1;k<IM+1;k++){
			ll A=(a[(j+n)%n]-a[i]+sum)%sum;
			ll B=(a[(k+n)%n]-a[(j+n)%n]+sum)%sum;
			ans=max(ans,min(A,min(B,sum-A-B)));
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4444
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int A,B; cin >> A >> B;
    int sum=0;
    for(int i=0; i<2; i++){
        if(B>A){
            swap(A,B);
        }
        sum+=A;
        A--;
    }
    cout << sum << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#include <iomanip>
#include <tuple>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
using namespace std;


int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int m,d;
	cin >> m >> d;
	int cnt=0;
	rep(i,1,m+1){
		rep(j,1,d+1){
			int d1 = j%10;
			int d2 = j/10;
			if(d1>=2 && d2>=2 && d1*d2==i) cnt++;
		}
	}
	cout << cnt << endl;
}


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

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

const ll MOD = (ll)(1e9 + 7);

ll dp[5005][5005];


ll mod_pow(ll a, ll b, ll p) {
  ll res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % p;
    a = (a * a) % p;
    b >>= 1;
  }
  return res;
}

ll mod_inv(ll a, ll p) {
  return mod_pow(a % p, p - 2, p);
}


int main2() {
  CLR(dp, 0);
  int N; cin >> N;
  string s; cin >> s;
  dp[0][0] = 1;
  for (int n = 1; n <= N; n++) {
    for (int l = 0; l <= N; l++) {
      ll res = 0;
      res += dp[n-1][l+1]; // backspace
      if (l == 0) res += dp[n-1][l]; // backspace
      if (l - 1 >= 0) res += dp[n-1][l-1] * 2; // 0, 1
      dp[n][l] = res % MOD;
    }
  }
  ll ans = dp[N][s.size()];
  ll inv2 = mod_inv(2, MOD);
  REP(i, s.size()) (ans *= inv2) %= MOD;
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 196096
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define ld long double
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int n, q;
char c[N + 1], d[N + 1];
string s;

int check (int mid)
{
    int cur = mid;
    FOR (i, 1, q)
    {
        if (s[cur] == c[i])
        {
            if (d[i] == 'L') cur--;
            else cur++;
        }
        
        if (cur == n + 1) return 2;
        if (cur == 0) return 0; 
    }
    return 1;
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n >> q >> s;
	s = 'x' + s;
    FOR (i, 1, q) cin >> c[i] >> d[i];
    
    int l, r, hi = n + 1, lo = 1;
    while (lo < hi)
    {
        int mid = (lo + hi)/2, reply = check(mid);
        
        if (reply == 0) lo = mid + 1;
        else hi = mid;
    }    
	
	l = lo;
	if (l == n + 1) {cout << 0; return 0;}
	
	lo = 0, hi = n;
	while (lo < hi)
    {
        int mid = (lo + hi + 1)/2, reply = check(mid);
        
        if (reply == 2) hi = mid - 1;
        else lo = mid;
    }
	
	r = hi;
	if (r == 0) {cout << 0; return 0;}
	cout << r - l + 1;
}



















Measured memory_bytes: 976
#include <iostream>
using namespace std;
typedef long long int ll;
ll mod;
ll dp[2][201][11][(1<<11)];
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N,K; cin >> N >> K >> mod;
    dp[0][0][1][1]=1;
    int kk=(1<<(1+K));
    for(int _=0;_<N;_++){
        for(int i=0;i<201;i++){
            for(int j=0;j<11;j++){
                for(int k=0;k<kk;k++){
                    dp[1][i][j][k]=0;
                }
            }
        }
        for(int i=0;i<2*N;i++){
            for(int j=1;j<=K;j++){
                for(int k=0;k<kk;k++){
                    if(dp[0][i][j][k]==0)continue;
                    //cout << i << " " << j << " " << k << endl;
                    int t=0;
                    while((k>>t)&1)t++;
                    if(t>K)continue;
                    int ii=i+t;
                    int kkk=(k>>t)+1;
                    for(int jj=1;jj<=K;jj++){
                        if((kkk>>jj)&1)continue;
                        if(ii+jj-i-j>K)continue;
                        if(i+j<ii+jj&&ii+jj<=2*N)(dp[1][ii][jj][kkk|(1<<jj)]+=dp[0][i][j][k])%=mod;
                    }
                }
            }
        }
        for(int i=0;i<201;i++){
            for(int j=1;j<11;j++){
                for(int k=0;k<kk;k++){
                    //f(dp[1][i][j][k])cout << dp[1][i][j][k] << endl;
                    dp[0][i][j][k]=dp[1][i][j][k];
                }
            }
        }
    }
    ll ans=0;
    for(int i=0;i<2*N;i++){
        for(int j=1;j<=K;j++){
            for(int k=0;k<kk;k++){
                (ans+=dp[0][i][j][k])%=mod;
                //cout << dp[0][i][j][k] << endl;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 71500
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

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

#define int long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define f first
#define s second
#define sz(x) int(x.size())
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout << (x) << endl
#define watch2(x,y) cout << (x) << " " << (y) << endl
#define watch3(x,y,z) cout << (x) << " " << (y) << " " << (z) << endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 
typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> oset;

// find_by_order(k) returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;

const int mod = 998244353;
const int inf = 9e18;
const int N = 1e5 + 5;

void solve(){
    int k;
    cin>>k;
    vector<string> v;
    queue<string> q;
    for(char i='1';i<='9';++i){
        string s;
        s+=i;
        v.pb(s);
        q.push(s);
    }
    int t=k;
    while(t--){
        string s=q.front(),s1,s2,s3;
        q.pop();
        char c=s.back();
        s1=s2=s3=s;
        if(c=='0'){
            s1+='0';
            s2+='1';
            v.pb(s1);
            v.pb(s2);
            q.push(s1);
            q.push(s2);
        }
        else if(c=='9'){
            s1+='8';
            s2+='9';
            v.pb(s1);
            v.pb(s2);
            q.push(s1);
            q.push(s2);
        }
        else{
            s1+=char(c-1);
            s2+=char(c);
            s3+=char(c+1);
            v.pb(s1);
            v.pb(s2);
            v.pb(s3);
            q.push(s1);
            q.push(s2);
            q.push(s3);
        }
    }
    cout<<v[k-1];
}

signed main(){
    fastio;
    int t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 23792
#include <bits/stdc++.h>
#define INF 2000000000
using namespace std;
typedef long long ll;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while(c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
int a, b;
void init(){
    a = read(), b = read();
}
void solve(){
    cout << max(0, a - b - b) << endl;
}
int main(){
    init();
    solve();
    return 0;
}

Measured memory_bytes: 256
// C - Sum of product of pairs
    #include <bits/stdc++.h>
    using namespace std;
     
    int main(){
    	int N; cin>>N;
    	int MOD = (1e9) + 7;
    	int64_t ans = 0, b = 0;
    	for(int i=0; i<N; ++i){
    		int a; cin>>a;
    		ans += a * b % MOD;
    		b += a;
    		b %= MOD;
    	}
    	cout<< ans % MOD <<endl;
    }

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

int main()
{
	long long int n, s, i, j, k, l, m, sum;
	cin >> n >> s;
	int flag = 0;
	long long int b = floor(sqrt(n));
	if (s > n) {
		cout << "-1" << endl;
	}
	else {
		if (n == s) {
			cout << n + 1 << endl;
		}
		else {
			for (i = 2; i <= b; i++) {
				m = n;
				sum = 0;
				while (m > 0) {
					sum += m % i;
					m /= i;
				}
				if (sum == s) {
					flag = 1;
					break;
				}
			}
			if (flag == 1) {
				cout << i << endl;
			}
			else {
				for (i = b; i > 0; i--) {
					if ((n - s) % i == 0) {
						m = n;
						k = (n - s) / i + 1;
						sum = 0;
						while (m > 0) {
							sum += m % k;
							m /= k;
						}
						if (sum == s) {
							flag = 1;
							break;
						}
						
					}
				}
				if (flag)
					cout << (n - s) / i + 1 << endl;
			}
			if (flag == 0) {
				cout << "-1" << endl;
			}
		}
	}
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a,b,c,d,e;
	scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
	printf("%d\n",a<0 ? -a*c+d+b*e :(b-a)*e);
	return 0;
}


Measured memory_bytes: 2060
K = int(input())
l = [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]
print(l[K-1])


Measured memory_bytes: 3064
I=lambda:list(map(int,input().split()[::-1]))
m,n=I()
c=[0]*-~n
a=[0]*m
for y,p,i in sorted(I()+[i]for i in range(m)):
  c[p]+=1
  a[i]='%06d%06d'%(p,c[p])
print('\n'.join(a))

Measured memory_bytes: 31172
#include <iostream>
#include <fstream>
#include <random>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <map>
#include <stack>
#include <algorithm>
#include <cassert>


using namespace std;

//
//


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

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

    int A, B, M;
    cin >> A >> B >> M;
    vector<pair<int, int>> a(A), b(B);
    map<pair<int, int>, int> mp_c;

    int mina = 1e9;
    int minb = 1e9;

    for (int i = 0; i < A; ++i) {
        cin >> a[i].first;
        mina = min(mina, a[i].first);
        a[i].second = i;
    }

    for (int i = 0; i < B; ++i) {
        cin >> b[i].first;
        minb = min(minb, b[i].first);

        b[i].second = i;
    }

    int ans = mina + minb;

    for (int i = 0; i < M; ++i) {
        int x,y ,c;
        cin >> x >> y >> c;
        x--; y--;
        mp_c[{x,y}] = c;
        ans = min(ans, a[x].first + b[y].first - c);
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 6528
n=int(input())
alist=list(map(int,input().split()))

MOD=10**9+7
inv_table = [0]+[1]
for i in range(2,n+2):
  inv_table.append(-(MOD//i)*inv_table[MOD%i]%MOD)

dic_a={}
same_pair=None
for i in range(n+1):
  if alist[i] in dic_a:
    same_pair=(dic_a[alist[i]],i)
    break
  else:
    dic_a[alist[i]]=i
pair_diff=n-(same_pair[1]-same_pair[0])
#print(same_pair,pair_diff)

comb1,comb2=1,1
for r in range(1,n+2):
  comb1*=(n-r+2)*inv_table[r]
  comb1%=MOD
  #print(comb1,comb2)
  print((comb1-comb2)%MOD)
  comb2*=(pair_diff-r+1)*inv_table[r]
  comb2%=MOD

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

int main() {
	int n; cin >> n;
	vector<int>A(n); for (auto&& x : A)cin >> x;

	if (A.size() == 1) {
		cout << 1 << endl;
		return 0;
	}
	
	int ans = 1;
	int status = 0;
	for (int i = 0; i < A.size()-1; i++) {
		if (status == 0) {
			if (A[i + 1] - A[i] > 0)status = 2;
			else if (A[i + 1] - A[i] < 0)status = 1;
		}

		if (A[i+1] - A[i] > 0 && status == 1) {
			ans++;
			status = 0;
		}
		else if (A[i + 1] - A[i] < 0 && status == 2) {
			ans++;
			status = 0;
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>

int main(void){
  long N;
  scanf("%ld",&N);

  long ans;
  for(int j = sqrt(N);j >= 1;j--){
    if(N%j == 0){
      ans = N/j;
      break;
    }
  }

  int cnt = 0;
  while(ans > 0){
    cnt++;
    ans /= 10;
  }

  printf("%d\n",cnt);

  return 0;
}

Measured memory_bytes: 128
var x = require('fs').readFileSync('/dev/stdin', 'utf8');
input = x.split(/ /);
a = parseInt(input[0]);
b = parseInt(input[1]);
c = parseInt(input[2]);
if ((a < b) && (b < c)){
  console.log("Yes");
} else {
  console.log("No");
}



Measured memory_bytes: 15120
/*
Nahid Hossain
Jahangirnagar University
Roll:54
*/
#include<bits/stdc++.h>
#include<string.h>
#define ll long long
#define pf printf
#define sf scanf
#define ff first
#define ss second
#define clr clear()
#define sz size()
#define pb push_back
#define mk make_pair
#define pi acos(-1)
#define inf 2000000000000000000
#define mod 1000000007
#define ull unsigned long long int
#define f(i,k,n) for(i=k;i<n;i++)
#define fr(i,n,k) for(i=n;i>=k;i--)
#define ent(a) scanf("%lld",&a)
#define ent2(a,b) scanf("%lld%lld",&a,&b)
#define ent3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define mem(a) memset(a,0,sizeof(a))
#define vec(v,s) vector<ll>v[s]
#define arr(a,s) ll a[s];
//knight and king//
int dr[]= {2,2,-2,-2,1,-1,1,-1};
int dc[]= {1,-1,1,-1,2,2,-2,-2};
int dr1[]= {0,0,1,1,1,-1,-1,-1};
int dc1[]= {1,-1,1,0,-1,0,1,-1};
int dr2[]= {0,0,1,-1};
int dc2[]= {1,-1,0,0};
////////////////////////////
using namespace std;
#define ma 500005

ll a[ma],b[ma];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,i,j,x,k;
    while(cin>>n)
    {

        for(i=1;i<=n;i++)
        {
            cin>>a[i]>>b[i];
        }
        ll s=0;
        ll ans=0;
        for(i=n;i>=1;i--)
        {
            ll r=(a[i]+s)%b[i];
            if(r==0)continue;
            r=b[i]-r;
            s+=r;
            ans+=r;
        }
        cout<<ans<<endl;

    }
    return 0;
}


Measured memory_bytes: 5120
#define __USE_MINGW_ANSI_STDIO
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef long long ull;
typedef pair<ll, ll> ii;

#define all(v)		((v).begin()), ((v).end())
#define sz(v)		((int)((v).size()))
#define endl		"\n"
#define fx(n)		fixed<<setprecision(n)
#define mk			make_pair	

void File()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
#ifdef ONLINE_JUDGE
	/*freopen("output.txt", "w", stdout);
	freopen("commandos.in", "r", stdin);*/
#endif
}
void fast()
{
	ios::sync_with_stdio(NULL);
	cout.tie(NULL);
	cin.tie(NULL);
	//File();
}
const double pi = acos(-1.0);
const ll oo = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int nn = 1e5 + 15;
int dx[8] = { 1, 0, -1, 0, 1, -1, 1, -1 };
int dy[8] = { 0, 1, 0, -1, 1, -1, -1, 1 };

ll dp[nn];
int main()
{
	fast();
	int n,k;
	cin >> n >> k;
	vector<int> arr(n + k + 1, oo);
	fill(dp, dp + nn, oo);
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	for (int i = n - 1; i <= n + k; i++)
		dp[i] = 0;
	for (int i = n - 2; i >= 0; i--)
	{
		ll mn = oo*oo;
		for (int j = i + 1; j <= i + k; j++)
		{
			mn = min(mn, dp[j] + abs(arr[i] - arr[j]));
		}
		dp[i] = mn;
	}
	cout << dp[0] << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

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


int main()
{
    int N, M;
    cin >> N >> M;
    vector<long long> A(N);
    REP(i, N) cin >> A[i];

    priority_queue<long long> q;
    REP(i, N) q.push(A[i]);

    while(M > 0){
        long long tmp = q.top();
        q.pop();
        tmp /= 2;
        q.push(tmp);
        --M;
    }

    long long ans = 0;
    while(!q.empty()){
        long long tmp = q.top();
        q.pop();
        ans += tmp;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 2168
using System;

class Program {

    const int BuildNum = 4;
    const int FloorNum = 3;
    const int RoomNum = 10;

    private static int Main() {
        // 公舎データを作成
        int[ , , ] data = new int[ BuildNum, FloorNum, RoomNum ];
        
        // データ件数を読み込み
        var countString = Console.ReadLine();
        int count = int.Parse( countString );

        for( int i = 0; i < count; ++i ) {
            var input = Console.ReadLine();
            var values = input.Split( ' ' );

            // 人数以外はそれぞれ 1 から始まっているので 0 からにするため 1 ずつ引く
            int b = int.Parse( values[ 0 ] ) - 1;
            int f = int.Parse( values[ 1 ] ) - 1;
            int r = int.Parse( values[ 2 ] ) - 1;
            int v = int.Parse( values[ 3 ] );

            data[ b, f, r ] += v;
        }

        var line = new string( '#', 20 );
        for( int b = 0; b < BuildNum; ++b ) {
            for( int f = 0; f < FloorNum; ++f ) {
                var sb = new System.Text.StringBuilder();
                for( int r = 0; r < RoomNum; ++r ) {
                    sb.Append( ' ' );
                    sb.Append( data[ b, f, r ] );
                }
                Console.WriteLine( sb );
            }

            if( b != BuildNum - 1 ) {
                Console.WriteLine( line );
            }
        }

        return 0;
    }
}

Measured memory_bytes: 5660
#include <iostream>
#include <string>

using namespace std;

int main(){

  string w;
  cin >> w;
  string v = w;

  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());

  char t;
  int count;
  int flag;

  for (int i = 0; i < v.size(); i++){
    t = v[i];
    count = 0;
    for (int j = 0; j < w.size(); j++){
      if (w[j] == t){
        count += 1;
      }
    }

    if ((count % 2) != 0){
      cout << "No" << endl;
      return 0;
    }
  }

  /*
  if (flag == 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  */

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

using namespace std;

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*b / gcd(a, b);}


int main(){
    int n; cin >> n;
    int q;
    vector<int> a(n);
    vector<int> cnt(100005);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        cnt[a[i]]++;
    }
    cin >> q;
    vector<int> b(q), c(q);
    ll sum = 0;
    for(int i = 0; i < n; i++){
        sum += a[i];
    }

    for(int i = 0; i < q; i++){
        cin >> b[i] >> c[i];
    }
    for(int i = 0; i < q; i++){
        if(cnt[b[i]] != 0){
            cnt[c[i]] += cnt[b[i]];
            sum -= (b[i]-c[i])*cnt[b[i]];
            cnt[b[i]] = 0;
        }
        cout << sum << "\n";
    }

    return 0;
}


Measured memory_bytes: 4724
#include <stdio.h> 
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <queue>
using namespace std;
queue<int> q1;
queue<int> q2; 
int main(){
	int n;
	scanf("%d", &n);
	int l[100010];
	int r[100010];
	int dis1[100010]={0};//dis1[i]表示点i与点1的距离 
	int dis2[100010]={0};//dis2[i]表示点i与点n的距离 
	int t[100010]={0};//t[i]表示与点i相邻的点的个数 
	int temp1[100010];
	int temp2[100010];
	int t1, t2, t3, t4; 
	int a[100010][201]={0};//a[i][1-t[i]]中记录了所有与点i相邻的点的编号 
	//这行应该可以用高级方法降低时间复杂度，每行有几个数开几个数 
	int i, j, k, m;
	for(i=1;i<=n;i++){
		scanf("%d%d", &l[i], &r[i]);
		t[l[i]]++;
		t[r[i]]++;
		a[l[i]][t[l[i]]]=r[i];
		a[r[i]][t[r[i]]]=l[i];
	}
	dis1[1]=-1;
	dis2[n]=-1;
	q1.push(1);
	q2.push(n);
	for(i=1;q1.size()!=0;i++){
		for(j=1;j<=t[q1.front()];j++){
			if(dis1[a[q1.front()][j]]==0){
				dis1[a[q1.front()][j]]=max(dis1[q1.front()]+1,1);
				q1.push(a[q1.front()][j]);
			}	
		}
		q1.pop();
	}
	for(i=1;q2.size()!=0;i++){
		for(j=1;j<=t[q2.front()];j++){
			if(dis2[a[q2.front()][j]]==0){
				dis2[a[q2.front()][j]]=max(dis2[q2.front()]+1,1);
				q2.push(a[q2.front()][j]);
			}	
		}
		q2.pop();
	}
	int Fennec=1;
	int Snuke=1;
	for(i=2;i<=n-1;i++){
		if(dis1[i]<=dis2[i]) Fennec++;
		if(dis1[i]>dis2[i]) Snuke++;
	}
	if(Fennec>Snuke) cout<<"Fennec";
	else cout<<"Snuke";
	return 0;
}

Measured memory_bytes: 80768
#include <iostream>

using namespace std;

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

    char b;
    cin >> b;

    if (b == 'A')
        b = 'T';
    else if (b == 'T')
        b = 'A';
    else if (b == 'G')
        b = 'C';
    else if (b == 'C')
        b = 'G';

    cout << b << endl;

    return 0;
}


Measured memory_bytes: 256
# AGC 011 A - Airport Bus
n,c,k=map(int,input().split())
T=[int(input()) for i in range(n)]
T.sort()

until_next=0
cur_t=0
bus_fig=False
bus=0
bus_people=0

for i in range(n):
    cur_t=T[i]
    if bus_fig==False:
        bus+=1
        bus_people+=1
        until_next=T[i]+k
        bus_fig=True
    elif bus_fig==True:
        if bus_people<c:
            if cur_t<=until_next:
                bus_people+=1
                pass
            elif cur_t>until_next:
                bus_fig=True
                bus+=1
                bus_people=1
                until_next=T[i]+k
        else:
            bus_fig=True
            bus+=1
            bus_people=1
            until_next=T[i]+k
print(bus)

Measured memory_bytes: 7504
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 1000005
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   string s;
   cin>>s;
   int cnt=0;
   string last="";
   string temp="";
   for(int i=0;i<s.length();i++)
   {
       temp+=s[i];
       if(temp == last)continue;
       else
       {
           last=temp;
           temp="";
           cnt++;
       }
   }
   cout<<cnt<<endl;

}



Measured memory_bytes: 720
import string
def ABC_71_B():
    s=list(input())
    li_all = [x for x in string.ascii_letters]

    if len(set(s))>=26:
        print('None')
    else:
        s.sort()
        for i in range(len(s)):
            if s.count(li_all[i])==0:
                print(li_all[i])
                break
    
if __name__ == '__main__':

    ABC_71_B()

Measured memory_bytes: 4844
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;
int main(){
	int N;
	scanf("%d", &N);
	printf("0\n");
	fflush(stdout);
	string a;
	string b="aa";
	cin>>a;
	if(a[0]=='V'){
		return 0;
	}
	int max=N-1;
	int min=0;
	while(b[0]!='V'){
		int m=(max+min+1)/2;
		printf("%d\n", m);
		fflush(stdout);
		cin>>b;
		if(m%2==0 && a[0]==b[0]){
			min=m;
		}else if(m%2==1 && b[0]!=a[0]){
			min=m;
		}else{
			max=m-1;
		}
	}
	return 0;
}

Measured memory_bytes: 852
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int ans = 0;
        for(int i = 1; i <= n; i++){
            int sum = sumDigit(String.valueOf(i).toCharArray());
            if(a <= sum && sum <= b){
                ans += i;
            }
        }
        System.out.println(ans);
    }
    
    public static int sumDigit(char[] c){
        int ret = 0;
        int len = c.length;
        for(int i = 0; i < len; i++){
            ret += Character.getNumericValue(c[i]);
        }
        return ret;
    }
}

Measured memory_bytes: 22868
#include <algorithm>
#include <cmath>
#include <iostream>

using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)

bool isPrime(int n) {
  if (n == 1)
    return false;
  int rn = floor(sqrt(n));
  for (int i = 2; i <= rn; i++) {
    if (n % i == 0)
      return false;
  }
  return true;
}

int main() {
  int n = 0;
  while (cin >> n, n) {
    int ans = 0;
    for (int i = n + 1; i <= 2 * n; i++) {
      ans += isPrime(i) ? 1 : 0;
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3016
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
int main()
{
   // ld dp[3001][3001]={0};
    ll i,j,n;
    cin>>n;
    ld dp[n+1][n+1]={0};
    ld p[n+1],ans=0.0;
    p[0]=0.0;
    for(i=1;i<=n;i++)
    cin>>p[i];
    dp[0][0]=1.0;
    for(i=1;i<=n;i++)
    dp[i][0]=dp[i-1][0]*(1-p[i]);
    for(j=1;j<=n;j++)
    dp[0][j]=0.0;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=i;j++)
        {
            dp[i][j]=dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*(p[i]);
        }
    }
    for(j=(n+1)/2;j<=n;j++)
    ans+=dp[n][j];
    cout<<fixed<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 144356
input_line = input()
info = [int(x) for x in input_line.split()]
N, M, C = info[0], info[1], info[2]
inputB = input()
B_list = [int(x) for x in inputB.split()]

count = 0
for i in range(N):
    inputA = input()
    A_list = [int(x) for x in inputA.split()]
    ans = C
    for m in range(M):
        ans += A_list[m]*B_list[m]
    if ans>0:
        count += 1

print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int a[100010],d[100010],t[100010];
long long x[100010],ans[100010];
int main()
{
	int n,m,tt;
	long long k;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%lld",x+i),d[i]=a[i]=i;
	scanf("%d%lld",&m,&k);
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&tt);
		swap(d[tt],d[tt+1]);
	}
	while(k)
	{
		if(k&1)
		{
			for(int i=1;i<=n;i++)t[i]=a[d[i]];
			for(int i=1;i<=n;i++)a[i]=t[i];
		}
		for(int i=1;i<=n;i++)t[i]=d[d[i]];
		for(int i=1;i<=n;i++)d[i]=t[i];
		k>>=1;
	}
	for(int i=1;i<=n;i++)ans[i]=x[a[i]]-x[a[i]-1];
	for(int i=1;i<=n;i++)printf("%lld.0\n",ans[i]+=ans[i-1]);
	puts("");
	return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h> 
using namespace std; 
int gi() { 
	int res = 0, w = 1; 
	char ch = getchar(); 
	while (ch != '-' && !isdigit(ch)) ch = getchar(); 
	if (ch == '-') w = -1, ch = getchar(); 
	while (isdigit(ch)) res = res * 10 + ch - '0', ch = getchar(); 
	return res * w; 
}
typedef long long LL; 
const int MAX_N = 2e5 + 5; 
int N, M, a[MAX_N]; 
char s[MAX_N]; 
int tag; 
queue<int> q; 
int main () { 
#ifndef ONLINE_JUDGE 
    freopen("cpp.in", "r", stdin); 
#endif 
	N = gi(), M = gi(); 
	scanf("%s", s + 1); 
	for (int i = 1; i <= N; i++) a[i] = s[i] - 'A'; 
	for (int i = 1; i <= N; i++) q.push(a[i]); 
	if (M > N << 1) M = (N << 1) + (M & 1); 
	for (int i = 1; i <= M; i++) { 
		int x = q.front() ^ tag; 
		if (!x) q.front() ^= 1; 
		else q.pop(), q.push(x ^ tag), tag ^= 1; 
	} 
	while (!q.empty()) putchar((q.front() ^ tag) + 'A'), q.pop(); 
	putchar('\n'); 
    return 0; 
} 

Measured memory_bytes: 5456
//vec[i]の範囲外エラー表示
#define _GLIBCXX_DEBUG
//includeとusing
#include <bits/stdc++.h>
using namespace std;
//型名省略
using ll = long long;
using st = string;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vc = vector<char>;
using vvc = vector<vector<char>>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using pcc = pair<char, char>;
//定数
const ll INF = 1e9;
const ll MOD = 1e9+7;
const vl dx = {1,0,-1,0,1,0,-1,0};
const vl dy = {0,1,0,-1,0,1,0,-1};
//マクロ
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define rrep(i,n) for(ll i = (ll) n - 1; i >= 0;i--)
#define REP(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define RREP(i,x,n) for(ll i = (ll) n - 1; i >= x; i--)
#define each(i,A) for(ll i: (vl) A)
#define all(A) A.begin(), A.end()
#define Size(A) ll(A.size())
//入力
template<typename T> T input() {T x; cin >> x; return x;}
//正誤判定
void Yes(bool ans){cout << (ans? "Yes" : "No") << endl;}
void YES(bool ans){cout << (ans? "YES" : "NO") << endl;}
//余り切り上げ
ll ceil(ll a,ll b) {return (a + b - 1) / b;}
//最大値・最小値
template <typename T> bool chmax(T &a, const T& b) {if(a < b) {a = b; return true;} return false;}
template <typename T> bool chmin(T &a, const T& b) {if(a > b) {a = b; return true;} return false;}
//最大公約数
ll gcd(ll a,ll b){if(a<b)swap(a,b); if(a%b==0)return b; return gcd(b,a%b);}
//最小公倍数
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
//n乗の余り
ll modpow(ll x,ll n,ll mod){ll res=1;for(ll i=0;i<n;i++){res=res*x%mod;}return res;}
ll MODpow(ll x,ll n){ll res=1;for(ll i=0;i<n;i++){res=res*x%MOD;}return res;}


/*--------------------------------------------------------------------------*/

//main関数
int main() {
    ll n,k,x,y; cin >> n >> k >> x >> y;
    ll ans = 0;
    if(n <= k) ans = n * x;
    else ans = k * x + (n - k) * y;
    cout << ans << endl;

}



Measured memory_bytes: 3492
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
const int MAXN=2e5+10;
ll cnt[MAXN];
int main(){
    ll n;scanf("%lld",&n);
    for(ll i=1;i<n;i++){
        ll val;scanf("%lld",&val);
        cnt[val]++;
    }
    for(int i=1;i<=n;i++){
        printf("%lld\n",cnt[i]);
    }
    return 0;
}


Measured memory_bytes: 4784
#include<bits/stdc++.h>
using namespace std;
bool dp[8001][16001];
int a[8001];
int main()
{
	ios::sync_with_stdio(false);
	string s;
	int x,y;
	cin>>s>>x>>y;
	int k=0,w=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='T')
		{
			a[++k]=w;
			w=0;
		}
		else w++;
	}
	a[++k]=w;
	dp[1][a[1]+8000]=true;
	for(int i=3;i<=k;i+=2)
	{
		for(int j=0;j<=16000;j++)
		{
			if(j+a[i]<=16000)
				dp[i][j]=dp[i-2][j+a[i]];
			if(j-a[i]>=0)
				dp[i][j]=dp[i][j]||dp[i-2][j-a[i]];
		}
	}
	dp[0][8000]=true;
	for(int i=2;i<=k;i+=2)
	{
		for(int j=0;j<=16000;j++)
		{
			if(j+a[i]<=16000)
				dp[i][j]=dp[i-2][j+a[i]];
			if(j-a[i]>=0)
				dp[i][j]=dp[i][j]||dp[i-2][j-a[i]];
		}
	}
	bool ans;
	if(k%2==0)
		cout<<(dp[k][y+8000]&&dp[k-1][x+8000]?"Yes\n":"No\n");
	else
		cout<<(dp[k][x+8000]&&dp[k-1][y+8000]?"Yes\n":"No\n");
	return 0;
}

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

int main() {
  int H,W;
  cin >> H >> W;
  vector<vector<char>> data(H, vector<char>(W));
  // 読み込み
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      cin >> data.at(i).at(j);
  	}
  }
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      if (data.at(i).at(j) == '#') {
        cout << '#';
      } else {
        int count = 0;
        for (int ki=i-1; ki<=i+1; ki++) {
          for (int kj=j-1; kj<=j+1; kj++) {
            if (ki>=0 && ki<H && kj>=0 && kj<W) {
              if (data.at(ki).at(kj) == '#')
                count++;
            }
          }
        }
        cout << count;
      }
  	}
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <functional> 
#include <vector>

using namespace std;

int main(){

    int n;
    cin >> n;

    for(int i=0;1;i++){
        if(i*i > n){
            cout << (i-1)*(i-1);
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
using ll=long long;
const ll MOD=1000003;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=b-1;i>=a;i--)
#define range(i) (i).begin(),(i).end()
#define rrange(i) (i).rbegin(),(i).rend()
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline constexpr int intpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans%MOD*(b&1?a:1)%MOD;
}
inline constexpr int modf(ll n){
    ll ans=1;
    rep(i,0,n) {ans=ans*(n-i)%MOD;}
    return ans;
}
inline long double median(vector<ll> v){
    ll size=v.size();
    sort(v.begin(),v.end());
    if (size % 2 == 1) return v[(size - 1) / 2];
    else return v[(size / 2) - 1] ;
}
template<class T> inline bool chmax(T& a,T b) {if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b) {if(a>b){a=b;return 1;} return 0;}
template<class T,class L>ostream& operator << (ostream& os, pair<T,L>& p){os << p.first << " " << p.second;return os;}

int main(){
    ll n;
    cin>>n;
    vector<ll> h(n);
    rep(i,0,n) cin>>h[i];
    vector<ll> dp(n);
    dp[1]=abs(h[1]-h[0]);
    rep(i,2,n){
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp.back();
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
int main(){
  double A,B,H,M;
  cin>>A>>B>>H>>M;
  double Ans = -1;
  double Bt = M * 2 * PI / 60;
  double At = ( H * 60 + M )* 2 * PI / (12 * 60);
  Ans = sqrt (pow( A , 2 ) + pow( B , 2 ) - 2 * A * B * cos( At - Bt ) );
  cout<<fixed<<setprecision(15)<<Ans;
}

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

int main() {
	
   long long int l,r,ans=2020;
	
	cin >> l >> r;
	
	
	for(long long int i=l;i<min(r,l+2020);i++)
	{
		for(long long int j=i+1;j<=min(r,l+2020);j++)
		{
		    if((i*j)%2019<ans) ans = (i*j)%2019;
		}
	}
	
	cout << ans;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
T = [list(map(int, input().split())) for i in range(N)]
dp = [[0 for i in range(3)] for j in range(N+1)]
dp[1] = T[0]
for i in range(2,N+1):
    dp[i][0] = max(dp[i-1][1]+T[i-1][0],dp[i-1][2]+T[i-1][0])
    dp[i][1] = max(dp[i-1][0]+T[i-1][1],dp[i-1][2]+T[i-1][1])
    dp[i][2] = max(dp[i-1][0]+T[i-1][2],dp[i-1][1]+T[i-1][2])
print(max(dp[-1]))

Measured memory_bytes: 47348
#![allow(non_snake_case)]
use proconio::input;
use std::cmp::min;

fn main() {
    input! {
        mut X: i64,
        mut K: i64,
        D: i64,
    }

    // 2回消費して空撃ちすることが可能。
    // 戦略としては、符号を維持するように移動 → 微調整 → 空打ちで消費か?

    // 絶対値を見るので、Xは正としてよい。
    if X < 0 {
        X = -X;
    }

    // let mut ans = std::i64::MAX;

    let cnt = min(X / D, K);
    K -= cnt;
    X -= D * cnt;

    if K == 0 {
        println!("{}", X);
        return;
    }

    // ここまでで、[0, D]の区間にいるはず
    // 奇数だったら1回、偶数だったら0回やっておしまい
    if K % 2 == 0 {
        println!("{}", X);
        return;
    } else {
        println!("{}", (X - D).abs());
        return;
    }
}


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

using namespace std;
using ll = long long;
using edge = struct {int to; ll cost;};

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)


//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);

void solve()
{
    ll n;
    cin >> n;
    if(n % 2 == 1 || n <= 9){
        cout << 0 << "\n";
        return;
    }
    ll bunbo = 10ll;
    ll ans = 0ll;
    while(n >= bunbo){
        ans += (ll)(n/bunbo);
        bunbo *= 5;
    }
    cout << ans << "\n";
}

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

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val s = sc.nextLine.toCharArray

    var count = 0
    for (i <- 0 until s.size / 2) {
      if (s(i) != s(s.size - i - 1)) {
        count += 1
      }
    }
    println(count)
  }
}


Measured memory_bytes: 27416
#include<iostream>
using namespace std;
int main(){
    int n;
    string s;
    cin >> n;
    cin >> s;

    int tmp=0,ans=0;
    for(int i=0; i<=n; i++){
        if(s[i]=='I')   tmp++;
        else    tmp--;
        ans = max(ans,tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256