akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define inf 0x3f3f3f3f
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout);
using namespace std;

const int N=300005,M=100005,mod=1e9+7;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
inline void ch(int &x,int y){x=(x+y)%mod;}
inline void read(int &x){
	x=0;char ch=getchar(),rev=0;
	while(ch>'9'||ch<'0') rev=(ch=='-'),ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	x=rev?-x:x;
}
inline int exp(int x,int y){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}
int w,h,n,cnt,ans,x[N],y[N],yy[N],sta[N][2],g[N][2],top[2];
int p[N<<2],flag[N<<2];

inline void ins(int x){yy[++cnt]=x;}
inline int get(int y){return lower_bound(yy+1,yy+cnt+1,y)-yy;}
inline void add(int k,int b){p[k]+=b;flag[k]+=b;}
inline void push(int k){
	if(!flag[k]) return;
	add(ls,flag[k]);add(rs,flag[k]);
	flag[k]=0;
}
void ch(int l,int r,int x,int y,int k,int b){
	if(x<=l&&r<=y){add(k,b);return;}
	push(k);
	int mid=l+r>>1;
	if(x<=mid) ch(l,mid,x,y,ls,b);
	if(y>mid) ch(mid+1,r,x,y,rs,b);
	p[k]=max(p[ls],p[rs]);
}
void build(int l,int r,int k){
	flag[k]=0;
	if(l==r){p[k]=-yy[l-1];return;}
	int mid=l+r>>1;
	build(l,mid,ls);build(mid+1,r,rs);
	p[k]=max(p[ls],p[rs]);
}
void solve(int mid){
	clr(flag,0);clr(top,0);cnt=0;
	for(int i=1;i<=n;i++)
		ins(y[i]);
	sort(yy+1,yy+cnt+1);
	cnt=unique(yy+1,yy+cnt+1)-yy-1;
	yy[0]=0;yy[cnt+1]=h;
	for(int i=1;i<=cnt+1;i++) gmax(ans,(w+yy[i]-yy[i-1])*2);
	build(1,cnt,1);
	for(int i=1;i<=cnt;i++)
		g[i][0]=mid,g[i][1]=w-mid;
	for(int i=1;i<=n;i++)
		if(x[i]<=mid) gmin(g[get(y[i])][0],mid-x[i]); else gmin(g[get(y[i])][1],x[i]-mid);
	for(int i=1;i<=cnt;i++){
		for(int x=0;x<2;x++){
			int last=i;
			ch(1,cnt,i,i,1,g[i][x]);
			while(top[x]&&g[sta[top[x]][x]][x]>g[i][x]){
				int l=sta[top[x]-1][x]+1,r=sta[top[x]][x];
				ch(1,cnt,l,r,1,g[i][x]-g[r][x]);
				top[x]--;
			}
			sta[++top[x]][x]=i;
		}
		gmax(ans,(p[1]+yy[i+1])*2);
	}
}

int main(){
#ifdef rqgao2014
	freopen("input.txt","r",stdin);
#endif
	scanf("%d%d%d",&w,&h,&n);
	int m=0;
	for(int i=1;i<=n;i++){
		scanf("%d%d",&x[i],&y[i]);
		if(x[i]>0&&x[i]<w&&y[i]>0&&y[i]<h) x[++m]=x[i],y[m]=y[i];
	}n=m;
	if(!n){printf("%d\n",(w+h)*2);return 0;}
//	for(int i=1;i<=n;i++) printf("%d %d\n",x[i],y[i]);
	solve(w/2);
	for(int i=1;i<=n;i++)
		swap(x[i],y[i]);
	swap(w,h);solve(w/2);
	printf("%d\n",ans);
	return 0;
}	

Measured memory_bytes: 17920
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b) {
    if (b==0) return 1;
    ll c = power(a,b>>1);
    c = (c*c)%mod;
    if (b&1) return (c*a)%mod;
    return c;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)3e5+5;
const int Q = 301;

void solve() {
    int n,x,l;
    cin>>n;
    vector<pi> v(n);
    REP(i,0,n-1) {
        cin>>x>>l;
        v[i] = {x+l,x-l};
    }
    sort(all(v));
    int ans = 0, p = INT_MIN;
    REP(i,0,n-1) {
        if (p <= v[i].second) {
            //cout<<v[i].first<<" "<<v[i].second<<"\n";
            ans++;
            p = max(p, v[i].first);
        }
    }
    cout<<ans;
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        //cout<<"\n";
    }
}


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

typedef long long ll;

