akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()

const int mod = 1e9+7;
const int inf = 2e18;

int32_t main()
{	
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int a,b;
	cin>>a>>b;
	cout<<a*b<<'\n';

	return 0;
}	

Measured memory_bytes: 3648
import Data.List
import Data.Array.IArray
import Data.Array.IO
import Control.Applicative
import Control.Monad

ub = 1000

primes = 2 : f [3] [3,5..]
  where
    f (x:xs) ys = let (ps, qs) = span (< x^2) ys in ps ++ f (xs ++ ps) [z | z<-qs, mod z x /= 0]

primes' = takeWhile (< ub) $! primes

parray = accumArray (\x y -> y) False (1,ub) [(i, True) | i<-primes'] :: Array Int Bool


primeFactorize n = pfactorize' n primes'
  where
    pfactorize' _ [] = []
    pfactorize' 1 _ = []
    pfactorize' n pr@(p:ps) =
      if parray ! n then
        [n]
      else
        if mod n p == 0 then p : (pfactorize' (div n p) pr) else pfactorize' n ps

main = do
  n <- read <$> getLine

  let factors = foldl1 (++) $ map primeFactorize [1..n]
  
  arr <- newArray (1,n) 0 :: IO (IOArray Int Integer)

  forM_ factors $ \x -> do
    r <- readArray arr x
    writeArray arr x (r+1)


  print
    =<< return . (foldl1 (\x y -> mod (x*y) (10^9+7))) . (map (+1))
    =<< getElems arr

  


Measured memory_bytes: 1276
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <tuple>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int m = max({a,b,c});
    int o = a+b+c-m;
    cout<<pow(2,k)*m+o<<endl; return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
using namespace std;

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

    char way[21 + 3][21 + 3] = {};
    int route[21 + 3][21 + 3] = {};

    int x0 = -1;
    int y0 = -1;

    for (int y = 1; y <= h; ++y) {
        for (int x = 1; x <= w; ++x) {
            char c;
            cin >> c;
            way[y][x] = (c == '.');
            if (way[y][x] && x0 < 0 && y0 < 0) {
                x0 = x;
                y0 = y;
            }
        }
    }

    auto open = vector<int>();
    open.reserve(20 * 20);

    struct XY {
        int x, y;
    };
    const XY dir[4] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
    struct XYR {
        int x, y, max_r;
    };

    const auto &fill_route = [&](int x_start, int y_start) {
        open.clear();
        open.push_back(x_start + y_start * 256);
        for (int y = 1; y <= h; ++y)
            for (int x = 1; x <= w; ++x)
                route[y][x] = 0;
        route[y_start][x_start] = 1;

        while (!open.empty()) {
            int xy = open.front();
            open.erase(open.begin()); // !! pop_front
            int x = xy % 256;
            int y = xy / 256;
            int K = route[y][x];

            for (auto d : dir) {
                int nx = x + d.x;
                int ny = y + d.y;
                if (!way[ny][nx])
                    continue;
                if (route[ny][nx])
                    continue;

                route[ny][nx] = K + 1;
                open.push_back(nx + ny * 256);
            }
        }
    };

    const auto &find_max = [&]() {
        int max_r = 0;
        for (int y = 1; y <= h; ++y) {
            for (int x = 1; x <= w; ++x) {
                max_r = max(route[y][x], max_r);
            }
        }
        return max_r;
    };

    int max_r = 0;
    for (int y = 1; y <= h; ++y) {
        for (int x = 1; x <= w; ++x) {
            if (!way[y][x])
                continue;
            fill_route(x, y);
            max_r = max(find_max(), max_r);
        }
    }

    cout << max(max_r - 1, 0);
    return 0;
}


Measured memory_bytes: 256
// Program to compute sum of ranges for different range
// queries
#include <bits/stdc++.h>
using namespace std;
#define N 500005

// Variable to represent block size. This is made global
// so compare() of sort can use it.
int block;

// Structure to represent a query range
struct Query
{
	int L, R;
	int idx=-1;
	int ans=0;
}q[N];
int c[N];
// Function used to sort all queries so that all queries
// of the same block are arranged together and within a block,
// queries are sorted in increasing order of R values.
bool compare(Query x, Query y)
{
	// Different blocks, sort by block.
	if (x.L/block != y.L/block)
		return x.L/block < y.L/block;

	// Same block, sort by R value
	return x.R < y.R;
}
bool cmm(Query x,Query y)
{
    return x.idx<y.idx;
}

// Prints sum of all query ranges. m is number of queries
// n is size of array a[].
void queryResults(Query q[], int m)
{
	// Find block size
	block = (int)sqrt(N);

	// are arranged together.
	sort(q, q + m, compare);

	int currL = 0, currR = 0;

	// Traverse through all queries
	int g[N];
	memset(g,0,sizeof g);
	int now=0;
	for (int i=0; i<m; i++)
	{
		// L and R values of current range
		int L = q[i].L, R = q[i].R;

		// Remove extra elements of previous range. For
		// example if previous range is [0, 3] and current
		// range is [2, 5], then a[0] and a[1] are subtracted
		while (currL < L)
		{
			if(g[c[currL]]==1)
                now--;
            g[c[currL]]--;
			currL++;
		}

		// Add Elements of current Range
		while (currL > L)
		{
			if(g[c[currL-1]]==0)
                now++;
            g[c[currL-1]]++;
			currL--;
		}
		while (currR <= R)
		{
			if(g[c[currR]]==0)
                now++;
            g[c[currR]]++;
			currR++;
		}

		while (currR > R+1)
		{
			if(g[c[currR-1]]==1)
                now--;
            g[c[currR-1]]--;
			currR--;
		}
        q[i].ans=now;
	}
    sort(q,q+m,cmm);
    for(int i=0;i<m;i++)
        cout<<q[i].ans<<'\n';
}

// Driver program
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++)
        cin>>c[i];
    for(int i=0;i<m;i++)
    {
        cin>>q[i].L>>q[i].R;
        q[i].L--;
        q[i].R--;
        q[i].idx=i;
    }
    queryResults(q,m);
	return 0;
}


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

