akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
int main(void){
  int N=0,M=0;
  cin>>N>>M;
  int A[N],B[M],D[N]={0},ans1=0,ans=0;
  for(int i=0;i<N;i++){
  	cin>>A[i];
  }
  for(int j=0;j<M;j++){
  	cin>>B[j];
    for(int i=0;i<N;i++){
      if(B[j]>=A[i]){
        D[i]++;
      	if(ans1<D[i])
        {
          ans=i;ans1=D[i];
     	}
         break;
      }
    }
  }
  cout<<ans+1<<endl;
  return 0;
}


Measured memory_bytes: 3096
#include "bits/stdc++.h"
using namespace std;
const int maxN=1e5+10;
int N,H[maxN],dp[maxN];
int main()
{
	cin>>N;
	int mx=0;
	for(int i=0;i<N;i++)
	{
		cin>>H[i];
		if(i)
		{
			if(H[i]<=H[i-1])
			{
				dp[i]=dp[i-1]+1;
			}
		}
		mx=max(mx,dp[i]);
	}
	cout<<mx<<endl;
	return 0;
}
/*
5
5 4 3 2 1
Output:4

7
10 9 7 1 6 5 5
Output:3 
*/

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
int main()
{
	long n, k;
	std::string s;
	std::cin >> n >> k;
	std::cin >> s;
	std::vector<long> reverse_place;
	reverse_place.push_back(0);
	for (unsigned long i = 0; i < s.size() - 1; i++)
	{
		if (s[i] != s[i + 1])
		{
			reverse_place.push_back(i + 1);
		}
	}
	reverse_place.push_back(s.size());
	long left = 0;
	long right, result;
	long max = 0;
	while (left < reverse_place.size())
	{
		if (s[reverse_place[left]] == '0')
		{
			if (reverse_place.size() - left < k * 2)
			{
				if (left == 0)
				{
					max = s.size();
				}
				else
				{
					right = reverse_place.size() - 1;
				}
			}
			else
			{
				if (reverse_place.size() < k * 2)
				{
					right = reverse_place.size() - 1;
				}
				else
				{
					right = k * 2 + left;
				}
			}
		}
		else
		{
			if (reverse_place.size() - left < k * 2 + 1)
			{
				if(left==0)
				{
					max = s.size();
				}
				else
				{
					right = reverse_place.size() - 1;
				}
			}
			else
			{
				if (reverse_place.size() < k * 2 + 1)
				{
					right = reverse_place.size() - 1;
				}
				else
				{
					right = k * 2 + 1 + left;
				}
				
			}		
		}
		if (reverse_place[right] < reverse_place[left])
		{
			right = reverse_place.size() - 1;
		}
		result = reverse_place[right] - reverse_place[left];
		if (max < result)
		{
			max = result;
		}
		left++;
	}

	std::cout << max << "\n";
	return 0;
}



