akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>

using namespace std;

int main() {
	int h, w, counts[26] = { 0 };
	char string[101];

	scanf("%d %d", &h, &w);
	for (int i = 0; i < h; i++) {
		scanf("%s", string);
		for (int j = 0; j < w; j++)
			counts[string[j] - 'a']++;
	}

	int two = 0, one = 0;
	for (int i = 0; i < 26; i++) {
		if (counts[i] & 2)
			two++;
		if (counts[i] & 1)
			one++;
	}

	if ((h & 1) && (w & 1)) {
		if ((one == 1) && (two <= (h + w - 2) / 2))
			printf("Yes\n");
		else
			printf("No\n");
	} else if ((h & 1) && !(w & 1)) {
		if ((one == 0) && (two <= (w / 2)))
			printf("Yes\n");
		else
			printf("No\n");
	} else if (!(h & 1) && (w & 1)) {
		if ((one == 0) && (two <= (h / 2)))
			printf("Yes\n");
		else
			printf("No\n");
	} else {
		if (one == 0 && two == 0)
			printf("Yes\n");
		else
			printf("No\n");
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using stkll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

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

    ll N, M;
    cin >> N >> M;
    vll s(M);
    vc c(M);
    rep(i, M) cin >> s[i] >> c[i];

    ll ans = -1;
    for(ll i = 0; i < pow(10, N); i++) {
        if (N > 1 && i < pow(10, N-1)) continue;

        bool ok = true;
        rep(j, M) {
            string t = to_string(i);
            if((ll)t.size() != N) ok = false;
            else if(t[s[j]-1] != c[j]) ok = false;
        }
        if(ok) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from itertools import groupby
n=int(input())
l=[]
for _ in range(n):
  s=input()
  s=''.join(sorted(s))
  l.append(s)
l.sort()
c=0
for i,j in groupby(l):
  z=len(list(j))
  c=c+(z*(z-1)//2)
print(c)

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef string ss;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    ll n,k;
    string s;
    cin >> n >> k >> s;
    ll cnt = 0;
    rep(i,n-1)if(s[i] == s[i+1])cnt++;
    rep(i,k){
        if(cnt < n-2)cnt += 2;
        else if(cnt == n-2)cnt++;
        else break;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
using namespace std;
long long n,m,sum;
int main()
{
    scanf("%lld%lld%lld",&n,&m,&sum);

        for(int i=0;i<n;i++)
        {
            if(i<m)
            {printf("%lld",sum);
            }
            else
            {
//                if(i==m &&m<n)
//                    printf("1000000000");
                if(sum!=1000000000)printf("1000000000");
                else printf("15485863");
            }
            if(i!=n-1) printf(" ");
            else printf("\n");
        }


    return 0;

}

Measured memory_bytes: 3812
#include<bits/stdc++.h>
using namespace std;
int main()
{
  map<string,int>m;
  map<string,int>::iterator it;
  string s;
  int n;
  cin>>n;
  while(n--)
  {
    int q,x;
    cin>>q;
    if(q==0)
    {
      cin>>s>>x;
      m[s]=x;
    }
    else if(q==1)
    {
      cin>>s;
      if(m.find(s)==m.end())
      {
        cout<<0<<endl;
      }
      else
      {
        cout<<m[s]<<endl;
      }
    }
    else if(q==2)
    {
      cin>>s;
      m.erase(s);
    }
    else
    {
      string l,r;
      cin>>l>>r;
      for(it=m.lower_bound(l);it!=m.upper_bound(r);it++)
      {
        cout<<it->first<<" "<<it->second<<endl;
      }
    }
  }
}



Measured memory_bytes: 27784
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;

int main(){
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);

    int n;
    cin >> n;
    int m = n/2;
    if(n%2){
        cout << n*(n-1)/2-m << endl;
        rep(i,1,n+1){
            rep(j,1,i){
                if(i+j!=n){
                    cout << i << " " << j << endl;
                }
            }
        }
    }else{
        cout << n*(n-1)/2-m << endl;
        rep(i,1,n+1){
            rep(j,1,i){
                if(i+j!=n+1){
                    cout << i << " " << j << endl;
                }
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define f(i,n) for(int i=0; i<n; ++i)
#define fi(i,st,n) for(int i=st; i<=n; ++i)
#define veci vector<int>
#define vecp vector<pair<int,int> >
#define vecl vector<ll>
int prime[100000+10];

ll lcm(ll a, ll b) {
	return a*b/__gcd(a,b);
}

ll power(ll a, ll n, ll mod) {
	ll res = 1;
	while(n > 0) {
		if(n&1) {
			res = (res*a)%mod;
		}
		a = (a*a)%mod;
		n = n/2;
	}
	return res;
}

ll sum(int arr[], int n) {
	ll res = 0;
	f(i,n) {
		res += arr[i];
	}
	return res;
}

void seive() {
	prime[1] = 0;
	for(int i=2; i<=100000; i++) {
		prime[i] = 1;
	}
	for(ll i=2; i<=100000; i++) {
		if(prime[i]) {
			for(ll j=i*i; j<=100000; j+=i) {
				prime[j] = 0;
			}
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--){
		int n;
		cin>>n;
		n*= 2;
		int arr[n];
		f(i,n) cin>>arr[i];
		sort(arr,arr+n);
		int ans = 0;
		for(int i=0; i<n; i+=2) ans += arr[i];
		cout<<ans<<"\n";
 	}
 	return 0;
}


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

using namespace std;

int main()
{
	vector<int> x(5);
	for (int i = 0; i < 5; ++i)
	{
		cin >> x[i];
	}
	for (int i = 0; i < 5; ++i)
	{
		if (x[i] == 0) cout << i + 1;
	}

	return 0;
}

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

int main(){
  ll h[2],m[2],k,ans;
  cin >> h[0] >> m[0] >> h[1] >> m[1] >> k;
  ans=(h[1]-h[0])*60+m[1]-m[0]-k;
  cout << ans;
}

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

int main() {
  vector<int> vec(5);
  int k;
  for (int i = 0; i < 5; i++) {
    cin >> vec.at(i);
  }
  cin >> k;
  int flag = 0;
  for (int i : vec) {
    for (int j : vec) {
      if (i - j > k) {
        flag = 1;
        break;
      }
    }
  }
  if (flag == 1) {
    cout << ":(" << endl;
  } else {
    cout << "Yay!" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll  long long
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=1e6+10;
const ll MOD=2019;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
vector<int>adj[MAX];
ll take_p5(ll n){
	return (n*n*n*n*n);
}
int main() 
{
	ll a, b, c, k;
	cin>>a>>b>>c>>k;
	ll ans=0;
	if(a<=k)
	{
		ans=ans+a;
		k=k-a;
	}
	else{
		cout<<k;
		//cout<<ans;
		return 0;
	}
	if(b<=k){
		k=k-b;
	}
	else{
		cout<<ans;
		return 0;
	}
	if(c<=k)
		ans=ans-c;
	else
		ans=ans-k;
	cout<<ans;
	return 0;


}

Measured memory_bytes: 27112
import java.io.*;
import java.io.IOException;

class Main{
	public static void main(String args[]){
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int  	n,
				x,
				a,			//1つ目の数
				b = 2,		//2つ目の数(ループの初期判定のために2で初期化)
				c = 3,		//3つ目の数(ループの初期判定のために3で初期化)
				count;	//組み合わせ数
		
		String[] input = new String[2];		//入力を受け取る配列
		String output = "";					//出力する文字列変数
		
		try{
			
			input = br.readLine().split("[\\s]+");		//入力
			
			while(true){
				n = Integer.parseInt(input[0]);
				x = Integer.parseInt(input[1]);
				
				//終了判定
				if(n == 0 && x == 0){		//2つのデータがすべて0の時に終了する
					break;
				}
				
				count = 0;
				for(a = 1;a < b;a++){			//aは最小値から徐々に+1していく
				
					for(b = a+1;b < c;b++){		//bはa+1からc-1まで+1していく
					
						for(c = n;c > b;c--){	//cは最大値から徐々に-1していく
						
							if(a + b + c == x){	//a,b,cの合計がxかどうか
							
								count++;		//組み合わせが見つかったためカウントアップ
							}
						}
						c = n;
					}
				}
				
				output += count + "\n";			//出力内容を入れる
				
				input = br.readLine().split("[\\s]+");	//2回目以降の入力
			}
		}catch(IOException e){
			System.out.println(e);
			return;
		}
		
		//出力
		System.out.print(output);
		
	}
}



Measured memory_bytes: 25964
#include<iostream>
#include<algorithm>
#include<vector>
#include<climits>

#define MAX_V (1<<17)
#define INF INT_MAX

using namespace std;

int dat[MAX_V*2],sz;

void update(int k,int x){
  k+=sz-1;
  dat[k]=x;
  while(k>0){
    k=(k-1)/2;
    dat[k]=min(dat[k*2+1],dat[k*2+2]);
  }
}

int query(int a,int b,int k,int l,int r){
  if(r<=a || b<=l)return INF;
  if(a<=l && r<=b)return dat[k];

  int vl=query(a,b,k*2+1,l,(l+r)/2);
  int vr=query(a,b,k*2+2,(l+r)/2,r);
  return min(vl,vr);
}

int main(void){

  fill(dat,dat+MAX_V*2,INF);

  int n,q;
  cin >> n >> q;
  sz=1;
  while(sz<n)sz*=2;

  while(q--){
    int com,x,y;
    cin >> com >> x >> y;
    if(com)cout << query(x,y+1,0,0,sz) << endl;
    else update(x,y);
  }

  return 0;
}

Measured memory_bytes: 2184
K, N = list(map(int, input().split()))

dprint = lambda *x:x

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 998244353 #出力の制限
__N = 8000
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, __N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )



def kumiawase(p, q):
    # dprint(p,q,cmb(p+q-1,q-1 ,mod))
    return cmb(p+q -1,q-1 ,mod)


def solve(n):
    assert n <= K+1
    # 組み合わせの組
    # abs(n-1)//2 + 偶数分 n//2?
    # 2 ->  1,1
    # 3 -> 1,2
    # 4 -> 1,3 2,2
    # 5 -> 1,4 2,3
    # 6 -> 1,5 2,4 3,3
    # 7  3通り

    # 組のうち片方だけ使用する数 p
    ans = 0
    kumi = (n - 1) // 2
    for p in range(kumi+1):
        # dprint("p",p,"n",n)
        if p>N:
            break
        # 使えるのは p個 + 組に関係ないやつ
        ans += 2**p *cmb(kumi,p,mod)* kumiawase(N - p, p+ (K-kumi*2- int(n%2==0) ) )
        # dprint("anstmp1",ans)
        if n % 2 == 0 and N - p -1 >= 0:
            ans += 2**p *cmb(kumi,p,mod) * kumiawase(N - p -1 , p+ (K-kumi*2- int(n%2==0) ) ) # K==n//2を使用
    # dprint("-------",ans)
    return ans


ans = []
for i in range(2, 2 * K +1):
    if i <= K+1:
        tmp = solve(i)%998244353
        ans.append(tmp)
        print(tmp)
    else:
        print(ans[-i + K])


Measured memory_bytes: 70236
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m,t;
vector<P>num[100005];
vector<P>ans[100005];
vector<int>vec;
int x[100005];
int main(){
	cin >> n >> m >> t;
	rep(i,m){
		int a,b,c; scanf("%d%d%d",&a,&b,&c);
		if(c == 1){
			rep(i,vec.size()){
				int d = vec[i];
				num[b].pb(mp(d,-a));
				num[d].pb(mp(b,-a));
			}
			vec.pb(b);
		}
		else{
			int id;
			rep(i,vec.size()){
				int d = vec[i]; if(d==b) {id=i;continue;}
				num[b].pb(mp(d,a));
				num[d].pb(mp(b,a));
			}
			if(id != vec.size()-1) swap(vec[id],vec[vec.size()-1]);
			vec.pop_back();
		}
	}
	rep(i,vec.size()) rep(j,vec.size()) if(i != j) { num[vec[i]].pb(mp(vec[j],t)); }
	memset(x,-1,sizeof(x));
	repn(i,n){
		rep(j,num[i].size()){
			int id = num[i][j].fi;
			if(x[id] == -1) {ans[i].pb(num[i][j]);x[id] = ans[i].size()-1; }
			else ans[i][x[id]].sc += num[i][j].sc;
		}
		rep(j,num[i].size()){
			int id = num[i][j].fi;
			x[id] = -1;
		}
		P ret = mp(0,(i==1?2:1));
		rep(j,ans[i].size()){
			if(ret.fi < ans[i][j].sc) ret = mp(ans[i][j].sc,ans[i][j].fi);
			else if(ret.fi == ans[i][j].sc && ret.sc > ans[i][j].fi) ret = mp(ans[i][j].sc,ans[i][j].fi);
		}
		printf("%d\n",ret.sc);
	}
}


Measured memory_bytes: 260428
S = input()
counter = 0
max_ = 0
for i in range(len(S)):
    if(S[i] == "A" or S[i] == "C" or S[i] == "G" or S[i] == "T"):
        counter += 1
    else:
        max_ = max(max_,counter) 
        counter = 0
max_ = max(max_,counter) 
print(max_)

Measured memory_bytes: 8740
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
#define ll long long 
#define ull unsigned ll 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REP1(i,n) for (int i=1;i<=(n);i++)
#define RREP(i,n) for (int i=(n)-1; i>=0; i--)
#define pii pair<int,int>
#define SZ(x) x.size()
#define ALL(x) x.begin(), x.end()
#define ull unsigned ll 
#define pb push_back
#define SQ(x) (x)*(x)
#define endl '\n'
using namespace std;
int main (){
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	string s; cin>>s;
	ll n=s.size();
	vector<ll> vc(n+100);
	ll ans=0;
	REP1(i,n) {
		if (s[i-1]=='B') vc[i]=vc[i-1]+1;
		else vc[i]=vc[i-1];
	}
	REP1(i,n) if (s[i-1]=='W') ans+=vc[i];
	cout<<ans<<endl;
}



Measured memory_bytes: 2196
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int n,m;
  cin>>n>>m;
  cout<<(n-1)*(m-1)<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3620
#include <stdio.h>
int main(void)
{
    int hotel[4][3][10],i,j,k,n,b,f,r,v;
    for(i=0; i<4; i++){
        for(j=0; j<3; j++){
            for(k=0; k<10; k++){
                hotel[i][j][k]=0;
            }
        }
    }
    scanf("%d",&n);
    for(i=0; i<n; i++){
        scanf("%d%d%d%d",&b,&f,&r,&v);
        hotel[b-1][f-1][r-1]+=v;
    }
    for(i=0; i<4; i++){
        for(j=0; j<3; j++){
            for(k=0; k<10; k++){
                printf(" %d",hotel[i][j][k]);
            }
            printf("\n");
        }
        if(i<3) printf("####################\n");
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	int N,A;
	cin >> N >> A;
	
	cout << N*N-A << endl;

	return 0;

}


Measured memory_bytes: 256
from collections import deque
import sys
sys.setrecursionlimit(10**7)
N,u,v=map(int, input().split())
D=[[] for i in range(N)]
for i in range(N-1):
  a,b=map(int, input().split())
  a-=1
  b-=1
  D[a].append(b)
  D[b].append(a)
Taka=[0]*(N+1)
Aoki=[0]*(N+1)
def f(n,p,A):
  for i in D[n]:
    if i!=p:
      A[i]=A[n]+1
      f(i,n,A)
      
f(u-1,-1,Taka)
f(v-1,-1,Aoki)
ans=0
for i in range(N):
  if Taka[i]<Aoki[i]:
    ans=max(ans,Aoki[i]-1)
print(ans)

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

int main() {
  int64_t x;
  long double y;
  cin >> x >> y;
  int z=y*100;
  cout << x*z/100 << endl;

}


Measured memory_bytes: 3676
while input = gets
	array = input.chomp.split("\s")
	x = array[0].to_i
	y = array[1].to_i
	while x != y
		if x < y
			y = y - x
		else
			x = x - y
		end
	end
	print x, " ", (array[0].to_i*array[1].to_i)/x, "\n"
end

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

int solve(int T, int D, int L) {
    vector<int> X(T);
    vector<int> nure(T + D + 10, 0);
    for (int i = 0; i < T; i++) {
        cin >> X[i];
    }

    for (int i = 0; i < T; i++) {
        if (X[i] >= L) {
            nure[i + 2] += 1;
            nure[i + D + 2] += -1;
        }
    }

    for (int i = 1; i < nure.size(); i++) {
        nure[i] += nure[i - 1];
    }
    int ret = 0;
    for (int i = 0; i <= T; i++) {
        if (nure[i] != 0) ret++;
    }
    // for (int test : nure) cout << test << " ";
    return ret;
}

int main(void) {
    int T, D, L;
    vector<int> ans;
    while (1) {
        cin >> T >> D >> L;
        if (!T && !D && !L) break;
        ans.push_back(solve(T, D, L));
    }
    for (int i : ans) cout << i << endl;
}


Measured memory_bytes: 4640
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define debug(x) cerr << #x << " " << x << endl;
#define debug_p(x) cerr << #x << " [" << x.fi << " " << x.se << "]"<<endl;
#define debug_v(x) {cerr << #x << " "; for (auto ioi : x) cerr << ioi << " "; cerr << endl;}
#define debug_vp(x) {cerr << #x << " "; for (auto ioi : x) cerr << '[' << ioi.fi << " " << ioi.se << ']'; cerr << endl;}
#define debug_v_v(x) {cerr << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cerr << ioi2 << " "; cerr << '\n';} cerr << "*/" << #x << endl;}
#define gen_clock(x) ll x = clock(); cerr << "Clock " << #x << " created" << endl;
#define check_clock(x) cerr << "Time spent in " << #x << ": " << (double)(clock() - x)/CLOCKS_PER_SEC << endl; x = clock();
#define reset_clock(x) x = clock()
 
const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
 
void solve()
{
	ll a,b,c;
	cin>>a>>c>>b;
	ll k;
	cin>>k;
	while((c<=a)&&(k>0))
	{
		k--;
		c*=2;
	}
	while((b<=c)&&(k>0))
	{
		k--;
		b*=2;
	}
	if((b>c)&&(c>a))
	cout<<"Yes";
	else
	cout<<"No";
	
	
	
	
}
 
int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


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

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

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

  sort(p, p+N);

  int ans = 0;
  for (int i = 0; i < K; i++) {
    ans += p[i];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int n;
	cin >> n;
	cout << n * n * n << endl;
}

Measured memory_bytes: 3568
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
char D[10]; int n, k;
int main() {
	cin >> n >> k;
	for (int i = 0; i < k; i++) { char F; cin >> F; D[F - '0'] = 1; }
	for (int i = n; i < 100000; i++) {
		string S = to_string(i);
		for (int j = 0; j < S.size(); j++) {
			if (D[(S[j] - '0')] == 1)goto E;
		}
		cout << i << endl; break; E:;
	}
	return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Data.List

main = do
    xs <- init . map (map (read :: String -> Double) . words) . lines <$> getContents
    let x = do
        [r0, w0, c, r] <- xs
        return . show . max 0 . ceiling $ (w0*c-r0) / r
    putStrLn . intercalate "\n" $ x


Measured memory_bytes: 4308
import sys
from functools import reduce
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def gcd_list(numbers):
    return reduce(gcd, numbers)
n = ni()
a = nl()
if len(a) == 2:
    print(max(a))
    exit()
minn = 10 ** 9 + 1
idx = -1
for i in range(n - 2):
    if minn >= gcd_list([a[i], a[i + 1], a[i + 2]]):
        minn = gcd_list([a[i], a[i + 1], a[i + 2]])
        idx = i
gcd1 = 0
gcd2 = 0
gcd3 = 0
for i in range(n):
    if i != idx:
        gcd1 = gcd(gcd1, a[i])
    if i != idx + 1:
        gcd2 = gcd(gcd2, a[i])
    if i != idx + 2:
        gcd3 = gcd(gcd3, a[i])
print(max(gcd1, gcd2, gcd3))


Measured memory_bytes: 14644
# no matter what in every operation u will be adding two to the sum of all the numbers
# check when 2*i is divisible by 3 and each no should be greater than the maximum
def main():
	a, b , c = map(int , input().split())
	if a==b and b==c:
		print(0)
	else:
		tot=0
		tot = tot+(a+b+c)
		mx = max(a, max(b, c))
		i = 0
		f=0
		while f==0:
			if((tot+2*i)%3==0):
				p = ((tot+2*i))//3
				if p>=mx:
					f=1
			i = i+1
		print(i-1)
if __name__=="__main__":
	main()

Measured memory_bytes: 61964
#include<bits/stdc++.h>//头文件不多说
using namespace std;
long long a,b=2;//一定要用long long,否则在#31-#41会WA
int main(){
    cin>>a;
    for(int i=0;i<a;i++)b=(b+1)*2;//乘法分配律
    cout<<b<<endl;
}

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

int main()
{
    ll n; cin >> n;
    vector<ll> h(n), dp(n, 0);
    for(ll& i : h) cin >> i;
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);
    for(ll i = 2; i < n; i++) {
        dp[i] = min(abs(h[i] - h[i-1]) + dp[i-1], abs(h[i] - h[i-2]) + dp[i-2]) ;
    }
    cout << dp[n-1] << '\n';
    return 0;
}

Measured memory_bytes: 4828
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for sc.Scan() {
		a, _ := strconv.Atoi(sc.Text())
		var h, m, s int
		h, m = a/3600, a%3600
		m, s = m/60, m%60
		fmt.Printf("%d:%d:%d\n", h, m, s)
	}
}



Measured memory_bytes: 1084
use std::io::*;
use std::str::FromStr;

fn main(){
    let a: i64 = read();
    let b: i64 = read();
    println!("{}", 
        if a < 0 && b > 0                   { "Zero" }
        else if b < 0 && (b - a) % 2 == 0   { "Negative" }
        else                                { "Positive" }
    )
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

Measured memory_bytes: 4352
#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>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
//https://drken1215.hatenablog.com/entry/2019/06/15/111500
const int mod = 1000000007;
struct mint {
ll x; 
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
 }
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
 }
 mint& operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res+=a;
}
mint operator-(const mint a) const {
mint res(*this);
return res-=a;
}
 mint operator*(const mint a) const {
mint res(*this);
return res*=a;
}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
 mint inv() const {
return pow(mod-2);
 }
  mint& operator/=(const mint a) {
return (*this) *= a.inv();
 }
mint operator/(const mint a) const {
mint res(*this);
return res/=a;
 }
};
struct combination {
vector<mint> fact, ifact;
combination(int n):fact(n+1),ifact(n+1) {
  assert(n < mod);
 fact[0] = 1;
 for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
 ifact[n] = fact[n].inv();
  for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
}
mint operator()(int n, int k) {
if (k < 0 || k > n) return 0;
return fact[n]*ifact[k]*ifact[n-k];
}
  };
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll n,m,k;
cin>>n>>m>>k;
combination c(n*m-2);
mint ans=0;
rep(i,n)rep(j,m){
    mint cur=mint(n-i)*mint(m-j)*mint(i+j);
    if(i*j!=0)cur*=2;
    ans+=cur;
}
ans*=c(n*m-2,k-2);
cout<<ans.x<<endl;

return 0;
}

Measured memory_bytes: 3328
/*

*/

#include <bits/stdc++.h>
using namespace std;
using ll=long long int;

template<class Monoid>
struct SWAG{
    //情報
    const vector<Monoid> &v;
    //function
    const function<Monoid(Monoid,Monoid)> &op;
    //単位元
    Monoid unit;
    //SWAG    
    Monoid front;
    stack<Monoid> back;
    //尺取りに使う
    int l,r;
    int sz;

    SWAG(vector<Monoid> &v,function<Monoid(Monoid,Monoid)> op,Monoid unit) 
            :v(v),op(op),unit(unit),front(unit),l(0),r(0),sz(v.size()){};

    //右に進んだ場合の値
    inline Monoid isR(){
        if(back.empty()){
            return op(front,v[r]);
        } 
        return op(op(front,v[r]),back.top());
    }

    inline Monoid Right(){
        front=op(front,v[r++]);
        if(back.empty()) return front;
        return op(back.top(),front);
    }

    inline Monoid Left(){
        if(back.empty()){
            Monoid tmp=unit;
            for(int u=r-1;u>l;u--){
                back.emplace(tmp=op(tmp,v[u]));
            }
            front=unit;
        }else back.pop();
        l++;
        if(back.empty()) return front;
        return op(back.top(),front);
    }
};

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout<<fixed<<setprecision(20);
    int N,Q;
    cin>>N>>Q;
    vector<ll> a(N);
    for(int i=0;i<N;i++) cin>>a[i];

    auto op=[](ll a,ll b){
        return a+b;
    };
    while(Q--){
        ll x;
        cin>>x;
        int l=0,r=0;
        SWAG<ll> swag(a,op,0);
        ll ret=0;
        while(l<N){
            while(r<N && swag.isR()<=x){
                swag.Right();
                r++;
            }
            ret+=r-l;
            if(r==l) swag.Right(),r++;
            swag.Left(),l++;
        }
        cout<<ret<<endl;
    }    
}


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

using namespace std;
const long long MOD = 1e18;

vector<pair<long long, long long>> factorize(long long n) {
    vector<pair<long long, long long>> a;

    for (long long i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            int cnt = 0;
            while (n % i == 0) {
                n /= i;
                cnt++;
            }
            a.push_back(make_pair(i, cnt));
        }
    }
    if (n > 1) a.push_back(make_pair(n, 1));
    return a;

}

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

    vector<pair<long long, long long>> factors = factorize(n);
    int cnt = 0;
    
    for (auto x : factors) {
        int sum = 0;
        for (int i = 1; i + sum <= x.second; i++) {
            sum += i;
            cnt++;
        }
    }
    
    
    cout << cnt;
    return 0;
}

Measured memory_bytes: 3628
package main

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

var N int
var A, B, C int
var l = []int{}
var Len = map[string]int{}
var Cnt = map[string]int{}
var ans = math.MaxInt64

func main() {
	sc := NewScanner(os.Stdin)
	N = sc.NextInt()
	A = sc.NextInt()
	B = sc.NextInt()
	C = sc.NextInt()
	for i := 0; i < N; i++ {
		l = append(l, sc.NextInt())
	}
	rec(0)
	fmt.Println(ans)
}

func rec(i int) {
	if i == N {
		if Cnt["A"] == 0 || Cnt["B"] == 0 || Cnt["C"] == 0 {
			return
		}
		ans = min(ans, (Cnt["A"]-1)*10+(Cnt["B"]-1)*10+(Cnt["C"]-1)*10+abs(A-Len["A"])+abs(B-Len["B"])+abs(C-Len["C"]))
		return
	}
	for _, a := range []string{"A", "B", "C"} {
		Len[a] += l[i]
		Cnt[a]++
		rec(i + 1)
		Len[a] -= l[i]
		Cnt[a]--
	}
	// not use
	rec(i + 1)
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

// scanner
type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner(r io.Reader) *Scanner {
	rdr := bufio.NewReaderSize(r, 1024)
	return &Scanner{r: rdr}
}

func (s *Scanner) ReadLine() {
	s.buf = make([]byte, 0)
	for {
		line, isp, err := s.r.ReadLine()
		if err != nil {
			os.Exit(1)
		}
		s.buf = append(s.buf, line...)
		if !isp {
			break
		}
	}
}

func (s *Scanner) NextInt() int {
	i, err := strconv.Atoi(s.Next())
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) NextFloat64() float64 {
	i, err := strconv.ParseFloat(s.Next(), 64)
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) Next() string {
	s.Pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	next := string(s.buf[start:s.p])
	s.p++
	return next
}

func (s *Scanner) Pre() {
	if s.p >= len(s.buf) {
		s.ReadLine()
		s.p = 0
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int>v(n + 3);
    int mx = -1e7, mn = 1e7, a = -1, b = -1;
    for(int i = 1; i <= n; i++){
        cin >> v[i];
        if(v[i] > mx){
            a = i;
            mx = v[i];
        }
        if(v[i] < mn){
            b = i;
            mn = v[i];
        }
    }
    if(abs(mx) >= abs(mn)){
        cout << 2 * n - 1 << '\n';
        for(int i = 1; i <= n; i++){
            if(i != a){
                v[i] = v[i] + mx;
                cout << a << ' ' << i << '\n';
            }
        }
        v[a] = v[a] + mx;
        cout << a << ' ' << a << '\n';
        for(int i = 2; i <= n; i++){
            v[i] = v[i - 1] + v[i];
            cout << i - 1 << ' ' << i << '\n';
        }
    }
    else{
        cout << 2 * n - 1 << '\n';
        for(int i = 1; i <= n; i++){
            if(i != b){
                v[i] = v[i] + mn;
                cout << b << ' ' << i << '\n';
            }
        }
        v[b] = v[b] + mn;
        cout << b << ' ' << b << '\n';
        for(int i = n - 1; i >= 1; i--){
            v[i] = v[i + 1] + v[i];
            cout << i + 1 << ' ' << i << '\n';
        }
    }
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << 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; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll n, t; cin >> n >> t;
    ll ans = INFLL;
    rep(i, n){
        ll ci, ti; cin >> ci >> ti;
        if(ti <= t) chmin(ans, ci);
    }
    if(ans == INFLL) cout << "TLE" << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
int a,b;
int main()
{
	cin>>a>>b;
        cout<<a*b<<" "<<a+b+a+b<<endl;
}

Measured memory_bytes: 1164
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>
#include <random>

int main() {
	int n; std::cin >> n;
	std::vector<int> cats(n); for (auto& a : cats) std::cin >> a;
	const auto all = std::accumulate(cats.begin(), cats.end(), 0, [](const int acc, const int value) {return acc ^ value; });
	for (auto i = 0; i < cats.size(); ++i) {
		if (i > 0) std::cout << ' ';
		std::cout << (all ^ cats[i]);
	}
	std::cout << '\n';
}

Measured memory_bytes: 4036
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<string> s(n);
	rep(i, n) {
		cin >> s[i];
		sort(all(s[i]));
	}
	sort(all(s));
	vector<ll> res;
	ll cnt = 1;
	string now = s.front();
	for (int i = 1; i < n; ++i) {
		if (s[i] == now) cnt++;
		else {
			res.emplace_back(cnt);
			cnt = 1;
			now = s[i];
		}
	}
	res.emplace_back(cnt);
	ll ans = 0;
	for (auto& c : res) {
		ans += c * (c - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6908
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <bits/stdc++.h>

using namespace std;

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

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define pb push_back
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};
string Ans[2] = {"No", "Yes"};
string ANS[2] = {"NO", "YES"};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (k < 0 || k > n) return 0;
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

int Root(int x, vector<int> &root)
{
    if (x == root[x]) return x;
    return root[x] = Root(root[x], root);
}

void Merge(int v, int u, vector<int> &root, vector<int> &sz)
{
    v = Root(v, root), u = Root(u, root);
    if (v == u) return;
    if (sz[v] < sz[u])
    {
        sz[u] += sz[v];
        root[v] = u;
    }
    else
    {
        sz[v] += sz[u];
        root[u] = v;
    }
}

int ok(int x, int n)
{
    return 0 <= x && x < n;
}

void bfs(int v, vi &dist, vector<vi> &graph)
{
    fill(all(dist), -1);
    dist[v] = 0;
    vi q = {v};
    for (int i = 0; i < q.size(); i++)
    {
        for (auto u : graph[q[i]])
        {
            if (dist[u] == -1)
            {
                dist[u] = dist[q[i]] + 1;
                q.push_back(u);
            }
        }
    }
}


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    double a, b; cin >> a >> b;
    printf("%.9f", a / b);
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
long long N,ans;
vector<long long> X;
int main(){
  cin >> N;
  X.assign(N+10,0);
  for (long long i=0;i<N;i++){
    cin >> X[i];
  }
  ans=0;
  for (long long i=1;i<N;i++){
    if (X[i-1]==X[i]){
      X[i]=-1;
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
from collections import *
from itertools import *
from bisect import *
from heapq import *
import copy
import math
from fractions import gcd

mod=10**9+7
#N=int(input())
S=input()
Q=int(input())
Query=[list(input().split()) for i in range(Q)]


lst=deque(S)

flag=0
for query in Query:
    if len(query)==1:
        flag+=1
        flag%=2
    else:
        _,F,C=query
        if (int(F)+flag)%2:
            lst.appendleft(C)
        else:
            lst.append(C)

if flag:
    lst.reverse()
print("".join(lst))


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    int N, X, Y;
    cin >> N >> X >> Y;
    X--, Y--;

    vector<vector<int>> D(N, vector<int>(N, INF));
    rep(i, N) D[i][i] = 0;

    rep(i, N) {
        rep(j, N) {
            if (i >= j) continue;
            D[i][j] = min(j - i, abs(X - i) + abs(Y - j) + 1);
        }
    }

    vector<int> ans(N);
    rep(i, N) {
        rep(j, N) {
            if (i >= j) continue;
            int idx = D[i][j];
            ans[idx]++;
        }
    }

    for (int k = 1; k < N; ++k) cout << ans[k] << endl;
}

Measured memory_bytes: 17024
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define int long long
#define pb push_back
#define fi first
#define se second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
#define sz(x) (int)x.size()
const int mod = 1e9 + 7;
const int mod1 = 998244353;
typedef long double f80;

#ifndef LOCAL
#pragma GCC optimize ("O2")
#define endl '\n'
#endif

template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}

ll pwr(ll a,ll b, ll mod){
    a %= mod;
    int ans = 1;
    while(b){
        if(b & 1) ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const int N = 1005;
bool vis[N][N];
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
char a[N][N];
void solve(){
	int n, m;
	cin >> n >> m;
	queue<pii> q;
	fr(i, 1, n){
		fr(j, 1, m){
			cin >> a[i][j];
			if(a[i][j] == '#'){
				q.push({i, j});
				vis[i][j] = 1;
			}
		}
	}
	queue<pii> temp;
	int ans = 0;
	while(!q.empty()){
		while(!q.empty()){
			pii x = q.front();
			q.pop();
			fr(j, 0, 3){
				pii y = {x.fi + dx[j], x.se + dy[j]};
				if(y.fi >= 1 && y.fi <= n && y.se >= 1 && y.se <= m && !vis[y.fi][y.se]){
					temp.push(y);
					vis[y.fi][y.se] = 1;
				}
			}
		}
		q = temp;
		while(!temp.empty()){
			temp.pop();
		}
		ans++;
	}
	cout << ans - 1;
}
signed main(){
    IO;
    #ifdef LOCAL
        freopen("inp.txt","r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    cout << setprecision(10) << fixed;
    int t = 1;
    // cin >> t;
    fr(tt, 1, t){
        solve();
    }
    return 0;
}

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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define maxn 100
#define int long long int
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

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 mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0)
    {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x)
{ //bit計算
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void)
{
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++)
    {
        if (!prime[i])
        {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i)
        {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num)
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
signed main()
{
    int N;
    cin >> N;
    vector<int> A;
    rep(i, N)
    {
        int a;
        cin >> a;
        A.push_back(a);
    }
    sort(A.begin(), A.end());
    int ans = 1;
    int all = A[0];
    for (int i = 1; i < N; i++)
    {
        if (all * 2 >= A[i])
        {
            ans++;
            all += A[i];
        }
        else
        {
            all += A[i];
            ans = 1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1400
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<utility>
#include<sstream>
#include<iomanip>
using namespace std;

#define ll long long
#define MP make_pair

int main(void) {
	int num=0;
	string s;
	cin>>s;
	for (int i = 0; i < s.size(); i++) {
		if(s[i]=='o')num++;
	}

	num=num+(15-s.size());

	if(num>=8)cout<<"YES\n";
	else cout<<"NO\n";



	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define F first
#define S second
#define PB push_back 
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef int ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
const int SIZE=1+1e+4;
map<string,int> toI;
VI edge[SIZE];
int price[SIZE];
PQ qu;
string s,a,b;
int main(){
	LL N,M;
	cin >> N;
	REP(i,N){
		cin >> s >> price[i];
		toI[s]=i;
	}
	cin >> M;
	REP(i,M){
		cin >> a>> b;
		edge[toI[a]].PB(toI[b]);
		edge[toI[b]].PB(toI[a]);
	}
	REP(i,N)
		qu.push(pr(price[i],i));
	int ans=0;
	while(!qu.empty()){
		int now=qu.top().S;
		int pri=qu.top().F;
		qu.pop();
		if(pri!=price[now]) continue;
		ans+=pri;
		REP(i,edge[now].size())
			if(price[edge[now][i]]>price[now]){
				price[edge[now][i]]=price[now];
				qu.push(pr(price[now],edge[now][i]));
			}
	}
	cout <<ans << endl;
}

Measured memory_bytes: 2220
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e7 + 5;
const int MAXM = 5e3 + 5;
const int P = 1e9 + 7;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int fac[MAXN], inv[MAXN];
int power(int x, int y) {
	if (y == 0) return 1;
	int tmp = power(x, y / 2);
	if (y % 2 == 0) return 1ll * tmp * tmp % P;
	else return 1ll * tmp * tmp % P * x % P;
}
int binom(int x, int y) {
	if (y > x) return 0;
	else return 1ll * fac[x] * inv[y] % P * inv[x - y] % P;
}
void update(int &x, int y) {
	x += y;
	if (x >= P) x -= P;
}
void init(int n) {
	fac[0] = 1;
	for (int i = 1; i <= n; i++)
		fac[i] = 1ll * fac[i - 1] * i % P;
	inv[n] = power(fac[n], P - 2);
	for (int i = n - 1; i >= 0; i--)
		inv[i] = inv[i + 1] * (i + 1ll) % P;
}
int n, m, dp[MAXM][MAXM], sum[MAXM][MAXM];
int func(int x, int y) {
	return 1ll * fac[x] * inv[x - y] % P;
}
int main() {
	read(n), read(m), init(n);
	dp[0][0] = 1, sum[0][0] = fac[m - 1];
	for (int i = 1; i <= m; i++)
	for (int j = 0; j <= i; j++) {
		update(dp[i][j], dp[i - 1][j - 1]);
		if (i >= 2) update(dp[i][j], 1ll * sum[i - 2][j] * inv[m - i] % P);
		sum[i][j] = (sum[i - 1][j] + 1ll * dp[i][j] * fac[m - i - 1]) % P;
	}
	int ans = 0;
	for (int i = 0; i <= m; i++)
	for (int j = 0; j <= i && j <= n - m; j++)
		update(ans, 1ll * dp[i][j] * fac[max(m - i - 1, 0)] % P * func(n - m, j) % P * func(i + (n - m - j) - 1, n - m - j) % P);
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main() {
	int n; cin >> n;
	vector<int> a(n);
	for (int& e : a) cin >> e;
	sort(a.begin(), a.end(),greater());
	long long ans = a[0];
	for (int i = 1; i <= (n - 2) / 2; ++i) ans += a[i] * 2;
	if (n & 1) ans += a[n / 2];
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4044