akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int N, MOD = 998244353, cnt;
long BIT[200020], s[4][200020];
long pow2[200020];
vector<pair<int,int>> p;

// 集合すべて(2^n-1)　に対して　集合の中の個数　をもとめる。
// その個数は　それが含まれる集合分足される。
// ｎ個の座標について、それが含まれる集合を数えればよい。
// 自分より大きい、小さいx座標の点, y座標の点の数(4種類)を全ての点に対して数える。

void add(int i) {
    for(;i <= N; i += i & -i) BIT[i] += 1;
}

int sum(int i) {
    int ret = 0;
    for(;i > 0; i -= i & -i) ret += BIT[i];
    return ret;
}

int main() {
    cin >> N;
    p.resize(N);
    for(int i = 0; i < N; ++i) cin >> p[i].first >> p[i].second;
    map<int,int> x, y;

    // 座圧
    cnt = 0;
    for(int i = 0; i < N; ++i) x[p[i].first] = 0;
    for(auto itr = x.begin(); itr != x.end(); ++itr) itr->second = ++cnt;
    for(int i = 0; i < N; ++i) p[i].first = x[p[i].first];

    cnt = 0;
    for(int i = 0; i < N; ++i) y[p[i].second] = 0;
    for(auto itr = y.begin(); itr != y.end(); ++itr) itr->second = ++cnt;
    for(int i = 0; i < N; ++i) p[i].second = y[p[i].second];
    sort(p.begin(), p.end());
    
    // x座標　昇順
    // 今見てるのより(x, y) = (小　小)-s[0]　(小　大)-s[1]　（大　小）-s[2]　（大　大）-s[3]
    for(int i = 1; i <= N; ++i) BIT[i] = 0;
    for(int i = 0; i < N; ++i) {
        s[0][i] = sum(p[i].second);
        s[1][i] = i - s[0][i];
        add(p[i].second);
    }

    for(int i = 1; i <= N; ++i) BIT[i] = 0;
    for(int i = N-1; i >= 0; --i) {
        s[2][i] = sum(p[i].second);
        s[3][i] = (N-1-i) - s[2][i];
        add(p[i].second);
    }

    // calc 2^n
    pow2[0] = 1;
    for(int i = 1; i <= N; ++i) pow2[i] = pow2[i-1] * 2 % MOD;

    long ans = 0;
    for(int i = 0; i < N; ++i) {
        long tmp1[4], tmp2[4];
        for(int j = 0; j < 4; ++j) {
            tmp1[j] = pow2[s[j][i]]; // 位置jの点を選ぶか選ばないか未定
            tmp2[j] = tmp1[j] - 1; // 位置jの点を必ず選ぶ
        }
        ans = (ans + tmp2[0] * tmp1[1] % MOD * tmp1[2] % MOD * tmp2[3] % MOD) % MOD;
        ans = (ans + tmp1[0] * tmp2[1] % MOD * tmp2[2] % MOD * tmp1[3] % MOD) % MOD;
        ans = (ans - tmp2[0] * tmp2[1] % MOD * tmp2[2] % MOD * tmp2[3] % MOD + MOD) % MOD;
        ans = (ans + tmp1[0] * tmp1[1] % MOD * tmp1[2] % MOD * tmp1[3] % MOD) % MOD;
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 29952
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

//const long long MOD = 1000000007;
const long long MOD = 998244353;
const long long INF = 1LL << 60;



const long double PI = 3.14159265359;
const int MAX_N = 100010;

vector<bool> seen;
void dfs(const vector<VE> &G, int v) {
	seen[v] = true;
	for (auto next_v : G[v]) {
		if (seen[next_v]) continue;
		dfs(G, next_v); // 再帰的に探索
	}
}
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m; cin >> n >> m;
	VE x(m), y(m), z(m); rep(i, m)cin >> x[i] >> y[i] >> z[i];
	vector<VE> G(n);
	rep(i, m) {
		x[i]--; y[i]--;
		G[x[i]].push_back(y[i]);
		G[y[i]].push_back(x[i]);
	}
	int count = 0;
	seen.assign(n, false);
	for (int v = 0; v < n; ++v) {
		if (seen[v]) continue; // v が探索済みだったらスルー
		dfs(G, v); // v が未探索なら v を始点とした DFS を行う
		++count;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define PB push_back
#define ST first
#define ND second
#define _ ios_base::sync_with_stdio(0); cin.tie(0);
//mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

using namespace std;

using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;

int x,y;

int main() {
	cin >> x >> y;
	for(int i = 0; i <= x; ++i) {
		int w = i * 4 + (x - i) * 2;
		if(w == y) {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
}


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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 300007;
const int MOD = SC ( int, 1e9 + 7 );

int n;
char s[MAXN];
int dp[MAXN][4][3];

void init ();
void input ();
void work ();

int add ( int x, int y )
{
	x += y;
	if ( x >= MOD ) x -= MOD;
	return x;
}

void addv ( int &x, int y )
{
	x += y;
	if ( x >= MOD ) x -= MOD;
}



int main ()
{
	init ();
	input ();
	work ();
}



void init ()
{
	// Init Everything Here

	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method

	scanf ( "%s", s + 1 );
}

void work ()
{
	// main work

	n = strlen ( s + 1 );

	dp[0][0][0] = 1;
	int vj, vk;
	lpi ( i, 1, n ) {
		if ( s[i] == '0' || s[i] == '?' ) {
			lp ( j, 0, 4 ) {
				lp ( k, 0, 3 ) {
					vk = k + 1;
					if ( vk == 3 ) vk = 1;
					addv ( dp[i][j][vk], dp[i - 1][j][k] );
				}
			}
		}
		if ( s[i] == '1' || s[i] == '?' ) {
			lp ( j, 0, 4 ) {
				lp ( k, 0, 3 ) {
					vj = j, vk = k;
					if ( !k ) vj = qmin ( vj + 1, 3 );
					else --vk;
					addv ( dp[i][vj][vk], dp[i - 1][j][k] );
				}
			}
		}
	}

	int ans = 0;
	lp ( j, 0, 4 ) lp ( k, 0, j ) addv ( ans, dp[n][j][k] );
	cout << ans << endl;
}

Measured memory_bytes: 14592
from collections import defaultdict
from itertools import product

n = int(input())
if n < 3:
    print(0)
else:
    rt = int(n ** 0.5)
    factors = defaultdict(int)
    N = n
    n_div = 2
    while n > 1:
        if n_div == int(n ** 0.5) + 2:
            factors[n] += 1
            break
        while not n % n_div:
            factors[n_div] += 1
            n = n // n_div
        n_div += 1
    lis = [1]
    for k, v in factors.items():
        facts = [k ** i for i in range(v + 1)]
        it = product(lis, facts)
        lis = [a * b for a, b in it]
    nums = [l - 1 for l in lis if l - 1]
    nums = [i for i in nums if (N //i) == (N % i)]
    print(sum(nums))


Measured memory_bytes: 3948
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue


template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 50;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE a(n); rep(i, n)cin >> a[i];
	sort(ALL(a));
	vector<int> sums(n);
	int sum = 0;
	rep(i, n) {
		sum += a.at(i);
		sums.at(i) = sum;
	}
	reverse(ALL(sums));
	int ans = 1;
	rep(i, n - 1) {
		if (sums.at(i + 1) * 3 >= sums.at(i))ans++;
		else break;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
n = int(input())
ans = [0] * 10050

for x in range(1, 105):
    for y in range(1, 105):
        for z in range(1, 105):
            zzz = (x + y + z) ** 2 - x * y - y * z - x * z
            if zzz < 10050:
                ans[zzz] += 1

for i in range(n):
    print(ans[i+1])


Measured memory_bytes: 69044
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    T = list(input())
    for i in range(len(T)):
        if T[i] == '?':
            T[i] = 'D'
    print(''.join(T))
if __name__ == '__main__':
    main()

Measured memory_bytes: 10892
#include<iostream>
#include<string>
#include<algorithm>
#include<list>
#include<stack>
#include<map>
#include<queue>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)

int l;

int main()
{
    while(1)
    {
        string s;
        getline(cin,s);
        if(s == ".")break;

        l = s.size();
        stack<char> bra;
        
        bool ans = true;
        REP(l)
        {

            if(s[i] == '('){ bra.push('(');continue; }
            if(s[i] == '['){ bra.push('[');continue; }

            if(s[i] == ')')
            {
                if(bra.empty() || bra.top() != '('){ans = false; break;}
                bra.pop();
            }
            if(s[i] == ']')
            {
                if(bra.empty() || bra.top() != '['){ans = false; break;}
                bra.pop();
            }
        }
        if(!bra.empty()) ans = false;

        if(ans) cout<< "yes" << endl;
        else cout << "no" << endl;
    }
    return 0;
}

Measured memory_bytes: 904
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def main():
    N = int(input())
    A = li_input()

    M = round(sum(A) / len(A))

    ans = 0

    for a in A:
        ans += (a - M) ** 2

    print(ans)


main()


Measured memory_bytes: 4692
package main

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

func main() {
	N := nextInt()
	K := nextInt()
	S := nextString()
	var trans int
	for i := 1; i < N; i++ {
		if S[i] != S[i-1] {
			trans++
		}
	}
	trans = max(trans-2*K, 0)
	fmt.Println(N - 1 - trans)
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var inf = int(1e9)

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}

var nextReader func() string

func init() {
	nextReader = newScanner()
}

func newScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}


Measured memory_bytes: 1024
def patty_num(N):
    if N == 0:
        return 1
    return 1 + 2 * patty_num(N - 1)

def burger_height(N):
    if N == 0:
        return 1
    else:
        return 3 + 2 * burger_height(N - 1)
    
def f(N, X):
    if X == 1:
        if N == 0:
            return 1
        else:
            return 0
    elif 1 < X and X <= burger_height(N - 1) + 1:
        return f(N - 1, X - 1)
    elif X == burger_height(N - 1) + 2:
        return patty_num(N - 1) + 1
    elif burger_height(N - 1) + 2 < X and X <= 2 * burger_height(N - 1) + 2:
        return patty_num(N - 1) + 1 + f(N - 1, X - 2 - burger_height(N - 1))
    
    return 2 * patty_num(N - 1) + 1
    
N, X = map(int, input().split())
print(f(N, X))
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && ch != '-') ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int const MAXN = 1e5 + 5;
char s[10];
int vis[MAXN], cnt[MAXN];

int main() {
  
#ifdef LOCAL
  FILEIO("a");
#endif

  int n, m; cin >> n >> m;
  int ans1 = 0, ans2 = 0;
  for (RI i = 1; i <= m; ++i) {
    int num; cin >> num;
    cin >> s;
    if (s[0] == 'W')
      cnt[num] += !vis[num];
    else {
      ans1 += !vis[num];
      vis[num] = 1;
    }
  }
  for (RI i = 1; i <= n; ++i)
    if (vis[i]) ans2 += cnt[i];
  printf("%d %d\n", ans1, ans2);

  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <numeric>

int main()
{
    std::size_t K;
    std::cin >> K;

    std::size_t ans = 0;
    for(std::size_t a=1; a<=K; a++)
    for(std::size_t b=1; b<=K; b++)
    for(std::size_t c=1; c<=K; c++)
    {
        ans += std::gcd(std::gcd(a, b), c);
    }
    std::cout << ans << std::endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int n,a,b;
  cin >> n >> a >> b;
  cout << min(a,b) << ' ' << max(0,a+b-n) << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	char c[3][3];
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> c[i][j];
		}
	}
	cout << (char) c[0][0] << (char) c[1][1] << (char) c[2][2] << endl;
	return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc165/submissions/12600948
# 写経

def main():
    from collections import deque
    import sys
    sys.setrecursionlimit(10 ** 7)

    N, M, Q = map(int, input().split())

    abcd = []
    for _ in range(Q):
        a, b, c, d = map(int, input().split())
        abcd.append((a - 1, b - 1, c, d))

    A = deque([1])

    def rec():
        if len(A) == N:
            return sum(d for a, b, c, d in abcd if A[b] == A[a] + c)

        ret = 0
        for x in range(A[-1], M + 1):
            A.append(x)
            ret = max(ret, rec())
            A.pop()
        return ret

    print(rec())


if __name__ == '__main__':
    main()


Measured memory_bytes: 9476
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define ll long long
int on[15][15];
int n,m,p[20];
int res(int msk,int sw){
    if(sw>n){
        if(msk==(1<<m)-1){
            return 1;
        }
        return 0;
    }
    int mk=0;
    for(int i=1;i<=m;i++){
        if(on[i][sw]){
            mk|=(1<<i-1);
        }
    }
    int ch1=res(msk^mk,sw+1);
    int ch2=res(msk,sw+1);
    return ch1+ch2;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        int x;
        cin>>x;
        for(int j=0;j<x;j++){
            int a;
            cin>>a;
            on[i][a]=1;
        }
    }
    int mask=0;
    for(int i=0;i<m;i++){
        cin>>p[i];
        if(p[i]==0) {
            mask |= (1 << i);
        }
        p[i]++;
        p[i]%=2;
    }
    cout<<res(mask,1)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
    int n,i,j,k,l,a,b;
    while(cin>>n){
    //a=(n/4)+2;


    int s=0;
    for(i=0;i<10;i++){
        for(j=0;j<10;j++){
                for(k=0;k<10;k++){
                    for(l=0;l<10;l++){
                        if(i+j+k+l==n)s++;
                }
            }
        }
    }
    cout<<s<<endl;
    }



    return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>
#include<type_traits>

using namespace std;
using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;
constexpr ll LONGINF = 1050000000000000000;

int main() {
	int a, b; cin >> a >> b;

	cout << (a - 1)*(b - 1) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
long long int poo(int,int);
int main(){
	long long int a,b;
	cin>>a>>b;
	long long int c=b/a;
	for(int i=0;;i++){
		if(c<poo(2,i)){
			cout<<i<<endl;
			break;
		}
	}
}
long long int poo(int a,int b){
	long long int c=a;
	for(int i=1;i<b;i++){
		c*=a;
	}
	if(b==0){
		c=1;
	}
	return c;
}

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

struct UnionFind
{
  std::vector<int> p;
  std::vector<int> r;

  UnionFind(int n)
    : p(n, 0)
    , r(n, 0)
  {
    for (int i = 0; i < n; ++i)
    {
      p[i] = i;
    }
  }

  int root(int x)
  {
    if (x != p[x])
    {
      p[x] = root(p[x]);
    }
    return p[x];
  }

  void unite(int x, int y)
  {
    x = root(x);
    y = root(y);
    if (x == y) return;
    if (r[y] > r[x]) std::swap(x, y);
    else if (r[y] == r[x]) ++r[x];
    p[y] = x;
  }

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


int main()
{
  int n, q;
  std::cin >> n >> q;

  UnionFind uf(n);

  while (static_cast<bool>(q--))
  {
    int com, a, b;
    std::cin >> com >> a >> b;
    if (com == 0)
    {
      uf.unite(a, b);
    }
    else if (com == 1)
    {
      if (uf.same(a, b))
      {
        std::cout << 1 << std::endl;
      }
      else
      {
        std::cout << 0 << std::endl;
      }
    }
  }

  return 0;
}



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

// --------------------------------------------------------------------------------
#define FASTIO	ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long 
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define frepi(a,b) for(int i=a;i<=b;++i)
// --------------------------------------------------------------------------------

void solve_main()
{
 	int n;cin>>n;
 	string s;cin>>s;
 	int r = count(s.begin(),s.end(),'R');
 	int ans = 0;
 	frepi(0,r-1)if(s[i]=='W')ans++;
 	cout<<ans<<"\n";   
}

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("/home/suryakant/input.txt","r",stdin);
		freopen("/home/suryakant/output.txt","w",stdout);
	#endif
	
    int t=1;
    // cin>>t;
    while(t--)
    {
    	solve_main();
    }    
}

Measured memory_bytes: 3732
from itertools import combinations_with_replacement as comb_rplc

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

req = [list(map(int, input().split())) for _ in range(q)]

ans = 0

for seq in comb_rplc(range(1 , (m + 1)), n):
  score = 0
  
  for a, b, c, d in req:
    if seq[b - 1] - seq[a - 1] == c:
      score += d
  
  ans = max(ans, score)
  
print(ans)

Measured memory_bytes: 9088
def get_name(n, alphabet):
  if n // len(alphabet):
    return get_name(n // len(alphabet), alphabet) + alphabet[n % len(alphabet)]
  return alphabet[n % len(alphabet)]

N = int(input())
i = 0
alphabet = 'abcdefghijklmnopqrstuvwxyz'
while True:
  N -= len(alphabet) ** i
  if N < len(alphabet) ** (i + 1):
    name = get_name(N, alphabet)
    for j in range(i + 1 - len(name)):
      name = alphabet[0] + name
    break
  else:
    i += 1
    
print(name)

Measured memory_bytes: 9172
import java.io.PrintWriter
import java.util.*
import kotlin.math.pow

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun Int.pow(n: Int) = pow(n.toLong())
fun Int.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()
fun Long.pow(n: Int) = pow(n.toLong())
fun Long.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val s = next()
    val que = ArrayDeque<Char>()
    for (c in s) {
        when (c) {
            '0' -> que.addLast(c)
            '1' -> que.addLast(c)
            else -> if (que.isNotEmpty()) que.removeLast()
        }
    }
    println(que.joinToString(""))
}


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

const int INF = 1001001001;

int main()
{
    double n;
    cin >> n;
    ll lb = 0, ub = INF;
    while(ub - lb > 1){
        ll mid = (lb + ub)/2;
        if(int(mid*1.08) <= n) lb = mid;
        else ub = mid;
    }
    if(int(double(lb*1.08)) != n) cout << ":(" << endl;
    else cout << lb << endl;
    return 0;
}


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

// #define multitest 1
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
#define pc(...) PC(#__VA_ARGS__, __VA_ARGS__);
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.first << ", " << p.second << ']';
	return out;
}
template <typename Arg>
void PC(const char *name, Arg &&arg)
{
	std::cerr << name << " { ";
	for (const auto &v : arg)
		cerr << v << ' ';
	cerr << " }\n";
}
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#define pc(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;
auto TimeStart = chrono::steady_clock::now();

const int nax = 2e5 + 10;

void solve()
{
	int n;
	cin >> n;
	vector<int> v(n);
	for (int &x : v)
		cin >> x;
	auto u = v;
	sort(v.begin(), v.end());
	int cnt = 0;
	for (int i = 0; i < n; ++i)
		cnt += v[i] != u[i];
	if (cnt <= 2)
		cout << "YES\n";
	else
		cout << "NO\n";
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
#ifdef TIME
	cerr << "\n\nTime elapsed: " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " seconds.\n";
#endif
	return 0;
}

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

template<typename T>
T get_value(std::istream& is);

int getMinNum_recursive(int _nOriginal, const std::set<char>& _avoid)
{
	std::string org = std::to_string(_nOriginal);
	for (auto& c : org)
	{
		if (_avoid.find(c) != _avoid.end())
		{
			return getMinNum_recursive(_nOriginal + 1, _avoid);
		}
	}

	return _nOriginal;
}


int getMinNum_bsearch_recursive(int _nOriginal, const std::vector<char>& _avoid)
{
	std::string org = std::to_string(_nOriginal);
	for (auto& c : org)
	{
		if (std::binary_search(_avoid.cbegin(), _avoid.cend(), c))
		{
			return getMinNum_bsearch_recursive(_nOriginal + 1, _avoid);
		}
	}

	return _nOriginal;
}

int getMinNum_bsearch(int _nOriginal, const std::vector<char>& _avoid)
{
	for (int i = _nOriginal; i < 100000; i++)
	{
		std::string strNum = std::to_string(i);
		bool bFound = false;
		for (auto& c : strNum)
		{
			if (std::binary_search(_avoid.cbegin(), _avoid.cend(), c))
			{
				bFound = true;
				break;
			}
		}

		if (!bFound) return i;
	}

	return -1;
}



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

	int N, K;

	std::cin >> N >> K;
	std::vector<char> v(K);
	//std::set<char> s;

	for (auto& e : v) {
		std::cin >> e;
		//s.insert(e);
	}

	//int answer = getMinNum(N, s);
	//int answer = getMinNum_bsearch(N, v);
	int answer = getMinNum_bsearch(N, v);
	std::cout << answer << std::endl;

	return 0;
};


template<typename T>
inline T get_value(std::istream& is)
{
	T v;
	is >> v;
	return v;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define eb emplace_back
#define emp emplace
#define fi first
#define se second
#define INF 0x3f3f3f3f
typedef long long ll;
typedef pair<int, int> ii;

int main(void) {
	ios_base::sync_with_stdio(false);

	int a, b, c, x; cin >> a >> b >> c >> x;

	int ans = 0;
	for (int i = 0; i <= c; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= a; k++) {
				if (50*i+100*j+500*k == x) ans++;
			}
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N;
  string S;
  cin >> N >> S;
  char current = '_';
  long ans = 0;
  rep (i, N) {
    if (current != S[i]) ans++;
    current = S[i];
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    FASTINOUT;
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if (a>=k)
        cout<<k<<endl;
    else{
        if (k-a<=b){
            cout<<a<<endl;
        }
        else{
            cout<<a-(k-a-b)<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
template<typename T> inline void add(T& a, T b) { a += b; if (a >= MOD) a -= MOD; }

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

  string A,B,C; cin >> A >> B >> C;
  int ai = 0, bi = 0, ci = 0;
  char next = 'a';
  while(true) {
    if(next == 'a') {
      if(ai >= A.size()) {
        cout << 'A' << endl;
        return 0;
      } else {
        next = A[ai];
        ++ai;
      }
    } else if (next == 'b') {
      if(bi >= B.size()) {
        cout << 'B' << endl;
        return 0;
      } else {
        next = B[bi];
        ++bi;
      }
    } else {
      if(ci >= C.size()) {
        cout << 'C' << endl;
        return 0;
      } else {
        next = C[ci];
        ++ci;
      }
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll n, k;
    cin >> n >> k;
    vector<ll> trees(n);
    for (int i = 0; i < n; i++)
        cin >> trees[i];
        sort(trees.begin(),trees.end());
    ll ans = 1145141919810;
    for(int i = k - 1; i < n; i++){
        ans = min(ans,trees[i] - trees[i - k + 1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
int main(){
    cin.tie(0);
    cout.sync_with_stdio(false);
    ll x; cin>>x;
    vector<ll> dp(100000+300);
    dp[100] = 1;
    dp[101] = 1;
    dp[102] = 1;
    dp[103] = 1;
    dp[104] = 1;
    dp[105] = 1;
    int v[6] = {100, 101, 102, 103, 104, 105};
    int N = 100000;
    for(ll i=100; i<=x; i++){
        if(dp[i]){
            REP(j, 6){
                dp[i+v[j]] = 1;
            }
        }
    }
    if(dp[x]) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  
  if (s.at(2) == s.at(3) && s.at(4) == s.at(5)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

template<typename T>
T gcd(T x, T y)
{
	return y ? gcd(y, x % y) : x;
}

void hawawa()
{
	string str;
	cin >> str;
	cout << count(begin(str), end(str), '1') << "\n";
}

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


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

int main(void){
  int i, j,  n, d[50], sum=0;
  cin >> n;
  for (i=0; i<n; ++i) 
  	cin >> d[i];
  
  for (i=0; i<n; ++i){
    for (j=i; j<n; ++j){
      if (i == j)
        continue;
      sum += d[i] * d[j];
      //cout << sum << endl;
    }
  }
  cout << sum;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))
from fractions import gcd
from functools import reduce
def g(l):
  return reduce(gcd,l)
if max(a)<k:
  print('IMPOSSIBLE')
else:
  z=g(a)
  if k in a or k%z==0:
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')

Measured memory_bytes: 14224
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
struct MaxFlow{
    int V;
    struct edge{int to,cap,rev;};
    vector<vector<edge>> G;
    vector<int> used;
    
    MaxFlow(int V):V(V),G(V),used(V){}
    void add_edge(int from,int to,int cap){
        G[from].push_back({to,cap,(int)G[to].size()});
        G[to].push_back({from,0,(int)G[from].size()-1});
    }

    int dfs(int v,int t,int f){
        if(v==t)return f;
        used[v]=true;
        for(int i=0;i<G[v].size();i++){
            edge &e=G[v][i];
            if(!used[e.to]&&e.cap>0){
                int d=dfs(e.to,t,min(f,e.cap));
                if(d>0){
                    e.cap-=d;
                    G[e.to][e.rev].cap+=d;
                    return d;
                }
            }
        }
        return 0;
    }
    int solve(int s,int t){
        int flow=0;
        while(1){
            fill(used.begin(),used.end(),false);
            int f=dfs(s,t,INT_MAX);
            if(!f){
                return flow;
            }
            flow+=f;
        }
    }
};
signed main(){
    int h,w;
    cin>>h>>w;
    vector<string> vec(h);
    REP(i,h){
        cin>>vec[i];
    }
    MaxFlow G(h+w+2);
    REP(i,h){
        REP(j,w){
            if(vec[i][j]=='S'){
                G.add_edge(0,i+2,INF);
                G.add_edge(i+2,0,INF);
                G.add_edge(0,j+h+2,INF);
                G.add_edge(j+h+2,0,INF);
            }else if(vec[i][j]=='T'){
                G.add_edge(1,i+2,INF);
                G.add_edge(i+2,1,INF);
                G.add_edge(1,j+h+2,INF);
                G.add_edge(j+h+2,1,INF);
            }else if(vec[i][j]=='o'){
                G.add_edge(i+2,j+h+2,1);
                G.add_edge(j+h+2,i+2,1);
            }
        }
    }
    ll ans=G.solve(0,1);
    if(ans>=INF){
        cout<<-1<<endl;
        return 0;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <queue>

using namespace std;

long long N;
queue<long long> q;

int main(){
    cin >> N;
    q.push(3);
    q.push(5);
    q.push(7);
    int count = 0;
    while(!q.empty()){
        long long n = q.front();
        q.pop();
        if(n > N) continue;
        bool a,b,c;
        a = b = c = false;
        long long m = n;
        while(m != 0){
            if(m % 10 ==3) a = true;
            if(m % 10 ==5) b = true;
            if(m % 10 ==7) c = true;
            m /= 10;
        }
        if(a && b && c) count++;
        q.push(n * 10 + 3);
        q.push(n * 10 + 5);
        q.push(n * 10 + 7);
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define f(i,j,k) for(int i=j;i<k;i++)
#define f2(i,j,k) for(int i=j;i>=k;i--)
int main(){
    long long n,ans=0;
    cin>>n;
    long long nn=sqrt(n);
    for(long long i=2;i<=nn;i++){
    long long j=0,top=1;
    while(n%i==0){
                n/=i;
                j++;
                if(j>=top){
                    j=0;
                    top++;
                    ans++;
                }
            }
        }
        if(n!=1){
            ans++;
        }
        cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 3668
s = input()
n = len(s)
start_1 = [0] * n
start_0 = [0] * n

for i in range(n):
    if i % 2 == 0:
        start_1[i] = 1
    else:
        start_0[i] = 1
        
d1 = 0
d2 = 0

for i in range(n):
    x = int(s[i])
    
    if x != start_1[i]:
        d1 += 1
        
    if x != start_0[i]:
        d2 += 1
        
print(min(d1,d2))

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

using namespace std;


int main(){

  string str;
  string str2;
  int n,s,s2;
  int cou[1024][1024] = {{}};
  int max = 0;

  cin >> n;

  for(int i = 0;i < n;i++){

    cin >> str >> str2;

    str = ' ' + str;
    str2 = ' ' + str2;


    s = str.size();
    s2 = str2.size();

    for(int j = 1;j < s;j++){
      for(int k = 1;k < s2;k++){
	if(str[j] == str2[k]){
	  cou[j][k] = cou[j - 1][k - 1] + 1;
	  if(cou[j][k] > max) max = cou[j][k];
	  // cout << "a: str = " << str[j] << " str2 = " << str2[k] << " cou = " << cou[j][k] << endl;
	}
	else if(cou[j - 1][k] > cou[j][k - 1]){
	  cou[j][k] =  cou[j - 1][k];
	  // cout << "str = " << str[j] << " str2 = " << str2[k] << " cou = " << cou[j][k] << endl;
	}
	else {
	  cou[j][k] = cou[j][k - 1];
	  // cout << "str = " << str[j] << " str2 = " << str2[k] << " cou = " << cou[j][k] << endl;
	}
      }
    }


    cout << max << endl;
      
    max = 0;

    for(int j = 0;j <= s;j++){
      for(int k = 0;k <= s2;k++){
	cou[j][k] = 0;
      }
    }
  }
}


	  

Measured memory_bytes: 7312
#pragma GCC optimize ("O3")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define all(a) a.begin(),a.end()
#define endl '\n'
#define ull unsigned long long
#define y1 ljhadglkjsadf
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define iter multiset<int>::iterator
#define iter1 set<int>::iterator
#define int long long
using namespace std;
using namespace __gnu_pbds;

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

template<class T>
using ordered_multiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rnd1(chrono::steady_clock::now().time_since_epoch().count());

//find_by_order
//order_of_key

const int N=2e5+7;
const int inf=1e18+1e9;
const int mod=1e9+7;
const ld eps=1e-9;

//const int MAX_MEM=4e8;
//int mpos=0;
//char mem[MAX_MEM];
//
//inline void * operator new(size_t n){
//    char *res=mem+mpos;
//    mpos+=n;
//    if (mpos>=MAX_MEM){
//        cout<<"BAD"<<endl;
//        exit(0);
//    }
//    return (void*)res;
//}
//
//inline void operator delete(void *) {}

int st[50];

main ()
{
    st[0]=1;
    for (int i=1;i<35;++i){
        st[i]=st[i-1]*2;
    }
    ios;
    int n;
    multiset<int>setik;
    cin>>n;
    for (int i=1;i<=n;++i){
        int x;
        cin>>x;
        setik.insert(x);
    }
    int ans=0;
    while(setik.size()>0){
        iter it=setik.end();
        --it;
        int x=(*it);
        setik.erase(it);
        int k=0;
        while(st[k]<=x)++k;
        int l=st[k]-x;
        iter it1=setik.find(l);
        if (it1!=setik.end()){
            ++ans;
            setik.erase(it1);
        }
    }
    cout<<ans<<endl;
}
//1
//3 15
//1 4
//3 5


Measured memory_bytes: 13040
local mfl, mce, mmi = math.floor, math.ceil, math.min
local SegTree = {}
SegTree.updateAll = function(self)
  for i = self.stagenum - 1, 1, -1 do
    for j = 1, self.cnt[i] do
      self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])
    end
  end
end
SegTree.create = function(self, n, func, emptyvalue)
  self.func, self.emptyvalue = func, emptyvalue
  local stagenum, mul = 1, 1
  self.cnt, self.stage, self.size = {1}, {{}}, {}
  while mul < n do
    mul, stagenum = mul * 2, stagenum + 1
    self.cnt[stagenum], self.stage[stagenum] = mul, {}
  end
  for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end
  self.stagenum = stagenum
  for i = 1, mul do self.stage[stagenum][i] = emptyvalue end
  self:updateAll()
end
SegTree.getRange = function(self, left, right)
  if left == right then return self.stage[self.stagenum][left] end
  local start_stage = 1
  while right - left + 1 < self.size[start_stage] do
    start_stage = start_stage + 1
  end
  local ret = self.emptyvalue
  local t1, t2, t3 = {start_stage}, {left}, {right}
  while 0 < #t1 do
    local stage, l, r = t1[#t1], t2[#t1], t3[#t1]
    table.remove(t1) table.remove(t2) table.remove(t3)
    local sz = self.size[stage]
    if (l - 1) % sz ~= 0 then
      local newr = mmi(r, mce((l - 1) / sz) * sz)
      table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, newr)
      l = newr + 1
    end
    if sz <= r + 1 - l then
      ret = self.func(ret, self.stage[stage][mce(l / sz)])
      l = l + sz
    end
    if l <= r then
      table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)
    end
  end
  return ret
end
SegTree.setValue = function(self, idx, value, silent)
  self.stage[self.stagenum][idx] = value
  if not silent then
    for i = self.stagenum - 1, 1, -1 do
      local dst = mce(idx / 2)
      local rem = dst * 4 - 1 - idx
      self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])
      idx = dst
    end
  end
end
SegTree.new = function(n, func, emptyvalue)
  local obj = {}
  setmetatable(obj, {__index = SegTree})
  obj:create(n, func, emptyvalue)
  return obj
end

local n = io.read("*n", "*l")
local s = io.read()
local q = io.read("*n", "*l")
local sts = {}
local t = {}
for i = 1, 26 do
  sts[i] = SegTree.new(n, function(a, b) return a or b end, false)
end
for i = 1, n do
  t[i] = s:sub(i, i):byte() - 96
  sts[t[i]]:setValue(i, true)
end

for iq = 1, q do
  local iqstr = io.read()
  local ic = iqstr:sub(1, 1)
  if ic == "1" then
    local i, cs = iqstr:match("%d (%d+) (%w)")
    i = tonumber(i)
    local c = cs:byte() - 96
    if t[i] ~= c then
      sts[t[i]]:setValue(i, false)
      t[i] = c
      sts[c]:setValue(i, true)
    end
  else
    local l, r = iqstr:match("%d (%d+) (%d+)")
    l, r = tonumber(l), tonumber(r)
    local cnt = 0
    for i = 1, 26 do
      if sts[i]:getRange(l, r) then cnt = cnt + 1 end
    end
    print(cnt)
  end
end


Measured memory_bytes: 317464