akhauriyash/Code-Regression huggingface dataset:
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}


ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}







/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll a;
  vector<ll> dp(31,0);
  dp[0]=1;
  dp[1]=dp[0];
  dp[2]=dp[0]+dp[1];
  for(ll i=3;i<=30;i++){
    dp[i]=dp[i-3]+dp[i-2]+dp[i-1];
  }
  while(cin>>a){
    if(!(a==0)) cout<<(((dp[a]+9)/10)+364)/365<<endl;
  }
}


Measured memory_bytes: 3136
#include<cstdio>
#include<cstring>

int main(){
	char str1[200], str2[100], str3[100];
	scanf("%s %s", str1, str3);
	strcpy(str2, str1);
	strcat(str1, str2);
	if( strstr(str1, str3) == NULL ){printf("No\n");}else{printf("Yes\n");}

return 0;
}

Measured memory_bytes: 968
#include<iostream>
using namespace std;
static const int MAX=100;
static const int INFTY=2000000000;
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n,M[MAX+1][MAX+1];
int prim(){
    int u,minv;
    int d[MAX+1],p[MAX+1],color[MAX+1];
    for(int i=1;i<=n;i++){
        d[i]=INFTY;
        p[i]=-1;
        color[i]=WHITE;
    }
    d[1]=0;
    while(1){
        minv=INFTY;
        u=-1;
        for(int i=1;i<=n;i++){
            if(minv>d[i]&&color[i]!=BLACK){
                u=i;
                minv=d[i];
            }
        }
        if(u==-1)break;
        color[u]=BLACK;
        for(int v=1;v<=n;v++){
            if(color[v]!=BLACK&&M[u][v]!=INFTY){
                if(d[v]>M[u][v]){
                    d[v]=M[u][v];
                    p[v]=u;
                    color[v]=GRAY;
                }
            }
        }
    }
    int sum=0;
    for(int i=1;i<=n;i++){
        if(p[i]!=-1) sum+=M[i][p[i]];
    }
    return sum;
}
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            int e;
            cin>>e;
            M[i][j]=(e==-1)?INFTY:e;
        }
    }
    cout<<prim()<<"\n";
    return 0;
}



Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

struct UnionFind
{
    vector< int > data;

    UnionFind(int sz)
    {
        data.assign(sz, -1);
    }

    bool unite(int x, int y)
    {
        x = find(x), y = find(y);
        if(x == y) return(false);
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return(true);
    }

    int find(int k)
    {
        if(data[k] < 0) return(k);
        return(data[k] = find(data[k]));
    }

    bool same(int x, int y)
    {
        return find(x) == find(y);
    }

    int size(int k)
    {
        return(-data[find(k)]);
    }
};

signed main() {
    int n, m, k;

    cin >> n >> m >> k;

    vector<vector<int> > friends(n + 1, vector<int>());
    vector<vector<int> > blocks(n + 1, vector<int>());

    UnionFind friend_group(n + 1);

    for(int i = 0; i < m; ++i)
    {
        int a, b;
        cin >> a >> b;

        friends[a].push_back(b);
        friends[b].push_back(a);

        friend_group.unite(a, b);
    }

    for(int i = 0; i < k; ++i)
    {
        int c, d;
        cin >> c >> d;

        blocks[c].push_back(d);
        blocks[d].push_back(c);
    }

    for(int i = 1; i <= n; ++i)
    {
        int groupSize = friend_group.size(i);
        int friendSize = (groupSize - 1) - friends[i].size();

        int ans = friendSize;

        for(int j = 0; j < blocks[i].size(); ++j)
        {
            if(friend_group.same(i, blocks[i][j]))
            {
                --ans;
            }
        }

        if(i == 1)
        {
            cout << ans;
        }
        else
        {
            cout << " " << ans;
        }
    }
    
    cout << endl;
}

Measured memory_bytes: 12280
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
 
