akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  ll N, H, W;
  cin >> N >> H >> W;
  ll X, Y;
  ll co = 0;
  rep(i, N) {
    cin >> X >> Y;
    if(X >= H && Y >= W) {
      co++;
    }
  }
  cout << co << endl;
}

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

int main(){
    char s[3][3],ans[3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> s[i][j];
        }
        ans[i]=s[i][i];
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }


struct SCC {
    V<int> id;
    VV<int> groups;
};

template<class E>
struct SCCExec : SCC {
    int n;
    const VV<E>& g;
    int tm = 0;
    V<bool> flag;
    V<int> low, ord, st;
    void dfs(int v) {
        low[v] = ord[v] = tm++;
        st.push_back(v);
        flag[v] = true;
        for (auto e: g[v]) {
            if (ord[e.to] == -1) {
                dfs(e.to);
                low[v] = min(low[v], low[e.to]);
            } else if (flag[e.to]) {
                low[v] = min(low[v], ord[e.to]);
            }
        }
        if (low[v] == ord[v]) {
            V<int> gr;
            while (true) {
                int u = st.back(); st.pop_back();
                gr.push_back(u);
                if (u == v) break;
            }
            for (int x: gr) flag[x] = false;
            groups.push_back(gr);
        }
    }
    SCCExec(const VV<E>& _g) : n(int(_g.size())), g(_g),
                               flag(n), low(n), ord(n, -1) {
        id = V<int>(n);
        for (int i = 0; i < n; i++) {
            if (ord[i] == -1) dfs(i);
        }
        reverse(groups.begin(), groups.end());
        for (int i = 0; i < int(groups.size()); i++) {
            for (int x: groups[i]) {
                id[x] = i;
            }
        }
    }
};

template<class E> SCC get_scc(const VV<E>& g) { return SCCExec<E>(g); }


int main() {
    int n, m;
    cin >> n >> m;
    struct E { int to; };
    VV<E> g(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b; a--; b--;
        g[a].push_back(E{b});
    }
    auto scc = get_scc(g);

    V<int> dp(n);
    for (auto gr: scc.groups) {
        int v = gr[0];
        for (auto e: g[v]) {
            int d = e.to;
            dp[d] = max(dp[d], dp[v] + 1);
        }
    }
    int ans = 0;
    for (int d: dp) ans = max(ans, d);
    cout << ans << endl;
    return 0;
}


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

int solve(const std::string &s) {
  char cur = s[0];
  int len = s.length();
  int res = 1;
  for (int i = 1; i < len; ++i) {
    if (s[i] == cur) continue;
    ++res;
    cur = s[i];
  }
  return res;
}

int main() {
  int n;
  std::cin >> n;
  std::string s;
  std::cin >> s;
  std::cout << solve(s) << std::endl;
  return 0;
}


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

int main(){
  int N,min_cost=1000000000;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    
  }
  for(int i=-100;i<101;i++){
    int cost=0;
    for(int j=0;j<N;j++){
      int B=A.at(j)-i;
      cost+=pow(B,2);
    }
    min_cost=min(min_cost,cost);
  }
  cout << min_cost << endl;
}  

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

const double EPS = 1e-9;

class Point
{
public:
    double x, y;
    Point(double x = 0, double y = 0) : x(x), y(y) {}

    double dist(double x1, double y1) const
    {
        double dx = x - x1, dy = y - y1;
        return sqrt(dx * dx + dy * dy);
    }
};

int N;
vector<Point> p;

double eval(double x, double y)
{
    double res = 0;
    for (int i = 0; i < N; i++)
    {
        res = max(res, p.at(i).dist(x, y));
    }
    return res;
}

double eval_x(double x)
{
    double b = 0, u = 1000;
    while (u - b > EPS)
    {
        double mb = (2 * b + u) / 3;
        double mu = (b + 2 * u) / 3;
        if (eval(x, mb) > eval(x, mu))
            b = mb;
        else
            u = mu;
    }
    return eval(x, b);
}

int main()
{
    cout << fixed << setprecision(18);

    cin >> N;
    p = vector<Point>(N);
    for (int i = 0; i < N; i++)
        cin >> p.at(i).x >> p.at(i).y;

    double l = 0, r = 1000;
    while (r - l > EPS)
    {
        double ml = (2 * l + r) / 3;
        double mr = (l + 2 * r) / 3;
        if (eval_x(ml) > eval_x(mr))
            l = ml;
        else
            r = mr;
    }
    cout << eval_x(l) << endl;
    return 0;
}


Measured memory_bytes: 3824
import java.util.Arrays;
import java.util.Scanner;

class C {
    static class UnionFind {
        final int[] tree;

        public UnionFind(int size) {
            tree = new int[size];
            Arrays.fill(tree, -1);
        }

        int root(int x) {
            return tree[x] < 0 ? x : (tree[x] = root(tree[x]));
        }

        void union(int x, int y) {
            x = root(x);
            y = root(y);
            if (tree[x] > tree[y])
                union(y, x);
            else if (x != y) {
                tree[x] += tree[y];
                tree[y] = x;
            }
        }
    }

