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

#define all(x) (x).begin(), (x).end()
#define sz(x) static_cast<int>((x).size())

using LL = long long;
template<class T, size_t D>
struct vec : vector<vec<T, D - 1>> {
  template<class... Args>
  vec(size_t n = 0, Args... args)
    : vector<vec<T, D - 1>>(n, vec<T, D - 1>(args...)) {}
};
template<class T>
struct vec<T, 1> : vector<T> {
  template<class... Args>
  vec(Args... args)
    : vector<T>(args...) {}
};

template<class T>
inline bool asMn(T& a, const T& b) { return a > b ? a = b, true : false; }
template<class T>
inline bool asMx(T& a, const T& b) { return a < b ? a = b, true : false; }
inline int nex(int i, int n) { return i == n - 1 ? 0 : i + 1; }
inline int pre(int i, int n) { return !i ? n - 1 : i - 1; }

const int INF = 1e9;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

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

  int n; cin >> n;
  vec<int, 2> adjEdge(n);
  for (int i = 1; i < n; ++i) {
    int u, v; cin >> u >> v; --u; --v;
    adjEdge[u].emplace_back(v);
    adjEdge[v].emplace_back(u);
  }
  vec<int, 1> a(n, -1);
  int k; cin >> k;
  while (k--) {
    int u, val; cin >> u >> val; --u;
    a[u] = val;
  }

  int root = static_cast<int>(find_if(all(a), [&](int i) { return ~i; }) - a.begin());
  vec<int, 1> prt(n); prt[root] = a[root] & 1;
  function<void(int, int)> calPrt = [&](int u, int par) {
    for (auto& v : adjEdge[u]) {
      if (v != par) {
        prt[v] = prt[u] ^ 1;
        calPrt(v, u);
      }
    }
  };
  calPrt(root, -1);
  for (int i = 0; i < n; ++i) {
    if (~a[i] && prt[i] != (a[i] & 1)) {
      cout << "No\n";
      return 0;
    }
  }

  vec<pair<int, int>, 1> range(n);
  function<void(int, int)> solve = [&](int u, int par) {
    range[u] = ~a[u] ? pair<int, int>{a[u], a[u]} : pair<int, int>{-INF, INF};
    if ((range[u].first & 1) != prt[u]) {
      ++range[u].first;
    }
    if ((range[u].second & 1) != prt[u]) {
      --range[u].second;
    }
    for (auto& v : adjEdge[u]) {
      if (v != par) {
        solve(v, u);
        asMx(range[u].first, range[v].first - 1);
        asMn(range[u].second, range[v].second + 1);
      }
    }
  };
  solve(root, -1);
  for (int i = 0; i < n; ++i) {
    if (range[i].first > range[i].second) {
      cout << "No\n";
      return 0;
    }
  }

  function<void(int, int)> trace = [&](int u, int par) {
    for (auto& v : adjEdge[u]) {
      if (v != par) {
        if (range[v].first <= a[u] - 1 && a[u] - 1 <= range[v].second) {
          a[v] = a[u] - 1;
        } else {
          a[v] = a[u] + 1;
        }
        trace(v, u);
      }
    }
  };
  trace(root, -1);
  cout << "Yes\n";
  for (auto& i : a) {
    cout << i << '\n';
  }

  return 0;
}


Measured memory_bytes: 19556
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <unordered_map>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k>0){
        if(k%2==1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k/=2;
    }
    return ans;
}
ll inv(ll a){
	return powmod(a, MOD-2);
}
ll f[8001];
ll invf[8001];
void fact(){
  f[0]=1;
  for(ll i=1; i<=8000; i++) f[i]=f[i-1]*i%MOD;
  invf[8000]=inv(f[8000]);
  for(ll i=7999; i>=0; i--) invf[i]=invf[i+1]*(i+1)%MOD;
}
ll cb[4001][4001];
ll comb(int a, int b){
  return f[a]*invf[b]%MOD*invf[a-b]%MOD;
}
void combcalc(){
  for(int i=0; i<=4000; i++){
    for(int j=0; j<=i; j++){
      cb[i][j]=comb(i, j);
    }
  }
}
int main()
{
	int n;
  cin>>n;
  fact(); combcalc();
  ll p[4001]={}, p0[4001]={};
  ll ct=0;
  for(int i=0; i<n; i++){
    int a, b; cin>>a>>b;
    ct+=comb(2*(a+b), 2*a);
    ct%=MOD;
    for(int j=0; j<=2000-a; j++){
      if((2000-a-j)%2) p[a+b+j]+=(MOD-cb[2000-a][j]);
      else p[a+b+j]+=cb[2000-a][j];
      p[a+b+j]%=MOD;
    }
  }
  for(int i=0; i<=4000; i++){
    for(int j=0; j<=i; j++){
      p0[j]+=(p[i]*cb[i][j]);
      p0[j]%=MOD;
    }
  }
  ll ans=0;
  for(int i=0; i<=4000; i++){
    ans+=(p0[i]*p0[4000-i]);
    ans%=MOD;
  }
  cout<<(ans-ct+MOD)*500000004%MOD<<endl;
	return 0;
}


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