int main() {
  int N;
  vector<int> a(9);
  rep(i,9) cin >> a[i];
  cin >> N;
  vector<int> b(N);
    rep(i,N) cin >> b[i];
  rep(in,N){
    rep(i,9){
      if(b[in]==a[i]) a[i] = 101;
    }
  }
    if(a[1]==a[4]&& a[4]==a[7]){
      cout << "Yes";
      return 0;
    }
  if(a[2]==a[5]&& a[5]==a[8]){
      cout << "Yes";
      return 0;
    }
  if(a[0]==a[3]&& a[3]==a[6]){
      cout << "Yes";
      return 0;
    }
  if(a[0]==a[1]&& a[1]==a[2]){
      cout << "Yes";
      return 0;
    }
  if(a[3]==a[4]&& a[4]==a[5]){
      cout << "Yes";
      return 0;
    }
  if(a[6]==a[7]&& a[7]==a[8]){
      cout << "Yes";
      return 0;
    }
  if(a[0]==a[4]&& a[4]==a[8]){
      cout << "Yes";
      return 0;
    }
  if(a[2]==a[4]&& a[4]==a[6]){
      cout << "Yes";
      return 0;
    }
 
  cout << "No";
}

Measured memory_bytes: 256
x, y = map(int, input().split())

a = 0
b = 0
det = 2
a = (4 * x - y) / det
b = (-2 * x + y) / det