Measured memory_bytes: 1528
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/reversed.hpp>
using namespace std;
constexpr char nl = '\n';
using ll = long long;
using boost::irange;
using boost::adaptors::reversed;
struct init_ { init_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_;

template<class C> auto operator>>(istream& in, C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, istream&>::type {
    for (auto& v : c) { in >> v; } return in; }
template<class C> auto operator<<(ostream& out, const C& c) -> typename enable_if<!is_void<decltype(c.begin())>::value && !is_same<C, string>::value, ostream&>::type {
    int i = 0; for (const auto& v : c) { if (i++) { out << ' '; } out << v; } return out; }
template<size_t N, class T, class R> using when_last = typename enable_if<N == tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N, class T, class R> using when_init = typename enable_if<N != tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_last<N, T, istream&> { return in >> get<N>(t); }
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_init<N, T, istream&> { return operator>><N + 1>(in >> get<N>(t), forward<T>(t)); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_last<N, T, ostream&> { return out << get<N>(t); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_init<N, T, ostream&> { return operator<<<N + 1>(out << get<N>(t) << ' ', t); }

#ifdef LOCAL
template<class T> void trace_(const char* s, const T& v) { cerr << s << "=" << v; }
template<class T, class... Ts> void trace_(const char* s, const T& v, const Ts&... vs) { for (; *s != ','; ++s) { cerr << *s; } cerr << "=" << v << ","; trace_(++s, vs...); }
#define TRACE(...) (cerr << "\033[2m\033[33m", trace_(#__VA_ARGS__, __VA_ARGS__), cerr << "\033[0m\n")
#else
#define TRACE(...)
#endif

int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> xs(n);
    cin >> xs;
    ll ans = numeric_limits<ll>::max();
    for (int l : irange(0, n - k + 1)) {
        int r = l + k - 1;
        ll d = xs[r] - xs[l];
        ans = min(ans, min(abs(xs[l]) + d, abs(xs[r]) + d));
    }
    cout << ans << nl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using namespace std;


int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll H,A;
  cin >> H >> A;
  if(H%A == 0) cout << H/A << endl;
  if(H%A != 0) cout << H/A + 1 << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] T = new long[n];
    long[] A = new long[n];
    T[0] = sc.nextLong();
    A[0] = sc.nextLong();
    for(int i = 1; i < n; i++) {
      long t = sc.nextLong();
      long a = sc.nextLong();
      long k = Math.max((T[i - 1] + t - 1) / t, (A[i - 1] + a - 1) / a);
      T[i] = t * k;
      A[i] = a * k;
    }
    System.out.println(T[n - 1] + A[n - 1]);
  }
}



Measured memory_bytes: 25104
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<cstring>
#define SF scanf
#define PF printf
#define MAXN 1100
using namespace std;
int n,wt,ht; 
int xs1[MAXN],ys1[MAXN],xs2[MAXN],ys2[MAXN];
int fld[MAXN*2][MAXN*2];
int w[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
int compress(int *x1,int *x2,int w){
	vector<int> xs;
	for(int i=0;i<n;i++){
		int t1=x1[i];
		int t2=x2[i];
		if(1<=t1&&t1<w) xs.push_back(t1);
		if(1<=t2&&t2<w) xs.push_back(t2);
	}
	xs.push_back(0);
	xs.push_back(w);
	sort(xs.begin(),xs.end());
	xs.erase(unique(xs.begin(),xs.end()),xs.end());//°´×?±?????£¬?\??
	for(int i=0;i<n;i++){
		x1[i]=find(xs.begin(),xs.end(),x1[i])-xs.begin();
		x2[i]=find(xs.begin(),xs.end(),x2[i])-xs.begin();//£¨????????find??????±?????????£?£?£?????×?±? 
	} 
	return xs.size()-1;//?????????¶?§ 
} 
void bfs(int x,int y){
	queue<pair<int,int> > q;
	q.push(make_pair(x,y));
	while(!q.empty()){
		pair<int,int> nxt=q.front();
		q.pop();
		for(int i=0;i<4;i++){
			int x1=nxt.first+w[i][0];
			int y1=nxt.second+w[i][1];
			if(x1>=0&&x1<wt&&y1>=0&&y1<=ht&&fld[x1][y1]==0){
				fld[x1][y1]=1;
				q.push(make_pair(x1,y1));
			}
		}
	}
}
int main(){
	while(SF("%d %d",&wt,&ht)!=EOF){
		memset(fld,0,sizeof fld);
		if(wt==0||ht==0)
			break;
		SF("%d",&n);
		for(int i=0;i<n;i++)
			SF("%d%d%d%d",&xs1[i],&ys1[i],&xs2[i],&ys2[i]);
		wt=compress(xs1,xs2,wt);
		ht=compress(ys1,ys2,ht);
		//????????????imos£¬????????????????£¬????????????????´????°×???
		//??°×??????????sum????±?????????£¬??°´??×???????????´?´????°×??? 
		for(int i=0;i<n;i++){
			fld[xs1[i]][ys1[i]]++;
			fld[xs2[i]][ys1[i]]--;
			fld[xs1[i]][ys2[i]]--;
			fld[xs2[i]][ys2[i]]++;
		} 
		for(int i=0;i<wt;i++)
			for(int j=1;j<ht;j++)
				fld[i][j]+=fld[i][j-1];
		for(int i=1;i<wt;i++)
			for(int j=0;j<ht;j++)
				fld[i][j]+=fld[i-1][j];
		int tot=0;
		for(int i=0;i<wt;i++)
			for(int j=0;j<ht;j++)
				if(fld[i][j]==0){
					//dfs(i,j); 
					//±??????????´??bfs?£?£?±??±¬????´???????????
					bfs(i,j);
					tot++;
				}
		PF("%d\n",tot);
	}
	
}

Measured memory_bytes: 21512
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
struct edge {
    ll to,cost;
};
/*
const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
*/

int main(){
    ll N; cin >> N;
    cout << N*(N-1)/2 << endl;
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

int main() {
    lint R, C, K;
    cin >> R >> C >> K;
    vector<vector<lint>> items(R, vector<lint>(C, LINF));
    rep(i, K) {
        int r, c, v;
        cin >> r >> c >> v;
        r--, c--;
        items[r][c] = v;
    }

    vector<vector<vector<lint>>> ma(
        R, vector<vector<lint>>(C, vector<lint>(4, -LINF)));
    ma[0][0][0] = 0;
    if (items[0][0] != LINF) { ma[0][0][1] = items[0][0]; }

    rep(r, R) rep(c, C) rep(k, 4) {
        // 下に行く場合
        if (r < R - 1) {
            int nr = r + 1, nc = c;
            ma[nr][nc][0] = max(ma[nr][nc][0], ma[r][c][k]);
            if (items[nr][nc] != LINF) {
                ma[nr][nc][1] = max(ma[nr][nc][1], ma[r][c][k] + items[nr][nc]);
            }
        }
        // 右に行く場合

        if (c < C - 1) {
            int nr = r, nc = c + 1;
            ma[nr][nc][k] = max(ma[nr][nc][k], ma[r][c][k]);
            if (items[nr][nc] != LINF && k < 3) {
                ma[nr][nc][k + 1] =
                    max(ma[nr][nc][k + 1], ma[r][c][k] + items[nr][nc]);
            }
        }
    }

    lint ans = -1;
    rep(i, 4) { ans = max(ans, ma[R - 1][C - 1][i]); }
    cout << ans << endl;

    return 0;
}

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


int main(){
    int N; cin >> N;
    //toは隣接リスト
    //costはtoに対応する隣接頂点までの距離
    vector<vector<int>> to(N),cost(N);
    for(int i = 0; i < N-1; i++){
        int u,v,w; cin >> u >> v >> w;
        to[u-1].push_back(v-1);
        to[v-1].push_back(u-1);
        cost[u-1].push_back(w%2); //辺は偶奇のみ記録
        cost[v-1].push_back(w%2);
    }

    vector<int> dist(N,-1); //最小共通祖先からの距離をもつ配列
    queue<int> Q; //関数定義しない幅優先探索に逃げます
    //便利なデータ構造に逃げる私を笑うがいい

    dist[0] = 0;
    Q.push(0); //最初の頂点を入れておく

    //BFS
    while(!Q.empty()){
        int front = Q.front();
        Q.pop();
        for(int i = 0; i < to[front].size(); i++){
            int totmp = to[front][i]; //現在訪れている頂点
            int costtmp = cost[front][i]; //対応する距離
            if(dist[ totmp ] != -1 ) continue; //distが既に分かっているなら飛ばす
            dist[ totmp ] = dist[ front ] + costtmp;
            Q.push(totmp); //現在訪れている点をpushして終了
        }
    }
    for(int i = 0; i < N; i++) cout << dist[i] % 2 << endl;
}

Measured memory_bytes: 11904
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define rep(i, n)for(int i=0; i<n; i++)

//整数nの桁が奇数であればtrueを返す
bool odd_dig(int n){
  int dig = 0;
  while(n != 0){
    n /= 10;
    dig++;
  }
  return dig%2 == 1;
}

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

  int count = 0;
  rep(i, N+1){
    if(odd_dig(i))
      count++;
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
using namespace std;
vector<ll> v;
vector<string> vs;
vector<pair<ll, ll>> vp;
vector<vector<ll>> vv(110, vector<ll>(50, 0));
vector<tuple<ll, ll, ll>> vt;
map<ll, ll> mp;

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

int main()
{
	priority_queue<ll> pq;
	REP(i,3)
	{
		ll t;
		cin >> t;
		pq.push(t);
	}
	pq.pop();
	ll ans = pq.top();
	pq.pop();
	ans += pq.top();
	cout << ans << endl;
}

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

using namespace std;

int dp[110][4][2];

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

    int n = S.size();
    dp[0][0][0] = 1;
    for (int i = 0; i < n; ++i) {// 上からi桁をみる
        for (int j = 0; j < 4; ++j) {// ０でない数はj個
            for (int k = 0; k < 2; ++k) {// 上からi桁がSと等しければk=0。小さければk=1
                int nd = S[i] - '0';// いま見ている桁の数字
                for (int d = 0; d < 10; ++d) {
                    // 上からi+1桁目に0をおくことは常に可能
                    int nj = j;
                    int nk = k;
                    // 上からi+1桁目に0以外をおくとき
                    if (d != 0) nj++;// 0以外の数字は増える
                    if (nj > K) continue; // 増え過ぎたらだめ
                    if (k == 0) { // Sとの大小の確定/未確定が変わる場合
                        if (d > nd) continue;
                        if (d < nd) nk = 1;
                    }
                    dp[i + 1][nj][nk] += dp[i][j][k];
                }
            }
        }
    }

    int ans = dp[n][K][0] + dp[n][K][1];
    cout << ans << endl;
    return 0;
}

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

using namespace std;

using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<ll> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
  int dp[n][2];
  dp[0][0] = dp[0][1] = 1;
  for (int i = 1; i < n; ++i) {
    if (v[i] == v[i - 1]) {
      dp[i][1] = dp[i - 1][1];
      dp[i][0] = dp[i - 1][0];
    }
    if (v[i] - v[i - 1] > 0) {
      dp[i][1] = dp[i - 1][1];
      dp[i][0] = min(dp[i - 1][0], dp[i - 1][1]) + 1;
    } else if (v[i] - v[i - 1] < 0) {
      dp[i][0] = dp[i - 1][0];
      dp[i][1] = min(dp[i - 1][0], dp[i - 1][1]) + 1;
    }
  }
  cout << min(dp[n - 1][0], dp[n - 1][1]) << endl;
}

Measured memory_bytes: 1792
import java.io.*;
import java.util.*;
import java.util.stream.*;

class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		
		double a = saori.Hayamin()*2;
		System.out.println(a*3.1415926535897932384);
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 32948
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

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


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long n, std::string s){
    int ans = 0;
    for(int i = 0; i < n - 2; ++i)
        ans += (s.substr(i, 3) == "ABC");
    cout << ans << endl;
}


signed main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1'000'000'000'000'000'000;
namespace utils{
    template<class T, class Compare> using p_queue = priority_queue<T, vector<T>, Compare>;
    template<class T> using min_queue = p_queue<T, greater<T>>;
    template<class T> using max_queue = p_queue<T, less<T>>;