int main () {

    ll N,W;
    cin >> N >> W;
    vector<ll> w(N),v(N);
    for(int i=0; i<N; i++) {
	cin >> w[i] >> v[i];
    }

    map<int,int> m; // w,v
    m[0] = 0;;
    for(int i=0; i<N; i++) {
	map<int,int> copy(m);
	for(auto& e : copy) {
//	    cout << e.first << " " << e.second << endl;
	    if( m.find(e.first + w[i]) != m.end() and m[e.first+w[i]] > e.second+v[i] )
		continue;
	    if( e.first + w[i] <= W )
		m[e.first+w[i]] = e.second + v[i];

//	    cout << e.first+w[i] << " " << e.second + v[i] << endl;;
}
    }
    int ans = 0;
    for(auto& e : m) {
	ans = max(e.second,ans);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	string s;
	cin >>s;
	string ss = to_string(s.size() - 2);
	cout << s[0]<<ss<<s[s.size()-1];
	return 0;
}

//Ctrl+Aを使わない

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

string s;
int a[10];
bool flag = false;

void dfs(int pos, int sum, string ans)
{
    if (pos == 4)
    {
        if (sum == 7 && !flag)
        {
            cout << ans + "=7" << endl;
            flag = true;
        }
    }
    else
    {
        if (pos == 0)
        {
            dfs(pos + 1, sum + a[pos], ans + s[pos]);
        }
        else
        {
            dfs(pos + 1, sum + a[pos], ans + "+" + s[pos]);
            dfs(pos + 1, sum - a[pos], ans + "-" + s[pos]);
        }
    }
}

int main(void)
{
    cin >> s;
    REP(i, 4)
    {
        a[i] = s[i] - '0';
        //cout << a[i] << endl;
    }
    dfs(0, 0, "");
}


Measured memory_bytes: 384
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
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;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

ll N;
vl a;
vl b;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> N;
    a = vl(N-2-0+1);
    b = vl(N-2-0+1);
    for(int i = 0; i < N-2-0+1; ++i){
        cin >> a[i];
        cin >> b[i];
    }
    solve();
}

// 2 ≤ N ≤ 10^5
// 0 ≤ a_i, b_i < N
// 与えられるグラフは木である。

vvl g;
vl cnt;

void f(ll x,ll p){
    if(g[x].size()>2){
        ++cnt[x];
        return;
    }
    for(ll to:g[x]){
        if(to==p)continue;
        f(to,x);
    }
}

// ll N, vl a, vl b
// 条件を満たすようにアンテナを設置するとき、アンテナの個数 K の最小値を出力せよ。
void solve(){
    g.resize(N);
    cnt.resize(N);
    rep(i,N-1){
        g[a[i]].push_back(b[i]);
        g[b[i]].push_back(a[i]);
    }

    rep(i,N){
        if(g[i].size()==1)f(i,-1);
    }
    ll ans=0;
    rep(i,N)ans+=max(0LL,cnt[i]-1);
    cout<<max(1LL,ans)<<endl;
}


Measured memory_bytes: 12800
#include<iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a>=1&&a<=13&&b>=1&&b<=13){
	
	  if(a==b)
	  cout<<"Draw"<<endl;
	  else if(a==1)
	  cout<<"Alice"<<endl;
	  else if(b==1)
	  cout<<"Bob"<<endl;
	  else if(a>b)
	  cout<<"Alice"<<endl;
	  else
	  cout<<"Bob"<<endl;
	  }
}

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

int main() {
  int N; cin >>N;
  int i = N % 10;
  string ans = "hon";
  if (i == 3) ans = "bon";
  else if (i == 0 || i == 1 || i == 6 || i == 8) ans = "pon";
  cout << ans << endl;

  return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;
using i32 = int;
using i64 = long long;
using f64 = double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf64 = vector<f64>;
using vstr = vector<string>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  i64 n, a, b;
  cin >> n >> a >> b;
  if (a > b) {
    cout << 0 << endl;
    return 0;
  }
  if (a != b && n == 1) {
    cout << 0 << endl;
    return 0;
  }
  if (n == 1) {
    cout << 1 << endl;
    return 0;
  }
  i64 min_sum = a + b + a * (n - 2);
  i64 max_sum = a + b + b * (n - 2);
  cout << max_sum - min_sum + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define vll vector<ll>
#define vvll vector<vll>
#define mll map<ll,ll>
#define f(i,m,n) for(i=m;i<n;i++)
#define ee endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define take(v,n) for(i=0;i<n;i++) cin>>v[i];
#define NO() cout<<"NO"<<endl
#define YES() cout<<"YES"<<endl
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sot(v) sort(v.begin(),v.end());
bool isPrime(int n) 
{ 
    // Corner cases 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
  
    // This is checked so that we can skip  
    // middle five numbers in below loop 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}

ll powe(ll x, ll y){
    ll res = 1;
    while (y > 0){
        if (y & 1) res = res*x;
        y = y>>1;
        x = x*x;
    }
    return res;
}
vll prime(10000001,2);
void cal()
{
    ll i,j,k;
    for(i=2;i<=10000000;i++)
    {
            for(j=i+i;j<=10000000;j+=i)
            {
                 prime[j]++;
            }
    }
}
void solve()
{
    ll i,j,k=0,n,l;
    cin>>n;
    ll ans=5;
    if(n==1)
    {
        cout<<1<<ee;
        return;
    }
    if(n==2)
    {
        cout<<5<<ee;
        return;
    }
    for(i=3;i<=n;i++)
    {
        //cout<<prime[i]<<" ";
        k=prime[i];
        ans+=(i*k);
    }
    cout<<ans<<ee;
}

int main() {
    cal();
    fast;
    ll i,j,l,k,t,n;
    t=1;
    while(t--)
    solve();
}


Measured memory_bytes: 81220
import java.util.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        int h = scan.nextInt();
        int w = scan.nextInt();
        int k = scan.nextInt();
        char[][] c = new char[h][w];
        for(int i = 0; i < h; i++){
            String s = scan.next();
            for(int j = 0; j < w; j++){
                c[i][j] = s.charAt(j);
            }
        }
        int out = 0;
        for(int i = 0; i < 1 << h; i++){
            for(int j = 0; j < 1 << w; j++){
                int ck = 0;
                char[][] cc = new char[h][w];
                for(int l = 0; l < h; l++) System.arraycopy(c[l], 0, cc[l], 0, w);
                for(int l = 0; l < h; l++){
                    if((1 & i >> l) == 1) Arrays.fill(cc[l], 'R');
                }
                for(int l = 0; l < w; l++){
                    if((1 & j >> l) == 1){
                        for(int m = 0; m < h; m++) cc[m][l] = 'R';
                    }
                }
                for(int l = 0; l < h; l++){
                    for(int m = 0; m < w; m++){
                        if(cc[l][m] == '#') ck++;
                    }
                }
                if(ck == k) out++;
            }
        }
        System.out.println(out);
        scan.close();
    }

    public static void main(String[] args){
        new Main().solve();
    }
}