using namespace std;

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

    int a,b;

    cin >> a >> b;

    int c;

    if (a>=13){
        c = b;
    }
    else if(a<=5){
        c = 0;
    }
    else{
        c = (int) b/2;
    }

    cout << c << endl; 

    return 0;
}

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

int main(){
	int n;
  	cin >> n;
  vector<int> A(n);
  for (auto &a: A)
    cin >> a;
  
  vector<int> B(n);
  
  for (int i = 1; i < n; i++)
    B[0] ^= A[i];
  
  int S = B[0] ^ A[0];
  
  cout << B[0] << " ";
  for (int i = 1; i < n; i++)
    cout << (S ^ A[i]) << " ";

}

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

#define int long long

int n; string s;

void solve() {
      int k; cin >> k;
      int ans = 0;

      int mcur = 0, dcur = 0;
      int ccur = 0;
      for (int i = 0; i < k; i++) {
            if (s[i] == 'D') {
                  dcur++;
            } else if (s[i] == 'M') {
                  mcur++;
                  ccur += dcur;
            } else if (s[i] == 'C') {
                  ans += ccur;
            }
      }

      for (int i = k; i < n; i++) {
            if (s[i-k] == 'D') {
                  ccur -= mcur;
                  dcur--;
            } else if (s[i-k] == 'M') {
                  mcur--;
            } else if (s[i-k] == 'C') {

            }

            if (s[i] == 'D') {
                  dcur++;
            } else if (s[i] == 'M') {
                  mcur++;
                  ccur += dcur;
            } else if (s[i] == 'C') {
                  ans += ccur;
            }
      }
      cout << ans << '\n';
}

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

      cin >> n >> s;
      int q; cin >> q;
      while (q--) {
            solve();
      }

      return 0;
}



Measured memory_bytes: 1948
def main():
    k,x = map(int,input().split())
    ans = set()
    for i in range(k):
        if  -1000000<=x+i<=1000000:
            ans.add(x+i)
        if  -1000000<=x-i<=1000000:
            ans.add(x-i)
    ans = list(ans)
    ans = sorted(ans)
    for i in ans:
        print(i,end=" ")