    template<class T> bool min_update(T& X, const T& A){ if(X > A) {X = A; return true;} return false; }
    template<class T> bool max_update(T& X, const T& A){ if(X < A) {X = A; return true;} return false; }
    using V_Set = unordered_set<int>;
    using E_Set = unordered_map<int, V_Set>;

    ll operator"" _64(unsigned long long x){ return ll(x); }

    ull operator"" _64u(unsigned long long x){ return ull(x); }

#define ALL(x) begin(x), end(x)
#define rALL(x) rbegin(x), rend(x)
}
using namespace utils;


void sub_main(istream &is) {
    ll N;
    is >> N;
    if(!is) return;
    double ans = 1;
    vector<ll> A;
    for (int i = 0; i < N; ++i) {
        ll a;
        is >> a;
        ans *= a;
        A.push_back(a);
    } // end i
    double pa = 0;
    for (int i = 0; i < N; ++i) {
        pa += ans / A[i];
    } // end i
    cout << double(ans) / pa << endl;

}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    string test_cases = "test_B.txt";
    cerr << "DEBUG MODE" <<  endl;
    cerr << test_cases << " -->" << endl;
    auto fs = fstream(test_cases, fstream::in);
    int lp = 0;
    while(fs) {
        lp++;
        cout << lp <<  "#------\n";
        sub_main(fs);
    }
    cout << "------#" << endl;
    if(lp <= 1) sub_main(cin);
#else
    sub_main(cin);
#endif
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

ll dp[110000][2];

int main() {
  string s;
  cin >> s;
  ll ans = 0;

  dp[0][0] = 0;
  dp[0][1] = 1;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == '0') (dp[i+1][1] += dp[i][1]) %= MOD;
    else {
      (dp[i+1][1] += dp[i][1] * 2) %= MOD;
      (dp[i+1][0] += dp[i][1]) %= MOD;
    }
    (dp[i+1][0] += dp[i][0] * 3) %= MOD;
    
  }

  cout << (dp[s.size()][0] + dp[s.size()][1]) % MOD << endl;
}