using namespace std;

int main() {
    string s;
    cin >> s;
    int n = s.length();
    string s_rev = s,
           s1 = s.substr(0, (n - 1) / 2),
           s2 = s.substr((n + 3) / 2 - 1),
           s1_rev = s1,
           s2_rev = s2;

    reverse(s_rev.begin(), s_rev.end());
    reverse(s1_rev.begin(), s1_rev.end());
    reverse(s2_rev.begin(), s2_rev.end());
    cout << (s_rev == s && s1_rev == s1 && s2_rev == s2 ? "Yes" : "No") << endl;
    return 0;
}


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

using namespace std;

int main(){
	string s,a[2];
	cin >> s;
	s.erase(s.end()-1);
//	cout << s;
	while(1){
		if(s.length()%2==0){
			a[0]=s.substr(0,s.length()/2);
//			cout << "substr(0,s.length()/2)=" << a[0] << endl;

			a[1]=s.substr(s.length()/2,s.length());
//			cout << "substr(s.length()/2,s.end())=" << a[1] << endl;
			if(a[0]==a[1]){
				cout << a[0].length()*2 << endl;
				break;
			}
		}
		s.erase(s.end()-1);
	}
		
}



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

int main()
{
	int N, T, A;
	cin >> N >> T >> A;
	vector<double> H(N);
	for (int i = 0; i < N; ++i) cin >> H[i];
	for (int i = 0; i < N; ++i) H[i] = abs(T - H[i] * .006 - A);
	cout << distance(H.begin(), min_element(H.begin(), H.end())) + 1 << '\n';
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;


//ABC159_C
int main() {
	double L;
	cin >> L;

	double x = L / 3;
	double v = x * 0.25 * (L - x) * (L - x);
	cout << fixed << setprecision(12);
	cout << v << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'

signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int a, b;
	cin >> a >> b;
	if(a < b) swap(a, b);
	if((a - b)&1) return cout << "IMPOSSIBLE", 0;
	else cout << b + ((a - b)>>1);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

struct Link {
    int src;
    int dst;
    int64_t cost;

    bool operator<(const Link& rhs) const {
        return cost < rhs.cost;
    }
};

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

    vector<Link> links;
    links.reserve(n * n);
    for (auto i : irange(0, n)) {
        for (auto j : irange(0, n)) {
            int64_t cost;
            cin >> cost;
            links.push_back(Link{i, j, cost});
        }
    }

    auto sorted_links = links;

    sort(sorted_links.begin(), sorted_links.end());

    vector<vector<int64_t>> costs(n, vector<int64_t>(n, -1));
    for (int i = 0; i < n; ++i) {
        costs[i][i] = 0;
    }

    int64_t total = 0;
    for (int i = 0; i < sorted_links.size(); ++i) {
        const auto& link = sorted_links[i];
        if (link.src <= link.dst) {
            continue;
        }

        if (costs[link.src][link.dst] >= 0 && link.cost > costs[link.src][link.dst]) {
            cout << "-1" << endl;
            return 0;
        }

        if (costs[link.src][link.dst] >= 0 && link.cost == costs[link.src][link.dst]) {
            continue;
        }

        bool updated = false;
        for (int i = 0; i < n; ++i) {
            if (costs[link.src][i] < 0) {
                continue;
            }

            for (int j = 0; j < n; ++j) {
                if (costs[link.dst][j] < 0) {
                    continue;
                }

                auto cost = costs[link.src][i] + link.cost + costs[link.dst][j];
                if (costs[i][j] >= 0 && cost >= costs[i][j]) {
                    continue;
                }

                costs[i][j] = cost;
                costs[j][i] = cost;
                updated = true;

                if (cost < links[i * n + j].cost) {
                    cout << "-1" << endl;
                    return 0;
                }
            }
        }

        if (updated) {
            total += link.cost;
        }
    }

    cout << total << endl;
}


Measured memory_bytes: 3840
H,W,K = map(int, input().split())

C = [input() for _ in range(H)]
cnt = 0

for i in range(2 ** H):
    for j in range(2 ** W):
        black = 0
        for x in range(H):
            for y in range(W):
                if ((i >> x) & 1) and ((j >> y) & 1) and C[x][y] == "#":
                    black += 1
        if black == K:
            cnt += 1
print(cnt)


Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    string s;
    cin>>s;
    if(s[2] == s[3] && s[4] == s[5]) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
//approach 3 dp
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
using namespace std;
int32_t main(){
    int n;
    cin>>n;
    int a[401];
    int sum[401];
    sum[0]=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum[i]=sum[i-1]+a[i];
    }
    int dp[401][401];
    
    int inf=LONG_LONG_MAX;
    memset(dp,inf,sizeof dp);
    //memset(dp,0,sizeof dp);
    for(int i=1;i<=n;i++){
        dp[i][i]=0;
    }
    for(int d=0;d<=n-1;d++){
        for(int i=1,j=d+1;i<=n-d && j<=n;i++,j++){
            if(i==j){
                continue;
            }
            int ans=LONG_LONG_MAX;
            for(int k=i;k<=j-1;k++){
                ans=min(ans,dp[i][k]+dp[k+1][j]);
            }
            dp[i][j]=(sum[j]-sum[i-1])+ans;
        }
    }    
    cout<<dp[1][n]<<endl;
    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

int main() {
  string S; cin >> S;
  if (stoi(S.substr(0, 4)) <= 2019 && stoi(S.substr(5, 2)) <= 4 && stoi(S.substr(8, 2)) <= 30) {
    cout << "Heisei" << endl;
  } else {
    cout << "TBD" << endl;
  }
}


Measured memory_bytes: 256
N = int(input())
T = list()
for index in range(N):
	T.append((int(i) for i in input().split()))

pt, px, py = (0, 0, 0)
for t, x, y in T:
	d = (t - pt) - (abs(x - px) + abs(y - py))
	if d >= 0 and d % 2 == 0:
		pt, px, py = (t, x, y)
	else:
		print("No")
		exit(0)

print("Yes")

Measured memory_bytes: 89356
s=input()
n=len(s)
w=int(input())
n=(n+w-1)//w
l,r=0,w
a=[]
for i in range(n):
  t=""
  if i==n-1:
    t=s[l:]
    a.append(t[0])
    continue
  t=s[l:r]
  a.append(t[0])
  l=r
  r+=w
print("".join(a))


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


int main() {
	int n,m;
    cin>>n>>m;
    priority_queue<int> q;
    ll ans=0;

    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        q.push(a);
    }
	
    rep(i,m){
        int b=q.top()/2;
        q.pop();
        q.push(b);
    }

    for(int i=0;i<n;i++){
        ans+=q.top();
        q.pop();
    }

    cout<<ans<<endl;
    
}


