akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n; cin>>n;
	vector<int> a(n);
	for(int i =0; i<n; ++i)
		cin>>a[i];
	sort(a.begin(), a.end());
	int right = n / 2;
	int left = n / 2 - 1;
	cout<<a[right] - a[left];
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main()
{
    int a,b,c,tm,tm2;
    scanf("%d%d%d",&a,&b,&c);
    tm=b-a;
    tm2=c-b;
    if(tm==tm2)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <iomanip>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <deque>
#include <string>

#include <algorithm>
#include <numeric>
#include <random>

#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define endl '\n'

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7;
const int MAXN = static_cast<int>(1e6) + 17;

int n;
string s;
int cnt[MAXN];

bool read() {
    if (!(cin >> n >> s))
        return false;

    return true;
}

void solve() {
    cnt[0] = 0;

    forn (i, n) {
        cnt[i + 1] = cnt[i];

        if (s[i] == 'W')
            ++cnt[i + 1];
    }

    int ans = n;

    forn (i, n) {
        int res = cnt[i] + (n - i - 1) - (cnt[n] - cnt[i + 1]);
        ans = min(ans, res);
    }

    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::mt19937 rand('S' + 'E' + 'R' + 'E' + 'Z' + 'H' + 'K' + 'A');

#ifdef SEREZHKA
    freopen("file.in", "r", stdin);
#endif

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 1812
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

typedef long long ll;

using namespace std;
//using namespace boost::multiprec

int main(){

    ll h,w,n;
    cin >> h >> w >> n;

    map<pair<ll,ll>, ll> m;

    rep(i,n){
        ll a,b;
        cin >> a >> b;

        rep(j,3){
            rep(k,3){
                ll tmpy = a - 1 + j;
                ll tmpx = b - 1 + k;

                if(2 <= tmpy && tmpy <= h - 1 && 2 <= tmpx && tmpx <= w - 1){
                    m[mpair(tmpy, tmpx)]++;
                }
            }
        }
    }

    vector<ll> ans(10);
    ans[0] = (h - 2) * (w - 2);

    for(auto itr = m.begin(); itr != m.end(); itr++){
        ans[(*itr).second]++;
        ans[0]--;
    }

    rep(i,10){
        cout << ans[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 56448
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

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

  int n, m;
  cin >> n >> m;
  vector<Pii> ab(m);
  for (auto &x: ab) cin >> x.first >> x.second;

  priority_queue<Pii, vector<Pii>, greater<Pii> > a_que;
  priority_queue<int, vector<int>, greater<int> > b_que;
  for (int i = 0; i < m; i++) a_que.emplace(ab[i].first, i);
  int ans = 1;
  while (!a_que.empty()) {
    auto now = a_que.top();
    a_que.pop();
    if (!b_que.empty()) {
      if (now.first >= b_que.top()) {
        ans++;
        b_que = priority_queue<int, vector<int>, greater<int> >();
      }
    }
    b_que.push(ab[now.second].second);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int main()
{
    int a;
    cin >> a;
    cout << (a + a * a + a * a * a);
    return 0;
}

Measured memory_bytes: 3592
// https://beta.atcoder.jp/contests/abc076
// status:

#define SUBMIT
//#define DEBUG

#include <utility>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <queue>
#include <numeric>
#include <limits>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

double R, G;

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    auto program_input = std::string(R"(4500
0
)");
    stringstream stream(program_input);
#endif
    stream >> R >> G;
    cout << (2 * G - R) << endl;
    return 0;
}

Measured memory_bytes: 256
'use strict';
const main = input => {
  input = input[0].split(' ');
  const a = parseInt(input[0]),b = parseInt(input[1]);
  console.log(a-2*b>0?a-2*b:0);
  
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 7372
#include <iostream>

using namespace std;

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

	int val = 1;

	while(n--) {
		if(val * 2 < val + k) {
			val *= 2;
		} else {
			val += k;
		}
	}

	cout << val << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int a[5], i, j, tmp;
	scanf("%d %d %d %d %d", &a[0],&a[1],&a[2],&a[3],&a[4]);
	loop:
	for (j = 0;j<4; j++)
	{
		if (a[j] < a[j+1])
		{
			tmp = a[j+1];
			a[j+1] = a[j];
			a[j] = tmp;
		}
	}
	for (i = 0; i < 4; i++)
	{
		if (a[i] < a[i + 1])goto loop;
	}
	printf("%d %d %d %d %d\n", a[0], a[1], a[2], a[3], a[4]);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int MOD = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct edge{
    ll to, cost;
};


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 素数
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){
        IsPrime.resize(max+1,true);
    } 
    IsPrime[0] = false;
    IsPrime[1] = false;

    for(size_t i=2; i*i<=max; ++i){
        if(IsPrime[i]){
            for(size_t j=2; i*j<=max; ++j){
                IsPrime[i*j] = false;
            }
        }
    }
}

// べき乗の余り
ll modpow(ll a, ll n, ll mod){
    ll res = 1;
    while(n){
        if(n & 1){
            (res *= a) %= mod;
        }else{
            (a *= a) %= mod;
        }
        n >>= 1;
    }
    return res;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    vector<ll> q(2*1e5+10, 0);
    for(ll i=0;i<n;++i){
        cin>>a[i];
        q[a[i]]++;
    }

    ll sum = 0;
    for(ll i=0;i<q.size();++i){
        sum += q[i] * (q[i] - 1) / 2;
    }
    for(ll i=0;i<n;++i){
        ll ans = sum;
        ans -= q[a[i]] * (q[a[i]] - 1) / 2;
        ans += (q[a[i]] - 1) * (q[a[i]] - 2) / 2;
        cout<<ans<<endl;
    }
}

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

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

fn main() {
    let n: i32 = read();
    let k: usize = read();
    let mut p: Vec<i32> = (0..n).map(|_| read()).collect();
    let mut sum = 0;
    let mut index: usize = 0;
    p.sort();
    while index < k {
        sum += p[index];
        index = index + 1;
    }
    p.sort();
    println!("{}", sum);
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define ALL(a) (a).begin(), (a).end()
#define p(a, b) printf(a, b);
#define c(s) cout << (s) << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define cyn(c) cout << (c ? "Yes" : "No") << endl;
#define cYN(c) cout << (c ? "YES" : "NO") << endl;
#define pyn(c) printf("%s\n", c ? "Yes" : "No");
#define pYN(c) printf("%s\n", c ? "YES" : "NO");
#define INF 1e18
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> P;
template <class T>
bool contain(const std::string &s, const T &v)
{
  return s.find(v) != std::string::npos;
}
ULL mod = 1e9 + 7;

int main(){
    int n,k; 
    string s;
    cin>>n>>s>>k;
    rep(i,n){
      if(s[i]!=s[k-1]){
        cout<<"*";
      }else{
        cout<<s[i];
      }
    }
    cout<<endl;
}


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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	vector<ll> a(n), b(n);
	for (int i=0; i<n; i++)
		cin>>a[n-1-i]>>b[n-1-i];
	ll added=0;
	for (int i=0; i<n; i++)
		added+=( ((a[i]+added+b[i]-1)/b[i]) * b[i] - (a[i]+added) );
	cout << added << endl;
	return 0;
}


Measured memory_bytes: 1792
class Array
  def cumsum!(s = 0); map!{|t| s += t } end
end

n, k = gets.to_s.split.map{|t| t.to_i }
a    = gets.to_s.split.map{|t| t.to_i }

ans = []
[k, 41].min.times do |i|
  ans = [0] * n
  a.each_with_index do |t, i|
    
    j = i - t
    if 0 <= j
      ans[j] += 1
    else
      ans[0] += 1
    end
    
    j = i + t + 1
    ans[j] += -1 if j < n
  end
  ans.cumsum!
  a = ans.dup
end

puts ans * ' '

Measured memory_bytes: 81172
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x) cin >> x
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int N;
    cin >> N;

    vll C(N), V(N);

    rep(i, N) in(V[i]);
    rep(i, N) in(C[i]);

    ll ans = -INF;

    rep(bit, (1 << N))
    {
        vector<int> S;
        rep(i, N)
        {
            // 列挙に i が含まれるか
            if (bit & (1 << i))
            {
                S.push_back(i);
            }
        }

        ll tmp = 0;

        for (auto x : S)
        {
            tmp += V[x] - C[x];
        }

        chmax(ans, tmp);
    }

    outl(ans);

    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法
#define JUUHATI 1000000000000000000 
#define JUUHATIPLUS 1000000000000000001 

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    string S,revS,partS,partS2;
    cin >> S;
    revS = S;
    int N;
    N = S.size();
    bool fla = true;

    reverse(revS.begin(),revS.end());

    if(revS != S)
        fla = false;

    for(int i = 0;i < (N -1)/2;i++){
        if(i == (N -1)/2 - 1){
            partS += S.at(i);
            revS = partS;
            reverse(revS.begin(),revS.end());
            if(partS != revS)
                fla = false;
        }
        partS += S.at(i);

    }

    for(int i = (N+3)/2 -1;i < N;i++){
        if(i == N - 1){
            partS2 += S.at(i);
            revS = partS2;
            reverse(revS.begin(),revS.end());
            if(partS2 != revS)
                fla = false;
        }
        partS2 += S.at(i);

    }

    if(fla)
        cout << "Yes" << endl;
    else
    {
        cout << "No" << endl;
    }
    



    

}

Measured memory_bytes: 3608
#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
using ll = long long;
int dd[] = { 0, 1, 0, -1, 0 }; //→↓←↑

using pi = pair<int, int>;
using ball = pair<pair<int, int>, int>;


void solve()
{
	int N; cin >> N;
	vector<ball> A(2 * N);
	for (int i = 0; i < 2 * N; i++)
	{
		int x, y;
		cin >> x >> y;
		A[i] = ball(pi(x, y), (i < N));
	}

	sort(A.begin(), A.end());
	set<int> S;

	int ans = 0;
	for (int i = 0; i < 2 * N; i++)
	{
		if (A[i].second) //赤玉
		{
			S.emplace(A[i].first.second);
		}
		else //青玉
		{
			auto id = S.lower_bound(A[i].first.second);
			if (id != S.begin())
			{
				ans++;
				S.erase(--id);
			}
		}
	}
	cout << ans << endl;

}

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

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i=0;i<N;i++) {
            A[i] = sc.nextInt();
        }

        long ans = A[0]-1;
        int max = 2;
        for (int i=1;i<N;i++) {
            if (A[i]==max) max++;
            else if (A[i]>max) {
                ans+=(A[i]-1)/max;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 52056
#include <cstdio>
using namespace std;

int parent(int x) { return x / 2; }
int left(int x) { return x * 2; }
int right(int x) { return (x * 2) + 1; }

int A[600];

int main()
{
	int n;
	scanf("%d", &n);

	for (int i = 1; i <= n; i++)
		scanf("%d", &A[i]);

	for (int i = 1; i <= n; i++) {
		printf("node %d: ", i);
		printf("key = %d, ", A[i]);
		if (parent(i) >= 1) printf("parent key = %d, ", A[parent(i)]);
		if (left(i) <= n) printf("left key = %d, ", A[left(i)]);
		if (right(i) <= n) printf("right key = %d, ", A[right(i)]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1028
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;

int main(void){
	int w, h, n, x[1000], y[1000], i, res=0;
	scanf("%d%d%d", &w, &h, &n);
	for(i=0; i<n; ++i){ scanf("%d%d", x+i, y+i); }
	for(i=1; i<n; ++i){ 
		if(((x[i-1]<=x[i])&&(y[i-1]<=y[i]))||((x[i-1]>=x[i])&&(y[i-1]>=y[i]))){ res+=max(abs(x[i-1]-x[i]), abs(y[i-1]-y[i])); }
		else{ res+=abs(x[i-1]-x[i])+abs(y[i-1]-y[i]); }
	}
	printf("%d\n", res);
	return(0);
}


Measured memory_bytes: 2768
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main()
{
    int n;
    cin >> n;
    ll a[100002], b[100002];
    P p[100002];
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
        p[i] = P(a[i] + b[i], a[i]);
    }
    sort(p, p + n, greater<P>());
    ll t = 0, s = 0;
    for(int i = 0; i < n; i++){
        if(i % 2) s += p[i].first - p[i].second;
        else t += p[i].second;
    }
    cout << t - s << endl;
}

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

#define x first
#define y second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pr pair<int,int>
#define Rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define For(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define debug(x) {cout<<(#x)<<" "<<x<<endl;}

using namespace std;
typedef long long ll;

const int N=40,INF=9999999;
const ll P=1e9+9;

template<typename T>
inline void read(T& x,char s=getchar()) {
	x=0;
	while(s>'9'||s<'0') s=getchar();
	while(s<='9'&&s>='0') x=x*10+s-'0',s=getchar();
}

inline ll _pow(ll a,ll b,ll r=1) {
	while(b) {
		if(b&1) (r*=a)%=P;
		(a*=a)%=P;
		b>>=1;
	}
	return r;
}

vector<pr> a,b;
map<int,int> ma;
int cnt;
int c[N];
int fa[N];
ll js[3000005];
ll fq[3000005];

inline int find(int x) {
	return x==fa[x]?x:fa[x]=find(fa[x]);
}

inline void unionn(int x,int y) {
	int fx=find(x);
	int fy=find(y);
	if(fx!=fy) fa[fy]=fx;
}

int main() {
	int n,m,x,y,t;
	ll ans=0;
	cin>>n>>m;
	js[0]=fq[0]=1;
	for(int i=1;i<=3*n;i++) {
		js[i]=js[i-1]*i%P;
		if(i%3==0) {
			fq[i]=fq[i-3]*i*2%P; 
			//if(i<=10) cout<<fq[i]<<" ";
		}
	}
	
	for(int i=1;i<=m;i++) {
		cin>>x>>y>>t;
		if(ma.count(x)) x=ma[x];
		else ma[x]=++cnt,x=cnt;
		if(ma.count(y)) y=ma[y];
		else ma[y]=++cnt,y=cnt;
		
		if(t==0) {
			a.pb(mp(x,y));
		}
		else {
			b.pb(mp(x,y));
		}
	}
	for(int j=0;j<(1<<b.size());j++) {
		ll num=0;
		for(int i=1;i<=cnt;i++) fa[i]=i;
		for(int i=0;i<a.size();i++) {
			unionn(a[i].x,a[i].y);
		}
		for(int i=0;i<b.size();i++) {
			if(j&(1<<i)) {
				num++;
				unionn(b[i].x,b[i].y);
			}
		}
//		cout<<"num: "<<j<<" "<<num<<endl;
		num=num&1?-1:1;
		
//		cout<<num<<": ";
		memset(c,0,sizeof(c));
		for(int i=1;i<=cnt;i++) {
			c[find(i)]++;
		}
		int _n=n;
		int qindian=0;
		ll tot=1;
		for(int i=1;i<=cnt;i++) {
//			cout<<c[i]<<" ";
			if(c[i]>3) {
				tot=0;
//				cout<<endl;
				break;
			}
			if(c[i]==3) _n--;
			if(c[i]==2) qindian++;
		}
//		cout<<endl;
		
		if(tot==0) continue;
		
//		ll test=_pow(6,P-2)*6%P;
//		cout<<"-==>"<<test<<endl;
		
		tot=js[_n*3-qindian*2]*_pow(js[_n*3-qindian*3],P-2)%P;
//		cout<<"-->"<<_n*3-qindian*2<<" "<<_n*3-qindian*3<<endl;
//		cout<<"-->"<<js[_n*3-qindian*2]<<" "<<js[_n*3-qindian*3]<<endl;
//		cout<<"-->"<<tot<<endl;
		_n-=qindian;
//		cout<<"__n: "<<_n<<endl;
		tot=tot*js[_n*3]%P*_pow(fq[_n*3],P-2)%P;
//		cout<<"-->"<<tot<<endl;
		ans=(ans+P+num*tot)%P;
	}
	cout<<ans<<endl;
	return 0;
}
/*
2 3
1 2 0
3 5 0
3 4 1

2 2
1 2 0
3 4 1

10003 2
1 2 0
3 4 1
*/

Measured memory_bytes: 49836
/*------U Have To DO It------*/
/* BY-> RicoProg */
/*        ___ 
           __|__|
          |  |___       */
#include <bits/stdc++.h>
using namespace std;
 
 
//---------------------------------------------------MACROS----------------------------------------------------------
#define ll long long
#define ld long double
#define beg(i ,n) for(ll i=0;i<n;i++)
#define beg1(i ,n) for(ll i=1;i<n;i++)
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back 
#define mp make_pair
#define nl "\n" 
#define vec(v , n) vector<ll> v(n)
#define all(x) x.begin() , x.end()
#define pii pair<int , int>
#define pll pair<ll , ll>
#define mii map<int , int>
#define mll map<ll , ll>
#define msi map<string , int>
#define mci map<char , int>
#define f1 first
#define f2 second

//---------------------------------------------------GLOBAL----------------------------------------------------------
const ll MOD = 1e9 + 7 ;
const ll MAX = 1e5 + 7 ;
const ll inf = 1e18 + 5 ;

//---------------------------------------------------FUNCTIONS-------------------------------------------------------

const ll nax = 2e3 + 5 ;
ll n , k ;

void add_self(ll &a , ll b){
	a+=b ;
	if(a>MOD) a-=MOD ;
}

ll mul(ll a , ll b){
	return a * b % MOD ;
}

struct M{
	vector<vector<ll> > mat ;
	M(){
		mat.resize(n , vector<ll>(n)) ;
	}
	M operator* (const M& m1){
		M pro = M() ;
		for(int i=0 ; i<n ; i++){
			for(int j=0 ; j<n ; j++){
				for(int k=0 ; k<n ; ++k){
					add_self(pro.mat[i][k] , mul(mat[i][j] , m1.mat[j][k])) ;
				}
			}
		}
		return pro ;
	}
};

void solve(){
	scanf("%lld %lld" , &n , &k) ;
	vector<vector<ll> > gr(n , vector<ll>(n));
	beg(i , n){
		beg(j , n) scanf("%lld" , &gr[i][j]) ;
	}
	M ini = M() ;
	ini.mat = gr ;
	M id = M() ;
	beg(i , n) id.mat[i][i] = 1 ;
	while(k>0){
		if(k&1){
			id = id * ini ;
		}
		k/=2 ;
		ini=ini*ini ;
	}
	ll ans=0 ;
	beg(i , n){
		beg(j , n){
			add_self(ans , id.mat[i][j]) ;
		}
	}
	printf("%lld" , ans) ;
}

//---------------------------------------------------DRIVER----------------------------------------------------------
int main()
{
    fast ;
    int t=1 ;
    //scanf("%lld" , &t) ;
    while(t--){
        solve() ;
        //cout << "A" << nl ;
    }
    return 0;
}   

Measured memory_bytes: 384
import numpy as numpy
n, m, x = map(int, input().split())
books = [list(map(int, input().split())) for i in range(n)]
ans = float('inf')
for i in range(2 ** n):
    cost = 0
    exp = numpy.array([0] * m)
    for j, b in enumerate(books):
        if i >> j & 1:
            continue
        cost += b[0]
        exp = exp + numpy.array(b[1:])
    if (exp < x).any():
        continue
    ans = min(cost, ans)
if ans == float('inf'):
    ans = -1
print(ans)


Measured memory_bytes: 27352
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        int ans = 0;

        if (a >= k) {
                ans = k;
            } else {
                ans += a;
                k -= a;
                if (b >= k) {
                    k = 0;
                } else {
                    k -= b;
                    ans -= k;
                    }
            }
        System.out.println(ans);
        }
}



Measured memory_bytes: 35444
num = int(input())
res = 0
if 400 <= num <= 599:
    res = 8
if 600 <= num <= 799:
    res = 7
if 800 <= num <= 999:
    res = 6
if 1000 <= num <= 1199:
    res = 5
if 1200 <= num <= 1399:
    res = 4
if 1400 <= num <= 1599:
    res = 3
if 1600 <= num <= 1799:
    res = 2
if 1800 <= num <= 1999:
    res = 1
print(res)

Measured memory_bytes: 9224
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int a, b;
    cin >> a >> b;
    if(a%2 != b%2) {
        puts("IMPOSSIBLE");
        return 0;
    }
    cout << (a+b)/2 << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define int long long

void solve() {
	int n, k; cin >> n >> k;
	int a[2020];
	rep(i, n) {
		cin >> a[i];
	}
	int cnt = 0;
	int cnt2 = 0;
	rep(i, n) {
		for(int j = i + 1; j < n; j++) {
			if(a[i] > a[j]) cnt ++;
			if(a[i] < a[j]) cnt2 ++;
		}
	}
	cnt %= mod;
	cnt2 %= mod;
	int ans = cnt * (k + (k * (k - 1) / 2) % mod) % mod;
	ans += (cnt2 * ((k * (k - 1) / 2) % mod) % mod);
	ans %= mod;
	cout <<  ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	getLine
	as <- readIntegers
	let
		l = foldl1 lcm as
	print $ foldl1 ( \a b -> ( a + b ) `mod` 1000000007 ) $ map ( l `div` ) as

Measured memory_bytes: 3580
def abc096_c():
    import numpy as np
    h, w = map(int, input().split())
    c = np.zeros([h + 2, w + 2], dtype=int)
    for i in range(h):
        row = "." + input() + "."
        for j in range(w + 2):
            c[i + 1][j] = [0, 1][row[j] == "#"]

    for i in range(1, h + 2):
        for j in range(1, w + 2):
            if c[i][j] == 1 and (np.sum([c[i - 1][j], c[i + 1][j], c[i][j - 1], c[i][j + 1]]) == 0):
                return "No"

    return "Yes"


print(abc096_c())

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

int main(){

  int t,n;
  for(int i=0;i<4;i++){
    cin >> t >> n;
    
    if(t==1){
      cout <<6000*n << endl;
    }
    if(t==2){
      cout << 4000*n << endl;
    }
    if(t==3){
      cout << 3000*n << endl;
    }
    if(t==4){
      cout << 2000*n << endl;
    }
    
  } 
  return 0;
}

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

set<int> G[100100];
int ans[100100];

int main(){
    int N; cin >> N;
    for(int i=0; i<N-1; i++){
        int a, b;
        cin >> a >> b;
        G[a].insert(b);
        G[b].insert(a);
    }
    priority_queue<int,vector<int>,greater<int> > pque, p1que;
    for(int i=0; i<N; i++){
        int c; cin >> c; pque.push(c); p1que.push(c);
    }
    long long M=0;
    for(int i=0; i<N-1; i++){
        int c = p1que.top(); M+=c; p1que.pop();
    }

    queue<int> que;
    for(int i=1; i<=N; i++){
        if(G[i].size()==1) que.push(i);
    }
    while(!que.empty()){
        int v = que.front(); que.pop();
        ans[v] = pque.top(); pque.pop();
        int u = *G[v].begin();
        G[v].erase(u);
        G[u].erase(v);
        if(G[u].size()==1) que.push(u);
    }
    
    cout << M << endl;
    for(int i=1; i<N; i++){
        cout << ans[i] << " ";
    }
    cout << ans[N];
    cout << endl;
}

Measured memory_bytes: 6144
#include <stdio.h>
#include <math.h>
#include <time.h>
#include<stdlib.h>
#include<string.h>

int main(void) {
    int a[5], loss = 0, ans = 0, i;

    scanf("%d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &a[4]);

    for (i = 0; i < 5; i++) {
        if (a[i] % 10 == 0) {
            ans += a[i];
            continue;
        }
        if (loss < 10 - a[i] % 10) {
            loss = 10 - a[i] % 10;
        }
        ans += (a[i] / 10) * 10 + 10;
    }
    ans -= loss;
    printf("%d", ans);
    return 0;
}

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

using namespace std;
typedef long long ll;

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

int main(int argc, char const *argv[])
{
    ll x, y;
    cin >> x >> y;
    ll res = 0;
    while (true)
    {
        if (x <= y)
        {
            res++;
            x *= 2;
        }
        else
        {
            break;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;
typedef long long int LL;
typedef pair<double,double> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

int n,m;
char ca[70][20];
int data[70][20];
double bottom[200][2];
double g[200];
vector<int> path[200];
int place[200][4][2];

void check2(int x,int y,int t,char c){
	if(x<0 || n<=x || y<0 || m<=y)return;
	if(data[y][x]!=-1 || ca[y][x]!=c)return;
	data[y][x]=t;
	int i;
	for(i=0;place[t][i][0]!=-1;i++);
	place[t][i][0]=x,place[t][i][1]=y;
	check2(x-1,y,t,c),check2(x+1,y,t,c);
	check2(x,y-1,t,c),check2(x,y+1,t,c);
}

int check(int x,int y,int t){
	check2(x,y,t,ca[y][x]);
	int p,q,r;
	r=t+1;
	for(int i=0;i<4;i++){
		p=place[t][i][0],q=place[t][i][1];
		if(q==m-1 || ca[q+1][p]=='.' || ca[q+1][p]==ca[y][x] || data[q+1][p]!=-1)continue;
		path[t].push_back(r);
		r=check(p,q+1,r);
	}
	return r;
}

P check3(int t){
	P pa,pb;
	pa=make_pair(g[t],1);
	for(int i=0;i<path[t].size();i++){
		pb=check3(path[t][i]);
		if(pb.second<0)return pb;
		pa.first=(pa.first*pa.second+pb.first*pb.second)/(pa.second+pb.second);
		pa.second+=pb.second;
	}
	if(pa.first<=bottom[t][0] || bottom[t][1]<=pa.first)pa=make_pair(0,-1);
	return pa;
}

int main(){
	int i,j,k;
	int a,b,c;
	int p;
	while(cin>>n>>m){
		if(n==0)break;
		for(i=m-1;i>=0;i--){
			cin>>ca[i];
		}
		for(i=0;i<200;i++)path[i].clear();
		memset(place,-1,sizeof(place));
		memset(data,-1,sizeof(data));
		memset(g,0,sizeof(g));
		for(i=0;ca[0][i]=='.';i++);
		p=check(i,0,0);
		for(i=0;i<p;i++){
			bottom[i][0]=100,bottom[i][1]=0;
			for(j=0;j<4;j++){
				a=place[i][j][0],b=place[i][j][1];
				g[i]+=a;
				if(b==0 || (ca[b-1][a]!=ca[b][a] && ca[b-1][a]!='.')){
					bottom[i][0]=min(bottom[i][0],(double)a);
					bottom[i][1]=max(bottom[i][1],(double)a+1);
				}
			}
			g[i]=g[i]/4.0+0.5;
		}
		P pa=check3(0);
		if(pa.second<0)cout<<"UNSTABLE"<<endl;
		else cout<<"STABLE"<<endl;
	}
}



Measured memory_bytes: 3076
#include <iostream>
#include <map>

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

int main()
{
	int h, w;
	map<P, int> d;

	for(int i=1; i<151; i++){
			for(int j=i+1; j<151; j++){
				d[P(i*i+j*j,i)] = j;
			}
	}

	while(cin >> h >> w){
		if(h==0 && w==0){return 0;}
		map<P, int>::iterator ite = d.find(P(h*h+w*w,h));
		ite++;
		cout << ((*ite).first).second << " " << (*ite).second << endl;
	}
}

Measured memory_bytes: 1892
#include<iostream>
#include<map>
#include<algorithm>

using namespace std;
int n,m,a;

void solve() {
    int ary[1003];
    for(int i=0;i<=n;i++) ary[i]=i;
    pair<int,pair<int,int> > amida[1003];
    for(int i=0;i<m;i++) {
        int h,p,q;
        cin>>h>>p>>q;
        amida[i]=(make_pair(h,pair<int,int>(p,q)));
    }

    sort(amida,amida+m);
    for(int i=0;i<m;i++) {
        swap(ary[amida[i].second.first],ary[amida[i].second.second]);
    }
    cout<<ary[a]<<endl;



}

int main() {
    while(cin>>n>>m>>a) {
        if(n+m+a==0) return 0;
        solve();
    }

    return 0;
}

Measured memory_bytes: 1180
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long llint;

llint a, b, sol;

int main() {
  scanf("%lld%lld", &a, &b);
  sol += a;
  a -= b;
  while (a > 0 && b > 0) {
    if (b > a) swap(a, b);
    if (a % b != 0) {
      sol += 2 * (a / b) * b;
    } else {
      sol += 2 * ((a-1) / b) * b;
      sol += b;
    }
    a %= b;
  }
  printf("%lld\n", sol);
  return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main() {
	int x,y,p[4]={0,300000,200000,100000},tot=0;
	cin>>x>>y;
	if(x<=3) tot+=p[x];
	if(y<=3) tot+=p[y];
	if(x==1&&y==1) tot+=400000;
	cout<<tot<<endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    n, m, k = list(map(int, input().split()))
    for i in range(n + 1):
        for j in range(m + 1):
            if (n * j + m * i) - 2 * i * j == k:
                print('Yes')
                exit()
    print('No')


if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> llVEC;
typedef vector<P> PVEC;
typedef priority_queue<P,PVEC,greater<P> > PPQ;
typedef priority_queue<ll, llVEC, greater<ll> > llPQ;

#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n-1; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue;
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

template<typename T>
ll sz(vector<T> &vec){ return (ll)vec.size(); }
ll sz(string &s){ return (ll)s.size(); }
ll gcd(ll a,ll b){ return ((!b) ?a :gcd(b, a%b)); }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b; }

int main(){
    ll t,n,m,a,b;
    cin >> t;

    rep(i,0,t){
        cin >> n >> m >> a >> b;
        cout << floor_sum(n,m,a,b) << endl;
    }
    return 0;
}


Measured memory_bytes: 3636
local n=io.read("n")
local a={}
for i=1,n do
    a[i]=io.read("n")
end

local mod=1000000007
local total=0
local two=1
for i=0,59 do
    local odd,even=0,0
    for j=1,n do
        if a[j]&(1<<i)>0 then
            odd=odd+1
        else
            even=even+1
        end
    end
    local add=(odd*even)%mod*two%mod
    total=(total+add)%mod
    two=(two*2)%mod
end
print(total)

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

int main()
{
    int n;
    // scanf("%d", &x);
    cin >> n;
    string s;
    cin >> s;
    long r = 0;
    long g = 0;
    long b = 0;
    rep(i, n)
    {
        // cout << i << s[i] << endl;
        if (s[i] == 'R')
        {
            r++;
        }
        else if (s[i] == 'G')
        {
            g++;
        }
        else
        {
            b++;
        }
    }
    long ans = r * g * b;
    rep(i, n)
    {
        for (int j = 1; i + 2 * j < n; ++j)
        {
            int i2 = i + j;
            int i3 = i + 2 * j;
            // cout << i << s[i] << i2 << s[i2] << i3 << s[i3] << endl;
            if (s[i] != s[i2] && s[i] != s[i3] && s[i2] != s[i3])
            {
                ans--;
            }
        }
    }
    cout << ans << endl;
    // printf("%d\n", x * x * x);
    // cout << x * x * x << endl;
}

Measured memory_bytes: 3628
def Int():
    return int(input())
def Ints():
    return map(int,input().split())
def IntList():
    return list(Ints())
def IntMat(N):
    return [IntList() for i in range(N)]

import sys

N,A,B,C = Ints()
            
QList = []
for i in range(N-1):
    QList.append(input())
QList.append(input())
#print(QList)
#print(QList[0]=='AB')
    
Ans = []
Wh = 1
now = 0

while now < N:
    q = QList[now]
    #print(A,B,C)
    if not (A>=0 and B>= 0 and C>=0):
        Wh = 0
        break
    if q=='AB':
        if A==0 and B==0:
            print('No')
            sys.exit()
        elif A==1 and B==1:
            if now==N-1:
                Ans.append('A')
                A += 1
                B -= 1
            else:
                nexq = QList[now+1]
                if nexq==q:
                    Ans.append('A')
                    A += 1
                    B -= 1
                elif nexq == 'AC':
                    Ans.append('A')
                    A += 1
                    B -= 1
                elif nexq == 'BC':
                    Ans.append('B')
                    B += 1
                    A -= 1
        else:
            if A<B:
                Ans.append('A')
                A += 1
                B -= 1
            else:
                Ans.append('B')
                B += 1
                A -= 1
    if q=='AC':
        if A==0 and C==0:
            print('No')
            sys.exit()
        elif A==1 and C==1:
            if now==N-1:
                Ans.append('A')
                A += 1
                C -= 1
            else:
                nexq = QList[now+1]
                if nexq==q:
                    Ans.append('A')
                    A += 1
                    C -= 1
                elif nexq == 'BC':
                    Ans.append('C')
                    C += 1
                    A -= 1
                elif nexq == 'AB':
                    Ans.append('A')
                    A += 1
                    C -= 1
        else:
            if A<C:
                Ans.append('A')
                A += 1
                C -= 1
            else:
                Ans.append('C')
                C += 1
                A -= 1
    if q=='BC':
        if B==0 and C==0:
            print('No')
            sys.exit()
        elif B==1 and C==1:
            if now==N-1:
                Ans.append('B')
                B += 1
                C -= 1
            else:
                nexq = QList[now+1]
                if nexq==q:
                    Ans.append('B')
                    B += 1
                    C -= 1
                elif nexq == 'AC':
                    Ans.append('C')
                    C += 1
                    B -= 1
                elif nexq == 'AB':
                    Ans.append('B')
                    B += 1
                    C -= 1
        else:
            if B<C:
                Ans.append('B')
                B += 1
                C -= 1
            else:
                Ans.append('C')
                C += 1
                B -= 1
    now += 1
                
if Wh==0:
    print('No')
else:
    print('Yes')
    for i in Ans:
        print(i)

Measured memory_bytes: 85808
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"

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

    vector<int> a(N);
    for (int i = 0; i < N; ++i) {
        if (S[i] == 'R') a[i] = 0;
        if (S[i] == 'G') a[i] = 1;
        if (S[i] == 'B') a[i] = 2;
    }
    vector<ll> cnt(3);
    for (int i = 0; i < N; ++i) {
        cnt[a[i]]++;
    }
    ll ans = 1;
    for (int i = 0; i < 3; ++i) {
        ans *= cnt[i];
    }
    for (int j = 0; j < N; ++j) {
        for (int i = 0; i < j; ++i) {
            int k = j + (j - i);
            if (k < N) {
                if (a[i] == a[j]) continue;
                if (a[i] == a[k]) continue;
                if (a[j] == a[k]) continue;
                ans--;
            }
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <stack>
using namespace std;
int to_i(string s){
    int res=0;
    for(int i=0;i<s.size();i++){
        res*=10;
        res+=s[i]-'0';
    }
    return res;
}
int main(){
    stack<int> v;
    int ans,a,b;
    string c;
    while(cin>>c){
        if(c=="+"||c=="-"||c=="*"){
            b=v.top();v.pop();
            a=v.top();v.pop();
            if(c=="+"){
                ans=a+b;
                v.push(a+b);
            }else if(c=="-"){
                ans=a-b;
                v.push(a-b);
            }else{
                ans=a*b;
                v.push(a*b);
            }
        }else{
            v.push(to_i(c));
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3156
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <list>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i,m,n) for (int i = (int) (m); i < (int) (n); i++)
#define rep1(i,m,n) for (int i = (int) (m); i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
int main(void){
    int N,sum=0,i;
    string S;
    cin>>N;
    cin>>S;
    rep(i,0,S.size()-2){
        if(S.at(i)=='A' && S.at(i+1)=='B' && S.at(i+2)=='C'){
            i+=2;
            sum++;
        }
    }
    cout<<sum<<endl;
}

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

int main()
{
	int value,value_2;
	
	while(cin >> value >> value_2)
	{
		int count = 1;
		int sum = value + value_2;
		while(sum / 10 != 0)
		{
			sum /= 10;
			count++;
		}

		cout << count << endl;
		count == 0;
	}
	return 0;
}

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

using namespace std;
int gcd(int x, int y)
{
	return x%y == 0 ? y : gcd(y, x%y);
}
int main()
{
	int n, x;
	int ans = 1;
	int a[100010];
	cin >> n >> x;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	a[n] = x;
	sort(a, a + n + 1);
	for (int i = 0; i < n; i++)
	{
		if (i == 0)
			ans = a[i + 1] - a[i];
		else
			ans = gcd(ans, a[i + 1] - a[i]);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 640
N=int(input())
p=[float(i) for i in input().split()]
dp=[[0]*(N+1) for i in range(N+1)]
dp[0][0]=1
for i in range(N):
  dp[i+1][0]=dp[i][0]*(1-p[i])
  for j in range(i+1):
    dp[i+1][j+1]=dp[i][j]*p[i]+dp[i][j+1]*(1-p[i])
print(sum(dp[N][N//2+1:]))

    

Measured memory_bytes: 263048
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;

int main(){
  ll x;
  cin >> x;
  ll y = x/11;
  ll z = x%11;
  if(z <= 6 && z != 0){
    cout << 2*y+1 << endl;
  }
  else if(z == 0)
    cout << 2*y << endl;
  else if(z > 6)
    cout << 2*(y+1) << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,M; cin >> N >> M;
    vector<vector<int>> G(M);
    rep(i,M) {
        int k; cin >> k;
        rep(j,k) {
            int s; cin >> s;
            --s;
            G[i].emplace_back(s);
        }
    }
    vector<int> p(M);
    rep(i,M) cin >> p[i];

    int ans = 0;
    rep(mask,1<<N) {
        bool ok = true;
        rep(i,M) {
            int cnt = 0;
            for (auto j : G[i]) {
                if (mask&(1<<j)) cnt++;
            }
            if (cnt%2!=p[i]) ok = false;
        }
        if (ok) ans++;
    }

    cout << ans << ln;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int N;
  cin>>N;
  
  vector<string> S(N);
  for(int i=0;i<N;i++){
    cin>>S[i];
  }
  
  
  int x1=0;
  int x2=0;
  int x3=0;
  int x4=0;
  
  for(int i=0;i<N;i++){
    if(S[i]=="AC"){
      x1++;
    }
    else if(S[i]=="WA"){
      x2++;
    }
    else if(S[i]=="TLE"){
      x3++;
    }
    else{
      x4++;
    }
  }
  
  cout<<"AC"<<" "<<"x"<<" "<<x1<<endl;
  cout<<"WA"<<" "<<"x"<<" "<<x2<<endl;
  cout<<"TLE"<<" "<<"x"<<" "<<x3<<endl;
  cout<<"RE"<<" "<<"x"<<" "<<x4<<endl;
}

Measured memory_bytes: 6420
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#pragma GCC optimize("Os")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt","r",stdin);
    //     freopen("output.txt","w",stdout);
    // #endif
}
int main()
{
    vok();
    ll n;
    IN n;
    ll nn=n;
    ll ans=0;
    set<ll> pq;
    ll countt=1;
    while(n%2==0)
    {
        pq.insert(P(2LL,countt,(ll)4e18));
        countt++;
        n/=2;
    }
    for(ll i=3; i<=sqrt(n); i++)
    {
        if(n%i==0)
        {
            ll countt=1;
            while(n%i==0)
            {
                pq.insert(P(i,countt,(ll)4e18));
                countt++;
                n/=i;
            }
        }
    }
    if(n>1LL)
    {
        pq.insert(n);
    }
    n=nn;
    auto it=pq.begin();
    while(it!=pq.end())
    {
        if(n<(*it))
        {
            break;
        }
        if(n%(*it)==0)
        {
            n/=(*it);
            ans++;
        }
        it++;
    }
    OUT ans<<endl
    return 0;
}

Measured memory_bytes: 3680
def main():
    N = int(input())
    ans = []
    for i in range(N):
        s = input()
        if s[0] in ["M", "A", "R", "C", "H"]:
            ans.append(s[0])
    from collections import Counter
    c = Counter(ans)
    ret = 1
    sumS = sum(int(c[s] > 0) for s in ["M", "A", "R", "C", "H"])
    accS = sum(c[s] for s in ["M", "A", "R", "C", "H"])
    if sumS >= 3:
        ret = accS*(accS-1)*(accS-2)//2//3
        for s in ["M", "A", "R", "C", "H"]:
            if c[s] == 2:
                ret -= (accS - c[s])
            elif c[s] >= 3:
                ret -= (c[s]*(c[s]-1)*(c[s]-2)//2//3) + \
                    ((c[s]-1)*(c[s])//2)*(accS - c[s])
    else:
        ret = 0
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 54616