Measured memory_bytes: 2048
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;

ll num(ll x, ll *a, ll n, ll *b) {
  ll L = -1, R = n, M;
  while (R - L > 1) {
    M = (R + L) >> 1;
    if (b[M] <= x) L = M;
    else R = M;
  }
  ll res = 0;
  for (int i = 0; i < n; i++) {
    //if (a[i] > x) break;
    ll key, l, r, med;
    if (a[i] > 0) {
      l = -1; r = n;
      while (r - l > 1) {
	med = (r + l) >> 1;
	if (a[med]*a[i] <= x) l = med;
	else r = med;
      }
      res += r;
    } else if (a[i] == 0) {
      if (x >= 0) res += n;
    } else if (a[i] < 0) {
      key = x / a[i];
      l = -1; r = n;
      while (r - l > 1) {
	med = (r + l) >> 1;
	if (a[med]*a[i] <= x) r = med;
	else l = med;
      }
      res += n - r;
    }
  }
  return (res - R) / 2;
}
    

int main(void) {

  ll n, k, a[200100];
  cin >> n >> k;
  rep(i, n) cin >> a[i];

  ll b[200100];
  rep(i, n) b[i] = a[i] * a[i];
  sort(b, b + n);

  
  sort(a, a + n);

  ll l = -1000000000000000000, r = 1000000000000000000, med;
  while (r - l > 1) {
    med = (l + r) >> 1;
    //cout << num(med, a, n, b) << endl;
    if (num(med, a, n, b) < k) l = med;
    else r = med;
  }

  cout << r << endl;
  
  return 0;

}
  