Measured memory_bytes: 1020
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if (a != 1 && b != 1) {
            System.out.println(1);
        } else if (a != 2 && b != 2) {
            System.out.println(2);
        } else {
            System.out.println(3);
        }
    }
}


Measured memory_bytes: 21716
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
 
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

int main() {
    string s, a;
    cin >> s >> a;
    int n, g;
    cin >> n >> g;
    string h;
    cin >> h;
    if(s == h){
        n--;
    }else{
        g--;
    }
    cout << n << " " << g;
    
    return 0;
}

Measured memory_bytes: 3588
import java.util.Scanner;

public class Main{
	static public void  main(String[] args){
		Scanner scan = new Scanner(System.in);

		String a = scan.next();
		int n = 0;
		for(int i = 0 ; i < a.length(); i++){
			if(a.charAt(i) == '2') n++;
		}
		System.out.println(n);
	}
}


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

#define fst first
#define snd second
#define ll long long
#define ld long double
#define pb push_back
#define emp emplace_back
#define pii pair<int, int>
#define usg unsigned
#define sg signed
#define mp make_pair

using namespace std;

void setIO(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
}

const ld PI = 4*atan((ld)1);
const int INF = 1e9+7;
const ll _INF = 1e18+7;

set<pii>st[2];

int main(){
	setIO();
	ll n, q;
	cin >> n >> q;
	ll sum = (n-2)*(n-2);
	st[0].insert({n, n});
	st[1].insert({n, n});
	while (q--){
		int t, x;
		cin >> t >> x; t--;
		auto it = st[t].lower_bound({x, -1});
		int y = (*it).snd;
		sum -= y-2;
		st[t^1].insert({y-1, x});
	}
	cout << sum << endl;
}

Measured memory_bytes: 12932
#include <cstdio>
#include <cstring>
#include <algorithm>

int n,K,head[300001],nxt[600001],b[600001],v[600001],k=1,p[300001],dis[300001],q[300001],h,t;
int P[2][300001],bel[2][300001],S,T;
void push(int s,int t,int val){
	nxt[++k]=head[s];
	head[s]=k;
	b[k]=t;
	v[k]=val;
}
void link(int s,int t,int val){
	push(s,t,val);
	push(t,s,0);
}
bool bfs(){
	for(int i=S;i<=T;i++)dis[i]=-1;
	dis[S]=0;
	h=t=0;
	q[++t]=S;
	bool cando=0;
	while(h<t){
		++h;
		for(int i=head[q[h]];i;i=nxt[i])
			if(v[i]&&!~dis[b[i]]){
				dis[b[i]]=dis[q[h]]+1;
				q[++t]=b[i];
				if(b[i]==T)cando=1;
			}
	}
	return cando;
}
int dfs(int x,int flow){
	if(x==T||!flow)return flow;
	int used=0;
	for(int i=p[x];i;i=nxt[i])
		if(v[i]&&dis[b[i]]==dis[x]+1){
			int w=dfs(b[i],std::min(flow-used,v[i]));
			v[i]-=w;
			v[i^1]+=w;
			used+=w;
			if(w)p[x]=i;
			if(flow==used)return flow;
		}
	if(!used)dis[x]=0;
	return used;
}
int main(){
	scanf("%d",&n);
	for(int j=0;j<2;j++){
		for(int i=1;i<=n;i++)scanf("%d",&P[j][i]),++P[j][i];
		for(int i=1;i<=n;i++)
			if(!bel[j][i]){
				bel[j][i]=i+j*n;
				int tem=P[j][i];
				while(tem!=i)bel[j][tem]=i+j*n,tem=P[j][tem];
			}
	}
	T=(n<<1)+1;
	int mx=0;
	for(int i=1;i<=n;i++){
		if(P[0][i]==P[1][i]&&P[0][i]==i)++mx;
		else if(P[0][i]==P[1][i]&&P[0][i]!=i)link(bel[0][i],bel[1][i],1),link(bel[1][i],bel[0][i],1);
		else if(P[0][i]==i&&P[1][i]!=i)link(S,bel[1][i],1);
		else if(P[0][i]!=i&&P[1][i]==i)link(bel[0][i],T,1);
		else if(P[0][i]!=P[1][i])link(bel[0][i],bel[1][i],1);
	}
	while(bfs()){
		memcpy(p,head,sizeof p);
		mx+=dfs(S,0x7f7f7f7f);
	}
	printf("%d\n",n-mx);
}

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