    public static void main(String... args) {
        final Scanner sc = new Scanner(System.in);
        final int H = sc.nextInt();
        final int W = sc.nextInt();
        final char[][] S = new char[H][];
        for (int i = 0; i < H; i++)
            S[i] = sc.next().toCharArray();
        final UnionFind uf = new UnionFind(H * W);
        for (int i = 0; i < H; i++)
            for (int j = 0; j < W; j++) {
                if (i > 0 && S[i - 1][j] != S[i][j])
                    uf.union(i * W + j, (i - 1) * W + j);
                if (j > 0 && S[i][j - 1] != S[i][j])
                    uf.union(i * W + j, i * W + j - 1);
            }
        final int[][] b = new int[H][W];
        final int[][] w = new int[H][W];
        for (int i = 0; i < H; i++)
            for (int j = 0; j < W; j++) {
                final int r = uf.root(i * W + j);
                if (S[i][j] == '.')
                    w[r / W][r % W]++;
                else
                    b[r / W][r % W]++;
            }
        long ans = 0;
        for (int i = 0; i < H; i++)
            for (int j = 0; j < W; j++)
                ans += (long) w[i][j] * b[i][j];
        System.out.println(ans);
    }
}
public class Main {
    public static void main(String... args) {
        C.main();
    }
}


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

using namespace std;

using i64 = long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


signed main(){
    i64 m;
    cin >> m;
    vector<i64> d(m), c(m);
    for(i64 i = 0; i < m; ++i)
        cin >> d[i] >> c[i];

    vector<vector<vector<pair<i64,i64>>>> dp(10, vector<vector<pair<i64,i64>>>(10, vector<pair<i64,i64>>(63)));

    // next, cnt
    for(i64 i = 0; i < 10; ++i)
        for(i64 j = 0; j < 10; ++j)
            dp[i][j][0] = make_pair((i + j + ((i + j) / 10)) % 10, 1 + (i + j) / 10);

    for(i64 k = 1; k < 63; ++k){
        for(i64 i = 0; i < 10; ++i){
            for(i64 j = 0; j < 10; ++j){
                i64 next, cnt;
                tie(next, cnt) = dp[i][j][k - 1];
                dp[i][j][k] = dp[next][j][k - 1];
                dp[i][j][k].second += cnt;
            }
        }
    }

    auto f = [&](i64 back, i64 next, i64 cnt){
        i64 ret_cnt = 0;
        for(i64 i = 0; i < 60; ++i){
            if(cnt & (1L << i)){
                auto p = dp[back][next][i];
                back = p.first;
                ret_cnt += p.second;
            }
        }
        return make_pair(back, ret_cnt);
    };


    i64 ans = 0, back = 0;
    for(i64 i = 0; i < m; ++i){
        auto p = f(back, d[i], c[i]);
        ans += p.second;
        back = p.first;
    }
    cout << ans - 1 << endl;

}


Measured memory_bytes: 3456
use std::collections::VecDeque;

#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let (h, w) = get!(i64, i64);
    let mut field = Vec::new();
    let mut white = 0;
    for _ in 0..h {
        let tmp = get!(String);
        let v: Vec<char> = tmp.chars().collect();
        white += v.iter().filter(|&&x| x == '.').count();
        field.push(v);
    }
    let dx = [0, 1, 0, -1];
    let dy = [-1, 0, 1, 0];
    let mut q = VecDeque::new();
    let mut memo = vec![vec![0; w as usize]; h as usize];
    memo[0][0] = 1;
    let goal = (w - 1, h - 1);
    q.push_back((0, 0));
    //eprintln!("white: {}", white);
    while !q.is_empty() {
        let now = *q.front().unwrap();
        q.pop_front();
        if now == goal {
            //eprintln!("{}", memo[now.1 as usize][now.0 as usize]);
            //for i in 0..h {
            //    eprintln!("{:?}", memo[i as usize]);
            //}
            println!("{}", white - memo[now.1 as usize][now.0 as usize]);
            return;
        }
        for i in 0..4 {
            let next = (now.0 + dx[i], now.1 + dy[i]);
            if next.0 < 0 || w <= next.0 || next.1 < 0 || h <= next.1 {
                continue;
            }
            if field[next.1 as usize][next.0 as usize] == '#' {
                continue;
            }
            if memo[next.1 as usize][next.0 as usize] != 0 {
                continue;
            }
            q.push_back(next);
            memo[next.1 as usize][next.0 as usize] += memo[now.1 as usize][now.0 as usize] + 1;
        }
    }
    println!("-1");
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
 
using namespace std;

 
const int MAX_N = int(1e6) + 10;
const long long int MOD=1e9+7;
const long long int INF=1e18;
 
typedef long long int ll;
typedef unsigned long long int llu;
 
 
 
inline ll mul(ll a,ll b){
 
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll c=a*b;
    c=(c+MOD)%MOD;
    return c;
}
inline ll add(ll a,ll b){
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll ans=(a+b);
    ans=(ans+MOD)%MOD;
    return ans;
}
ll power(ll a,ll b,ll c=0){
    ll ans=1;
    while(b){
        if(b&1){
            ans=mul(ans,a);
        }
        a=mul(a,a);
        b=b/2;
    }
    return ans;
}
 
  
 
 
#define all(x) (x).begin(),(x).end()




//s.reserve(32768); //updated !
//s.max_load_factor(0.25);


ll a[200005];
ll u[200005];
ll v[200005];


int main(){
 
    

    int n;
    cin>>n;

    for(int i=1;i<=n-1;i++){
        cin>>u[i]>>v[i];
    }

    ll ans=0;

    for(int i=1;i<=n;i++){
        ll N=n-i+1;
        ans+=N*(N+1)/2LL;
    }

    for(int i=1;i<=n-1;i++){
        ans-=min(u[i],v[i])*(n-max(u[i],v[i])+1);
    }

    cout<<ans<<"\n";

    



    
    
    




    

}
    

    






    
    

    
 
    
 

 
 
    
 
 