Measured memory_bytes: 3328
import java.util.*;
import java.util.Arrays;
import java.util.Set;
public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        int d=Math.min(a,b);
        int e=Math.min(c,b);
        if(d!=e){
            System.out.println(d+e);
        }else{
            System.out.println(d+Math.min(a,c));
        }

        }
        
        
    }


Measured memory_bytes: 21716
n = int(input())
num_list = [int(x) for x in input().split()]
cnt = 0
flag = False
while flag != True:
    for i in num_list:
        if i % 2 != 0:
            flag = True
        
    if flag:
        print(cnt)
        break
    
    for j in range(len(num_list)):
        num_list[j] = num_list[j] / 2
    
    cnt+=1


Measured memory_bytes: 2940
#include<bits/stdc++.h>    
using namespace std;
#define ll long long 
#define pi pair<ll,ll>
#define pd pair<ld,ld>
#define pb push_back
#define inf 1e18
#define mod 1000000007
#define en '\n'
#define ld long double
#define ff first
#define ss second
#define ull unsigned long long 
#define lb lower_bound
#define ub upper_bound
#define fr(a,b,c) for(ll a = b ; a <= c ; ++a )
#define frn(a,b,c) for(ll a = b ; a >= c ; a -- )
#define fra(a,b) for(auto a: b)
#define ms(a) memset(a,0,sizeof a);
#define alla(a) a,a+n
#define allv(a) a.begin(),a.end()
#define size(a) (ll)a.size()
#define getMat(x,n,m,val) vector<vector<ll>>x(n,vector<ll>(m,val))
const ll MAXN = 2e5+5;
#define pii 3.14159265358979323846 
ll pw(ll b, ll r, ll md){
	ll ans = 1;
	while(r){
		if(r&1)ans = (ans*b)%md;
		b = (b*b)%md;
		r>>=1;
	}
	return ans;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n,m,k;cin>>n>>m>>k;
	ll a[n+1],b[m+1];fr(i,0,n-1)cin>>a[i];
	fr(i,0,m-1)cin>>b[i];
	fr(i,1,m-1)b[i]+=b[i-1];
	ll sum = 0;
	ll ans = 0 ; 
	fr(i,0,n){
		ll rem = k-sum;
		if(rem<0)break;
		ll ind = (upper_bound(b,b+m,rem)-b);
		ans = max(ans,i+ind);
		sum+=a[i];
	}
	cout<<ans<<en;
	return 0 ;
}

Measured memory_bytes: 6760
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Darshan
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a, b;
            a = in.nextInt();
            b = in.nextInt();
            if (a > 8 || b > 8) {
                out.println(":(");
            } else
                out.print("Yay!");
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21332
//include <bits/stdc++.h>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <cstring> 
#define db double 
#define LL long long
//#define int LL
#define rep(i,x,y) for (int i=x;i<=y;++i)

