akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }


// 最小全域有向木 O(EV)
// 0-index
// 例外判定のために Edge[0] => {-1,-1,-1} が必須なため　辺のindexは 1-index
const int MAXV = 10010;
const int MAXE = 10010;
const int MAXW = 2147483647;
struct Edge {
    int u, v, c;
    Edge(int x = 0, int y = 0, int z = 0) : u(x), v(y), c(z) {}
};
int V, E, root;
Edge edges[MAXE];
inline void addEdge(int u, int v, int c){ edges[E++] = Edge(u, v, c);}
bool con[MAXV];
int mnInW[MAXV], prv[MAXV], cyc[MAXV], vis[MAXV];
inline int DMST() {
    fill(con, con + V, 0);
    int r1 = 0, r2 = 0;
    while (true) {
        fill(mnInW, mnInW + V, MAXW);
        fill(prv, prv + V, -1);
        for (int i = 0; i < E; i++) {
            int u = edges[i].u, v = edges[i].v, c = edges[i].c;
            if (u != v && v != root && c < mnInW[v]){mnInW[v] = c; prv[v] = u;}
        }
        fill(vis, vis + V, -1);
        fill(cyc, cyc + V, -1);
        r1 = 0;
        bool jf = false;
        for (int i = 0; i < V; i++) {
            if (con[i]) continue;
            if (prv[i] == -1 && i != root) {
                return -1;
            }
            if (prv[i] >= 0) r1 += mnInW[i];
            int s;
            for (s = i; s != -1 && vis[s] == -1; s = prv[s]) vis[s] = i;
            if (s >= 0 && vis[s] == i) {
                // get a cycle
                jf = true; int v = s;
                do { cyc[v] = s; con[v] = true; r2 += mnInW[v]; v = prv[v];
                } while (v != s);
                con[s] = false;
            }
        }
        if (!jf) break;
        for (int i = 0; i < E; i++) {
            int &u = edges[i].u;
            int &v = edges[i].v;
            if (cyc[v] >= 0) edges[i].c -= mnInW[edges[i].v];
            if (cyc[u] >= 0) edges[i].u = cyc[edges[i].u];
            if (cyc[v] >= 0) edges[i].v = cyc[edges[i].v];
            if (u == v){ edges[i--] = edges[--E]; }
        }
    }
    return r1 + r2;
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int e;
    cin >> V >> e >> root;
    for(int i = 0; i < e;i++) {
        int a, b, c;
        cin >> a >> b >> c;
        addEdge(a, b, c);
    }
    cout << DMST() << endl;
    
    return 0;
}



Measured memory_bytes: 3348
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#define ll long long 
using namespace std;
int n;
ll x;
ll a[105];
int main()
{
	int cnt = 0, j = 0;
	int cn = 0, jj = 1;
	cin >> n >> x;
	ll t = x;
	int ans;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	while (x - a[j] >= 0 && j < n)
	{
		x = x - a[j];
		cnt++;
		j++;
	}
	while (t - a[n - jj] >= 0 && jj <= n)
	{
		t = t - a[n - jj];
		cn++;
		jj++;
	}
	if (t > 0 && cn == n)
		cn = cn - 1;
	if (x > 0 && cnt == n)
		cnt = cnt - 1;
	ans = max(cn, cnt);
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
N=int(input())
Alist=list(map(int,input().split()))
Blist=list(map(int,input().split()))
Clist=list(map(int,input().split()))
 
Cplus=0
for n in range (0,N-1):
  if Alist[n+1] == Alist[n]+1:
    Cplus += Clist[Alist[n]-1]
 
print(sum(Blist)+Cplus)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <set>
#include <complex>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

bool operator<(const pair<int, int> &a, const pair<int, int> &b)
{
    if (a.first == b.first)
    {
        return a.second < b.second;
    }
    return a.first < b.first;
}
int rnk[110];
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //cout << fixed << setprecision(7);

    vector<pair<int, int>> vp;

    int p, s;
    char c;
    while (cin >> p >> c >> s)
    {
        if (p == 0 && s == 0)
            break;
        vp.push_back(make_pair(s, p));
    }
    sort(vp.rbegin(), vp.rend());

    int point = vp[0].first;
    int idx = 1;
    for (int i = 0; i < vp.size(); ++i)
    {
        if (point == vp[i].first)
        {
            rnk[vp[i].second] = idx;
        }
        else
        {
            point = vp[i].first;
            idx++;
            rnk[vp[i].second] = idx;
        }
    }

    int q;
    while (cin >> q)
    {
        cout << rnk[q] << endl;
    }
    return 0;
}


Measured memory_bytes: 3036
## B - Good Distance(ABC133)
N,D=list(map(int, input().split()))
X=[]
A=0
B=[]
for i in range(N):
    X.append(list(map(int, input().split())))
for i in range(N):
    for v in range(i+1,N):
        A=0
        for x in range(D):
            A+=(X[i][x]-X[v][x])**2
            if x==D-1:
                B.append(A)
C=0
for i in B:
    for v in range(1,i+1):
        if i/v==v:
            C+=1
            break