Measured memory_bytes: 38320
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  cin >> N;
  
  bool step = true; 
  for (int i = 0; i < N.size(); i = i + 2){
    if (N.at(i) != 'R' && N.at(i) != 'U' && N.at(i) != 'D'){
      step = false;
    }
  }
  for (int i = 1; i < N.size(); i = i + 2){
    if (N.at(i) != 'L' && N.at(i) != 'U' && N.at(i) != 'D'){
      step = false;
    }
  }
  if (step) cout << "Yes" << endl; 
  else cout << "No" << endl;
}
 

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
using namespace __gnu_pbds;
using namespace std;

#define pb                push_back
#define all(x)            (x).begin(),(x).end()
#define int               long long
#define INF               2e18
#define ff                first
#define ss                second
#define vi                vector<int>
#define pii               pair<int,int>
#define mii               map<int,int>
#define endl              "\n"
#define GCD(x,y)          (__gcd((x), (y)))
#define LCM(x,y)          (((x)/__gcd((x), (y)))*(y))
#define debug(x)          cout<<#x<<" is "<<(x)<<endl
#define mem(a,x)          memset(a,x,sizeof(a))
#define rep(i,a,b)        for(long long i=a;i<b;i++)
#define sp(ans,p)         fixed <<setprecision(p)<<ans;
#define IOS ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

// constexpr int N=;

int n, a[55];
string s[55];
bool vis[55][25][2];
int dp[55][25][2];

int recur(int ke, int pos, bool dik)
{
    if (pos == s[ke].size()) return 0;
    bool &done = vis[ke][pos][dik];
    int &w = dp[ke][pos][dik];
    if (done) return w;
    done = 1, w = INF;

    bool pal = 1;
    if (!dik)
    {
        for (int j = pos, k = s[ke].size() - 1; j < k; j++, k--)
        {
            if (s[ke][j] != s[ke][k]) pal = 0;
        }
    }
    else
    {
        for (int j = 0, k = pos; j < k; j++, k--)
        {
            if (s[ke][j] != s[ke][k]) pal = 0;
        }
    }
    if (pal) return w = 0;

    rep(i, 0, n)
    {
        bool yes = 1;
        int j, k;
        if (!dik)
        {
            for (j = pos, k = s[i].size() - 1; j < s[ke].size() && k >= 0 && yes; j++, k--)
            {
                if (s[ke][j] != s[i][k]) yes = 0;
            }
            if (yes)
            {
                if (k < 0) w = min(w, a[i] + recur(ke, j, 0));
                else w = min(w, a[i] + recur(i, k, 1));
            }
        }
        else
        {
            for (j = pos, k = 0; k < s[i].size() && j >= 0 && yes; j--, k++)
            {
                if (s[ke][j] != s[i][k]) yes = 0;
            }
            if (yes)
            {
                if (j < 0) w = min(w, a[i] + recur(i, k, 0));
                else w = min(w, a[i] + recur(ke, j, 1));
            }
        }
    }
    return w;
}


void solve()
{
    cin >> n;
    rep(i, 0, n) cin >> s[i] >> a[i];
    int ans = INF;
    rep(i, 0, n) ans = min(ans, a[i] + recur(i, 0, 0));
    if (ans == INF) ans = -1;
    cout << ans << endl;
}

signed main()
{
    IOS;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    // sieve();
    int t = 1;
    // cin >> t;
    while (t--)   solve();
    return 0;
}