if __name__ == '__main__':
    main()

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>string join(const vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T>ostream& operator<<(ostream& o, const vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, const vector<vector<T> >&vv)
{int l=vv.size();if(l){o<<endl;rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const ll INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int h, w, k;
vector<string> s;
vvi cs;

int sum(int si, int sj, int ti, int tj){
    return cs[ti][tj] - cs[ti][sj] - cs[si][tj] + cs[si][sj];
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    cin >> h >> w >> k;
    s = vector<string>(h);
    rep(i,h) cin >> s[i];
    cs = vvi(h+1,vi(w+1));

    rep(i,h) rep(j,w){
        int c = s[i][j] - '0';
        cs[i+1][j+1] = cs[i+1][j] + cs[i][j+1] - cs[i][j] + c;
    }
    int ans = INF;
    rep(bit,1<<(h-1)){
        vi H;
        H.push_back(0);
        rep(i,h-1) if(bit>>i & 1) H.push_back(i+1);
        H.push_back(h);
        int nh = H.size();

        bool ok = true;
        int cnt = 0, pj = 0;
        rep(j,w+1){
            rep(i,nh-1){
                if(sum(H[i],pj,H[i+1],j) > k){
                    if(j - pj == 1) ok = false;
                    cnt += 1;
                    pj = j-1;
                    break;
                }
            }
        }
        if(ok) ans = min(ans, nh-2 + cnt);
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
	int h, m, s;
	cin >> s;
	h = s / 3600;
	m = (s % 3600) / 60;
	s = s % 60;
	cout << h << ":" << m << ":" << s << endl;
	return 0;

	
}


Measured memory_bytes: 3096
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
mt19937 mrand(random_device{}());

void calc(string ss){
    ll n = ss.size();
    vector<ll> cur;
    rep(i,0,n) cur.push_back(ss[i] - '1');
    rrep(t,n-1,1){
        vector<ll> nxt;
        rep(i,0,t){
            nxt.push_back(abs(cur[i] - cur[i+1]));
        }
        cur = nxt;
        // printa(cur, t);
    }
    if(cur[0] == 1) print(ss);
    // print(cur[0]);
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    string A;
    cin >> A;
    // ll T = 10;
    ll M = N-1;
    ll cnt2 = 0;
    rep(i,0,N){
        if(A[i] == '2') cnt2++;
    }
    bool check[1000010] = {};
    check[0] = true;
    check[N-1] = true;
    rep(i,1,N-1){
        if((M&i) == i){
            check[i] = true;
        }else{
            check[i] = false;
        }
    }
    ll cnt = 0;
    if(cnt2 == 0){
        rep(i,0,N){
            if(check[i] == true && A[i] == '3') cnt++;
        }
        if(cnt % 2 == 1){
            print(2);
        }else{
            print(0);
        }
    }else{
        rep(i,0,N){
            if(check[i] == true && (A[i] - '0') % 2 == 1) cnt++;
        }
        if(cnt % 2 == 1){
            print(1);
        }else{
            print(0);
        }
    }

    // while(T--){
    //     ll N = 5;
    //     string ss = "";
    //     rep(i,0,N){
    //         ll r = mrand() % 2;
    //         ss += to_string(r);
    //     }
    //     calc(ss);
    // }
    // rep(bit,0,(1LL<<10)){
    //     string ss = "";
    //     rep(i,0,10){
    //         if((bit>>i) & 1) ss += '1';
    //         else ss += '0';
    //     }
    //     reverse(ss.begin(), ss.end());
    //     calc(ss);
    // }
    // ll n = 22;
    // rep(i,0,n){
    //     string ss = "";
    //     rep(j,0,n){
    //         if(i == j){
    //             ss += '1';
    //         }else{
    //             ss += '0';
    //         }
    //     }
    //     calc(ss);
    // }

    

}

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

#define int long long
#define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)x.size())
template <class T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> using V = vector<T>;
using P = pair<int, int>;

/*
 */

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

  set<string> st;
  rep(i, 0, n){
    string s;
    cin >> s;
    st.insert(s);
  }

  cout << sz(st) << endl;

  return 0;
}


Measured memory_bytes: 19176
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines

# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
	n,m,k=map(int,input().split())
	u=UnionFind(n)
	f=[-1]*n
	for i in range(m):
		a,b=map(int,input().split())
		u.union(a-1,b-1)
		f[a-1]-=1
		f[b-1]-=1
	
	for i in range(k):
		a, b = map(int, input().split())
		if u.same(a-1,b-1):
			f[a - 1] -= 1
			f[b - 1] -= 1
	
	for i in range(n):
		f[i]+=u.size(i)
	
	print(*f)
	
	

if __name__ == "__main__":
	main()


Measured memory_bytes: 82140
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <assert.h>
using namespace std;

typedef long long ll;
#define REP(i,n) for (ll i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

int main ()
{
	int N,K;
	cin >> N >> K;
	int ans = 0;
	
	for (int i = 1; i <= N; i++) {
		if (i % 2 == 1) ans++;
	}

	if (ans >= K) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}

	return 0;
}


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

template<class T>
ostream& operator<<(ostream& os,vector<T> const& v){for(auto itr=v.begin();itr!=v.end();++itr){if(itr!=v.begin())os<<' ';os<<*itr;}return os;}

signed main(){

  int n;
  cin>>n;
  vector<int> a(n);
  for(auto& ai:a)cin>>ai;

  int q;
  cin>>q;
  while(q--){
    int b,e,t;
    cin>>b>>e>>t;
    swap_ranges(a.begin()+b,a.begin()+e,a.begin()+t);
  }
  cout<<(a)<<endl;

}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}


ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

int main(){
  int n;string s;cin>>n>>s;
  
 
 rep(i,s.size()) {
    int x=s[i]-'A';//文字を数に変換してAの時に0を返すように規格化している。
   
   x+=n;
    x%=26;
    s[i]=(char)(x+'A');//数を文字に変換。数を65('A')に戻している。
  }
  cout <<s<<endl;
}
  


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ll;


using Graph = vector<vector<int>>;//グラフ型
void dfs(const Graph& G, int v/*根*/, vector<bool>& seen) {
	seen[v] = true;  //vを訪問済にする
	for (auto next_v : G[v]) { //訪問済にしたvとつながっている場所を順番に探す
		if (seen[next_v]) continue; //もし探索済みならスルー
		dfs(G, next_v, seen); //再帰的に探索
	}
}

void bfs(const Graph& G, queue<int>& que/*発見したが訪問はしていない*/, vector<int>& dist/*開始地点からの距離*/) {
	
	while (!que.empty()) {
		int v = que.front();//queのうち先頭のものからスタート
		que.pop();//先頭を削除

		for (int nv : G[v]) {//vとつながっている点を列挙
			if (dist[nv] != -1) continue;//発見済(=距離が格納されている)であればスルー
			dist[nv] = dist[v] + 1;//vとつながっている点に距離の情報を追加
			que.push(nv);//vとつながっている点を発見済にする
		}
	}
}

int main(void) {
	ll n;
	cin >> n;
	vector<ll>s(n, 0);
	vector<ll>a(n);
	ll q = 0;
	for (ll i = 0; i < n; ++i) {
		cin >> a[i];
		s[a[i] - 1]++;
	}
	for (ll i = 0; i < n; ++i) {
		q += s[i] * (s[i] - 1) / 2;
	}
	for (ll i = 0; i < n; ++i) {
		--s[a[i] - 1];
		cout << q - s[a[i] - 1] << endl;
		++s[a[i] - 1];
	}
}

/*
2 1  1
3 3  2
4 6  3
5 10 4

*/

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

using namespace std;
int ans[100005];
bool prime[100005];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    for (int i = 1; i <= 100000; i++)
        prime[i] = true;
    prime[1] = false;
    for (int i = 2; i * i <= 100000; i++)
    {
        if (!prime[i]) continue;
        for (int j = i * i; j <= 100000; j += i)
            prime[j] = false;
    }
    ans[0] = 0;
    for (int i = 1; i <= 100000; i++)
    {
        ans[i] = ans[i - 1];
        if (i % 2 == 1 && prime[i] && prime[(i + 1) / 2]) ans[i]++;
    }

    int q;
    cin >> q;
    for (int i = 1; i <= q; i++)
    {
        int l, r;
        cin >> l >> r;
        cout << ans[r] - ans[l - 1] << '\n';
    }
    return 0;
}



Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    cout << a*b/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i,n,N[10000],q,cnt=0,j,p;
  //arry input
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&N[i]);
  //-------
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&p);
    for(j=0;j<n;j++)
      if(N[j]==p){
	cnt++;
	break;
      }
  }
  printf("%d\n",cnt);
  return 0;
}