print(C)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(n) (n).begin(),(n).end()
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int main(){
	int n,a,b,c;
	string s;
	cin >> a >> b >> c;
	if((a==b) || (b==c) || (a==c)){
		if(a==b && b==c){
			cout << "No" << endl;
		}else{
			cout << "Yes" << endl;
		}
	}else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
//usr/bin/env scala $0 $@;exit
object Main{
	def calc(r:Long,i:Long,n:Long):Long = {
		val x = n-i*(i-1)/2
		if(x>=i){
			if(x%i==0){
				calc(r+1,i+1,n)
			}else{
				calc(r,i+1,n)
			}
		}else{
			r
		}
	}

	def main(args: Array[String]) = {
		val cin=new java.util.Scanner(System.in)
		while(cin.hasNext()){
			var n=cin.nextLong()
			if(n>0)println(calc(0,2,n))
		}
	}
}

Measured memory_bytes: 45204
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
using namespace std;

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

    int N;
    cin >> N;
    vector<pair<int, int>> xy(N);
    for (int i = 0; i < N; i++)
    {
        cin >> xy[i].first >> xy[i].second;
    }

    int ans = N;
    map<pair<int, int>, int> mp;
    for (int i = 0; i < N; i++)
    {
        set<pair<int, int>> st;
        for (int j = 0; j < N; j++)
        {
            if (i == j)
            {
                continue;
            }

            int x_sub = xy[i].first - xy[j].first;
            int y_sub = xy[i].second - xy[j].second;
            pair<int, int> p = make_pair(x_sub, y_sub);
            st.insert(p);
        }

        for (pair<int, int> p : st)
        {
            mp[p]++;
        }
    }

    int mx = 0;
    for (auto p : mp)
    {
        mx = max(mx, p.second);
    }
    cout << N - mx << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<double,double> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;

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

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const double PI = 4*atan(1);
const ll INF = 1e18;
const int MX = 100001;

int N;
ll ans = 0;
vi B;
bitset<51> posi[50];

bool ok(int ind, int mx) {
    bitset<51> tmp = posi[ind];
    FORd(i,1,mx+1) F0R(j,51) if (tmp[j]) tmp[j%i] = 1;
    return tmp[B[ind]];
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N;
    F0R(i,N) {
        int a; cin >> a;
        posi[i][a] = 1;
    }
    B.resize(N);
    F0R(i,N) cin >> B[i];
    
    F0R(i,N) if (!ok(i,50)) {
        cout << -1;
        return 0;
    }
    
    FORd(j,1,51) {
        bool need = 0;
        F0R(i,N) {
            if (!ok(i,j-1)) {
                need = 1;
                break;
            }
        }
        if (need) {
            ans += (1LL<<j);
            F0R(i,N) F0R(k,51) if (posi[i][k]) posi[i][k%j] = 1;
        }
    }
    cout << ans;
}

// read the question correctly (is y a vowel?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)

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

public class Main {

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    for(int i = 1; i <= n; i++){
      a[sc.nextInt() - 1] = i;
    }
    Arrays.stream(a).forEach(num -> {
      System.out.print(num + " ");
    });
  }
}


Measured memory_bytes: 61536
#include <iostream>

using namespace std;

int main(void) {
	long long ans;
	int i;
	int N, K;
	// get input -----------------------------
	cin >> N >> K;
	// count penki ---------------------------
	ans = K;
	for (i = 1; i < N; i++) {
		ans *= (K - 1);
	}
	// disp answer ---------------------------
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <numeric>
// #include <windows.h>
using namespace std;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = V<VV<T>>;
template<class T1, class T2> using P = pair<T1, T2>;
using I = int;
using D = double;
using B = bool;
using C = char;
using S = string;
using LL = long long;
using LD = long double;
using ULL = unsigned long long;
using PII = P<I, I>;
using VPII = V<PII>;
using PLL = P<LL, LL>;
using VPLL = V<PLL>;
using VI = V<I>;
using VVI = VV<I>;
using VLL = V<LL>;
using VVLL = VV<LL>;
using VC = V<C>;
using VVC = VV<C>;
using VS = V<S>;
using VVS = VV<S>;
using VB = V<B>;
using VVB = VV<B>;
#define REP(type, i, n) for (type i = 0; i < (type)(n); ++i)
#define REP2(type, i, m, n) for (type i = (m); i < (type)(n); ++i)
#define REPR(type, i, n) for (type i = (n)-1; i >= 0; --i)
#define REPR2(type, i, m, n) for (type i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a, type) sort(ALL(a), greater<type>())
#define SORTF(a, comp) sort(ALL(a), comp)
#define REVERSE(a) reverse(ALL(a))
#define SIZE(a, type) ((type)(a).size())
#define bit_search(bit, n) REP(LL, bit, 1LL<<(n))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) (lower_bound(ALL(a), (x)) - a.begin())
#define bisect_right(a, x) (upper_bound(ALL(a), (x)) - a.begin())
#define INPUT(a) REPx(&x, a) cin >> x;
#define INPUT2(a) REPx(&x, a) INPUT(x);
#define INPUTP(a) REPx(&x, a) cin >> x.first >> x.second;
#define ENDL cout << endl;

const int INF = 2e9;
// const LL INF = 9e18;
const LL MOD = 1e9+7;

template<class T> using PRIORITY_QUEUE = priority_queue< T, V<T>, greater<T> >;
template<class T> inline bool chmin(T &a, T b){if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b) {a = b; return true;} return false;}
template<class T> inline void debug1(V<T> A){REP(int, i, SIZE(A, int)){if (A[i] == INF) cout << "I ";else cout << A[i] << " ";}ENDL}
template<class T> inline void debug2(VV<T> A){REP(int, i, SIZE(A, int)){REP(int, j, SIZE(A[i], int)){if (A[i][j] == INF) cout << "I "; else cout << A[i][j] << " ";}ENDL}}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  LL h, w, ans;
  cin >> h >> w;
  if (h == 1 || w == 1) ans = 1;
  else if (h % 2 == 0) ans = w * (h / 2);
  else ans = w * ((h-1)/2) + (w%2 ? w/2+1 : w/2);
  cout << ans << endl;

  return 0;
}


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