Measured memory_bytes: 6756
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c,n) for(int i=c;i<n;i++)
 
int main() {
  int x,a,b;
  cin>>x>>a>>b;
  
  if(abs(a-x)<abs(b-x)){cout<<"A"<<endl;}
  else{cout<<"B"<<endl;}
  
  return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define step(i,s,n,c) for(int i=(s);i<(n);i+=(c))
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define each(i,vec) for(auto i:vec)
#define cinv(n,vec) VL vec(n);for(auto&v:vec)cin>>v;
#define int long long
#define itn int
#define pb push_back
#define eb emplace_back
#define m_p make_pair
#define m_t make_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a),greater<>())
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (signed)(a.size())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define callp(a) for(auto [k,v]:a)cout<<k<<":"<<v<<endl
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define out(a) cout<<(a)<<endl
#define ENDL cout<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define fi first
#define se second
#define V vector
#define P pair
#define T tuple
#define PQ priority_queue
#define cont const auto
#define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a))
typedef long long ll;
typedef double D;
typedef long double LD;
typedef string str;
typedef vector<ll> VL;
typedef pair<ll,ll> PL;
typedef vector<pair<ll,ll>> VP;
typedef tuple<ll,ll,ll> T3;
typedef tuple<ll,ll,ll,ll> T4;
const signed INF = (1LL<<30);
const long long MOD = (1e9+7);
const long long LINF = (1LL<<60);
const long long LMAX = LLONG_MAX;
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
ll vmax(VL v){int m;for(auto e:v)chmax(m,e);return m;}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(10);
  
  int k,t;
  cin>>k>>t;
  cinv(t,a);

  int mx=vmax(a);
  cout<<max(mx-1-(k-mx),0LL)<<endl;
  
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;


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

      int cnt1 = 0,cnt2 = 0;
      rep(i,s.size()){
        if(i%2 == 0 && s[i] != '0')cnt1++;
        else if(i%2 != 0 && s[i] != '1')cnt1++;
        if(i%2 == 0 && s[i] != '1')cnt2++;
        else if(i%2 != 0 && s[i] != '0')cnt2++;
        
      }
      int ans = min(cnt1,cnt2);
      cout<<ans<<endl;
      
    }
      