Measured memory_bytes: 2108
# coding=utf-8
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heappushpop, heapify
import copy
import sys
INF = float('inf')
mod = 10**9+7
sys.setrecursionlimit(10 ** 6)


def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


n = I()
cnt = 0
flg = 0
for i in range(n):
    d1, d2 = LI()
    if d1 == d2:
        cnt += 1
    else:
        cnt = 0
    if cnt > 2:
        flg = 1
if flg:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 67992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    map<ll,bool>m;
    ll ans=0;
    rep(i,N){
        ll d;
        cin>>d;
        if(m[d]==0){
            ans++;
            m[d]=1;
        }
    }
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int n;
  cin>>n;
  string s;
  cin>>s;
  string ns = "";
  REP(i,2*n){
    if(i%2==0){
      if(s[i]=='B'){
        ns += 'W';
      }else{
        ns += 'B';
      }
    }else{
      ns += s[i];
    }
  }
  
  long long ans = 1;
  long long cnt = 0;
  int bnum = 0;
  REP(i,2*n){
    if(ns[i]=='W'){
      cnt++;
    }else{
      if(cnt==0){
        ans = 0;
        break;
      }else{
        ans *= cnt;
        ans = mod(ans);
        cnt--;
      }
    }
  }
  
  REP(i,2*n){
    if(ns[i]=='B'){
      bnum++;
    }
  }
  if(bnum != n){
    ans = 0;
  }
  
  if(ans==0){
    cout<<0<<endl;
    return 0;
  }
  
  for(long long i=1;i<=(long long)n;i++){
    ans *= i;
    ans = mod(ans);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 776
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, M = [int(x) for x in input().split()]

    print(M * (M - 1) // 2 + N * (N - 1) // 2)


if __name__ == '__main__':
    main()



Measured memory_bytes: 2940
#include<stdio.h>
int main()
{
	long long  x,y,z;
	scanf("%lld%lld%lld",&x,&y,&z);
	int lose=0;long long anc=1;
	if(y-z<=0&&y>=x)
		lose=1;
	else
		if(y-z>0)
		{
			
			anc=(x-y)/(y-z);
			if(anc*(y-z)+y>=x)  
				anc=anc*2+1;
			else
			{
				anc=(anc+1)*2+1;
			}
			lose=1;
		}
		else
			lose=0;
	if(lose)
		printf("%lld\n",anc);
	else
		printf("-1\n");
		
} 

Measured memory_bytes: 128
function main(input) {
    var arr = input.replace(/\r?\n/g, "").split(" ");
    const A = parseInt(arr[0]), B = parseInt(arr[1]), C = parseInt(arr[2]);
    if (A == B && B == C) console.log("No");
    else console.log(arr.some(v => v == (A ^ B ^ C)) ? "Yes" : "No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define ll long long
#define all(a) (a).begin(), (a).end()
#define int long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz() size()
#define fr first
#define sc second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define rc(s) return cout<<s,0
using namespace std;

int n,ans1,ans2;
string s,a,b;


int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie();cout.tie();
    cin >> s;
    n=s.size();
    for(int i=0;i<n;i++){
        if(i%2==1){
            a.push_back('1');
            b.push_back('0');
        }
        else{
            a.push_back('0');
            b.push_back('1');
        }
    }
    for(int i=1;i<=n;i++){
        if(s[i-1]!=a[i-1]) ans1++;
        if(s[i-1]!=b[i-1]) ans2++;
    }
    cout<<min(ans1,ans2);
}



Measured memory_bytes: 720
#include<bits/stdc++.h>
#define title "title"
#define ll long long
#define ull unsigned ll
#define fix(x) fixed<<setprecision(x)
#define pii pair<int,int>
#define vint vector<int>
#define pb push_back
using namespace std;
void Freopen(){
	freopen(title".in","r",stdin);
	freopen(title".out","w",stdout);
}
int read(){
	int g=0,f=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch&&ch<='9'){g=g*10+ch-'0';ch=getchar();}
	return g*f;
}
const int N=605;
bool vis[N][N];
int n,d1,d2,cnt;
void solve(int dis){
	int tim=0;
	while(!(dis%4))dis/=4,tim++;
	if(dis&1){for(int i=0;i<n<<1;i++)for(int j=0;j<n<<1;j++)if((i>>tim)+(j>>tim)&1)vis[i][j]=true;}
	else{for(int i=0;i<n<<1;i++)for(int j=0;j<n<<1;j++)if((i>>tim)&1)vis[i][j]=true;}
}
signed main(){
	n=read(),d1=read(),d2=read();
	solve(d1),solve(d2);
	for(int i=0;i<n<<1;i++)for(int j=0;j<n<<1;j++){
		if(!vis[i][j])cout<<i<<' '<<j<<'\n',cnt++;
		if(cnt==n*n)return signed();
	}return signed();
}

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

int main(){
 int n;
 cin >> n;
 vector<int> v(n),c(n);
 rep(i,n) cin >> v[i];
 rep(i,n) cin >> c[i];
 int ans = 0;
 rep(i,n){
     if(v[i] > c[i]){
         ans += v[i]-c[i];
     }
 }
 cout <<ans<< endl;

}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    string s;
    cin >> s;
    bool ans = true;
    REP(i, size(s)){
        if(i%2 == 0) ans &= (s[i] != 'L');
        else ans &= (s[i] != 'R');
    }
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=input()

moi=[['x'] for i in range(K)]

for i in range(N):
    moi[i%K].append(T[i])

for i in range(K):
    moi[i].pop(0)

moji=''

for i in range(K):
    cnt=0
    for j in range(len(moi[i])):
        if j==0:
            moji+=moi[i][j]
        else:
            if moi[i][j-1]!=moi[i][j]:
                moji+=moi[i][j]
                cnt=0
            if moi[i][j-1]==moi[i][j] and cnt==1:
                moji+=moi[i][j]
                cnt=0
            elif moi[i][j-1]==moi[i][j] and cnt==0:
                cnt+=1

ans=0
for i in range(len(moji)):
    if moji[i]=='r':
        ans+=P
    elif moji[i]=='s':
        ans+=R
    else:
        ans+=S

print(ans)

Measured memory_bytes: 19588
#include <algorithm>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<vector<int> > group((n + 1) / 2);
  if (n & 1) {
    FOR(i, 1, (n + 1) / 2) group[i - 1] = {i, n - i};
    group.back() = {n};
  } else {
    FOR(i, 1, n / 2 + 1) group[i - 1] = {i, n + 1 - i};
  }
  vector<int> a, b;
  REP(i, (n + 1) / 2) {
    for (int e : group[i]) {
      FOR(j, i + 1, (n + 1) / 2) {
        for (int ee : group[j]) {
          a.emplace_back(e);
          b.emplace_back(ee);
        }
      }
    }
  }
  cout << a.size() << '\n';
  REP(i, a.size()) cout << a[i] << ' ' << b[i] << '\n';
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  ll N,A,B,C,D;
  cin >> N >> A >> B >> C >> D;
  ll d=A-B;
  rep(x,N) {
    int y=N-1-x;
    ll l=C*x-D*y;
    ll r=D*x-C*y;
    if(l<=d&&d<=r) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3648
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())

d = (T1 * A1 - T1 * B1) + (T2 * A2 - T2 * B2)
d1 = (T1 * A1 - T1 * B1)

import math
if d == 0:
    ans = 'infinity'
else:
    ans = 0

    # T1
    if d1 == 0:
        ans += 1
    elif d * d1 < 0:
        ans += abs(d1) // abs(d)

    # T2
    if d1 * d < 0:
        ans += math.ceil(abs(d1) / abs(d))

print(ans)


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

using namespace std;

#define ll long long int
#define inf 0x3f3f3f3f
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define ii pair<int, int>
#define all(x) (x).begin(), (x).end()
#define N 1000007 // 10e6 + 7

int dp[N];

int n;
int h[N];


int go(int curr){
 	int &ret = dp[curr];
 	if(ret!=-1)return ret;
 	if(curr==n-1)return ret=0;
 	ret=inf;
 	for(int i=curr+1; i<min(n, curr+3); i++){
 		ret=min(ret, go(i)+abs(h[i]-h[curr]));
 	}
 	return ret;
}

int main(int argc, char const *argv[]){
	cin >> n;
	memset(dp, -1, sizeof dp);

	for(int i=0; i<n; i++){
		cin >> h[i];
	}
	cout << go(0) << endl;
	return 0;
}

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



int main(){
    int N;
    cin >> N;
    vector<int> retu(N);
    for(int i = 0;i<N;i++){
        cin >> retu.at(i);
    }

    sort(retu.begin(),retu.end());
    reverse(retu.begin(),retu.end());

    cout << retu.at(0) - retu.back() << endl;
}

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

int main(){
    int a,b,c;
    int count = 0;
    cin >> a >> b >> c;
    for(int i = a; i <= b; i++){
        if(c % i == 0){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

char s[15];
int pos[15];
long long num(int l,int r)
{
    long long ans=0;
    for(int i=l;i<=r;i++)
    {
        ans=ans*10+s[i]-'0';
    }
    return ans;
}
long long solve(int n)
{
    int l=-1,r=0;
    long long ans=0;
    pos[n]=1;
    for(int i=0;i<=n;i++)
    {
        if(pos[i]==0)
            r++;
        else
        {
            ans+=num(l+1,i);
            l=i;
        }
    }
    return ans;
}
int main()
{
    scanf("%s",s);
    int n=strlen(s);
    long long ans=0;
    int R= (1<<(n-1))-1 ;
    for(int i=0;i<=R;i++)
    {
        memset(pos,0,sizeof(pos));
        int tot=0;
        int temp=i;
        while(temp)
        {
            pos[tot++]=temp%2;
            temp=temp/2;
        }
        ans+=solve(n-1);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let k: usize = scan(tokens);
    let r = n % k;
    let ans = std::cmp::min(r, k - r);
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define sz(x) (int)((x).size())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define FOR(i, a, n, step) for (int (i) = (a); (i) < (int)(n); (i) += (step))
#define ROF(i, a, n, step) for (int (i) = (a); (i) >= (int)(n); (i) += (step))
#define FOREACH(it, v) for (auto (it) : (v))

using namespace std;

typedef unsigned long long ull;
typedef long long ll ;
typedef long double ld;
typedef pair <int, int> pii;

template <class T>
const bool is_impar(const T &x) {return (bool) (x & 1);}

string S, T;
bool ok;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> S >> T;
    for (int i = 0; i < sz(T); i++) {
        string Trot;
        for (int i1 = i; i1 < sz(T); i1++)
            Trot += T[i1];
        for (int i1 = 0; i1 < i; i1++)
            Trot += T[i1];
        ok |= (S == Trot);
    }

    if (ok) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

class TopologicalSort{
    public:
        int n;
        vector<vector<int>> edge;
        vector<int> sorted;
        vector<int> mark;

        TopologicalSort(int n, vector<vector<int>>edge)
            : n(n), edge(edge), sorted(), mark(n) {}

        bool sort(){
            rep(i, n){
                if(mark[i] != 0){
                    continue;
                }
                if(not dfs(i)){
                    return false;
                }
            }
            return true;
        }

        //sortedが辞書順最小
        bool kahn_sort(){
            priority_queue<int, vector<int>, greater<int>> s;
            vector<int> in(n);

            rep(v, n){
                for(int u : edge[v]) in[u]++;
            }

            rep(v, n){
                if(in[v] == 0) s.push(v);
            }

            while(not s.empty()){
                int v = s.top();
                sorted.push_back(v);
                s.pop();

                for(int u : edge[v]){
                    in[u]--;
                    if(in[u] == 0){
                        s.push(u);
                    }
                }
            }

            rep(i, n){
                if(in[i] > 0){
                    return false;
                }
            }
            return true;
        }

    private:
        bool dfs(int v){
            if(mark[v] == -1){
                return false;
            }
            if(mark[v] == 1){
                return true;
            }
            mark[v] = -1;

            for(int u : edge[v]){
                if(not dfs(u)){
                    return false;
                }
            }

            mark[v] = 1;
            sorted.push_back(v);
            return true;
        }
};

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

    int n, m;
    cin >> n >> m;
    vector<vector<int>> edge(n, vector<int>());
    rep(i, m){
        int x, y;
        cin >> x >> y;

        edge[x-1].push_back(y-1);
    }

    TopologicalSort ts(n, edge);
    ts.sort();

    vector<int> depth(n, 0);
    for(int i = n - 1; i >= 0; i--){
        int v = ts.sorted[i];
        for(int u : edge[v]){
            depth[u] = max(depth[u], depth[v] + 1);
        }
    }

    int ans = 0;
    rep(i, n){
        ans = max(ans, depth[i]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 17880
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	int H, W, i, h, w;
	for (i = 0; i < 1000; i++){
		cin >> H >> W;
		if (W == 0 && H == 0)
		{
			break;
		}
		else{
			for (h = 0; h < H; h++){
				for (w = 0; w < W; w++){
					if ( (h + w) % 2==0){
						cout << "#";
					}
					else{
						cout << ".";
					}
				}
				cout << endl;
			}
			cout << endl;
		}
	}return 0;
}




Measured memory_bytes: 3096
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M, K = map(int, input().split())
Network = UnionFind(N)
Friend = [0] * N  #人indexの友達の数
BlockInNetwork = [0] * N  #同じグループの中でブロックされている人の数

for _ in range(M):  #友達関係
    a, b = map(int, input().split())
    Network.union(a-1, b-1)
    Friend[a-1] += 1
    Friend[b-1] +=1

for _ in range(K): #ブロック関係
    c, d = map(int, input().split())
    if Network.same(c-1, d-1):  #same=aとbが同じグループか True or False
        BlockInNetwork[c-1] += 1
        BlockInNetwork[d-1] += 1

out = [0] * N  #友達候補の数 = そのグループの数 - 直の友達の数 - ブロックされている人の数 - 自分
for i in range(N):
    out[i] = Network.size(i) - Friend[i] - BlockInNetwork[i] - 1
print(*out)



Measured memory_bytes: 85904
def power(x,y):
    if x%y != 0:
        return 0
    else:
        return 1+power(x/y,y)


def main():
    n = int(input())
    prime=[]
    fact = {}
    num_list = [i for i in range(2,n+1)]
    i = 0
    ans = 1
    if n ==1:
        print(ans)
        exit()
    mod = 10**9+7
    while i <=n**0.5:
        i = num_list.pop(0)
        prime.append(i)
        for j in num_list:
            if j%i ==0:
                num_list.remove(j)
    prime = prime + num_list

    for i in range(1,n+1):
        for j in prime:
            if i <j:
                break
            elif j in fact.keys():
                fact[j] += power(i,j)
            else:
                fact[j] = power(i,j)
    for i in fact.values():
        ans *= (i+1)
        ans %= mod
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int g,q,x,nt,st[100007];
    scanf("%d",&q);
    for(g=1;g<=q;g++){
        x=g,nt=0;
        while(x){
            nt++;
            x/=10;
        }
        if(nt&1)st[g]=1;
        else st[g]=0;
    }
    for(g=1,x=0;g<=q;g++)
        x+=st[g];
    printf("%d\n",x);
    return 0;
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10**9)
input = lambda: sys.stdin.readline().rstrip()
inpl = lambda: list(map(int,input().split()))
N = int(input())
edge = [set() for _ in range(N)]
ab = []
for i in range(N-1):
    a, b = inpl()
    a -= 1
    b -= 1
    ab.append((a,b))
    edge[a].add(i)
    edge[b].add(i)

K = 0
ans = [0]*(N-1)
def dfs(node, prev=0):
    global K
    c = 0
    for i in edge[node]:
        c += 1
        if c == prev:
            c += 1
        a, b = ab[i]
        if node == a:
            x = b
        else:
            x = a
        edge[x].remove(i)
        ans[i] = c
        dfs(x, c)
    if c >= K:
        K = c

dfs(0)
print(K)
for i in range(N-1):
    print(ans[i])


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

//策略正确，但是有一组样例卡掉了，目前没有检查出来哪里有bug
/*string a;
bool b[10];

int main()
{
    int n;
    while(cin>>a>>n)
    {
        int x;
        memset(b,0,sizeof(b));
        int mi;
        for(int i=0;i<n;i++)
        {
            cin>>x;
            b[x]=1;
        }
        for(int i=0;i<10;i++)
        {
            if(b[i]==1)
                continue;
            else
            {
                mi=i;
                break;
            }
        }
        string ans;
        int t,tlen;
        int len=a.length();
        int flg=0;
        for(int i=len-1;i>=0;i--)
        {
            t=a[i]-'0';
            if(b[t]==0&&t<=9)
            {
                ans=a[i]+ans;
            }
            else
            {
                tlen=ans.length();
                for(int j=0;j<tlen;j++)
                    ans[j]='0'+mi;
                if(t>=9)
                {
                    a[i]=mi+'0';
                    ans=a[i]+ans;
                    if(i==0)
                    {
                        if(mi!=0)
                            ans=a[i]+ans;
                        else
                        {
                           int tmp=mi+1;
                           while(b[tmp]==1)
                            tmp++;
                           a[i]=tmp+'0';
                           ans=a[i]+ans;
                        }
                    }
                    else
                        a[i-1]=a[i-1]+1;
                    continue;
                }
                while(b[t]==1&&t<=9)
                    t++;
                if(t==10&&i==0)
                {
                    a[i]=mi+'0';
                    ans=a[i]+ans;
                    if(mi!=0)
                            ans=a[i]+ans;
                        else
                        {
                           int tmp=mi+1;
                           while(b[tmp]==1)
                            tmp++;
                           a[i]=tmp+'0';
                           ans=a[i]+ans;
                        }
                }
                else
                {
                    a[i]='0'+t;
                    ans=a[i]+ans;
                }
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}*/

bool b[10];

bool check(int x)
{
    int t=x;
    while(t)
    {
        if(b[t%10]==1)
        {
            return false;
        }
        t/=10;
    }
    return true;
}

int main()
{
    int n,k;
    while(cin>>n>>k)
    {
        memset(b,0,sizeof(b));
        int x;
        for(int i=0;i<k;i++)
        {
            cin>>x;
            b[x]=1;
        }
        int ans=n;
        for( ; ; )
        {
            if(check(ans))
            {
                cout<<ans<<endl;
                break;
            }
            else
                ans++;
        }
    }
    return 0;
}


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

int main() {
    int N; cin >> N;
    string A, B, C; cin >> A >> B >> C;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] == B[i] && B[i] == C[i]) {
            continue;
        } else if (A[i] == B[i] || B[i] == C[i] || C[i] == A[i]) {
            ans++;
        } else {
            ans += 2;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/*Coding Space*/
int main(){
  int a,b,c,x; cin >> a >> b >> c >> x;
  int ans = 0;
  rep(i,a+1)rep(j,b+1)rep(k,c+1)
    if(500*i + 100*j + 50 *k == x)  ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256