using namespace std ;

const int MAX = 1e5 + 10 ;
const long double PI = acos(-1) ;
int arr[MAX] ;
int n ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	long double r ;
	cin>>r ;
	long double ans = 2.00 * PI * r ;
	return cout<<fixed<<setprecision(1)<<ans<<"\n" , 0 ;
}		

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

constexpr int MAX_N = 1e5 + 1;

vector< int > e[3][MAX_N];
int dist[3][MAX_N];

int main() {
  int n,m; cin>>n>>m;
  for(int i=0;i<m;++i){
    int u,v; cin>>u>>v;
    --u; --v;
    for(int j=0;j<3;++j){
      e[j][u].push_back(v);
    }
  }

  int s,t; cin>>s>>t;
  --s;--t;

  memset(dist, -1, sizeof(dist));

  // queue< status, node >
  queue< pair<int,int> > q;
  q.push(make_pair(0,s));
  dist[0][s] = 0;

  while(!q.empty()){
    int stat, from;
    tie(stat, from) = q.front(); q.pop();

    for(auto &&to: e[stat][from]) {
      // 更新されてたらcontinue
      if (~dist[(stat+1)%3][to]) continue;
      dist[(stat+1)%3][to] = dist[stat][from] + 1;
      q.push(make_pair((stat+1)%3,to));
    }
  }

  int ans = dist[0][t]/3;
  if (dist[0][t]<0) ans = dist[0][t];
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 17792
n = gets.to_i

h = Hash.new(50)
x = Hash.new
n.times do
    ("a".."z").each{|c| x[c] = 0}
    gets.chomp.each_char{|c| x[c] += 1}
    x.each{|k,v| h[k] = v if h[k] > v}
    x.clear
end

puts h.sort_by{|k,v| k}.inject(""){|r,i| r + i[0] * i[1]}

Measured memory_bytes: 1916
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

using namespace std;

int main(){
    double result;
    int R;

    cin >> R;

    result = M_PI * 2 * R;

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3252
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef pair<int,int> P;
typedef long long ll;



int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    if(a-b>c)cout<<0<<endl;
    else cout<<c-(a-b)<<endl;
    return 0;
}

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

using namespace std;
int a[1234567];
int Eve(int n,int k)
{
    sort(a,a+n);
    int ans=INT_MAX;
    for (int i=0;i<n-k+1;i++)
    {
        ans=min(ans,a[i+k-1]-a[i]);
    }
    return ans;
}
int main()
{
    int n,k;
    cin >>n >> k;
    for (int i=0;i<n;i++)
    {
        cin >> a[i];
    }
    cout <<Eve(n,k)<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <set>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <map>
#include <queue>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef long double ld;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<pii> vii;
typedef vector<string> vs;
//typedef long long int;

int main() {
std::ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vl a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  ll res = 0;
  for (int i = 0; i < 1000; ++i) {
    sort(a.begin(), a.end());
    if (a.back() - a[0] > n) {
      ll d = min((a.back() - n + 1) / n, (a.back() - a[0]) / (n + 1));
      a.back() -= d * n;
      for (int j = 0; j + 1 < n; ++j) a[j] += d;
      res += d;
    }
  }
  ll mi = a[0];
  for (int i = 0; i < n; ++i) {
    mi = min(mi, a[i]);
  }
  ll d = mi - (n - 1);
  if (d > 0) {
    res += n * d;
    for (int i = 0; i < n; ++i) a[i] -= d;
  }
  while (1) {
    bool go = 0;
    for (int i = 0; i < n; ++i) if (a[i] >= n) {
      a[i] -= n;
      for (int j = 0; j < n; ++j) if (i != j) ++a[j];
      ++res;
      go = 1;
    }
    if (!go) break;
  }
  cout << res << endl;
  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define prin(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int in=f;in<f+n;in++) cin>>V[in]
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "

const int MOD = 1e9+7,MAX = 1e6+5;
/////////////////FastExp///////////////////
ll powN(ll a,ll p,ll mod)
{
	if(p==0) return 1;
	ll z=powN(a,p/2,mod);
	z=(z*z)%mod;
	if(p%2) z=(z*a)%mod;
	return z;
}
/////////////////FastExp///////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX, true);
vector<int> MinDiv(MAX);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
    		MinDiv[i]=i;
        	for (j = i * i; j <= MAX; j += i)
            {
				is_prime[j] = false;
				MinDiv[j]=i;
    		}
    	}
	}
	for(int i=2;i<=MAX;i++) if(is_prime[i]) MinDiv[i]=i;
}
//////////////////Sieve////////////////////

int main()
{
	string s;
	cin>>s;
	cout<<s[0]<<s[1]<<s[2]<<endl;
}		