Measured memory_bytes: 3696
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
	long a, b, c, x, y, sum = 0;
	cin >> a >> b >> c >> x >> y;

	if (a + b > 2 * c) {
		int mi = min(x, y);
		x -= mi;
		y -= mi;
		sum = c * 2 * mi;

		if (x && a > 2*c) {
			sum += c * 2 * x;
			x = 0;
		}
		else if (y && b > 2*c) {
			sum += c * 2 * y;
			y = 0;
		}
	}

	sum += a * x + b * y;

	cout << sum << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
	string S, T;

	cin >> S >> T;

	for (int i = 0; i < S.length(); i++) {
		for (int j = 0; j < S.length(); j++) {
			if (i + j < S.length()) {
				if (S[i + j] != T[j]) break;
			}
			else {
				if (S[i + j - S.length()] != T[j]) break;
			}

			if (j == S.length() - 1) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int N;
ll A, B;
ll X[100000];

ll dp[100000][2];

signed main(){
    cin >> N >> A >> B;
    rep(i, N){
        cin >> X[i];
    }

    ll m1 = LLONG_MAX, m2 = LLONG_MAX;
    for(int i=N-1; i>=0; i--){
        if(i == N-1){
            rep(j, 2) dp[i][j] = 0;
            m1 = min(m1, dp[i][0]+A*X[i]);
            m2 = min(m2, dp[i][0]+2*A*X[i]);
            continue;
        }
        rep(j, 2){
            dp[i][j] = 1e16;
            dp[i][j] = min(dp[i][j], m1-A*X[i+1]+B);
            dp[i][j] = min(dp[i][j], m2-2*A*X[i+1]+B);
            if(j == 1) dp[i][j] = min(dp[i][j], dp[i+1][1]+A*(X[i+1]-X[i]));
        }
        m1 = min(m1, dp[i][0]+A*X[i]);
        m2 = min(m2, dp[i][0]+2*A*X[i]);
    }
    cout << dp[0][1] << endl;
}

Measured memory_bytes: 5920
// わからなかった
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int c[10][1005];

int main()
{
    int h, w, k;
    cin >> h >> w >> k;

    vector<string> s(h);
    rep(i, h) {
        cin >> s[i];
    }

    int ans = INF;

    rep(div, 1 << (h - 1)) {
        int g = 0;
        vector<int> id(h);
        rep(i, h) {
            id[i] = g;
            if (div >> i & 1) ++g;
        }
        ++g;

        rep(i, g)rep(j, w) c[i][j] = 0;
        rep(i, h)rep(j, w) c[id[i]][j] += (s[i][j] - '0');

        int num = g - 1;
        vector<int> now(g);
        auto add = [&](int j) {
            rep(i, g) now[i] += c[i][j];
            rep(i, g) if (now[i] > k) return false;
            return true;
        };
        rep(j, w) {
            if (!add(j)) {
                num++;
                now = vector<int>(g);
                if (!add(j)) {
                    num = INF;
                    break;
                };
            }
        }
        chmin(ans, num);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int a, b;
  scanf("%d", &a);
  if(a < 3){
    printf("0\n");
  } else if(a % 2 == 0) {
    printf("%d\n", (a - 2)/2);
  } else {
    printf("%d\n", (a - 1)/2);
  }
  return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define log_2(a) (log((a)) / log(2))
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

int root[SIZE];

void init() {
    for(int i = 0; i < SIZE; ++i) {
        root[i] = i;
    }
}

int Root(int x) {
    if(x == root[x]) return x;

    return root[x] = Root(root[x]);
}

bool Unite(int x, int y) {
    int rx, ry;
    rx = Root(x);
    ry = Root(y);

    if(rx == ry) return false;
    root[rx] = ry;

    return true;
}

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

    init();
    int N, M;
    cin >> N >> M;
    for(int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        Unite(a, b);
    }

    set<int> st;
    for(int i = 1; i <= N; ++i) {
        Root(i);
        st.insert(root[i]);
    }

    cout << st.size() - 1 << endl;
    return 0;
}


Measured memory_bytes: 8372
#include <bits/stdc++.h>
#define MAXN 1000
#define vi vector<int>
#define F first
#define S second

using namespace std;

int main(){
    string ent;
    int n;
    scanf("%d", &n);
    cin >> ent;    
    for(int i = 0; i < ent.length(); i++){
        ent[i] += n;
        if(ent[i] > 'Z'){
            ent[i] = ((int)ent[i] % (int)'Z') + (int)'A' - 1;            
        }
    }
    cout << ent << endl;
    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

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

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class CFennecVsMonster {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, k; cin >> n >> k;
      vector<int> h(n);
      rep(i, n) {
        cin >> h[i];
      }
      sort(all(h));
      ll ans = 0;
      rep(i, n-k) {
        ans += h[i];
      }
      cout << ans << endl;
    }
};

signed main() {
  CFennecVsMonster solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

long int d[100010];

long int 
main(){
	 long int N,M,i;
	 long int cnt=0;
	long int K;
	scanf("%ld %ld",&N,&M);
	N = 1<<N;
	for(i=0;i<N;i++){
		d[i]=100010;
	}
	long int tmp,tmp_num;
		
	d[0]=0;
	for(i=0;i<M;i++){
		scanf("%ld %ld",&tmp,&tmp_num);
		long int j, k=0;
		for(j=0;j<tmp_num;j++){
			long int tt;
			scanf("%ld",&tt);
			
			k += 1<<(tt-1);
		}
		for(j=0;j<N;j++)
		d[j|k] = (d[j|k]>d[j]+tmp) ?  d[j]+tmp : d[j|k];
		
	}

	if(d[N-1]>100000){
		printf("-1\n");return 0;	
	}
	printf("\n%ld\n",d[N-1]);
 return 0;
}

Measured memory_bytes: 256
s=input()
n=len(s)
a,b=-1,-1
for i in range(n-1):
  if s[i]==s[i+1]:
    a,b=i+1,i+2
    break
for i in range(n-2):
  if s[i]==s[i+2]:
    a,b=i+1,i+3
    break
print(a,b)

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

namespace ConsoleApp69 {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            Console.WriteLine(a.Max() - a.Min());


        }
    }
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<ll> x(N), y(N);
    REP(i, N) cin >> x[i] >> y[i];

    vector<pair<ll, ll>> xPairs, yPairs;
    REP(i, N)
    {
        xPairs.push_back(make_pair(x[i], i));
        yPairs.push_back(make_pair(y[i], i));
    }
    sort(ALL(xPairs));
    sort(ALL(yPairs));

    vector<pair<ll, ll>> G[N];
    REP(i, N - 1)
    {
        pair<ll ,ll> p, q;
        p = xPairs[i];
        q = xPairs[i + 1];
        G[p.second].push_back(make_pair(abs(p.first - q.first), q.second));
        G[q.second].push_back(make_pair(abs(p.first - q.first), p.second));
    }
    REP(i, N - 1)
    {
        pair<ll ,ll> p, q;
        p = yPairs[i];
        q = yPairs[i + 1];
        G[p.second].push_back(make_pair(abs(p.first - q.first), q.second));
        G[q.second].push_back(make_pair(abs(p.first - q.first), p.second));
    }

    ll ans = 0;
    priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> q;
    q.push(make_pair(0, 0));
    vector<bool> isVisited(N, false);
    while(!q.empty())
    {
        pair<ll, ll> p = q.top();
        q.pop();
        if (isVisited[p.second]) continue;
        isVisited[p.second] = true;
        ans += p.first;
        REPV(it, G[p.second])
        {
            q.push(*it);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 22500
#include <iostream>
#include <vector>
#include <cmath>

int n, m;
int dp[100000] = {};
std::vector<int> path[100000];//gyaku

int dfs(int ima) {
	if (dp[ima] != 0) return dp[ima] + 1;
	else {
		for (int i = 0; i < path[ima].size(); i++) {
			int temp = dfs(path[ima][i]);
			if (dp[ima] < temp)dp[ima] = temp;
		}
	}
	return dp[ima] + 1;
}


int main() {
	std::cin >> n >> m;
	int temp, temp2;
	for (int i = 0; i < m; i++) {
		std::cin >> temp >> temp2;
		path[temp2 - 1].push_back(temp - 1);
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (dp[i] == 0) {
			temp = dfs(i);
			if (temp > ans)ans = temp;
		}
	}
	std::cout << ans-1 << std::endl;
}


Measured memory_bytes: 13980
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
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;
}
int main(){
    string s;cin >> s;
    ll sum=0;
    rep(i,s.size()){
        sum+=s[i]-'0';
    }
    if(sum%9)cout << "No" <<endl;
    else cout << "Yes" <<endl;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N, K; cin >> N >> K;
    int ans = 0;
    REP(i, 0, N) {
        int a; cin >> a;
        if (a >= K) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
int last[40];
int s[400][400];
int c[26];
int d;
int calc(vector<int> &t){
    int ret = 0;
    
        rep(i,d){
            //use t[i];
            ret += s[i][t[i]-1];
            last[t[i]-1] = i+1;
            rep(j,26){
                ret -= c[j]*(i+1-last[j]);
            }
            
    
    
    
                    
        }
        return ret;

}
signed main(){
    cin >> d;
    rep(i,26)cin >> c[i];
    vector<int> ans(d);
    vector<int> t(d);
    rep(i,d)rep(j,26)cin >> s[i][j];
    int cnt = 0;
    int res = 0;
    while(cnt < 10000){
        rep(i,d){
            t[i] = (cnt+i)%26+1;
        }
        
        if(res < calc(t)){
            res = max(res,calc(t));
            rep(i,d)ans[i] = t[i];
        }
        cnt++;
    }
    rep(i,d)cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 4788
#include <iostream>
#include <string>
#include <vector>
#include <queue>
using namespace std;


int N, M;

int solve(vector<vector<int> > G){
    queue<pair<int,int>> Q;
    vector<int> used(N+2, 0);
    
    int count = 0;

    Q.push(make_pair(1,1));
    
    while(!Q.empty()){
        pair<int,int> p = Q.front(); Q.pop();
        int now = p.first;
        //cout<<now<<" <><> "<<p.second<<endl;
        if(used[now]){
            if(used[now] != p.second) return -1;
            else continue;
        }
//cout<<now<<" [][]  "<<p.second<<endl;
        used[now] = p.second;

        if(p.second == 1) count++;
        
        for(int y : G[now]){
            if(p.second == 1)Q.push(make_pair(y, p.second+1));
            else Q.push(make_pair(y, p.second-1));
        }
    }

    return count;
}

int main(void)
{

    while(true){
        vector<vector<int> > G;
        int ans;
        int u, v, n;

        
        cin>>N>>M;

        if(!N && !M) break;

        n = N;
        
        G.resize(N+1);

        for(int i = 0; i < M; i++){
            cin>>u>>v;
            G[u].push_back(v);
            G[v].push_back(u);
        }


        ans = solve(G);

        //  cout<<"count "<<ans<<endl;
        
        if(ans == -1){
            cout<<0<<endl;
        } else if(ans%2 == 0 && (n - ans)%2 == 0 && ans != n - ans){
            cout<<2<<endl;
            if(ans < (n-ans)){
                cout<<ans/2<<endl;
                cout<<(n-ans)/2<<endl;
            }else {
                cout<<(n-ans)/2<<endl;
                cout<<ans/2<<endl;
            }
        } else if(ans%2 == 0 && (n - ans)%2 == 0){
            cout<<1<<endl;
            cout<<ans/2<<endl;
        } else if(ans%2 == 0){
            cout<<1<<endl;
            cout<<ans/2<<endl;
        } else if((n-ans)%2 == 0){
            cout<<1<<endl;
            cout<<(n-ans)/2<<endl;
  
        }  else {
            cout<<0<<endl;
        }
    }
   
    return 0;
}



Measured memory_bytes: 3276
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 100000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back

int h,w,d;
P a[100000];
int s[100000];

int main(){
  cin>>h>>w>>d;
  rep(i,h){
    rep(j,w){
      int b;
      cin>>b;
      a[b]=P(i+1,j+1);
    }
  }

  FOR(i,1,d+1){
    for(int j=0+i;j<=h*w-d;j+=d){
      s[j+d]=abs(a[j].F-a[j+d].F)+abs(a[j].S-a[j+d].S);
    }
  }
  FOR(i,1,d+1){
    for(int j=0+i;j+d<=h*w;j+=d){
      s[j+d]+=s[j];
    }
  }

  int q;
  cin>>q;
  while(q--){
    int x,y;
    cin>>x>>y;
    cout<<s[y]-s[x]<<endl;
  }
}


Measured memory_bytes: 2176
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#define INF 9999999999
#define EPS 1.0e-6

using namespace std;

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

int V,E;
ll d[105][105];

void warshall_floyd()
{
	int ope = 0;
	for (int k = 0; k < V; k++) {
		for (int i = 0; i < V; i++) {
			for (int j = 0; j < V; j++) {
				if (d[i][j] + d[j][k] + d[k][i] < 0) {
					ope++; break;
				}
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	if (ope == 0) {
		for (int i = 0; i < V; i++) {
			for (int j = 0; j < V - 1; j++) {
				if (d[i][j] > 2000000000)cout << "INF"<<" ";
				else cout << d[i][j]<<" ";
			}
			if (d[i][V - 1] > 2000000000)cout << "INF" << endl;
			else cout << d[i][V-1] << endl;
		}
	}
	else cout << "NEGATIVE CYCLE" << endl;
}

int main()
{
	cin >> V >> E;
	int s, t, di;

	for (int i = 0; i < V; i++) {
		for (int j = 0; j < V; j++) {
			d[i][j] = INF;
			if (i == j)d[i][j] = 0;
		}
	}
	for (int i = 0; i < E; i++) {
		cin >> s >> t >> di;
		d[s][t] = di;
	}
	warshall_floyd();

	return 0;
}

Measured memory_bytes: 3176
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <map>
#include <vector>
using namespace std;
typedef long long LL;

LL q,tmp = 0,f,op;
string bs,s1,s2,s3;
char ch;

int main(){
	cin >> bs;
	cin >> q; s1 = ""; s2 = ""; s3 = "";
	while(q --){
		cin >> op;
		if(op == 1) tmp ^= 1;
		if(op == 2){
			cin >> f >> ch; f --;
			if((tmp ^ f) == 0) s1 += ch;
			else s2 += ch;
		}
	}
	for(LL i = s1.length() - 1;i >= 0;i --) s3 += s1[i];
	s3 += bs; s3 += s2;
	if(tmp) reverse(s3.begin(),s3.end());
	cout << s3 << endl;
	return 0;
}

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

int main(void){
	int N,M;
	cin >> N >> M;
	int road[N];
	int c;
	for(int i=0;i<N;i++){
		road[i]=0;
	}
	for(int i=0;i<M*2;i++){
		cin >> c;
		road[c-1]++;
	}
	for(int i=0;i<N;i++){
			cout << road[i] << endl;
	}
	return 0;
}


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

int main()
{
  int H, W;

  while(true){
      cin >> H >> W;
      if(H==0&W==0) break;
      else {
        for(int i=0; i<H; i++){
          for(int j=0; j<W; j++){
            if(i%2==0){ // 偶数行は#から始まる
              if(j%2==0)cout << "#";
              else cout << ".";
            } else {
              if(j%2==0) cout << ".";
              else cout << "#";
            }
          }
          cout << endl;
        }
        cout << endl;
      }
  }
}



Measured memory_bytes: 3084
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        double sum = 0;
        for(int i = n; i > 0; i--) {
            int count = 0;
            int num = i;
            while(num < k) {
                num *= 2;
                count++;
            }
            double temp = 1;
            for(int j = 0; j < count; j++) {
                temp *= (0.5);
            }
            sum += temp;
        }
        double extra = 0;
        if(n > k) extra += (k/n);
        System.out.println(sum / n + extra);
    }
}


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

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

    int num0 = 0;
    int num1 = 0;
    for (int i = 0; i < S.length(); ++i) {
        if (S[i] == '0') {
            num0++;
        }
        else {
            num1++;
        }
    }

    cout << min(num0, num1) * 2 << endl;
    return 0;
}

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

int main(){

    string S,T;
    cin >> S >> T;

    int cnt;
    int res = T.length();
    for(int i=0;i <= S.length() - T.length();i++){
        cnt = T.length();
        for(int j=0;j<T.length();j++){
            if(S[j+i] == T[j]){
                cnt--;
            }
        }
        if(cnt < res){
            res = cnt;
        }
    }

    cout << res;
    return 0;
}

Measured memory_bytes: 3628
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
b = [int(input()) for _ in range(N)]

f=0
for v in b:
	for i in range(9):
		if A[i // 3][i % 3] == v:
			f|=1<<i
ans=[v for v in [7,56,73,84,146,273,292,448]if f&v==v]
print('Yes' if ans else 'No')


Measured memory_bytes: 9028
S = input()

head = int(S[:2])
tail = int(S[2:])

if 1 <= head <= 12:
    if 1 <= tail <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1 <= tail <= 12:
        print('YYMM')
    else:
        print('NA')


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

int main(){
	string s, ss;
	int v[8][8];
	while(cin >> s){
		int sx = -1, sy = -1;
		if(s[0] == '\n')cin >> s;
		for(int i = 0;i < 8;i++)v[0][i] = s[i]-'0';
		for(int i = 1;i < 8;i++){
			cin >> s;
			for(int j = 0;j < 8;j++)v[i][j] = s[j] - '0';
		}
		
		for(int i = 0;i < 8&&sx==-1;i++){
			for(int j = 0;j < 8&&sx==-1;j++){
				if(v[i][j]){sy = i;sx = j;}
			}
		}
		
		/*for(int i = 0;i < 8;i++){
			for(int j = 0;j < 8;j++){
				cout << v[i][j] << " ";
			}
			cout << endl;
		}*/
		
		char ans = 'a';
		if(sx<7 && v[sy][sx+1]){//A,C,E,G
			if(sx<6){
				if(v[sy][sx+2])ans = 'C';
				else if(sy<7&&v[sy+1][sx+2])ans = 'E';
			}
			if(0<sx && sy<7 && v[sy+1][sx-1])ans = 'G';
			if(ans == 'a')ans = 'A';
		}else{
			if(0<sx && v[sy+1][sx-1])ans = 'D';
			if(sx<7 && v[sy+1][sx+1])ans = 'F';
			if(ans == 'a')ans = 'B';
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int N;
	string A, B, C;
	cin >> N >> A >> B >> C;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (A[i] == B[i] && B[i] == C[i] && A[i] == C[i]) {
			ans += 0;
		}
		else if (A[i] != B[i] && B[i] != C[i] && A[i] != C[i]) {
			ans += 2;
		}
		else {
			ans += 1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
for(int i=0;;i++){
int a,s;
cin>>a>>s;
if(a==0 &&s==0) break;
if(a>=s){
cout<<s<<" "<<a<<endl;
}
else if(a<s){
cout<<a<<" "<<s<<endl;
}
}
}



Measured memory_bytes: 3012
#!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
sys.setrecursionlimit(1000000)
mod = 1000000007


#A
def A():
    n = input()
    if n == "A":
        print("T")
    elif n == "C":
        print("G")
    elif n == "G":
        print("C")
    else:
        print("A")
    return

#B
def B():
    s = S()
    ans = 0
    n = len(s)
    for i in range(n):
        for j in range(i,n):
            f = 1
            for k in range(i,j+1):
                if s[k] not in list("AGCT"):f = 0
            if f:
                ans = max(ans,j+1-i)
    print(ans)
#C
def C():
    n,q = LI()
    s = S()
    f = [0 for i in range(n)]
    for i in range(n-1):
        if s[i:i+2] == ["A","C"]:
            f[i+1] += 1
    for i in range(n-1):
        f[i+1] += f[i]
    f.insert(0,0)
    for i in range(q):
        l,r = LI()
        print(f[r]-f[l])
    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__":
    C()


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

ll distance(ll p, ll q) {
    return sqrt(p*p + q*q);
}

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

    int cnt = 0;

    rep(i, N) {
        ll x, y;
        cin >> x >> y;
        if (x*x + y*y <= D * D) cnt++;
    }

    cout << cnt << endl;

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  if(N%10 == 7||N%100 == 70||N%100 == 71||N%100 == 72||N%100 == 73||N%100 == 74||N%100 == 75||N%100 == 76||N%100 == 78||N%100 == 79||N/100 == 7){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>
#define llint long long

using namespace std;

int a, b, m;
bool prime[100005];
vector<int> vec;

int main(void)
{
  for(int i = 2; i < 400; i++){
    if(prime[i]) continue;
    for(int j = 2*i; j < 100000; j+=i) prime[j] = true;
  }
  for(int i = 2; i< 100000; i++){
    if(!prime[i]) vec.push_back(i);
  }

  while(1){
    cin >> m >> a >> b;
    if(a == 0 && b == 0 && m == 0) break;
    llint maxp = 0, maxq = 1, p, q;
    for(int i = 0; i < vec.size(); i++){
      q = vec[i];
      llint it = upper_bound(vec.begin(), vec.end(), min(m/q, q)) - vec.begin() - 1;
      if(it < 0) continue;
      p = vec[it];

      if(a*q > b*p) continue;
      if(p*q > maxp*maxq) maxp = p, maxq = q;
    }
    cout << maxp << " " << maxq << endl;
  }

  return 0;
}



Measured memory_bytes: 3372
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
using R = double;
using P = complex<R>;
#define x real()
#define y imag()
const R eps = 1e-9,PI = acos(-1);

bool equal(R a,R b){return abs(b-a)<eps;}
bool equal0(R a){return equal(a,0.0);}

P operator*(const P& p,const R& d){
    return P(p.x*d,p.y*d);
}

istream &operator>>(istream& is,P& p){
    R a,b;
    is >> a >> b;
    p = P(a,b);
    return is;
}

ostream &operator<<(ostream& os,P& p){
    os << fixed << setprecision(10) << p.real() << " " << p.imag();
}
//内積
double dot(P a,P b) {return (conj(a)*b).real();}
//外積
double cross(P a,P b) {return (conj(a)*b).imag();}

struct L{
    P a,b;
    L(P a,P b):a(a),b(b){}
    L(R A,R B,R C){
        if(equal(A,0)) a = P(0,C/B),b = P(1,C/B);
        else if(equal(B,0)) b = P(C/A,0),b = P(C/A,1);
        else a = P(0,C/B),b = P(C/A,0);
    }
};

//pをbに射影
P projection(P p,P b) {return b*dot(p,b)/norm(b);}

//pとp1 to p2 に射影
P projection(L l,P p){
    p -= l.a; l.b -= l.a;
    P proj = projection(p,l.b);
    return l.a+proj;
}

struct S:L{
    S(P a,P b):L(a,b){}
};

//点の回転方向を判定
int ccw(P& p0,P p1,P p2){
    p1 -= p0,p2 -= p0;
    if(cross(p1,p2)>eps) return 1; //"COUNTER_CLOCKWISE"
    if(cross(p1,p2)<-eps) return -1; //"CLOCKWISE"
    if(dot(p1,p2)<0) return 2; //"ONLINE_BACK"
    if(norm(p1)<norm(p2)) return -2; //"ONLINE_FRONT"
    return 0; //"ON_SEGMENT"
}

bool is_parallel(L& l1,L& l2){
    return equal0(cross(l1.b-l1.a,l2.b-l2.a));
}

bool is_orthogonal(L& l1,L& l2){
    return equal0(dot(l1.a-l1.a,l2.b-l2.a));
}

//pをlに関して対称移動
P reflection(L l,P p){
    P pj = projection(l,p);
    return 2.0*pj-p;
}

//pがl上にあるか
bool is_online(L& l,P& p){
    return abs(ccw(l.a,l.b,p))!=1;
}

bool is_onsegment(S& s,P& p){
    return ccw(s.a,s.b,p)==0;
}

int main(){
    P p1,p2;
    cin >> p1;
    cin >> p2;
    int Q;
    cin >> Q;
    for(int i=0;i<Q;i++){
        P p;
        cin >> p;
        int res = ccw(p1,p2,p);
        if(res==1) cout << "COUNTER_CLOCKWISE" << endl;
        if(res==-1) cout << "CLOCKWISE" << endl;
        if(res==0) cout << "ON_SEGMENT" << endl;
        if(res==2) cout << "ONLINE_BACK" << endl;
        if(res==-2) cout << "ONLINE_FRONT" << endl;
    }
}


Measured memory_bytes: 3292
#include<iostream>
using namespace std;
long long k,b[100005],n;
int main(){
	cin>>n>>k;
	long long ans=(long long)(n/k)*(n/k)*(n/k);
	if(k%2==0){
		long long x=0;
		for(int i=1;i<=n;i++){
			if(i%k==(k/2)) x++;
		}
		ans+=(long long)x*x*x;
	}
	cout<<ans;
}

Measured memory_bytes: 3620