Measured memory_bytes: 512
def main():
    A, B = map(int, input().split())

    def gcd(x, y):
        while y != 0:
            x, y = y, x % y
        return x

    def prime_factorize(n):
        arr = []
        temp = n
        for i in range(2, int(-(-(n ** 0.5) // 1)) + 1):
            if temp % i == 0:
                cnt = 0
                while temp % i == 0:
                    cnt += 1
                    temp //= i
                arr.append([i, cnt])

        if temp != 1:
            arr.append([temp, 1])


        return arr

    cd = gcd(A, B)
    ans = len(prime_factorize(cd)) + 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define ff first
#define ss second
#define nl '\n'
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */



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

  int n;
  ll c; cin >> n >> c;
  ll x[1+n], v[1+n];
  ll pref[1+n], suff[1+n];
  
  pref[0] = 0;
  for(int i=1; i<=n; i++) {
    cin >> x[i] >> v[i];
    pref[i] = pref[i-1] + v[i];
  }
  suff[n] = v[n];
  for(int i=n-1; i>=0; i--) {
    suff[i] = suff[i+1] + v[i];
  }

  ll ans = 0;
  for(int i=1; i<=n; i++) {
    ans = max(ans, -x[i]+pref[i]);
  }
  for(int i=n; i>=1; i--) {
    ans = max(ans, -c+x[i]+suff[i]);
  }

  ll X[1+n], Y[1+n];
  // cw -> ccw
  for(int i=1; i<=n; i++) X[i] = pref[i] - 2 * x[i];
  for(int i=1; i<=n; i++) Y[i] = suff[i] - c + x[i];
  for(int i=2; i<=n; i++)
    X[i] = max(X[i], X[i-1]);
  for(int i=n-1; i>=1; i--)
    Y[i] = max(Y[i], Y[i+1]);
  for(int z=1; z<n; z++)
    ans = max(ans, X[z] + Y[z+1]);

  for(int i=1; i<=n; i++) X[i] = pref[i] - x[i];
  for(int i=1; i<=n; i++) Y[i] = suff[i] - 2 * (c - x[i]);
  for(int i=2; i<=n; i++)
    X[i] = max(X[i], X[i-1]);
  for(int i=n-1; i>=1; i--)
    Y[i] = max(Y[i], Y[i+1]);
  for(int z=1; z<n; z++)
    ans = max(ans, X[z] + Y[z+1]);
  
  cout << ans << nl;

  return 0;
}
/* -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- -*- */


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

#define llong long long 
typedef struct data{
	int low;
	int high;
	int eva;
}data;
int D, N;
int temp[201];
data kind[200];
int score[201][200][200];

int solve(int d, int k, int yk){
	if(score[d][k][yk] != -1) return score[d][k][yk];
	if(d == D) return score[d][k][yk] = fabs(kind[k].eva - kind[yk].eva);

	int e = 0;
	for(int i = 0; i < N; i++){
		data use = kind[i];
		if(use.low > temp[d + 1] || use.high < temp[d + 1]) continue;
		int sum;
		if(d > 1)sum = fabs(kind[k].eva - kind[yk].eva) + solve(d + 1, i, k);
		else sum = solve(d + 1, i, k);
		e = max(e, sum);
	}

	return score[d][k][yk] = e;
}

int main(){
	fill_n(temp, 201, -1);
	fill_n(**score, 201 * 200 * 200, -1);
	cin >> D >> N;
	for(int i = 1; i <= D; i++){
		cin >> temp[i];
	}
	for(int i = 0; i < N; i++){
		cin >> kind[i].low >> kind[i].high >> kind[i].eva;
	}

	cout << solve(0, 0, 0) << endl;
	return 0;
}

Measured memory_bytes: 34508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1<<18,INF=1<<30;

bool compare(pair<pair<int,int>,int> a,pair<pair<int,int>,int> b){
    if(a.first.second==b.first.second) return a.first.first>b.first.first;
    return a.first.second>b.first.second;
}

int main(){
    
    int N,M;cin>>N>>M;
    vector<int> dp(N+1,INF);
    vector<pair<pair<int,int>,int>> P(M);
    for(int i=0;i<M;i++){
        cin>>P[i].first.first>>P[i].first.second;
        P[i].second=i+1;
    }
    
    sort(all(P),compare);
    
    for(int i=0;i<M;i++){
        auto it=upper_bound(all(dp),-P[i].first.second);
        *it=min(*it,-P[i].first.first);
    }
    int ans=0;
    
    for(int i=0;i<N;i++){
        if(dp[i]==INF){
            ans=i;
            break;
        }else{
            dp[i]=-dp[i];
        }
    }
    
    reverse(all(P));
    
    //for(int i=0;i<N;i++) cout<<dp[i]<<endl;
    
    cout<<ans<<endl;
    
    /*if(ans==1){
        cout<<1<<endl;
        return 0;
    }
    int nowsee=0,start=-1;
    priority_queue<pair<int,pair<int,int>>,vector<pair<int,pair<int,int>>>,greater<pair<int,pair<int,int>>>> PQ;
    
    bool room=false;
    
    for(int i=ans-2;i>=-1;i--){
        if(room) cout<<" ";
        if(i==-1){
            while(nowsee<N){
                PQ.push({P[nowsee].second,{P[nowsee].first.first,P[nowsee].first.second}});
                nowsee++;
            }
            if(PQ.empty()) return 1;
            while(1){
                pair<int,pair<int,int>> p=PQ.top();PQ.pop();
                if(p.second.first>=start){
                    cout<<p.first;
                    room=true;
                    start=p.second.second;
                    break;
                }
            }
        }else{
            while(nowsee<N&&P[nowsee].first.second<=dp[i]){
                PQ.push({P[nowsee].second,{P[nowsee].first.first,P[nowsee].first.second}});
                nowsee++;
            }
            if(PQ.empty()) return 1;
            while(1){
                pair<int,pair<int,int>> p=PQ.top();PQ.pop();
                if(p.second.first>=start){
                    cout<<p.first;
                    room=true;
                    start=p.second.second;
                    break;
                }
            }
        }
    }
    cout<<endl;*/
}





Measured memory_bytes: 1792
import collections
h, w, n = map(int, input().split(" "))
list_include = []
for i in range(n):
  a, b = map(int, input().split(" "))
  for y in range(3):
    for x in range(3):
      if a - y > 0 and a - y + 2 <= h:
        if b - x > 0 and b - x + 2 <= w:
          list_include.append((a - y, b - x))
count = collections.Counter(list_include)
result = [0 for _ in range(10)]
for item in count.items():
  result[item[1]] += 1
result[0] = (h - 2) * (w - 2) - sum(result)
for one_result in result:
  print(one_result)


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

int main(){
  int N;
  cin >> N;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  int judge = 0;
  int difference;
  for (int i = 0; i < N-1; i++){
    difference = A.at(i+1) - A.at(i);
    if (difference == 0){
      judge++;
    }
  }
  if (judge > 0){
    cout << "NO" << endl;
  }
  else{
    cout << "YES" << endl;
  }
}

Measured memory_bytes: 1792
def solve(s):
    preds = {s}
    i = 1
    while True:
        if s % 2 == 0:
            s /= 2
        else:
            s = 3 * s + 1
        i += 1
        if s in preds:
            return i
        preds.add(s)
s = int(input())
print(solve(s))


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

using namespace std;

int main(){
    vector< vector < int > > m;
    for(int i = 0; i < 3; i++){
        vector<int> v;
        for(int j = 0; j < 3; j++){
            int aux; cin >> aux;
            v.push_back(aux);
        }
        m.push_back(v);
    }

    if(m[0][1] - m[0][0] == m[1][1] - m[1][0] && m[0][1] - m[0][0] == m[2][1] - m[2][0] &&
       m[0][2] - m[0][1] == m[1][2] - m[1][1] && m[0][2] - m[0][1] == m[2][2] - m[2][1] &&
       m[1][0] - m[0][0] == m[1][1] - m[0][1] && m[1][0] - m[0][0] == m[1][2] - m[0][2] &&
       m[2][0] - m[1][0] == m[2][1] - m[1][1] && m[2][0] - m[1][0] == m[2][2] - m[1][2]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "p", long, "dist");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    long n, p;
    scan(n, p);
    auto p_factor = p.prime_factorization();
    long ans = 1;
    foreach (key, e; p_factor)
    {
        auto k = e / n;
        ans *= key ^^ k;
    }
    ans.writeln();
}

// 因数分解を行う。計算量はO(sqrt(n))
auto factorization(long a)
{
    auto factor = new long[](0);
    auto limit = cast(long) sqrt(cast(float) a);
    foreach (i; iota(limit))
    {
        long tmp = i + 1;
        if (a % tmp == 0)
        {
            factor ~= tmp;
            if (tmp != a / tmp)
                factor ~= a / tmp;
        }
    }
    factor.sort();
    return factor;
}

auto prime_factorization(long a)
{
    auto f = a.factorization();
    long[long] pf;
    foreach (e; f[1 .. $]) // ignore 1
    {
        while (a % e == 0)
        {
            if (e in pf)
                pf[e]++;
            else
                pf[e] = 1;
            a /= e;
        }
    }
    return pf;
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		List<String> lst=new ArrayList<String>();
		boolean roop=true;
		while(roop){
			String s=br.readLine();
			lst.add(s);
			if(s.equals("0"))roop=false;
		}
		for(int i=0;i<(lst.size()-1);i++){
			System.out.println("Case "+(i+1)+": "+lst.get(i));
		}
		
	}
}

Measured memory_bytes: 32252
#include<bits/stdc++.h>
#define LL long long
#define db double
#define il inline

using namespace std;
const int N=3e5+10;
il LL rd()
{
    LL x=0,w=1;char ch=0;
    while(ch<'0'||ch>'9') {if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') {x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
    return x*w;
}
#define mid ((l+r)>>1)
struct sgmttr
{
	LL s[N<<2],tg[N<<2];
	void psup(int o){s[o]=min(s[o<<1],s[o<<1|1]);}
	void ad(int o,LL x){s[o]+=x,tg[o]+=x;}
	void psdn(int o){if(tg[o]) ad(o<<1,tg[o]),ad(o<<1|1,tg[o]),tg[o]=0;}
	void bui(int o,int l,int r)
	{
		s[o]=1ll<<50;
		if(l==r) return;
		bui(o<<1,l,mid),bui(o<<1|1,mid+1,r);
	}
	/*void modifa(int o,int l,int r,int ll,int rr,int x)
	{
		if(ll<=l&&r<=rr){ad(o,x);return;}
		psdn(o);
		if(ll<=mid) modifa(o<<1,l,mid,ll,rr,x);
		if(rr>mid) modifa(o<<1|1,mid+1,r,ll,rr,x);
		psup(o);
	}*/
	void modifc(int o,int l,int r,int lx,LL x)
	{
		if(l==r){s[o]=x;return;}
		psdn(o);
		if(lx<=mid) modifc(o<<1,l,mid,lx,x);
		else modifc(o<<1|1,mid+1,r,lx,x);
		psup(o);
	}
	LL quer(int o,int l,int r,int ll,int rr)
	{
		if(ll>rr) return 1ll<<50;
		if(ll<=l&&r<=rr) return s[o];
		psdn(o);
		LL an=1ll<<50;
		if(ll<=mid) an=min(an,quer(o<<1,l,mid,ll,rr));
		if(rr>mid) an=min(an,quer(o<<1|1,mid+1,r,ll,rr));
		psup(o);
		return an;
	}
}tr1,tr2;
int n,q,a[N];

int main()
{
	n=rd(),q=rd()+2,a[1]=rd(),a[2]=rd();
	for(int i=3;i<=q;++i) a[i]=rd();
	tr1.bui(1,1,n),tr2.bui(1,1,n);
	tr1.modifc(1,1,n,a[1],abs(a[3]-a[2])-a[1]),tr2.modifc(1,1,n,a[1],abs(a[3]-a[2])+a[1]);
	tr1.modifc(1,1,n,a[2],abs(a[3]-a[1])-a[2]),tr2.modifc(1,1,n,a[2],abs(a[3]-a[1])+a[2]);
	LL ans;
	for(int i=4;i<=q;++i)
	{
		ans=min(tr1.quer(1,1,n,1,a[i])+a[i],tr2.quer(1,1,n,a[i]+1,n)-a[i]);
		tr1.ad(1,abs(a[i]-a[i-1])),tr2.ad(1,abs(a[i]-a[i-1]));
		tr1.modifc(1,1,n,a[i-1],ans-a[i-1]),tr2.modifc(1,1,n,a[i-1],ans+a[i-1]);
	}
	ans=1ll<<50;
	for(int i=1;i<=n;++i) ans=min(ans,min(tr1.quer(1,1,n,i,i)+i,tr2.quer(1,1,n,i,i)-i));
	printf("%lld\n",ans);
    return 0; 
}


Measured memory_bytes: 24448
n = int(input())
listA = list(map(int, input().split()))
listA.sort()
listA.reverse()

index=0
beforeC =""
count=0
a=0
b=0
while index < n:
    if listA[index] == beforeC:
        count+=1
        if count == 2:
            if a ==0:
                a = listA[index]
            elif b ==0:
                b = listA[index]
                break
            count=0
            beforeC = ""
    else:
        beforeC = listA[index]
        count = 1
    index+=1

print(a*b)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
# define ll long long int
#define M 998244353
#define pb push_back
#define ss second
#define ff first
#define inf 1000000000000000
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x ;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
												//nestedcode
 
ll binpow(ll a, ll b, ll m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }

}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,k,l,r,m,ans,fans = 0,i;
    cin>>n>>k;
    ll a[n+5];
    for(i=0;i<n;i++){
    	cin>>a[i];
	}
    l = 1;
    r = 1000000000;
    while(l<=r){
    	m = (l+r)/2;
    	ans = 0;
    	for(i=0;i<n;i++){
    		ans += ((a[i]-1)/m);
		}
		if(ans <= k){
			fans = m;
			r = m-1;
		}else{
			l = m+1;
		}
	}
	cout<<fans<<endl;
}
   
  

	  


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