Measured memory_bytes: 6984
import numpy as np
from collections import defaultdict
from functools import reduce

# s = input()
# n = int(input())
# A = list(map(int, input().split()))
W, H, x, y = map(int, input().split())

if W/2 == x and H/2 == y:
    res = 1
else:
    res = 0

print(W*H/2, res)


Measured memory_bytes: 12508
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pri pair<int,int>
#define mpi map<int,int>
#define prl pair<ll,ll>
#define mp make_pair
#define mpl map<ll,ll>
#define umpl unordered_map<ll,ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 2e18
#define EPS 1e-3
#define PI 3.1415926535897932385
#define display(v) f(v.size())cout << v[i]<<" "
const double h = 1e-6;
const int MAX_  = 100005;

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////


struct UnionFind {
    vector<int> par;
    vector<int> sz;
 
    UnionFind(int n=0){ if(n>0) initialize(n); }
    void initialize(int n){
        par.resize(n);
        sz.assign(n, 1);
        for(int i=0; i<n; i++){
            par[i] = i;
        }
    }
 
    int find(int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = find(par[x]);
        }
    }
 
    bool unite(int x, int y){
        x = find(x), y = find(y);
        if(x == y) return false;
        if(sz[x] > sz[y]) swap(x, y);
        par[x] = y;
        sz[y] += sz[x];
        return true;
    }
 
    bool same(int x, int y){ return find(x) == find(y); }
    int size(int x){ return sz[find(x)]; }
};

struct node  
{
  int a,b;
};
int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m,k; cin>>n>>m>>k;
    node fr[m];
    node em[k];
    f(m)
    {
      int a,b;  cin>>a>>b;
      a--,b--;
      fr[i].a = a;
      fr[i].b = b;
    }
    f(k)
    {
      int a,b;  cin>>a>>b;
      a--,b--;
      em[i].a = a;
      em[i].b = b;
    }
    UnionFind uf(n);
    for(int i =0;i<m;i++)
    {
      int a = fr[i].a;
      int b = fr[i].b;
      uf.unite(a,b);
     }
     vi ans(n);  // candidates
     for(int i=0;i<n;i++)
     {
       ans[i] = uf.size(i);
       ans[i] --;   // remove itself
     }
     //remove friends
     for(int i =0;i<m;i++)
     {
       int a = fr[i].a;
       int b = fr[i].b;
       ans[a] --;
       ans[b] --;
     }
     //remove enemies if they belong to same set
     f(k)
     {
       int a = em[i].a;
       int b = em[i].b;
       if(uf.same(a,b))
       {
         ans[a]--;
         ans[b]--;
       }
     }
     f(ans.size()) cout << ans[i] << " ";
     cout << "\n";


    
    
    return 0;
 }

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

using namespace std;
using ll = long long;
constexpr int mod = 1e9+7;
constexpr int md = mod;
int main(){
    ll n,k;
    cin>>n>>k;
    if(n >= k + (k-1)) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << "is " << (x) << '\n';
using namespace std;

bool is_in(vector<int>& v, int d){
	for (int digit : v){
		if (d == digit){
			return true;
		}
	}
	return false;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	int money; int k; vector<int> banned;
	cin >> money >> k;
	
	for (int i = 0; i < k; i++){
		int d; cin >> d; 
		banned.push_back(d);
	}

	for (int i = money; i < 100000; i++){
		string num = to_string(i);
		bool valid = true;
		for (char c : num){
			int digit = (int)c - '0';
			if (is_in(banned, digit)){
				valid = false;
			}
		}
		if (valid){
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        int N = sc.nextInt();
	        long[] ans = new long[2];
	        long[] t1 = new long[2];
	        long[] t2 = new long[2];
	        ans[0]= Long.parseLong(sc.next());
	        ans[1]= Long.parseLong(sc.next());
	        for (int i=0 ; i<N-1; i++) {
	            long a = Long.parseLong(sc.next());
	            long b = Long.parseLong(sc.next());
	            long t = ans[0]/a;
	            if(ans[0]%a!=0)t++;
	            t1[0]=a*t;
	            t1[1]=t1[0]/a*b;
	            t = ans[1]/b;
	            if(ans[1]%b!=0)t++;
	            t2[1]=b*t;
	            t2[0]=t2[1]/b*a;
	            if(t1[0]<t2[0]) {
	            	ans[0]=t2[0];
	            	ans[1]=t2[1];	            	
	            } else {
	            	ans[0]=t1[0];
	            	ans[1]=t1[1];
	            }

	        }


	        System.out.println(ans[0]+ans[1]);
		 }
	}

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

int main(){
  int num = 0;
  int dp = 2;
  int x;
  
  while(cin >> x){
    dp = 2;
    
    for(int i = 1; i<x ; ++i){
      dp += (i + 1);
    }

    cout << dp << endl;
  }
  return 0;
}



Measured memory_bytes: 2992
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e3+7, p = 1e9+7;
int f[N][N];
char s[N][N];
int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; i++)
	{
		scanf("%s", s[i]+1);
	}
	f[1][1] = s[1][1] == '.' ? 1 : 0;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= m; j++)
		{
			if(i==1&&j==1)
			{
				continue;
			}
			if(s[i][j]=='#')
			{
				continue;
			}
			f[i][j] = (f[i-1][j]+f[i][j-1])%p;
		}
	}
	printf("%d\n", f[n][m]);
	return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <algorithm>