using namespace std;
//const int N  =  ;
//const int mod = ;
void read(int &x)
{
	int f=1;
	x=0;
	char ch=getchar();
	while (!isdigit(ch)) (ch=='-'?f=-1:0),ch=getchar();
	while ( isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	x*=f;
	return ;
}
signed main()
{
	int n,m,d;
	read(n);read(m);read(d);
	db ans=(db)2.0*(m-1)*(n-d)/n/n;
	if (d==0) ans/=2.0;
	printf("%.8f",ans);
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>

#define min(a, b) ((a) < (b) ? (a) : (b))

int main()
{
  int n, t, c, l;
  scanf("%d %d %d", &n, &t, &c);
  
  long long ans = 0;
  for (int i = 1; i < n; ++i)
  {
    l = c;
    scanf("%d", &c);
    ans += min(c - l, t);
  }
  ans += t;
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll k, s;
  cin >> k >> s;

  ll ans = 0;

  rep(x, k+1) {
    rep(y, k+1) {
      if (s-x-y >= 0 && s-x-y <= k) ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long lol;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
#define VL vector<lol>
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol result{0};
    lol h, w, m; cin >> h >> w >> m;
    lol row[h+1] = {}, col[w+1] = {};
    map<pair<int, int>, int> sets;
    lol maxrow{0}, maxcol{0};
    REP(i, m)
    {
        lol hi, wi; cin >> hi >> wi;
        sets[make_pair(hi, wi)] = 100;
        row[hi]++;
        maxrow = max(maxrow, row[hi]);
        col[wi]++;
        maxcol = max(maxcol, col[wi]);
    }
    list<int> b;
    FOR(i, 1, w)
    {
        if(col[i] == maxcol)
        {
            b.push_back(i);
        }
    }
    bool TF = false;
    FOR(i, 1, h)
    {
        if(row[i] != maxrow) continue;
        for(list<int>::iterator itr = b.begin(); itr != b.end(); itr++)
        {
            //cout << *itr << endl;
            if(sets[make_pair(i, *itr)] != 100)
            {
                //cout << "a" << endl;
                result = maxcol + maxrow;
                TF = true;
                goto skip;
            }
        }
    }
    if(!TF) result = maxcol + maxrow - 1;
    skip:
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 36436
#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);
    double val = (arr[0]+arr[1])/2.0;
    for(int i=2; i<n; i++)
        val = (val + arr[i])/2.0;
    cout<<fixed<<setprecision(24)<<val;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
typedef vector<char> vc;
typedef vector<vc> vcc;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define F first
#define S second
#define in insert
#define mina(a,b) (a)=min((a),(b));
#define maxa(a,b) (a)=max((a),(b));
const int INF = 1e9 + 7;
void solve(){
    string s; cin>>s;
    int y=(s[0]-'0')*1000+(s[1]-'0')*100+(s[2]-'0')*10+(s[3]-'0');
    int m=(s[5]-'0')*10+(s[6]-'0');
    int d=(s[8]-'0')*10+(s[9]-'0');
    if(y<2019) cout<<"Heisei";
    else if(y>2019) cout<<"TBD";
    else{
        if(m<4) cout<<"Heisei";
        else if(m>4) cout<<"TBD";
        else{
            if(d<=30) cout<<"Heisei";
            else cout<<"TBD";
        }
    }

}
int main(){
    int T=1;
    //cin>>T;
    for(int i = 0; i < T; i++) solve(); 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    string s; cin >> s;
    ll n = s.size();
    ll cnt_bw = 0, cnt_wb = 0;
    ll toggle_bw = 0, toggle_wb = 1;    // 0:Black 1:White
    rep(i, n){
        if(s[i]-'0' != toggle_bw) cnt_bw++;
        if(s[i]-'0' != toggle_wb) cnt_wb++;
        toggle_bw ^= 1;
        toggle_wb ^= 1;
    }
    cout << min(cnt_bw, cnt_wb) << endl;
}

Measured memory_bytes: 512
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<string> v(n);
    rep(i,0,n) cin >> v[i];
    ll ans = 0;
    ll fb = 0, la = 0, ba = 0;
    rep(i,0,n){
        rep(j,0,v[i].size()-1){
            if(v[i][j] == 'A' && v[i][j+1] == 'B')ans++;
        }
        if(v[i][0] == 'B' && v[i].back() == 'A')ba++;
        else if(v[i][0] == 'B')fb++;
        else if(v[i].back() == 'A')la++;
    }
    debug(ba,la,fb,ans);
    if(la + fb >= ba){
        ans += ba;
        ans += min(la, fb);
    }
    else{
        ans += min(la, fb) + ba;
        if(max(la, fb) == 0)ans -= 1;
    }

    cout << ans << endl;
}

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

using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using f64 = double;
using f80 = long double;

#define FOR(v, a, b) for(i64 v = (a); v < (b); ++v)
#define FORE(v, a, b) for(i64 v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(i64 v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

using namespace std;

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T> void pout(const T &value){std::cout << value << "\n";}
template <typename T, typename ...Args> void pout(const T &value, const Args&... args){std::cout << value << " ";pout(args...);}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}
template <typename T> auto make_vector(int n, int m, const T &value){return vector<vector<T>>(n, vector<T>(m, value));}


struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  int N, M;
  while(cin >> N >> M){
    vector<i64> A(M); cin >> A;

    i64 s = accumulate(ALL(A), 0LL);

    if(s > N){
      pout(-1);
    }else{
      pout(N-s);
    }
  }


  return 0;
}


Measured memory_bytes: 3736
#include<bits/stdc++.h>
#include<cctype>
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 rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;


int main(){
  int N, M, K; cin >> N >> M >> K;
  vector<vector<int>> G(N);
  rep(i,M){
    int a, b; cin >> a >> b;
    --a, --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  vector<int> num(N, -1);
  vector<int> gnum(N,0);
  int c = 0;
  rep(i,N){
    if (num[i]!=-1) continue;

    queue<int> q;
    num[i] = c;
    gnum[c]++;
    q.push(i);
    while (!q.empty()){
      int v = q.front(); q.pop();
      for (auto p : G[v]){
        if (num[p]==-1) {
          num[p] = c;
          gnum[c]++;
          q.push(p);
        }
      }
    }
    c++;
  }
  int ans[N];
  rep(i,N){
    ans[i] = gnum[num[i]]-1 - G[i].size();
  }

  vector<vector<int>> B(N);
  rep(i,K){
    int c, d; cin >> c >> d;
    --c, --d;
    if (num[c]==num[d]) {
      ans[c]--;
      ans[d]--;
    }
  }
  rep(i,N) {
    if (i>0) cout << " ";
    cout << ans[i];
  }
  cout << endl;


  




  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 12800
import java.util.*;
 
 
public class Main {
    public static void main(String[] args) {
 
        Scanner sn = new Scanner(System.in);
        int N = sn.nextInt();
        int M = sn.nextInt();
        
        if(N == M){
          System.out.print("Yes");
        }else{
          System.out.print("No");
        } 
	}
}

Measured memory_bytes: 21716
import sys
input = sys.stdin.readline

from heapq import heappush, heappushpop

"""
銅貨の集合を固定すると、金-銀でソートして貪欲に金をとることになる
逆に金-銀でソートしておくと、金が埋まるまでは金or銅の2択

最後にとる金の番号X+nをfix → 手前は金-銅で貪欲 → queueで管理できる
"""

X,Y,Z = map(int,input().split())
ABC = [[int(x) for x in input().split()] for _ in range(X+Y+Z)]

ABC.sort(key = lambda x: x[0]-x[1],reverse=True)

q = []
sum_a = 0
sum_c = 0
for a,b,c in ABC[:X]:
    # 金を入れる。銅-金の優先度
    heappush(q,(a-c,a))
    sum_a += a
A = [0] * (Z+1)
LC = [0] * (Z+1)
A[0] = sum_a
for i,(a,b,c) in enumerate(ABC[X:X+Z],1):
    sum_a += a
    x,del_a = heappushpop(q,(a-c,a))
    sum_a -= del_a
    sum_c += del_a-x
    A[i] = sum_a
    LC[i] = sum_c

ABC_rev = ABC[::-1]
q = []
sum_b = 0
sum_c = 0
for a,b,c in ABC_rev[:Y]:
    heappush(q,(b-c,b))
    sum_b += b
B = [0] * (Z+1)
RC = [0] * (Z+1)
B[0] += sum_b
for i,(a,b,c) in enumerate(ABC_rev[Y:Y+Z],1):
    sum_b += b
    x,del_b = heappushpop(q,(b-c,b))
    sum_b -= del_b
    sum_c += del_b-x
    B[i] = sum_b
    RC[i] = sum_c

answer = max(sum(x) for x in zip(A,LC,B[::-1],RC[::-1]))
print(answer)



Measured memory_bytes: 39276
#include <bits/stdc++.h>
using namespace std;
int main(){
	vector<int> x(5);
	for (int i = 0; i < 5; i++){
    cin >> x.at(i);
    	if(x.at(i) == 0){
        cout << i+1 ;
        }
    }
  cout << endl;
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

LL N,M;

int main(){
	cin >> N >> M;
	if(N == 1 || M == 1){
		if(N+M==2) cout << 1 << endl;
		else if(N+M==3) cout << 0 << endl;
		else cout << N+M-3 << endl;
	} else {
		cout << (N-2) * (M-2) << endl;
	}
	return 0;
}


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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ld PI = 3.14159265359;

const ll MOD = (ll) 1e9 + 7;
const ll MAXN = (ll) 1e5 + 10;
const ll INF = (ll) 2242545357980376863;
const ld EPS = (ld) 1e-12;

vector<ll> G[MAXN];

ll ans= 0;

ll DFS(ll u, ll p){
	ll s = 0, cnt = 0;
	for(auto adj : G[u]){
		if(adj == p) continue;
		cnt ++;
		s += DFS(adj, u);
	}
	if(cnt == 0) return 1;
	if(cnt == 1) return s;
	ans += max(s - 1ll, 0ll);
	return 0;
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n;
	cin >> n;
	ll u, v;
	for(int i = 1; i < n; i++){
		cin >> u >> v;
		G[u].pb(v);
		G[v].pb(u);
	}
	ll cnt = 0;
	for(int i = 0;i<n;i++) if(G[i].size() != 2) cnt ++;
	if(cnt == 2) return cout << 1, 0;
	ll ind = 0;
	for(int i = 0; i < n; i++) if(G[i].size() > 2) ind = i;
	DFS(ind, -1);
	cout << ans;	
	return 0;
}


/*

                                 ____              ,----..               ,----..
   ,---,                       ,'  , `.           /   /   \             /   /   \
  '  .' \                   ,-+-,.' _ |          /   .     :           /   .     :
 /  ;    '.              ,-+-. ;   , ||         .   /   ;.  \         .   /   ;.  \
:  :       \            ,--.'|'   |  ;|        .   ;   /  ` ;        .   ;   /  ` ;
:  |   /\   \          |   |  ,', |  ':        ;   |  ; \ ; |        ;   |  ; \ ; |
|  :  ' ;.   :         |   | /  | |  ||        |   :  | ; | '        |   :  | ; | '
|  |  ;/  \   \        '   | :  | :  |,        .   |  ' ' ' :        .   |  ' ' ' :
'  :  | \  \ ,'        ;   . |  ; |--'         '   ;  \; /  |        '   ;  \; /  |
|  |  '  '--'          |   : |  | ,             \   \  ',  /          \   \  ',  /
|  :  :                |   : '  |/               ;   :    /            ;   :    /
|  | ,'                ;   | |`-'                 \   \ .'              \   \ .'
`--''                  |   ;/                      `---`                 `---`
                       '---'

*/




Measured memory_bytes: 9472
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int main() {
  int k, a, b;
  cin >> k >> a >> b; k++;
  if (k <= a || b - a < 2) {
    cout << k << endl;
    return 0;
  }
  long long ans = a;
  k -= a;
  ans += (1ll * (k / 2) * (b - a)) + k % 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
<?php
  fscanf(STDIN, "%d%d", $n, $m);
  if($n == 1 && $m == 1){
      echo "1";
  }else if($n == 1){
      echo $m-2;
  }else if($m == 1){
      echo $n-2;
  }else if($n == 2 || $m == 2){
      echo "0";
  }else{
      echo ($n*$m)-(($n*2)+($m-2)*2);
  }

Measured memory_bytes: 4604
#! /usr/bin/env/python3

line = input().split()

west_leave = int(line[0])
east_leave = int(line[1])
for tower in range(1000):
    west_tower = (tower * (tower+1))/2
    east_tower = ((tower+1) * (tower+2))/2
    if( (west_tower - west_leave) == (east_tower - east_leave) ):
        print (int(west_tower - west_leave))


Measured memory_bytes: 2940