using namespace std;

int main(){
    int n;
    cin >> n;
    int arr[n];
    for(int i = 0; i < n; ++i)cin >> arr[i];
    sort(arr, arr + n);
    arr[n - 1] = arr[n - 1] / 2;
    cout << accumulate(arr, arr + n, 0);
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);	

	int n;
	cin >> n;
	vector<int> a(n);
	for (auto &t : a) {
		cin >> t;
	}
	int ans = 0;
	map<int, int> cnt;
	for (int i = n - 1; i >= 0; i--) {
		ans += cnt[-(a[i] + i)];
		cnt[a[i] - i]++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 27368
#include <iostream>
 
using namespace std;
 
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if ((a > b && c > b && a>c) || (a < b && c < b&&a<c)) cout << "Yes";
	else cout << "No";
	cout << endl;
 
 
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

struct edge{
    ll to,d;
};
const ll INF = 1e12;
signed main(){
    int n,m; cin >> n >> m;
    vector<edge> to[n];
    vector<edge> from[n];
    rep(i,m){
        ll l,r,d; cin >> l >> r >> d;
        l--; r--;
        to[l].pb({r,d}); //l->r
        from[r].pb({l,d});
    }
    vector<bool> ok(n,0);
    vector<ll> dist(n,INF);
    rep(i,n){
        if(ok[i]) continue;
        queue<int> q;
        q.push(i); ok[i]=1;
        dist[i]=0;
        while(!q.empty()){
            int v=q.front(); q.pop();
            for(auto u:to[v]){
                if(dist[u.to]!=INF && dist[u.to]!=dist[v]+u.d){
                    //rep(j,n)cout<<dist[j]<<" ";
                    cout << "No" << endl;
                    return 0;
                }
                if(ok[u.to]) continue;
                ok[u.to]=1;
                q.push(u.to);
                dist[u.to]=dist[v]+u.d;
            }
            for(auto u:from[v]){
                if(dist[u.to]!=INF && dist[u.to]!=dist[v]-u.d){
                    //rep(j,n)cout<<dist[j]<<" ";
                    cout << "No" << endl;
                    return 0;
                }
                if(ok[u.to]) continue;
                ok[u.to]=1;
                q.push(u.to);
                dist[u.to]=dist[v]-u.d;
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 16128
SIZE = int(1e5 + 1)
is_prime = [True] * SIZE
is_prime[0] = is_prime[1] = False
for i in range(2, SIZE):
    if is_prime[i]:
        for j in range(i * 2, SIZE, i):
            is_prime[j] = False

cnt = [0] * (SIZE)
for i in range(1, SIZE, 2):
    if is_prime[i] and is_prime[(i + 1) // 2]:
        cnt[i] += 1

for i in range(1, SIZE):
    cnt[i] += cnt[i - 1]


Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print(cnt[r] - cnt[l - 1])


Measured memory_bytes: 7156
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include <iomanip>
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long ll;
//#define INF 1000000000000 //10^12:極めて大きい値,∞
#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--)

void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}

int main(){
    int n,x;
    cin >> n;
    for(int i=1; i<=n; i++){
        if(i%3==0){
            cout << ' ' << i;
        }
        else{
            x = i;
            while(x){
                if(x%10==3){
                    cout << ' ' << i;
                    x = 0;
                }
                x /= 10;
            }
        }
    }
    cout << endl;
    //call(n);
    return 0;
}


Measured memory_bytes: 3076
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <numeric>

using namespace std;

const int INF = 1 << 30;
const uint64_t MOD = 1000000000 + 7;

int main()
{
	string s, t;
	cin >> s;

	for (int i = 0; i < s.length(); i++)
	{
		string c = s.substr(i, 1);
		if (c == "B")
		{
			if (t.length() > 0)
			{
				t.erase(t.length() - 1, 1);
			}
		}
		else
		{
			t += c;
		}
	}

	cout << t << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
const int Mod=998244353;
int n;
#define Maxn 300010
char str[Maxn];
int fact=1,Ans=1;
int a[7];//empty R G B RG BG RB
int main(){
	scanf("%d",&n);
	for(register int i=1;i<=n;++i)fact=1ll*fact*i%Mod;
	scanf("%s",str+1);
	for(register int i=1;i<=3*n;++i){
		if(str[i]=='R'){
			if(a[5]){
				Ans=1ll*Ans*a[5]%Mod;
				a[5]--;
				continue;
			}
			if(a[2]){
				Ans=1ll*Ans*a[2]%Mod;
				a[2]--;
				a[4]++;
				continue;
			}
			if(a[3]){
				Ans=1ll*Ans*a[3]%Mod;
				a[3]--;
				a[6]++;
				continue;
			}
			a[1]++;
		}else if(str[i]=='G'){
			if(a[6]){
				Ans=1ll*Ans*a[6]%Mod;
				a[6]--;
				continue;
			}
			if(a[1]){
				Ans=1ll*Ans*a[1]%Mod;
				a[1]--;
				a[4]++;
				continue;
			}
			if(a[3]){
				Ans=1ll*Ans*a[3]%Mod;
				a[3]--;
				a[5]++;
				continue;
			}
			a[2]++;
		}else{
			if(a[4]){
				Ans=1ll*Ans*a[4]%Mod;
				a[4]--;
				continue;
			}
			if(a[1]){
				Ans=1ll*Ans*a[1]%Mod;
				a[1]--;
				a[6]++;
				continue;
			}
			if(a[2]){
				Ans=1ll*Ans*a[2]%Mod;
				a[2]--;
				a[5]++;
				continue;
			}
			a[3]++;
		}
	}
	printf("%d\n",1ll*Ans*fact%Mod);
	return 0;
}

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

int main()
 {   int n,q;
     cin>>n>>q;
     string s;
     cin>>s;
     map <int,int> ps;
     int c=0;
     for (int i=1;i<n;i++)
      { if (s.substr(i-1,2)=="AC") c++;
        ps[i]=c; 
      }
    int a,b;
    for (int i=0;i<q;i++)
     {cin>>a>>b;
      a--;b--;
      cout<<ps[b]-ps[a]<<endl;
     }
    
    return 0;
    
}

Measured memory_bytes: 5632
#include <iostream>
using namespace std;
bool f(int n) {
  if (n == 0) {
    return true;
  }
  if (n < 0) {
    return false;
  }
  return f(n - 4) || f(n - 7);
}

int main(int argc, char** argv) {
  int n;
  cin >> n;

if (n < 4) {
  cout << "No";
return 0;
}
if (((n % 4) == 0) || ((n % 7) == 0)) {
  cout << "Yes";
  return 0;
}

if (f(n)) {
  cout << "Yes";
} else {
  cout << "No";
}
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

typedef struct node {
    int H, W;
    struct node *next;
} node;


int main()
{
    node *head = NULL, *cur = NULL;

    while( 1 ){
        //メモリ確保
        node *new = (node *)malloc(sizeof(node));
        if( new == NULL ) fprintf(stderr, "ERROR! : malloc\n"), exit(-1);

        //標準入力
        scanf("%d %d", &new->H, &new->W);
        new->next = NULL;

        //終了判定
        if( new->H == 0 && new->W == 0 ) break;

        //連結
        if( head == NULL ) head = new;
        else cur->next = new;
        cur = new;
    }

    //標準出力
    cur = head;
    while( cur ){
        int i, j;
        for( i = 0; i < cur->H; ++i ){
            for( j = 0; j < cur->W; ++j ){
                if( i % 2 == 0 ){
                    if( j % 2 == 0 ) printf("#");
                    else printf(".");
                } else {
                    if( j % 2 == 0 ) printf(".");
                    else printf("#");
                }
            }
            printf("\n");
        }
        printf("\n");
        cur = cur->next;
    }

    return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
//#define int long long
typedef pair<int,int> ii;
typedef tuple<int,int,int> iii;
#define ll long long
#define iiMPQ priority_queue<ii,vector<ii>,greater<ii> >
#define MPQ priority_queue<int,vector<int>,greater<int> >
#define PQ priority_queue<int>
#define iiPQ priority_queue<ii>
#define US unordered_set<int>
#define UMS unordered_multiset<int>
#define UM unordered_map<int>
#define ST stack<int>
#define MS multiset<int>
#define scan(n) cin>>n
#define scann(a,b) cin>>a>>b
#define scannn(a,b,c) cin>>a>>b>>c
#define print(n) cout<<n
#define println(n) cout<<n<<"\n"
#define first fi
#define second se
#define REP(i,n) for(int i=0;i<n;++i)
 
struct node {
    int s, e, m, v; node *l, *r;
    node(int _s, int _e){
        s = _s; e = _e; m = (s+e)/2; v = 0;
        if(s != e){
            l = new node(s, m);
            r = new node(m+1, e);
        }
    }
    void update(int x, int nv){
        if(s == e){ v = nv; return; }
        if(x > m) r -> update(x, nv);
        if(x <= m) l -> update(x, nv);
        v = (l -> v) ^ (r -> v);
    }
    int STquery(int x, int y){
        if(s==x && e==y) return v;
        if(x > m) return r -> STquery(x, y);
        if(y <= m) return l -> STquery(x, y);
        return (l -> STquery(x, m)) ^ (r -> STquery(m+1, y));
    }
} *root;

void m1(){
  int n,k; scan(n);
  root = new node(0,n);
  REP(i,n){
    scan(k);
    root->update(i,k);
  }
  REP(i,n){
    if(i == 0){
      cout << root->STquery(1,n-1) << " ";
    }else if(i == n-1){
      cout << root->STquery(0,n-2);
    }else{
      int val = (root->STquery(0,i-1))^(root->STquery(i+1,n-1));
      cout << val << " ";
    }
  }
}
/* 
void m2(){
  int t; scan(t);
  while(t--) m1();
}
*/
 
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  //freopen("in.txt","r",stdin);
  m1();
  //m2();
}

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

const int maxn = 1e5+5;
char ele[4]={'0','A','B','C'};
int ans[maxn];
int n,num[4];
int tot = 0;
int tag[2][2],cnt=0;
bool opr(int x,int y){
	if (!num[x] && !num[y]) return 0;
	if (num[x] > num[y]) swap(x,y);
	else if (num[x]==1 && num[y]==1 && num[6-x-y]==0 && tot!=n-1) {
//		cout << x << ' ' << y << endl;
		tag[++cnt][0]=x;tag[cnt][1]=y;
//		cout << tag[cnt][0] << ' ' << tag[cnt][1] << endl;
		return 1;
	}
//	cout << x << ' ' << y << ' ' << num[x] << ' ' << num[y] << endl; 
	num[x]++,num[y]--;
	ans[++tot] = x;
	return 1;		
}
int main(){
	cin >> n;
	for (int i=1;i<=3;i++) cin >> num[i];
	for (int i=1;i<=n;i++){
		string s;
		cin >> s;
		int x,y;
		if (s=="AB") x=1,y=2;
		else if (s=="BC") x=2,y=3;
		else if (s=="AC") x=1,y=3;
		if (cnt!=0){
//			cout << tag[cnt][0] << ' ' << tag[cnt][1] << endl;
			if (x == tag[cnt][0] && y == tag[cnt][1]) {ans[++tot]=x;ans[++tot]=y;cnt--;continue;}
			if (x == tag[cnt][0] && y != tag[cnt][1]) {ans[++tot]=x;num[x]++;num[tag[cnt][1]]--;cnt--;}
			else if (x != tag[cnt][0] && y == tag[cnt][1]) {ans[++tot]=y;num[y]++;num[tag[cnt][0]]--;cnt--;}	
			else if (x == tag[cnt][1]){ans[++tot]=x;num[x]++;num[tag[cnt][0]]--;cnt--;}
			else if (y == tag[cnt][0]){ans[++tot]=y;num[y]++;num[tag[cnt][1]]--;cnt--;}
		}
		if (!opr(x,y)){
			cout << "No"; return 0;	
		}
//		cout << tot << endl;
	}
	cout << "Yes" << endl;
//	cout << tot << endl;
//	for (int i=1;i<=n;i++) cout << ans[i] << endl;
	for (int i=1;i<=n;i++) cout << ele[ans[i]] << endl;
	return 0;
}


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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef string str;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

#define MAX_H 50
#define MAX_W 50

int h, w;
bool is_land[MAX_H][MAX_W] = { false };

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

inline bool is_in_range(const int y, const int x) {
    return 0 <= y && y < h && 0 <= x && x < w;
}

void dfs(const int y, const int x) {
    is_land[y][x] = false;
    REP(i, 8) {
        int nx = x + dx[i], ny = y + dy[i];
        if(is_in_range(ny, nx) && is_land[ny][nx]) dfs(ny, nx);
    }
}

int main() {
    while(true) {
        cin >> w >> h;
        if(w == 0 && h == 0) break;
        REP(j, h) {
            REP(i, w) {
                int c;
                cin >> c;
                is_land[j][i] = (c == 1);
            }
        }
        int ans = 0;
        REP(j, h) {
            REP(i, w) {
                if(is_land[j][i]) {
                    dfs(j, i);
                    ans++;
                }
            }
        }
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

ll dp[105][100005];

int main(){
	int n; ll wmax;
	cin >> n >> wmax;
	vector<int> w(n);
	vector<int> v(n);
	for( int i = 0; i < n; ++i ) cin >> w[i] >> v[i];
	ll vsum = accumulate( v.begin(), v.end(), 0ll );
	for( int i = 0; i <= n; ++i ){
		for( int j = 0; j <= vsum; ++j ){
			dp[i][j] = INF;
		}
	}
	dp[0][0] = 0;
	for( int i = 0; i < n; ++i ){
		for( int j = 0; j <= vsum; ++j ){
			dp[i+1][j] = dp[i][j];
			if( j >= v[i] ){
				dp[i+1][j] = min( dp[i][j], dp[i][j-v[i]] + w[i] );
			}
		}
	}
	ll ans = 0;
	for( ll j = 0; j <= vsum; ++j ){
		if( dp[n][j] <= wmax ) ans = max( ans, j );
	}
	cout << ans << endl;
	return 0;
}

// 14:54

Measured memory_bytes: 80128
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		String[] tokens = in.readLine().split(" ");
		int A = Integer.parseInt(tokens[0]);
		int B = Integer.parseInt(tokens[1]);
		in.close();
		int result = 0;
		if (A == B) {
			result = A + B;
		} else {
			result = 2 * Math.max(A,  B) - 1;
		}
		System.out.println(result);

	}

}

Measured memory_bytes: 22100
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() {
    const TARGET: char = '#';
    let h: usize = read();
    let w: usize = read();
    let board: Vec<Vec<char>> = (0..h).map(|_| read::<String>().chars().collect()).collect();
    let mut flg = true;
    for j in 0..h {
        for k in 0..w {
            if board[j][k] == TARGET {
                let mut f = false;
                if 0 < j && board[j - 1][k] == TARGET {
                    f = true;
                }
                if 0 < k && board[j][k - 1] == TARGET {
                    f = true;
                }
                if j < h - 1 && board[j + 1][k] == TARGET {
                    f = true;
                }
                if k < w - 1 && board[j][k + 1] == TARGET {
                    f = true;
                }
                if !f {
                    flg = false;
                    break;
                }
            }
        }
    }
    println!("{}", if flg { "Yes" } else { "No" })
}


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

int main() {
  ll N, A, B, C, D, E;
  cin >> N >> A >> B >> C >> D >> E;
  cout <<  max({ (N - 1) / A, (N - 1) / B, (N - 1) / C, (N - 1) / D, (N - 1) / E }) + 5 << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  string s;
  cin >> s;
  int n = s.size();
  vector<int> a(26, 0);
  REP(i, n) a[s[i]-'a']++;
  bool ok = true;
  REP(i, 26) if(a[i]%2) ok = false;
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
N=int(input())
X=input().split()
for i in range(len(X)):
    X[i]=int(X[i])
Xmin=min(X)
Xmax=max(X)
for P in range(Xmin,Xmax+1):
    p=0
    for xi in X:
        p+=(xi-P)**2
    if P==Xmin:
        m=p
    elif p<m:
        m=p
print(m)


Measured memory_bytes: 3064