int euclidean_gcd(int a, int b) {
	while(a > 0 && b > 0) {
		if(a > b) a %= b;
		else b %= a;
	}
	int ret = (a == 0 ? b : a);
	return ret;
}

int main(void) {
	// input
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	for(int i = 0; i < n; ++i) {
		std::cin >> a[i];
	}
	
	// erase and calc
	std::vector<int> l(n + 1);
	std::vector<int> r(n + 1);
	
	l[0] = 0;
	for(int i = 1; i < n + 1; ++i) {
		l[i] = euclidean_gcd(l[i - 1], a[i - 1]);
	}

	r[n] = 0;
	for(int i = n - 1; i >= 0; --i) {
		r[i] = euclidean_gcd(r[i + 1], a[i]);
	}
	
	std::vector<int> gcds(n);
	for(int i = 0; i < n; ++i) {
		gcds[i] = euclidean_gcd(l[i], r[i + 1]);
	}

	// max
	std::vector<int>::iterator gcd = std::max_element(gcds.begin(), gcds.end());

	// out
	std::cout << *gcd << std::endl;

	return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
main(){
  int n,r=0;
  cin>>n;
  vector<int> a(n),b;
  for(auto& i:a)cin>>i;
  b=a;
  sort(a.begin(),a.end());
  for(int i=0;i<n;++i){
    if(a[i]!=b[i])r++;
    if(r>2){cout<<"NO";return 0;}
  }
  cout<<"YES";
}

Measured memory_bytes: 256
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

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

@njit((i8[:], i8), cache=True)
def get_sum(bit, i):
    s = 0
    while i:
        s += bit[i]
        i -= i & -i
    return s


@njit((i8[:], i8, i8), cache=True)
def add(bit, i, x):
    while i < len(bit):
        bit[i] += x
        i += i & -i

@njit((i8, i8[:]), cache=True)
def main(M, LR):
    L, R = LR[::2], LR[1::2]
    R = R + 1
    D = R - L
    argsort = np.argsort(D)
    L, R, D = L[argsort], R[argsort], D[argsort]
    idx = np.searchsorted(D, np.arange(M + 2))

    bit = np.zeros(M + 10, np.int64)
    rest = len(L)
    for d in range(1, M + 1):
        # 長さ d の区間を追加
        for i in range(idx[d], idx[d + 1]):
            rest -= 1
            add(bit, L[i], 1)
            add(bit, R[i], -1)
        ans = rest
        for n in range(d, M + 1, d):
            ans += get_sum(bit, n)
        print(ans)

N, M = map(int, readline().split())
LR = np.array(read().split(), np.int64)

main(M, LR)

Measured memory_bytes: 146104
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int A[50001];
ll ans = 1;
const ll mod = 1e9 + 7;
const int ma = 31;

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


	int N = getint();
	if (N & 1) {
		rep(i, N) {
			int a = getint();
			if (a & 1) {
				printf("0");
				return 0;
			}
			A[a / 2]++;
		}
		if (A[0] != 1) {
			printf("0");
			return 0;
		}
		rep1(i, N / 2) {
			if (A[i] != 2) {
				printf("0");
				return 0;
			}
			ans = ans << 1;
			if (!(i & ma)) ans %= mod;
		}
		printf("%lld", ans % mod);
	}
	else {
		rep(i, N) {
			int a = getint();
			if (!(a & 1)) {
				printf("0");
				return 0;
			}
			A[a / 2]++;
		}
		rep(i, N / 2) {
			if (A[i] != 2) {
				printf("0");
				return 0;
			}
			ans = ans << 1;
			if (!(i & ma)) ans %= mod;
		}
		printf("%lld", ans % mod);
	}

	Would you please return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const ll mod=998244353;
const int maxn=210;
int n,x[maxn],y[maxn];
ll ans,mi[maxn];
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	for (int i=1;i<=n;i++)
		read(x[i]),read(y[i]);
	mi[0]=1;
	for (int i=1;i<=n;i++) mi[i]=mi[i-1]*2%mod;
	ans=mi[n]-n-1;
	for (int i=1;i<=n;i++)
	for (int j=1;j<i;j++) {
		int cnt=0;
		for (int k=1;k<j;k++)
			if ((x[i]-x[k])*(y[i]-y[j])==(x[i]-x[j])*(y[i]-y[k]))
				cnt++;
		ans-=mi[cnt]; ans=(ans+mod)%mod;
	}
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;

#define PI 3.14159265358979323846264338327950L

string res = "No";

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

    string a,b;
    cin >> a>>b;
    int number = stoi(a + b);
    for(int i = 1; i < 1000; i++ )
    {
        if (number == i*i){
            res = "Yes";
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <string.h>
#include <math.h>
#include <map>

using namespace std;

int main(){
	int D, G;
	int p[10], c[10];
	int ans = 1e9;

	cin >> D >>G;

	for (int i = 0; i < D; ++i){
		cin >> p[i] >> c[i];
	}

	for (int mask = 0; mask < (1 << D); ++mask){
		int s = 0, max = 0, total = 0;
		for (int i = 0; i < D; ++i){
			if (mask >> i & 1){
				s += 100 * (i + 1) * p[i] + c[i];
				total += p[i];
			}
			else
				max = i;
		}
		if (s < G){
			int rest = (G - s + (max + 1) * 100 - 1) / ((max + 1) * 100);
			if (rest >= p[max])
				continue;
			total += rest;
		}
		ans = min(total, ans);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
n, k, q = map(int, input().split())

a = []
for i in range(q):
    a.append(int(input()))

point = [0 for _ in range(n)]

for i in range(q):
    point[a[i] - 1] += 1

for i in range(n):
    if k - q + point[i] > 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 8640
#include<cstdio>
#include<queue>
#include<utility>

using namespace std;

typedef pair<int, int> P;

const int MAX_N = 400;

const int di[] = {1, 0, -1, 0};
const int dj[] = {0, 1, 0, -1};

bool color[MAX_N][MAX_N];
int H, W;

char ch[MAX_N + 1];

void input(){
	scanf("%d%d", &H, &W);
	for(int i = 0; i < H; ++i){
		scanf("%s", ch);
		for(int j = 0; j < W; ++j){
			color[i][j] = (ch[j] == '#');
		}
	}
}

bool isin_(int i, int j){
	return i >= 0 && i < H && j >= 0 && j < W;
}

bool check_(int i, int j, int d){
	int ni = i + di[d];
	int nj = j + dj[d];
	if(!isin_(ni, nj)) return false;
	if(color[i][j] == color[ni][nj]) return false;
	return true;
}

bool used[MAX_N][MAX_N];

long long solve(){
	long long ans = 0;
	long long b = 0, w = 0;
	for(int i = 0; i < H; ++i){
		for(int j = 0; j < W; ++j){
			if(used[i][j]) continue;
			b = 0;
			w = 0;
			queue<P> que;
			used[i][j] = true;
			que.push(P(i, j));
			while(!que.empty()){
				P p = que.front();
				que.pop();
				int ci = p.first, cj = p.second;
				if(color[ci][cj]) b++;
				else w++;
				for(int d = 0; d < 4; ++d){
					if(!check_(ci, cj, d)) continue;
					int ni = ci + di[d], nj = cj + dj[d];
					if(used[ni][nj]) continue;
					used[ni][nj] = true;
					que.push(P(ni, nj));
				}
			}
			ans += b * w;
		}
	}
	return ans;
}

int main(){
	input();
	long long ans = solve();
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3496
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

bool col[225816],visited[225816],used[225816];
vector<int> g[225816];
int ans[225816],p[225816],cnt[2];
queue<int> q;

void dfs(int v = 0){
	int u,i;
	visited[v] = true;
	++cnt[col[v]];
	for(i=(g[v].l_ength()-1); i>=0; --i){
		u = g[v][i];
		if(visited[u]){
			continue;
		}
		col[u] = (!col[v]);
		p[u] = v;
		dfs(u);
	}
	if(!cnt){
		q.push(v);
	}
}

int main(void){
	int n,a,b,i,x,y,z;
	bool flag = true;
	cin >> n;
	for(i=1; i<n; ++i){
		cin >> a >> b;
		--a; --b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs();
	if(cnt[0]<cnt[1]){
		swap(cnt[0],cnt[1]);
		for(i=0; i<n; ++i){
			col[i] = (!col[i]);
		}
	}
	if(cnt[1]<=n/3){
		x = 3;
		for(i=0; i<n; ++i){
			if(col[i]){
				ans[i] = x;
				used[x] = true;
				x += 3;
			}
		}
		x = 1;
		for(i=0; i<n; ++i){
			if(!col[i]){
				ans[i] = x;
				used[x] = true;
				while(used[x]){
					++x;
				}
			}
		}
		for(i=0; i<n; ++i){
			cout << ((i)?" ":"") << ans[i];
		}
		cout << endl;
	}else{
		x = 1; y = 2; z = 3;
		for(i=0; i<n; ++i){
			if(col[i]){
				if(x>n){
					ans[i] = z;
					z += 3;
				}else{
					ans[i] = x;
					x += 3;
				}
			}else{
				if(y>n){
					ans[i] = z;
					z += 3;
				}else{
					ans[i] = y;
					y += 3;
				}
			}
		}
		for(i=0; i<n; ++i){
			cout << ((i)?" ":"") << ans[i];
		}
		cout << endl;
	}
	return 0;
}


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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int ans;
string s;

main() {
    cin >> s;
    rep(i,s.size()) ans += (int)(s[i]-'0');
    if (ans==1) ct(10)
    else ct(ans)
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    char S[5];
    char C1,C2;

    scanf("%s",S);


    C1=S[0];

    if(C1 != S[1]){
        C2 = S[1];

        if(S[2] != S[3]){
            if(((S[2]==C1)&&(S[3]==C2))||(S[2]==C2)&&(S[3]==C1)){
                printf("Yes\n");
            } else {
                printf("No\n");
            }
        } else {
            printf("No\n");
        }
    } else {
        if((S[2] == S[3]) && (S[2] != C1)){
            printf("Yes\n");
        } else {
            printf("No\n");
        }
    }

    
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include <iostream>
#include <cstring>
#include <climits>
#include<cmath>
#include <algorithm>
#define ll unsigned  long long
using namespace std;
int n;
char a[300005];
int main()
{
    cin>>n;
    cin>>a;
    int right_e=0;
    int left_w=0;
    for(int i=0;i<n;i++){
        if(a[i]=='E'){
            ++right_e;
        }
    }
    
    int res = INT_MAX;
    
    int temp;
    for(int i=0;i<n;i++){
        
        if(a[i]=='E'){
            --right_e;
        }
        
        temp = right_e + left_w;
        res = min(res,temp);
        
        if(a[i]=='W'){
            ++left_w;
        }
        
    }
    
    
    cout<<res<<endl;

    return 0;
}




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

typedef long long ll;

typedef pair<int, int> p;

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

    vector<int> a(3);

    for(int i = 0; i < 3; i++) cin >> a[i];

    sort(a.begin(), a.end());

    cout << a[0] + a[1] << endl;
}

Measured memory_bytes: 256
from sys import stdin

N = int(stdin.readline().rstrip())
h_lst = [int(x) for x in stdin.readline().rstrip().split()][::-1]

if len(h_lst) < 1:
  print("Yes")
else:
  f = "Yes"
  prev = h_lst[0]
  for i in h_lst[1:]:
    if prev - i >= 0:
      prev = i
    elif prev - i == -1:
      prev = i - 1
    else:
      f = "No"
      break

print(f)

Measured memory_bytes: 14396
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<cmath>
#include<string>

#define ls (t<<1)
#define rs ((t<<1)+1)
#define mid ((l+r)>>1)
#define fi first
#define se second
#define mk make_pair
#define pb push_back

#define N 1000005
#define M 200005
#define seed 23333
#define Mo 1000000007

using namespace std;
int i,j,m,n,p,k,fac[N],inv[N],ans,s[N],f[N];
int power(int x,int y)
{
		int sum=1;
		for (;y;y>>=1)
		{
				if (y&1) sum=1ll*sum*x%Mo;
				x=1ll*x*x%Mo;
		}
		return sum;
}
int C(int x,int y)
{
		if (x==y) return 1;
		if (y==-1) return 0;
		return 1ll*fac[x]*inv[y]%Mo*inv[x-y]%Mo;
}
void jia(int &x,int y)
{
		x+=y; if (x>=Mo) x-=Mo;
}
int main()
{
	scanf("%d",&n);
	fac[0]=1; for (i=1;i<=n;++i) fac[i]=1ll*fac[i-1]*i%Mo;
	for (i=0;i<=n;++i) inv[i]=power(fac[i],Mo-2);
	f[0]=1; s[0]=f[0];
	for (i=1;i<=n;++i)
	{
		f[i]=(s[i-1]-(i==1?0:f[i-2])+Mo)%Mo;
		s[i]=(s[i-1]+f[i])%Mo;
	}
	ans=f[n];
	jia(ans,1ll*f[n-1]*(n-1)%Mo);
	for (i=1;i<n;++i)
	{
		jia(ans,1ll*f[i-1]*i%Mo);
		jia(ans,1ll*f[i-1]*(n-1)%Mo*(n-1)%Mo);
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 15872
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)


int main(){
  ll n;
  cin >> n;
  vector<pair<int,int> >red(n),blue(n);
  ll ans=0,counter=0;
  int a,b,c,d;
  rep(i,n){
    cin >> a >> b;
    red[i]=make_pair(b,a);
  }
  rep(i,n){
    cin >> c >> d;
    blue[i]=make_pair(c,d);
  }
  sort(red.rbegin(),red.rend());
  sort(blue.begin(),blue.end());
  //rep(i,n){
  for(auto i=blue.begin();i!=blue.end();i++){
    //rep(j,n){
    for(auto j=red.begin();j!=red.end();j++){
      if(i->first>j->second&&i->second>j->first){
        red.erase(j);
        counter++;
        break;
      }
    }
  }
  cout << counter << endl;
}


Measured memory_bytes: 256
n,m = list(map(int,input().split()))
lis = list(map(int,input().split()))
total = 0

for i in range(m):
  total += lis[i] * 0.5 + 0.5
ans = total

for k in range(m,n):
  total -= lis[k-m]/2 - lis[k]/2
  ans = max(ans,total)
  
print(ans)



Measured memory_bytes: 24548
def examA():
    N, M = LI()
    if N==M:
        print("Yes")
    else:
        print("No")
    return

def examB():
    A, B = LI()
    if A>B:
        ans = str(B)*A
    else:
        ans = str(A)*B
    print(ans)
    return

def examC():
    N = I()
    P = LI()
    minP = N+1
    ans = 0
    for i in range(N):
        if minP>P[i]:
            minP=P[i]
            ans +=1
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examC()

"""

"""

Measured memory_bytes: 26084
def func(x, y):
  if len(y)==1:
    dic.append(x*10+int(y))
  else:
    for j in range(len(y)):
      func(x*10+int(y[j]), y[:j]+y[j+1:])
dic = []
 
N = int(input())
func(0, "".join([str(i) for i in range(1,N+1)]))
 
A = int(input().replace(" ", ""))
B = int(input().replace(" ", ""))
ans = abs(dic.index(A)-dic.index(B))
print(ans)

Measured memory_bytes: 10380
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

#include <stdio.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define vec vector
#define ref(a) &(a)

typedef long long ll;

using namespace std;

string s;

string solve() {
  sort(s.begin(), s.end());
  if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) return "Yes";
  else return "No";
}

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

Measured memory_bytes: 256
using System;
using System.Linq;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split();
            var n = int.Parse(_[0]);
            var x = int.Parse(_[1]);

            var m = new int[n];
            for(var i = 0; i < n; i++){
                m[i] = int.Parse(Console.ReadLine());
            }

            var count = m.Count();
            x -= m.Sum();
            count += x / m.Min();

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13268
import sys
sys.setrecursionlimit(10**8)
def mi(): return map(int, sys.stdin.readline().split())

H, W, K = mi()
C = [input() for i in range(H)]

B_i = 2 ** H
B_j = 2 ** W

ans = 0
for x in range(B_i):
    for y in range(B_j):
        cnt = 0
        for i in range(H):
            for j in range(W):
                if (x & (1 << i)) or y & (1 << j):
                    continue
                if C[i][j] == '#':
                    cnt += 1
        if cnt == K:
            ans += 1
                
print(ans)


Measured memory_bytes: 9104
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>

using namespace std;

int main() {
	string o, e; cin >> o >> e;
	if (o.size() == e.size()) {
		for (int i = 0; i < o.size(); i++) {
			cout << o[i] << e[i];
		}
	}
	else {
		for (int i = 0; i < o.size()-1; i++) {
			cout << o[i] << e[i];
		}
		cout << o[o.size() - 1];
	}
	

}









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

using namespace std;
typedef long long ll;
typedef pair<int,int>pa;

const int N=2e5+100;
const int mod=1e9+7;
ll a[N];
int n;
ll slove(ll f)
{
    ll sum=0,ans=0;
    for(int i=1;i<=n;i++){
        sum+=a[i];
        if(sum*f<=0) {
            ans+=abs(f-sum);
            sum=f;
        }
      f=-f;
    }
    return ans;
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    ll ans=min(slove(1),slove(-1));
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 4396
#include <bits/stdc++.h>
#define int long long
#define N 100010
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
int h,w,cx,cy;

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

int calc2(int x1,int y1,int x2,int y2){
  if(x1 > x2) swap(x1, x2), swap(y1, y2);  
  if(x1 >= w) return 0;

  if(x1 < 0){
    if(y1 - y2 < 0) y1 += abs(x1) ,x1 = 0;
    if(y1 - y2 > 0) y1 -= abs(x1) ,x1 = 0;
  }

  if(x2 >= w){
    if(y1 - y2 < 0) y2 -= abs(x2-(w-1)) ,x2 = w-1;
    if(y1 - y2 > 0) y2 += abs(x2-(w-1)) ,x2 = w-1;
  }
  if(y1 > y2) swap(x1, x2), swap(y1, y2);
  if(y1 >= h) return 0;

  if(y1 < 0){
    if(x1 - x2 < 0) x1 += abs(y1) ,y1 = 0;
    if(x1 - x2 > 0) x1 -= abs(y1) ,y1 = 0;
  }

  if(y2 >= h){
    if(x1 - x2 < 0) x2 -= abs(y2-(h-1)) ,y2 = h-1;
    if(x1 - x2 > 0) x2 += abs(y2-(h-1)) ,y2 = h-1;
  }
  
  if(!in(x1,y1) || !in(x2,y2)) return 0;
  return abs(x2 - x1)+1;
}

int calc(int d){
  if(d == 0) return 1;
  return 
    calc2(cx,cy+d,cx+d,cy) + 
    calc2(cx+d,cy,cx,cy-d) +
    calc2(cx,cy-d,cx-d,cy) +
    calc2(cx-d,cy,cx,cy+d) -
    (in(cx,cy+d) + in(cx+d,cy) + in(cx,cy-d) + in(cx-d,cy));
}


template< class T >
void printVec(T a,char ch = ' '){
  for(int i=0;i<a.size();i++){
    if(i)cout<<ch;
    cout<<a[i];
  }
  cout<<endl;
}

signed main(){

  int X,Y,Z,A,B,C,n;
  cin>>X>>Y>>Z>>A>>B>>C>>n;
  w = X;
  h = Y;
  cx = A;
  cy = B;
  int D[N]={};
  for(int i=0;i<=X+Y;i++){
    D[i%n] += calc(i);
  }
  
  int ans = 0;
  int L1 = 0, R1= 0;
  int L2 = 0, R2= n-1;
  for(int i=0;i<Z-C;i++){
    int c = i%n;
    ans += D[(n-c)%n];
    L1 = (n - c)%n;
  }

  for(int i=1;i<=C;i++){
    int c = i%n;
    ans += D[(n-c)%n];
    L2 = (n - c)%n;
  }
  
  vector<int> Ans(1,ans);
  

  for(int i=1;i<n;i++){
    ans -= D[L1];
    L1+=1;L1%=n;
    
    R1+=1;R1%=n;     
    ans += D[R1];
    
    ans -= D[L2];    
    L2+=1;L2%=n;
    
    R2+=1;R2%=n; 
    ans += D[R2];

    
    Ans.push_back(ans);
  }
  printVec(Ans);
  return 0;
}

Measured memory_bytes: 3952
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {

            Solve();

            //Console.WriteLine(ans);
            Console.ReadKey();
        }

        static void Solve()
        {
            var N = GetInt();
            var A = GetInt();
            var ans = YesNo(A >= N % 500);
            Console.WriteLine(ans); 
        }




        static public string GetStr() { return Console.ReadLine(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
    }
}

Measured memory_bytes: 13140