int main() {
    long long n, m, k;
    cin >> n;
    m = ((1 + n) * n) >> 1;
    k = n / 3;
    m -= ((1 + k) * k * 3) >> 1;
    k = n / 5;
    m -= ((1 + k) * k * 5) >> 1;
    k = n / 15;
    m += ((1 + k) * k * 15) >> 1;
    cout << m << endl;
}


Measured memory_bytes: 3536
#include<stdio.h>

#define MAX 2000000

int H,A[MAX+1];

void maxHeapify(int i)
{
  int l,r,largest,x;
    l = 2*i;
    r = 2*i + 1;

    if(l <= H && A[l] > A[i]) largest = l;
    else largest = i;
    if(r <= H && A[r] > A[largest]) largest = r;

    if(largest != i)
      {
	x = A[i];
	A[i] = A[largest];
	A[largest] = x;
       maxHeapify(largest);
      }
}

int main()
{
    int i;
    scanf("%d",&H);
    for(i=1;i<=H;i++)
    {
	scanf("%d",&A[i]);
    }
    for(i = H/2 ;i>=1;i--)
    {
        maxHeapify(i);
    }
    for(i=1;i<=H;i++)
    {
      printf(" %d",A[i]);
    }
    printf("\n");

    return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MAX 2000005
#define MOD 1000000007
#define MOD2 998244353
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define vi vector<ll>
#define vp vector<pii>
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

ll mexp(ll a, ll b){
    ll ans=1;
    a%=MOD;
    while(b){
        if(b&1) ans=ans*a%MOD;
        b>>=1;
        a=a*a%MOD;
    }
    return ans;
}


int main(){
    IOS

    int n;
    cin>>n;
    int p[n+1];
    FOR(i,1,n+1){
        cin>>p[i];
    }
    int c=0;
    FOR(i,2,n){
        int mn=min(p[i],min(p[i-1],p[i+1]));
        int mx=max(p[i],max(p[i-1],p[i+1]));
        if(p[i]!=mn && p[i]!=mx){
            c++;
        }
    }
    cout<<c;

    cerr<<"Time: "<<1.0/CLOCKS_PER_SEC<<" ms"<<endl;
    return 0;
}

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

typedef double db;

int main(){
  db a, b, x;
  cin >> a >> b >> x;
  db ans = 0;
  if ( a * b * a >= 2 * x ) {
    ans = atan(a * b * b / (2 * x));
  } else {
  	ans = atan(2 * (a * a * b - x) / (a * a * a));
  }
  cout << fixed << setprecision(10) << ans * 180 / acos(-1) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
using vi = vector<int>;
const int MOD = 1e9+7;


int main() {
    string O, E;
    cin >> O >> E;
    string ans = "";
    int o = O.size();
    int e = E.size();
    if (o == e) {
        rep(i, o) {
            ans = ans + O[i];
            ans = ans + E[i];
        }
    }
    else {
        rep(i, e) {
            ans = ans + O[i];
            ans = ans + E[i];
        }
        ans = ans + O[o-1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using cpx = complex<double>;
using namespace std::literals;
using Int = long long;
using Double = long double;
#ifdef __GNUG__
#define _GLIBCXX_DEBUG
#endif
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define F first
#define S second
#define PUTS(x) cout << (x) << endl;
#define perm(c)                   \
    sort((c).begin(), (c).end()); \
    for (bool c##p = 1; c##p; c##p = next_permutation((c).begin(), (c).end()))
vector<Int> IntsIn(int n) {
    auto v = vector<Int>(0);
    for (int i = 0; i < n; i++) {
        Int a;
        cin >> a;
        v.push_back(a);
    }
    return v;
}
template <typename T>
void Puts(T x) {
    cout << x << endl;
}
void setPrecision(int num = 20) {
    std::cout << std::fixed << std::setprecision(num);
}
template <typename T>
T Max(T a) {
    return a;
}
template <typename T, typename... Args>
T Max(T a, Args... args) {
    return std::max(Max(args...), a);
}
template <typename T>
T Min(T a) {
    return a;
}
template <typename T, typename... Args>
T Min(T a, Args... args) {
    return std::min(Min(args...), a);
}
template <typename T>
bool vector_contains(std::vector<T> vec, T value) {
    return (std::distance(vec.begin(), std::find(vec.begin(), vec.end(), value)) != vec.size());
}
template <typename T>
long indexOf(std::vector<T> &vec, const T &value) {
    auto result = std::distance(vec.begin(), std::find(vec.begin(), vec.end(), value));
    return ((long)result == (long)vec.size()) ? -1 : result;
}
template <typename T>
void removeAt(std::vector<T> &vec, unsigned int index) {
    vec.erase(vec.begin() + index);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &value) {
    std::fill((T *)array, (T *)(array + N), value);
}
Int gcd(Int a, Int b) {
    Int M = max(a, b);
    Int m = min(a, b);
    while (true) {
        Int r = M % m;
        if (r == 0) break;
        M = m;
        m = r;
    }
    return m;
}
Int lcm(Int a, Int b) {
    return a / gcd(a, b) * b;
}
int main() {
    Int n, M;
    cin >> n >> M;
    auto v = vector<Int>();
    Int L = 1;
    rep(i, n) {
        Int a;
        cin >> a;
        a /= 2;
        v.PB(a);
        L = lcm(L, a);
    }
    if (M < L) {
        puts("0");
        return 0;
    }
    for (auto a : v) {
        if ((L / a) % 2 == 0) {
            puts("0");
            return 0;
        }
    }
    PUTS((M - L) / (2 * L)+1);
}


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

using namespace std;

const int MAX = 101;

int field[MAX][5][5][5];
int N;
vector<int> birth,die;

void input(){
  for(int i = 0; i < 5; i++)
    for(int j = 0; j < 5; j++)
      for(int k = 0; k < 5; k++){
	char c;
	cin >> c;
	field[0][i][j][k] = c-'0';
      }
  
  int M;
  cin >> M;
  birth.resize(M);
  for(int i = 0; i < M; i++) cin >> birth[i];
  cin >> M;
  die.resize(M);
  for(int i = 0; i < M; i++) cin >> die[i];
}

void print(int D){
  for(int i = 0; i < 5; i++){
    if(i) cout << endl;
    for(int j = 0; j < 5; j++){
      for(int k = 0; k < 5; k++) cout << field[D][i][j][k];
      cout << endl;
    }
  }
}
int find(const vector<int>& v, int num){
  for(int i = 0; i < (int)v.size(); i++)
    if(v[i] == num) return 1;
  return 0;
}

bool isInside(int x, int y, int z){return 0<=x&&x<5&&0<=y&&y<5&&0<=z&&z<5;}

void sim(int life, int t, int x, int y, int z){
  int touch = 0;
  
    for(int i = x-1; i <= x+1; i++)
      for(int j = y-1; j <= y+1; j++)
	for(int k = z-1; k <= z+1; k++){
	  if(!isInside(i,j,k)) continue;
	  if(i == x && j == y && k == z) continue;
	  touch += field[t][i][j][k];
	}

    if(life) field[t+1][x][y][z] = find(die,touch);
    else field[t+1][x][y][z] = find(birth,touch);
}


void solve(int rev){
  for(int i = 0; i < N; i++)
    for(int j = 0; j < 5; j++)
      for(int k = 0; k < 5; k++)
	for(int l = 0; l < 5; l++) sim(field[i][j][k][l],i,j,k,l);
  cout << "Case " << rev << ":" << endl;
  print(N);
}

int main(){
  int rev = 0;
  while(cin >> N && N){
    if(rev) cout << endl;
    input();
    solve(++rev);
  }
  return 0;
}

Measured memory_bytes: 1268
N = int(input())
info = []
for i in range(1,N):
    info.append(tuple(map(int, input().split())))

for i in range(N):
    t = 0
    for j in range(i,N-1):
        if t < info[j][1]:
            t = info[j][1]
        elif t % info[j][2] == 0:
            pass
        else:
            t = t + info[j][2] - t % info[j][2]
        t += info[j][0]
    print(t)

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<string>
#include<iterator>
#include<cmath>
using namespace std;

int main()
{
   int N, i, x, y, z, sq, count;
   cin>>N;
   for(i=1;i<=N;i+=1)
   {
       count=0;
       sq = (int)pow(i, 0.5);
       for(x=1;x<=sq;x+=1)
       {
           for(y=1;y<=sq;y+=1)
           {
               if(x*x+y*y>i)
               {
                   break;
               }
               for(z=1;z<=sq;z+=1)
               {
                   if(x*x+y*y+z*z+x*y+y*z+z*x>i)
                   {
                       break;
                   }
                   if(x*x+y*y+z*z+x*y+y*z+z*x==i)
                   {
                       count+=1;
                   }
               }
           }
       }
       cout<<count<<endl;
   }
}


Measured memory_bytes: 3908
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
int dp[90005],dp2[90005];
int main()
{
	int n,sum=0,ans=1;
	scanf("%d",&n);
	dp[0]=1;
	dp2[0]=1;
	while (n--)
	{
		int a;
		scanf("%d",&a);
		sum+=a;
		for (int i=sum;i>=0;i--)
		dp[i]=(2LL*dp[i]+(i>=a? dp[i-a]:0))%mod;
		for (int i=sum;i>=0;i--)
		dp2[i]=(dp2[i]+(i>=a? dp2[i-a]:0))%mod;
		ans=(3LL*ans)%mod;
	}
	for (int i=(sum+1)/2;i<=sum;i++)
	ans=(ans-3LL*dp[i]%mod+mod)%mod;
	if (sum%2==0)
	ans=(ans+3LL*dp2[sum/2]+mod)%mod;
	printf("%d",ans);
}

Measured memory_bytes: 4368
/******************
*  Author: BD747  *
******************/
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
#include<bits/stdc++.h>
using namespace std;

long long dp[105][100005];
long long w[105],v[105];
int n,wt;

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>wt;
	for(int i=1;i<=n;i++){
		cin>>w[i]>>v[i];
	}
	for(int i=n;i>=1;i--){
		for(int j=0;j<=wt;j++){
			if(j<w[i]){
				dp[i][j]=dp[i+1][j];
			}else{
				dp[i][j]=max(dp[i+1][j],dp[i+1][j-w[i]]+v[i]);
			}
		}
	}
	cout<<dp[1][wt];

	return 0;
}


Measured memory_bytes: 79360
from collections import deque

h, w = map(int, input().split())

maze = [input() for i in range(h)]

ans = 0
INF = 20 * 20 + 1
for j in range(h):
    for i in range(w):
        if maze[j][i] == ".":
            cnt = [[INF] * w for _ in range(h)] 
            cnt[j][i] = 0
            q = deque([(j,i)])
            while q:
                y,x = q.popleft()
                for by,bx in ((0,1),(0,-1),(1,0),(-1,0)):
                    by += y
                    bx += x 
                    if 0 <= by < h and 0 <= bx < w:
                        ct = cnt[y][x] + 1
                        if maze[by][bx] == "." and ct < cnt[by][bx]:
                            q += [(by,bx)] 
                            cnt[by][bx] = ct
                            ans = max(ans, cnt[by][bx])

print(ans)

Measured memory_bytes: 3316
N= int(input())
def f(x):
    z=0
    if int(x) >N:
        return 0
    if x.count('3')>0 and x.count('5')>0 and x.count('7')>0:
        z = 1
    z +=f(x+'3')
    z +=f(x+'5')
    z +=f(x+'7')
    return z
print(f('0'))


Measured memory_bytes: 3060
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  int a[N]; FOR(i,0,N) cin >> a[i];
  int ans = 0;
  FOR(i,0,N) {
    FOR(j,i+1,N) {
      int pro = a[i] * a[j];
      int x = 10;
      bool ok = true;
      while(pro) {
        if(x != 10 && pro % 10 != x - 1) {
          ok = false;
          break;
        }
        x = pro % 10;
        pro /= 10;
      }
      if(ok) ans = max(ans, a[i] * a[j]);
    }
  }
  if(ans == 0) ans = -1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3148
# coding: utf-8
# Your code here!
#import collections
# c = collections.Counter()
#import itertools as it
#import math
#import numpy as np
#import sys 
#sys.exit()
 
s = input()
#k = int(input())
#a, b  = map(int, input().split())
'''
#  = list(map(int, input().split()))
'''
'''
n = input()
a = [int(input()) for i in range(n)]
'''
'''
n,m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(m)]
'''
 
#-------------------------------#
 
if s=='ABC':
	print('ARC')
else:
  	print('ABC')

Measured memory_bytes: 9032
n = int(input())
k = int(input())
R = len(str(n))
r = R - 1
q = 0
num = [0] * 4
index = [0] * 4
s = str(n)
for i in range(R):
    if s[i] != "0":
        num[q] = int(s[i])
        index[q] = i
        q += 1
    if q == 4:
        break

if k == 1:
    ans = 9 * r + num[0]
elif k == 2:
    ans = 81 * r * (r-1) // 2
    if num[1] != 0:
        pass
    else:
        num[0] -= 1
        num[1] = 9
        index[1] = 1
    ans += 9 * (R - 1) * (num[0] - 1) + num[1] + 9 * (R - index[1] - 1)
elif k == 3:
    ans = 243 * r * (r-1) * (r-2) // 2
    if num[2] != 0:
        pass
    elif num[1] != 0:
        num[1] -= 1
        index[2] = index[1] + 1
        num[2] = 9
    else:
        num[0] -= 1
        index = [0, 1, 2]
        num[1], num[2] = 9, 9
    ans += 81 * (R-1)*(R-2)*(num[0]-1)//2 + 9 * (R - index[1] - 1) * (num[1] - 1)
    ans += 81 * (R-index[1]-1)*(R-index[1]-2) // 2
    ans += 9 * (R - index[2] - 1) + num[2]
print(ans)

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

int a[2001];
int main()
{
    int n,z,w;
    scanf("%d%d%d",&n,&z,&w);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    if (n!=1) cout<<max(abs(a[n]-w),abs(a[n-1]-a[n]))<<endl;
    else cout<<abs(a[n]-w)<<endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(300000)
from fractions import gcd
from collections import defaultdict

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


N = I()
d = defaultdict(int)
zero = 0
for i in range(N):
    a, b = MI()
    if a == 0 and b == 0:
        zero += 1
        continue
    g = gcd(a, b)
    a, b = a // g, b // g
    minus = (-1) ** ((a < 0) + (b < 0))
    d[(minus * abs(a), abs(b))] += 1

ans = 1
seen = set()
for a, b in d:
    if (a, b) not in seen:
        if (a, b) in [(1, 0), (0, 1)]:
            ainv, binv = b, a
        else:
            ainv, binv = b * (1 if a < 0 else -1), abs(a)
        lans = (2 ** d[(a, b)] - 1)
        lans += (2 ** d[(ainv, binv)] - 1) if d.get((ainv, binv)) is not None else 0
        lans += 1
        ans = ans * lans % MOD
        seen.add((a, b))
        seen.add((ainv, binv))
ans = (ans + zero) % MOD
print((ans + MOD - 1) % MOD)


Measured memory_bytes: 110252
#include <stdio.h>
#include <limits.h>

int stack[1000];
int top;

int pop()
{
    return stack[--top];
}

void push(int n)
{
    stack[top++] = n;
}

int main()
{
#ifdef TEST
    freopen("input", "r", stdin);
#endif

    char s[5];
    while (scanf("%s", s) != EOF) {
        if (s[0] == '+') {
            int a = pop();
            int b = pop();
            push(a + b);
        } else if (s[0] == '-') {
            int a = pop();
            int b = pop();
            push(b - a);
        } else if (s[0] == '*') {
            int a = pop();
            int b = pop();
            push(a * b);
        } else {
            push(atoi(s));
        }
    }

    printf("%d\n", stack[0]);

    return 0;
}



Measured memory_bytes: 2092
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define reverse(x) reverse(x.begin(), x.end())
#define sort(x) sort(x.begin(), x.end())
#define pb push_back
#define pii pair<int, int>
#define pll pair<long long,long long>
#define f first
#define s second
typedef long long ll;
const int mod = 1e9+7;
using namespace std;
int a[123], n, i, x;
int main(){
	cin >> x >> n;
	map<int, int> m;
	for(i=1;i<=n;i++){
		cin >> a[i];
		m[a[i]]++;
	}
	if(n == 0){
		cout << x;
		return 0;
	}
	int mn = 0, mnabs = 1e9;
	for(i=-1000;i<=1000;i++){
		if(!m[i]){
			if(mnabs > abs(x-i)){
				mnabs = abs(x-i);
				mn = i;
			}
		}
	}
	cout << mn;
}


Measured memory_bytes: 3728
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn = 1e5;
int i;
int a[maxn];
int main(void)
{
	int n;
	scanf("%d",&n);
	for(i = 1;i<n;i++)
		scanf("%d",&a[i]);
	int count = 0;
	for(i = 2;i<=n-1;i++)
	{
		count += min(a[i-1],a[i]);
	}
	count += a[1] + a[n-1];
	printf("%d",count);
	return 0;
}

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

using namespace std;

int main() {
  int k, a, b;
  scanf("%d %d %d", &k, &a, &b);
  long long ans = k+1;
  if (b - a > 2 && k >= a-1) {
    k -= a - 1;
    long long cur = a;
    if (k & 1)
      ++cur;
    cur += 1LL * (k / 2) * (b - a);
    ans = max(ans, cur);
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    map<int, int> mp;
    rep(i, n) mp[a[i]]++;
    bool ans = false;
    if (sz(mp) == 1 && a[0] == 0) {
        ans = true;
    } else if (n%3 == 0 && sz(mp) == 2) { 
        for (auto p : mp) if (p.fi == 0 && p.se == n/3) ans = true;
    } else if (n%3 == 0 && sz(mp) == 3) {
        vp x;
        for (auto p : mp) x.eb(p.fi, p.se);
        if ((x[0].fi^x[1].fi^x[2].fi) == 0 && x[0].se == n/3 && x[1].se == n/3) ans = true;
    }
    cout << (ans ? "Yes" : "No") << endl;
}

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

int main() {
  int A,B,C,D,E,F;
  cin >> A >> B >>C >> D >> E >> F;
  if(E-A<=F){
    cout << "Yay!" << endl;
  }
  else{
	cout << ":(" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define speed_up ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ara(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<int>())
using namespace std;
int main()
{
  speed_up;
  ll n, x, i, sum, d, b, cnt = 0;
  cin>>n>>x;
  ll a[n];
  for(i = 0; i<n; i++)
  {
      cin>>a[i];
  }
  for(i = 0; i<n-1; i++)
  {
      sum = a[i] + a[i+1];
      if(sum>x)
      {
         cnt += sum - x;
         d = a[i+1] -sum + x;
         if(d<0) d = 0;
         a[i+1] = d;
      }
  }
  /*for(i = 0; i<n; i++)
  {
      cout<<a[i]<<endl;
  }*/
  //cout<<endl;
  cout<<cnt<<endl;

  return 0;
}



Measured memory_bytes: 4416
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int N;
  cin >> N;
  ll sum=0;
  vector<ll> A(N+1);
  for (int i = 0; i < N+1; i++){
    cin >> A[i]; sum+=A[i];
  }
  
  ll ans=0;
  ll n=1;
  for(int i=0;i<N+1;i++){
    if(A[i]<=n){
      ans+=n;
      n-=A[i];
      sum-=A[i];
      n=min(2*n,sum);
    }else{
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4052
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	s := getNextString(scanner)
	rr := make([]rune, 0)
	n := len(s)
	ans := 0
	for i := 0; i < n; i++ {
		if i == n-1 {
			rr = append(rr, rune(s[i]))
			continue
		}
		if s[i] == 'B' && s[i+1] == 'C' {
			rr = append(rr, rune('D'))
			i++
			continue
		}
		rr = append(rr, rune(s[i]))
	}
	rn := len(rr)
	l := 0
	for i := 0; i < rn+1; i++ {
		if i == rn || rr[i] == rune('B') || rr[i] == rune('C') {
			a := 0
			for l < i {
				if rr[l] == rune('A') {
					a++
				}
				if rr[l] == rune('D') {
					ans += a
				}
				l++
			}
		}
	}
	fmt.Fprintln(writer, ans)

	writer.Flush()
}


Measured memory_bytes: 5760
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
R = range(N-M+1)

for i in R:
    for j in R:
        for k in range(M):
            if A[j+k][i:i+M] != B[k]:
                break
        else:
            print('Yes')
            exit()
print('No')


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll A, B;
    cin >> A >> B;

    cout << (A-1)*(B-1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<climits>
#include<algorithm>
#include<vector>
#include<valarray>
#include<string>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iostream>
#include<iomanip>
using namespace std;


#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;i>=0;i--)
#define DREP(i,n) for(int i=n;i>0;i--)
#define Rep(i,m,n) for(int i=m;i<n;i++)
#define ReP(i,m,n) for(int i=m;i<=n;i++)
#define scani(a) scanf("%d",&a)
#define scand(a) scanf("%lf",&a)
#define scans(s) scanf("%s",s)
#define readi(a) int a;scanf("%d",&a)
#define printi(a) printf("%d",a)
#define prints(s) printf("%s",s)
#define even(n) (((n)+1)%2)
#define odd(n) ((n)%2)
#define sg(x) ((x)?1:0)
#define LF printf("\n")
#define SPACE printf(" ")
#define pb push_back
#define mp make_pair
#define bs binary_search
#define all(a) (a).begin(),(a).end()
#define forall(itr,a) for(auto itr=(a).begin();itr!=(a).end();++itr)

typedef long long LL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<double,double> pdd;
typedef pair<int,int> pii;

const double pi = acos(-1.0);
double rad(double t){return t*pi/180.0;}
double deg(double d){return d*180.0/pi;}
template<typename T>T GCD(T x,T y){return y?GCD(y,x%y):x;}
template<typename T>T LCM(T x,T y){return x/GCD(x,y)*y;}
template<class T>ostream& operator<<(ostream& os,const set<T>& s){os<<"{";for(auto itr=s.begin();s.end() != itr;++itr){if(itr!=s.begin())os<<',';os<<*itr;}os<<"}";return os;}
template<class S,class T>ostream& operator<<(ostream& os,const pair<S,T>& p){os<<'('<<p.first<<','<<p.second<<')';return os;}
const int MOD = (int)pow(10,9) +7;


//begin global variable
//


//
//end   global variable

int main(){
  ios::sync_with_stdio(false);
  //begin main()
  //

  string s;
  int c=0,f=0;
  cin >> s;

  for(int i=0;i<s.size();++i){
    if(s[i]=='C') c = 1;
    else if(s[i]=='F' && c) f = 1;
  }

  cout << (f?"Yes":"No") << endl;
  //
  //end   main()
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>


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

  int n;
  scanf("%d", &n);
  
  double p;
  int count = 0;
  for (int i = 1; i <= n; i++){
      if (i%2 == 1){
          count++;
      }
  }

  p = (double)count/n;
  printf("%f\n", p);

  return 0;
}

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

int main(void)
{
    int m, f, r;
    
    while (true) {
        cin >> m >> f >> r;
        if ( m == -1 && f == -1 && r == -1) break;
        else if (m == -1 || f == -1) cout << 'F' << endl;
        else if (m + f >= 80) cout << 'A' << endl;
        else if (m + f >= 65 && m + f < 80) cout << 'B' << endl;
        else if (m + f >= 50 && m + f < 65) cout << 'C' << endl;
        else if (m + f >= 30 && m + f < 50) {
            if (r >= 50) cout << 'C' << endl;
            else cout << 'D' << endl;
        } else cout << 'F' << endl;

    }
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Jun 14 16:33:01 JST 2020
 **/

signed main() {
    Int n;
    std::cin >> n;
    std::vector<Int> a(n);
    REP(i, n) std::cin >> a[i];
    Int Q;
    std::cin >> Q;
    REP(q, Q) {
        Int k;
        std::cin >> k;
        std::cout << std::lower_bound(a.begin(), a.end(), k) - a.begin() << "\n";
    }
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define MAX 105
using namespace std;

int arr[50][50];
int b[50];

int main()
{
    int n, m, c;

    cin>>n>>m>>c;

    for(int i = 0; i < m; i++)
        cin>>b[i];

    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin>>arr[i][j];
        }
    }


    int cnt = 0, sum = 0;
    for(int i = 0; i < n; i++){
        sum = 0;
        for(int j = 0; j < m; j++){
            sum += (arr[i][j] * b[j]);
        }
        sum += c;
        if(sum > 0)
            cnt++;
    }

    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b, c, x int
	fmt.Scan(&a, &b, &c, &x)

	count := 0
	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {
				total := 500*i + 100*j + 50*k
				if total == x {
					count++
				}
			}
		}
	}
	fmt.Println(count)
}

Measured memory_bytes: 512
#include<stdio.h>

int main(void){
  char S[256];
  int N,K;
  scanf("%d%d",&N,&K);
  scanf("%s",S);
  
  for(int i=0;i<N;i++){
    if((i+1)==K){
      S[i]=S[i] + 0x20;
    }
  }
 
  
  printf("%s\n",S);
  
  return 0;
  
}

Measured memory_bytes: 128