if a < 0 or b < 0 or y % 2 == 1:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 9180
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#include<bitset>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	ll N;
	int Q;
	scan(N);scan(Q);
	rep(i,Q){
		ll v[2];
		//map<ll,bool> visited;
		vll visit;
		scan(v[0]);scan(v[1]);
		//visited[v[0]]=true;
		//visited[v[1]]=true;
		visit.push_back(v[0]);
		visit.push_back(v[1]);
		if(N==1){
			prin(min(v[0],v[1]));
			continue;
		}
		while(1){
			if(v[0]==1&&v[1]==1){
				break;
			}
			rep(k,2){
				if(v[k]>1){
					v[k]=(v[k]-1)/N+((v[k]-1)%N!=0);
					/*if(visited[v[k]]==true){
						prin(v[k]);
						flag=1;
						break;
					}
					visited[v[k]]=true;*/
					visit.push_back(v[k]);
				}
			}
			//if(flag) break;
		}
		sort(visit.begin(),visit.end());
		for(int j=visit.size()-1;j>0;j--){
			if(visit[j]==visit[j-1]){
				prin(visit[j]);
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 1280
from sys import setrecursionlimit
#setrecursionlimit(10**5)
class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納
        # par[x]=xの時そのノードは根　
        self.par = [i for i in range(n)]
        # rank
        self.rank = [0] * n
        self.size = [1] * n

    def find(self, x):
        # 根の番号を返す(所属する集合を確認する)
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def check(self, x, y):
        # x,yが同じ集合に属するかどうか調べる
        return self.find(x) == self.find(y)


    def union(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)
        if x == y:return
        # rankの小さいものを大きいほうにくっつける
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def count_group(self):
        return len({self.find(x) for x in range(n)})

n, m = map(int,input().split())

uf = UnionFind(n)
for i in range(m):
    x, y, z = map(int,input().split())
    uf.union(x - 1, y - 1)

print(uf.count_group())

Measured memory_bytes: 17568
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,a[100005]={},b[100005]={},ans=0;
  cin >> n;
  for(int i=0; i<=n; i++) {
    cin >> a[i];
  }
  for(int i=0; i<n; i++) {
    cin >> b[i];
  }
  for(int i=0; i<n; i++) {
    if(b[i]>=a[i]) {
      ans+=a[i]+min(b[i]-a[i],a[i+1]);
      a[i+1]-=min(a[i+1],b[i]-a[i]);
    }
    else {
      ans+=b[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
  int a,b;

  scanf("%d%d",&a,&b);

  if(a==b)    printf("Draw");
  else if(a==1)printf("Alice");
  else if(b==1)printf("Bob");
  else if(a<b)printf("Bob");
  else if(a>b)printf("Alice");

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <unordered_set>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <map>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 90001

using namespace std;

int H, W, D, Q, L, R;
int lx[NCONS], ly[NCONS];
int dp[NCONS];

int main(void)
{
	cin.tie(NULL); ios_base::sync_with_stdio(false);
	cin >> H >> W >> D;
	for (int i = 1; i <= H; i++)
	{
		for (int j = 1; j <= W; j++)
		{
			int a; cin >> a;
			lx[a] = i;
			ly[a] = j;
		}
	}

	for (int i = D + 1; i <= H * W; i++)
	{
//		cout << i - D << " " << abs(lx[i] - lx[i - D]) << " " << abs(ly[L] - ly[L - D]) << endl;
		dp[i] = dp[i - D] + abs(lx[i] - lx[i - D]) + abs(ly[i] - ly[i - D]);
	}


	cin >> Q;

	while (Q--)
	{
		cin >> L >> R;
		cout << dp[R] - dp[L] << endl;
	}

	return 0;
}

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

int main() {
//    int A, B, C, D, E;
//    cin >> A >> B >> C >> D >> E;
    vector <int> A(5);
    vector <int> B(5);
    for (int i=0; i<5; i++) cin >> A.at(i);
    int ans=0;
    int tmp,tmp2=0;
    for (int i=0; i<5; i++) {
        tmp = A.at(i);
        tmp2 = 0;
        while (true) {
            if (tmp%10==0) {
                B.at(i) = tmp2;
                break;
            }
            tmp++;
            tmp2++;
        }
    }
    sort(B.begin(), B.end());
    for (int i=0; i<5; i++) ans += A.at(i);
    for (int i=0; i<4; i++) ans += B.at(i);
    cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define db long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator

#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define EB emplace_back
#define fi first
#define se second

#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));

#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2

#define INF ((1ll<<60)-233)
#define sqr(x) ((x)*(x))
#define debug puts("wzpkking")
using namespace std;
const int N=100005;
const int mo=1000000007;
int n,ans=1;
int a[N],deg[N];
int pre[N],cnt[N],f[N];
bool vis[N];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]),deg[a[i]]++;
	for (int i=1;i<=n;i++){
		if (deg[i]>2) return puts("0"),0;
		if (deg[i]<2||vis[i]) continue;
		int j=i;
		do{
			if (vis[j]) return puts("0"),0;
			vis[j]=1; pre[a[j]]=j; j=a[j];
		}while (i!=j);
	}
	for (int i=1;i<=n;i++) if (!deg[i]){
		int l1=0,l2=0,j=i;
		for (;!vis[j];j=a[j]) vis[j]=1,l1++;
		for (j=pre[j],l2++;deg[j]==1;j=pre[j],l2++);
		if (l1>l2) return puts("0"),0;
		if (l1<l2) ans=1ll*ans*2%mo;
	}
	for (int i=1;i<=n;i++) if (!vis[i]){
		int l=0;
		for (int j=i;!vis[j];j=a[j])
			vis[j]=1,l++;
		cnt[l]++;
	}
	for (int i=1;i<=n;i++){
		int l=((i&1)&&(i>1))+1;
		f[0]=1; f[1]=l;
		for (int j=2;j<=cnt[i];j++)
			f[j]=(1ll*f[j-2]*(j-1)*i+1ll*f[j-1]*l)%mo;
		ans=1ll*ans*f[cnt[i]]%mo;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
 
int main() {
    unsigned long long a, b;
    char s[6];
 
    scanf("%lld%s", &a, s);
    b = (s[0]-'0')*100 + (s[2]-'0')*10 + (s[3]-'0'); 
 
    printf("%llu\n", a*b/100);
 
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> vec;
    if(n==0){
        cout << 0 << endl;
        return 0;
    }
    long long i=2,k=1;
    while(n!=0){
        if(n>0&&i>0){
            if(n%i==k){
            vec.push_back(1);
            n-=k;
            }
            else{
            vec.push_back(0);
            }
        }
        else if(n<0&&i>0){
            if((-1*n)%i==k){
            vec.push_back(1);
            n-=k;
            }
            else{
            vec.push_back(0);
            }
        }
        else if(n>0&&i<0){
            if((-1*n)%i==k){
            vec.push_back(1);
            n-=k;
            }
            else{
            vec.push_back(0);
            }
        }
        else if(n<0&&i<0){
            if(n%i==k){
            vec.push_back(1);
            n-=k;
            }
            else{
            vec.push_back(0);
            }
        }
        i*=-2;
        k*=-2;
    }
    for(int i=vec.size()-1;i>=0;i--){
        cout << vec[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<cmath>
#include<string>

#define ls (t<<1)
#define rs ((t<<1)+1)
#define fi first
#define se second
#define mk make_pair
#define pb push_back

#define N 100005
#define M 200005
#define seed 23333

using namespace std;
int i,j,p,k;
long long n,m;
int main()
{ 
		scanf("%lld%lld",&n,&m);
		long long l=0,r=(long long)1e15,mid=0;
		for (;(l+r)>>1!=mid;)
		{
				mid=(l+r)>>1;
				if (mid*2<=m&&(m-mid*2)/2+n>=mid) l=mid;
				else r=mid;
		}
		printf("%lld\n",l); 
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (n, k) = (v[0], v[1]);
    let a = read_vec::<i64>();

    let mut k_binary = vec![];
    let mut k = k;
    while k != 0 {
        k_binary.push(k % 2);
        k /= 2;
    }
    k_binary.reverse();
    debug!(k_binary);

    let mut one_count = vec![0i64; k_binary.len()];
    let mut init = 0i64;
    for &num in a.iter() {
        let mut num = num;
        let mut i = 0;
        while num != 0 {
            if i < k_binary.len() {
                one_count[i] += num % 2;
            } else {
                init += (num % 2) << i;
            }
            num /= 2;
            i += 1;
        }
    }
    one_count.reverse();

    let mut dp = vec![vec![-1; 2]; k_binary.len() + 1];
    dp[0][0] = 0;
    for (i, &c) in k_binary.iter().enumerate() {
        if one_count[i] > (n - 1) / 2 {
            let add = one_count[i] * (1 << (k_binary.len() - 1 - i));
            dp[i + 1][0] = max(dp[i][0] + add, dp[i + 1][0]);
            if dp[i][1] >= 0 {
                dp[i + 1][1] = max(dp[i][1] + add, dp[i + 1][1]);
            }
            if c == 1 {
                dp[i + 1][1] = max(dp[i][0] + add, dp[i + 1][1]);
            }
        } else {
            let add0 = one_count[i] * (1 << (k_binary.len() - 1 - i)); // if one use
            let add1 = (n - one_count[i]) * (1 << (k_binary.len() - 1 - i)); // if one use
            assert!(add1 > add0);
            if c == 0 {
                dp[i + 1][0] = max(dp[i][0] + add0, dp[i + 1][0]);
            } else {
                dp[i + 1][0] = max(dp[i][0] + add1, dp[i + 1][0]);
                dp[i + 1][1] = max(dp[i][0] + add0, dp[i + 1][1]);
            }
            if dp[i][1] >= 0 {
                dp[i + 1][1] = max(dp[i][1] + add1, dp[i + 1][1]);
            }
        }
    }

    let ans = max(dp[k_binary.len()][1], dp[k_binary.len()][0]);
    debug!(init);
    println!("{:?}", ans + init)
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 8444
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1e18;

bool cmp(pll& a, pll& b) { return (a.second < b.second); }

int main() {
  //
  ll n;
  cin >> n;
  vl a(n);
  rep(i, n) cin >> a[i];
  vl b = a;
  sort(ALL(a));
  sort(ALL(b), greater<ll>());

  vl cnt(n, 0), cnt2(n, 0);
  rep(i, n - 1) {
    if ((i & 1) == 0) {
      cnt[i]--;
      cnt[i + 1]++;
      cnt2[i]++;
      cnt2[i + 1]--;
    } else {
      cnt[i]++;
      cnt[i + 1]--;
      cnt2[i]--;
      cnt2[i + 1]++;
    }
  }
  sort(ALL(cnt));
  sort(ALL(cnt2));

  int i = 0;
  ll ans = 0, ans2 = 0;
  for (auto& c : cnt) {
    ans += c * a[i];
    i++;
  }
  i = 0;
  for (auto& c : cnt2) {
    ans2 += c * a[i];
    i++;
  }

  cout << max(ans, ans2) << endl;
  return 0;
}


Measured memory_bytes: 3960
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    r,g = IR(2)
    print(2*g-r)

#B
def B():
    n = I()
    k = I()
    a = 1
    for i in range(n):
        if a > k:
            a += k
        else:
            a *= 2
    print(a)
#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    B()


Measured memory_bytes: 39024
n,k = map(int,input().split())
# print('n,k',n,k)
# print('---')
ans = 0
q,r = divmod(n,k)
# print('q',q,'r',r)
for a in range(1, n+1):
    b = k - a%k
    c = k - b%k
    if (c+a)%k == 0:
        # print(a,b,c)
        now = 1
        if 1 <= b%k <= r: now *= q+1
        else: now *= q
        if 1 <= c%k <= r: now *= q+1
        else: now *= q
        ans += now

# print('ans',ans)
print(ans)


Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int x;
  cin >> x;
  cout << (x ^ 1) << endl;
  return 0;
}

Measured memory_bytes: 3520
#!/usr/bin/env python3
import sys
import itertools
import collections
import functools
import math
from queue import Queue
# import numpy as np
INF = float("inf")


def solve(a: int, b: int, c: int, d: int, e: int, k: int):
    if e-a > k:
        print(":(")
    else:
        print("Yay!")
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    c = int(next(tokens))  # type: int
    d = int(next(tokens))  # type: int
    e = int(next(tokens))  # type: int
    k = int(next(tokens))  # type: int
    solve(a, b, c, d, e, k)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4576
import itertools

N, C = map(int, input().split())
# N, C = 500, 30

D = []
for _ in range(C):
    D.append(list(map(int, input().split())))
    # D.append([100] * C)

diff_by_pos_color_pair = [[0 for _ in range(C)] for _ in range(3)]
for i in range(N):
    for j, color_from in enumerate(map(lambda x: int(x) - 1, input().split())):
        # for j, color_from in enumerate([0] * N):
        pos = (i + j) % 3
        for color_to in range(C):
            diff_by_pos_color_pair[pos][color_to] += D[color_from][color_to]


min_diff = float("inf")
for ccs in itertools.permutations(range(C), 3):
    diff = 0
    for pos, color in enumerate(ccs):
        diff += diff_by_pos_color_pair[pos][color]
    min_diff = min(min_diff, diff)

print(min_diff)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int sum=0;
    while(n--)
    {
        int x;
        cin>>x;
        sum+=(x%2);
    }
    if(sum%2==1)cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 384
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int h,w,k;
    cin>>h>>w>>k;
    vector<vector<char>> f(h,vector<char>(w));
    rep(i,h){
        rep(j,w){ 
            cin>>f[i][j];
        }
    }

    int ans=0;
    int cnt_black=0;
    rep(i,h){
        rep(j,w){
             if(f[i][j]=='#') cnt_black ++;
        }
    }

    for(int tmp = 0;tmp< (1<<h+w); tmp++){
        bitset<12> s(tmp);
        vector<vector<bool>> is_seen(h,vector<bool>(w,0));
        int cnt_red=0;
        rep(i,h){
            if(!s.test(i)) continue;
            rep(j,w){
                if(f[i][j]=='#'){
                    cnt_red ++;
                    is_seen[i][j]=1;
                }
            }
        }
        rep(i,w){
            if(!s.test(h+i)) continue;
            rep(j,h){
                if(f[j][i]=='#' && !is_seen[j][i]){
                    cnt_red ++;
                }
            }
        }
        if(cnt_black-cnt_red==k) ans ++;
    }
    cout<<ans<<endl;
}/*
./problem.exe
*/

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N, M;
typedef tuple<int, int> takahashi;
vector<takahashi> V;

int main () {
  cin >> N >> M;
  for (auto i = 0; i < N; ++i) {
    int L, R;
    cin >> L >> R;
    V.push_back(takahashi(L, R));
  }
  sort(V.begin(), V.end());
  priority_queue<int, vector<int>, greater<int> > Q;
  vector<int> W;
  int ind = 1;
  for (auto x : V) {
    Q.push(get<1>(x));
    if (ind <= get<0>(x)) {
      ++ind;
    } else {
      // cerr << Q.top() << endl;
      W.push_back(Q.top());
      Q.pop();
    }
  }
  for (auto it = W.begin(); it != W.end(); ++it) {
    *it = min(M+1 - ind, M+1 - *it);
  }
  sort(W.begin(), W.end());
  /*
  for (auto x : W) {
    cerr << x << " ";
  }
  cerr << endl;
  */
  ind = 1;
  int ans = 0;
  for (auto x : W) {
    if (ind <= x) {
      ++ind;
    } else {
      ++ans;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3696
# coding: utf-8
#import numpy as np
inf = float('inf')

def main():
    # input
    N = int(input())
    A = [0] + list(map(int, input().split()))
#    N = 2*10**5-1
#    A = [0] + np.random.randint(-10**9, 10**9, 2*10**5-1).tolist()

    dp1 = [-inf] * (N+1)
    dp2 = [-inf] * (N+1)
    dp1[1] = 0
    dp2[1] = 0
    dp1[2] = A[1]
    dp2[2] = A[2]
    for i in range(3, N+1):
        if i%2 == 0:
            dp1[i] = dp1[i-2] + A[i-1]
            dp2[i] = max(dp2[i-2] + A[i], dp1[i-2] + A[i])
        else:
            dp1[i] = max(dp2[i-1], dp1[i-2]+A[i-1])
            dp2[i] = max(dp2[i-2] + A[i], dp1[i-2] + A[i])

    if N % 2 == 0:
        ans = max([dp1[N], dp2[N]])
    else:
        ans = max(dp1[-2:] + dp2[-2:])

    # print(DP0)
    # print(DP1)
    # print(DP2)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 34016
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
using P = std::pair<ll, int>;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

struct edge{
	int to,cost;
	ll dist;
};

int c[55];
ll dist[55][6666],d[55];
std::priority_queue<P, std::vector<P>, std::greater<P> > pq;
std::vector<edge> g[55];

int main(void){
	int n,m,i,u,v,a,s;
	ll b;
	P p;
	edge e;
	std::fill(dist[0],dist[55],INFLL);
	std::cin >> n >> m >> s; s = std::min(s,5999);
	for(i=0; i<m; ++i){
		std::cin >> u >> v >> a >> b;
		--u; --v;
		e.to = v; e.cost = a; e.dist = b;
		g[u].push_back(e);
		e.to = u; g[v].push_back(e);
	}
	for(i=0; i<n; ++i){
		std::cin >> c[i] >> d[i];
	}
	dist[0][s] = 0ll;
	pq.push(P(dist[0][s],s));
	while(!pq.empty()){
		p = pq.top();
		pq.pop();
		u = p.second/6000; a = p.second%6000;
		if(dist[u][a]>p.first){
			continue;
		}
		// printf("%d %d %lld\n",u,a,dist[u][a]);
		for(i=(g[u].l_ength()-1); i>=0; --i){
			e = g[u][i]; v = e.to;
			if(a < e.cost){
				continue;
			}
			if(dist[v][a-e.cost] > dist[u][a] + e.dist){
				dist[v][a-e.cost] = dist[u][a] + e.dist;
				pq.push(P(dist[v][a-e.cost],v*6000+a-e.cost));
			}
		}
		if(dist[u][std::min(a+c[u],5999)]>dist[u][a]+d[u]){
			dist[u][std::min(a+c[u],5999)] = dist[u][a]+d[u];
			pq.push(P(dist[u][std::min(a+c[u],5999)],u*6000+std::min(a+c[u],5999)));
		}
	}
	for(i=1; i<n; ++i){
		for(a=1; a<6000; ++a){
			dist[i][0] = std::min(dist[i][0],dist[i][a]);
		}
		std::cout << dist[i][0] << std::endl;
	}
	return 0;
}


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

using namespace std;

int gcd(int a, int b) {
    if (b==0) return a;
    return gcd(b, a%b);
}

long long lcm(int a, int b) {
    return (long long)a*b/gcd(a,b);
}

int main(void) {
    int M, N, G;
    long long L;
    string S, T;
    cin >> N >> M >> S >> T;
    G = gcd(N,M);
    L = lcm(N,M);
    for (long long i=0;i<L;i+=L/G) {
        if (S[i/(L/N)] != T[i/(L/M)]) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << L << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
struct edge {
    int to; 
    int weight;
    edge(int t, int w) : to(t),weight(w) {}
};
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){

    int n,h; cin >> n >> h;
    vector<int> b(n);
    int a_max = 0;
    rep(i,n){
        int x,y; cin >> x >> b.at(i);
        chmax(a_max,x);
    }
    sort(all(b));
    reverse(all(b));
    ll cnt = 0;

    while(cnt < n && b.at(cnt) >= a_max){
        h -= b.at(cnt);
        cnt++;
        if(h <= 0) break;
    }
    while(h > 0){
        h -= a_max;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}


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

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) i64((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

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

  i64 H, W, M, i, x, y;
  cin >> H >> W >> M;
  vvi yx(H);
  vi CX(W, 0);
  REP(0, M, i) {
    i64 y, x;
    cin >> y >> x;
    y--; x--;
    yx[y].pb(x);
    CX[x]++;
  }

  set<pi, greater<pi>> SX;
  REP(0, W, x) {
    if(CX[x] != 0) {
      SX.insert({CX[x], x});
    }
  }

  i64 ans = 0;
  REP(0, H, y) {
    i64 candidate = sz(yx[y]);
    for(auto x: yx[y]) {
      SX.erase(SX.find({CX[x], x}));
      SX.insert({CX[x]-1, x});
    }
    candidate += SX.begin()->first;
    for(auto x: yx[y]) {
      SX.erase(SX.find({CX[x]-1, x}));
      SX.insert({CX[x], x});
    }
    ans = max(ans, candidate);
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int n;
  int a;
  string ans = "No";
  
  cin >> n;
  a = n / 100;
  if(a == 7){
    ans = "Yes";
  }
  n = n % 100;
  a = n / 10;
  if(a == 7){
    ans = "Yes";
  }
  n = n % 10;
  if(n == 7){
    ans = "Yes";
  }
  cout << ans << endl;
}


Measured memory_bytes: 3600
my ($A,$B) = split(/\s+/, <>);
my $ans;

#print "$B\n";
my ($B1,$B2) = split(/\./, $B);
#print "$B1 $B2\n";
$B= $B1*100 +$B2;
$ans = $A * $B;
$ans = $ans - ($ans%100);
$ans = $ans/100;
print "$ans";


Measured memory_bytes: 4940
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()

    ret = 0
    for a in range(1, N):
        b = N // a
        if N - (a * b) <= 0:
            ret += b - 1
        else:
            ret += b
    print(ret)


if __name__ == '__main__':
    main()


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

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll X, Y;

int main() {
  cin >> X >> Y;

  if (X == Y || Y == X+1 || Y == X-1) {
    cout << "Brown" << endl;
  } else {
    cout << "Alice" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
S = list(input())
N = len(S)-1
ans = 0
for i in range(2**N):
    tmp = S[0]
    for j in range(N):
        if i>>j & 1:
            tmp += S[1+j]
        else:
            ans += int(tmp)
            tmp = S[1+j]
    ans += int(tmp)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = 2e18;

signed main() {
    string S;
    cin >> S;
    int ans = 0, count = 0;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] == 'B') break;
        count++;
    }

    for (int i = count + 1; i < S.length(); i++) {
        if (S[i] == 'W') {
            ans += i - count;
            count++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define mp make_pair
#define all(v) v.begin(),v.end()
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

ll power(ll a, ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans*=a;
        a*=a;
        n>>=1;
    }
    return ans;
}

int main()
{
    IOS;
    ll n,k;
    cin>>n>>k;
    ll h[n];
    repf(i,0,n) cin>>h[i];
    ll ans=0;
    repf(i,0,n) if(h[i]>=k) ans++;
    cout<<ans<<endl;
    return 0;  
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define res register ll
#define ll long long
using namespace std;
ll n,x,ans;
inline ll read()
{
  ll X=0,w=0;
  char ch=0;
  while(!isdigit(ch))
  {
    w|=ch=='-';
    ch=getchar();
  }
  while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
  return w?-X:X;
}
inline void dfs(res l,res s)
{
  if(l%s==0)
  {
    ans+=(l<<1)-s;
    return;
  }
  ans+=l/s*s*2;
  dfs(s,l%s);
}
int main()
{
  n=read(),x=read();
  ans=n;
  if(x>=n-x)
    dfs(x,n-x);
  else
    dfs(n-x,x);
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace spam
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var A1 = new List<long>() { A[0] };
            var A2 = new List<long>() { A[0] };
            foreach (var item in A.Skip(1))
            {
                A1.Add(A1[A1.Count - 1] ^ item);
                A2.Add(A1[A1.Count - 1] + item);
            }
            var l = 0L;
            var r = 1L;
            var tmp1 = A1[0];
            var tmp2 = A2[0];
            var count = 0L;
            while (true)
            {
                if ((l == N - 1) && (r == N))
                {
                    count++;
                    break;
                }

                if ((r != N) && ((tmp1 ^ A[r + 1 - 1]) == (tmp2 + A[r + 1 - 1])))
                {
                    if (tmp1 == tmp2)
                    {
                        count += 1;
                    }
                    r++;
                    tmp1 = tmp1 ^ A[r - 1];
                    tmp2 = tmp2 + A[r - 1];
                    continue;
                }
                else
                {
                    if (tmp1 == tmp2)
                    {
                        count += r - l - 1;
                    }
                    tmp1 = tmp1 ^ A[l];
                    tmp2 = tmp2 - A[l];
                    l++;
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 40788
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    string s;
    cin>>n>>s;
    int ans=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A'){
            if(s[i+1]=='B'){
                if(s[i+2]=='C'){
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
int adj[305][305];
int dp[305][305];
int main(){
    int n, m, l, q, a, b, c;
    scanf("%d%d%d", &n, &m, &l);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(i != j) adj[i][j] = 1e9+1;
            dp[i][j] = 1e9;
        }
    }
    for(int i=1;i<=m;i++){
        scanf("%d%d%d", &a, &b, &c);
        adj[a][b] = c;
        adj[b][a] = c;
    }
    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                adj[i][j] = min(adj[i][j], adj[i][k] + adj[k][j]);
            }
        }
    }

    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(adj[i][j] <= l) dp[i][j] = 1;
        }
    }

    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }

    scanf("%d", &q);
    while(q--){
        int s, t;
        scanf("%d%d", &s, &t);
        if(dp[s][t] == 1e9) printf("-1\n");
        else printf("%d\n", dp[s][t]-1);
    }
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define ld double
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
//#define len length()
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect


void solve() {
    int a, b;
    cin >> a >> b;
    if (a < b)
        loop(i, b) cout << a;
    else loop(i, a) cout << b;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<int, int> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };


int main() {

	int n, m;
	cin >> n >> m;
	vector<string> a(n);
	vector<string> b(m);
	rep(i, n) cin >> a.at(i);
	rep(i, m) cin >> b.at(i);

	bool ans = false;

	rep(i, n - (m - 1)) {
		rep(j, n - (m - 1)) {
			int x = i;
			int y = j;
			int cnt = 0;
			rep(k, m) {
				rep(l, m) {
					if (a.at(x + k).at(y + l) == b.at(k).at(l)) {
						cnt++;
					}
					else {
						break;
					}
				}
			}
			if (cnt == m * m) {
				ans = true;
				break;
			}
		}
		if (ans) break;
	}
	if (ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
////////////////////////////////////////////////
int main()
{
    int n, m;
    cin >> n;

    m = (n + 1) / 2;

    cout << (double)m / n << endl;
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  int n, m;
  cin >> n >> m;
  vector<int> ans(n);
  REP(i,m){
    int a, b;
    cin >> a >> b;
    --a; --b;
    ans[a]++;
    ans[b]++;
  }

  for(auto x: ans) cout << x << endl;
  return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

vector<int> calc_divisor(int n)
{
    vector<int> divisor;
    for (int i = 1; i*i <=n ; i++)
    {
        if(n%i==0)
        {
            divisor.push_back(i);
            if(i*i!=n)divisor.push_back(n/i);
        }
    }
    return divisor;
}

vector<int> calc_common_divisor(int n,vector<int>& v)
{
    vector<int> cd;
    for (int i = 0; i < v.size(); i++)
    {
        if(n%v[i]==0)cd.push_back(v[i]);
    }
    return cd;
}

int main()
{
    int a,b,k;
    cin>>a>>b>>k;
    int m=min(a,b);
    int l=max(a,b);
    vector<int> d=calc_divisor(m);
    sort(d.begin(),d.end());
    vector<int> cd=calc_common_divisor(l,d);
    cout<<cd[cd.size()-k]<<endl;   
    
    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::HashSet;
fn main() {
    input! {
        n: usize,
        m:usize,
        x: usize,
        ass: [usize; m],
    }
    // let mut ass = ass;
    // ass.sort();
    let precost:usize = ass.iter().filter(|&&y| y < x).count();
    let sufcost:usize = ass.iter().filter(|&&y| y > x).count();

    println!("{}", std::cmp::min(precost, sufcost));
}


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

#define ll long long
#define endl "\n"
#define int ll

signed main ()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n, k;
	cin >> n >> k;
	vector <int> scores(n);
	for (auto &i : scores) cin >> i;

	queue <int> now;
	for (int i = 0; i < k; i++) {
		now.push(scores[i]);
	}

	for (int i = k; i < n; i++) {
		int current = now.front();
		now.pop();
		if (current < scores[i]) cout << "Yes" << endl;
		else cout << "No" << endl;
		now.push(scores[i]);
	}

	return 0;

}


Measured memory_bytes: 6332
#include <iostream>

int main()
{
    int N, M;
    std::cin >> N >> M;
    
    int minCardId = 1, maxCardId = N;
    for (int i = 0; i < M; i++)
    {
        int L, R;
        std::cin >> L >> R;
        minCardId = std::max(L, minCardId);
        maxCardId = std::min(R, maxCardId);
    }

    int numAllPassCards = maxCardId - minCardId + 1;
    if (numAllPassCards < 0)
        numAllPassCards = 0;
    std::cout << numAllPassCards << std::endl;
    return 0;
}


Measured memory_bytes: 888