akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>

using namespace std;
typedef long long ll;

int main() {
  int d, g;
  cin >> d >> g;
  
  int p[d], c[d];
  int num = 0;
  for (int i = 0; i < d; i++) {
    cin >> p[i] >> c[i];
    num += p[i];
  }
  
  int dp[d + 1][num + 1];
  for (int i = 0; i <= d; i++) {
    for (int j = 0; j <= num; j++) {
      dp[i][j] = 0;
    }
  }

  for (int i = 0; i < d; i++) {
    for (int j = 0; j <= num; j++) {
      for (int k = 0; k <= p[i]; k++) {
        if (j >= k) {
          if (p[i] == k) {
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - k] + 100 * (i + 1) * k + c[i]);
          } else {
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - k] + 100 * (i + 1) * k);
          }
        } else {
          dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
        }
      }
    }
  }
  
  for (int i = 0; i < num + 1; i++) {
    if (dp[d][i] >= g) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}


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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define mxn 100005
using namespace std;

int main()
{
    FLASH
    ll x,n,mn = 99999,el = 99999;
    cin >> x >> n;
    map<ll,ll> mp;
    for(int i = 0; i < n; i++)
    {
        ll k;
        cin >> k;
        mp[k] = 1;
    }
    ll k = x;
    for(int i = k; i >= -200; i--)
    {
        if(mp[i] == 0)
        {
            el = i;
            break;
        }
    }
    for(int i = k; i <= 200; i++)
    {
        if(mp[i] == 0)
        {
            if(abs(i - x) < abs(el - x))
            {
                el = i;
            }
            break;
        }
    }
    cout << el ;
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()

{
    int t, ac=0,tle=0,wa=0,re=0;
    cin>>t;
    while(t--)

    {
        string s;
        cin>>s;

        if(s=="AC")
            ac++;
        if(s=="WA")
            wa++;
        if(s=="TLE")
            tle++;
        if(s=="RE")
            re++;

    }
    cout<<"AC"<<" x "<<ac<<endl;
    cout<<"WA"<< " x "<<wa<<endl;
    cout<<"TLE"<<" x "<<tle<<endl;
    cout<<"RE"<< " x "<<re<<endl;
}


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

using namespace std;
typedef long long ll;

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    set<int> b(a.begin(), a.end());

    string ans;
    if (a.size() == b.size()) ans = "YES";
    else ans = "NO";
    cout << ans << endl;
}



Measured memory_bytes: 10368
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const ll MOD = 1000000007;
const double EPS = 1e-9;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;


int main(void) {

    string a,b,c;
    cin>>a>>b>>c;
    int pa=0,pb=0,pc=0;
    char turn = 'a';
    while(1){
        if(turn == 'a'&&pa==a.size()){
            fin("A");
            return 0;
        } else if(turn == 'b'&&pb == b.size()){
            fin("B");
            return 0;
        } else if(turn == 'c'&&pc == c.size()){
            fin("C");
            return 0;
        }
        // cout<<pa<<" "<<pb<<" "<<pc<<endl;
        if(turn == 'a'){
            turn = a[pa];
            pa++;
        } else if(turn == 'b'){
            turn = b[pb];
            pb++;
        } else {
            turn = c[pc];
            pc++;
        }
    }


}


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

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,ll>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}


vector<vector<P>>G;
vector<int>res;
void dfs(int v,int p){
    for(auto nv : G[v]){
        if(nv.first==p)continue;
        if(nv.second==0)res[nv.first] = res[v];
        else res[nv.first] = 1-res[v];
        dfs(nv.first,v);
    }
}

int main(){
    int n;cin>>n;
    vector<ll>a(n);
    int cnt = 0;
    ll res = 0;
    rep(i,n){
        cin>>a[i];
        if(a[i]<0){
            cnt++;
            a[i] = -a[i];
        }
        res += a[i];
    }
    sort(ALL(a));
    if(cnt%2&1){
        res -= (2*a[0]);
    }
    cout<<res<<endl;
}



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

int main(){
	int a, b, c;
  	cin >> a >> b >> c;
  
  	bool ans = true;
  	if(a == b) ans = false;
    if(b == c) ans = false;
  	if(a == c) ans = false;
	if(a == b && b == c) ans = true;
  
  	if(ans) cout << "No" << endl;
  	else cout << "Yes" << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

int main(){
    ll n,W;cin>>n>>W;
    vector<pair<ll,ll>> vw(n);
    rep(i,n)cin>>vw[i].second>>vw[i].first;
    vector<pair<ll,ll>> a,b;
    a.push_back(make_pair(0ll,0ll));
    b.push_back(make_pair(0ll,0ll));
    rep(i,n/2){
        ll asz=a.size();
        rep(j,asz){
            if(a[j].first+vw[i].first<=W){
                a.push_back(make_pair(a[j].first+vw[i].first,a[j].second+vw[i].second));
            }
        }
    }
    rep(i,n/2,n){
        ll bsz=b.size();
        rep(j,bsz){
            if(b[j].first+vw[i].first<=W){
                b.push_back(make_pair(b[j].first+vw[i].first,b[j].second+vw[i].second));
            }
        }
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    ll asz=a.size();
    ll bsz=b.size();
    ll curmax=0;
    rep(i,bsz){
        if(curmax>b[i].second)b[i].second=curmax;
        curmax=b[i].second;
    }
    ll ans=0;
    
    rep(i,asz){
        if(a[i].first>W)continue;
        auto it=lower_bound(b.begin(),b.end(),make_pair(W-a[i].first+1,-1ll));
        --it;
        chmax(ans,a[i].second+(it->second));
    }
    cout<<ans<<endl;
}

    


Measured memory_bytes: 43652
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define FASTIO cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define ll long long int
#define F first
#define S second
#define pll pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vpii vector<pair<int,int> >
#define vvpii vector<vpii >
#define vpll vector<pair<ll,ll> >
#define vvpll vector<vpll >
#define pb push_back
#define MOD 1000000007

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;

struct compare {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		if ((a.S - a.F) != (b.S - b.F)) return ((a.S - a.F) > (b.S - b.F));
		else return (a.F < b.F);
	}
};

void add_self(ll &a, ll b) {
	a += b;
	if (a >= MOD) a -= MOD;
}

void subt_self(ll &a, ll b) {
	a -= b;
	if (a < 0) a += MOD;
}

int main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	FASTIO;
	ll n, k; cin >> n >> k;
	vl dp(k + 2); dp[0] = 1;
	for (ll i = 0; i < n; i++) {
		ll mx; cin >> mx;
		vl v(k + 2);
		for (ll j = k; j >= 0; j--) {
			ll temp = dp[j], L = j + 1, R = min(k, j + mx);
			if (R >= L) {
				add_self(v[L], temp); subt_self(v[R + 1], temp);
			}
		}
		ll prefix = 0;
		for (ll ii = 0; ii < k + 2; ii++) {
			add_self(prefix, v[ii]);
			add_self(dp[ii], prefix);
		}
	}
	cout << dp[k] << endl;
}

Measured memory_bytes: 1792
N, K = map(int, input().split())
A = list(map(int ,input().split()))

X = [0]*N
Y = [0]*N

for i in range(N):
    for j in range(i+1, N):
        if A[i] > A[j]:
            X[i] += 1
        elif A[i] < A[j]:
            Y[j] += 1

mod = 10**9+7
ans = 0
for i in range(N):
    ans += K*(K+1)*X[i]//2%mod
    ans += (K-1)*K*Y[i]//2%mod
print(ans%mod)


Measured memory_bytes: 41564
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
	int n;
	while (cin >> n)
	{
		if (cin.eof()) break;
		cout << "3C" << setw(2) << setfill('0') << ((n%39==0)?39:n%39) << endl;
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

const long long int inf=199999;
long long int mod;

const long long int INF = 9999999999999999;

struct edge {
	long long int  to, cost;
};
typedef pair<long long int, long long int> P;
vector<edge> G[300101];
long long int d[301000];
long long int V, E;

void dijkstra(long long int s) {

	priority_queue<P, vector<P>, greater<P> >que;
	fill(d, d + V, INF);
	d[s] = 0;
	que.push(P(0, s));

	while (!que.empty()) {
		P p = que.top();
		que.pop();
		long long int v = p.second;
		if (d[v] < p.first)continue;
		for (int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}
long long int S,T,v,u;
int main() {
	cout << fixed << setprecision(10);
	cin>>V>>E;
	for(int i=0;i<E;i++){
		cin>>u>>v;
		u--;
		v--;
		G[u].push_back({v+V,1});
		G[u+V].push_back({v+2*V,1});
		G[u+2*V].push_back({v,1});

	}
	cin>>S>>T;
	S--;
	T--;
	V*=3;
	dijkstra(S);
	if(d[T]==INF){
		cout<<-1<<endl;
	}else{
		cout<<d[T]/3<<endl;
	}
} 


Measured memory_bytes: 18944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef pair<long double, int> l_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N;
long double A[40050], B[40050], C[40050];
struct SegmentTree {
private:
    int n;
    vector<int> node;
 
public:
    SegmentTree() {
        int sz = 50000;
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, INF);
        for(int i=0; i<sz; i++) node[i+n-1] = 0;
        for(int i=n-2; i>=0; i--) node[i] = min(node[2*i+1], node[2*i+2]);
    }
 
    void update(int x, int val) {
        x += (n - 1);
        node[x] = val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = (node[2*x+1] + node[2*x+2]);
        }
    }
    // hannkaikukann 
    int getsum(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        if(r <= a || b <= l) return 0;
        if(a <= l && r <= b) return node[k];
 
        int vl = getsum(a, b, 2*k+1, l, (l+r)/2);
        int vr = getsum(a, b, 2*k+2, (l+r)/2, r);
        return (vl + vr);
    }
};


long double solve() {
    vector<l_i> m(N);
    for(int i = 1; i <= N; i++) {
        m[i - 1] = {-A[i] / B[i], i};
    }
    sort(m.begin(), m.end());
    vector<int> inv(N + 1);
    for(int i = 0; i < N; i++) {
        inv[m[i].second] = i + 1;
        //cerr << i << " " << m[i].second << " " << m[i].first << endl;
    }
    long double ok = 1e18;
    long double ng = -1e18;
    for(int time = 0; time < 100; time++) {
        long double mid = (ok + ng) / 2.0;
        SegmentTree seg;
        vector<l_i> now(N);
        for(int i = 1; i <= N; i++) {
            now[i - 1] = {(A[i] * mid - C[i]) / (-B[i]), i};
        }
        sort(now.begin(), now.end());
        int inversion = 0;
        //cerr << "NOW: " << mid << endl;
        for(int i = 0; i < N; i++) {
            int nowindex = inv[now[i].second];
            //cerr << i << " " << nowindex << " " << now[i].first << endl;
            inversion += seg.getsum(0, nowindex);
            seg.update(nowindex, 1);
        }
        //cerr << mid << " " << inversion << endl;
        if(2 * inversion >= N * (N - 1) / 2) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main() {
    cout.precision(20);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> A[i] >> B[i] >> C[i];
    long double ansx = solve();
    for(int i = 1; i <= N; i++) swap(A[i], B[i]);
    long double ansy = solve();
    cout << ansx << " " << ansy << endl;
    return 0;
}


Measured memory_bytes: 7316
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <iomanip>
#include <cmath>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)
#define rrep(i, j, n) for(int i = (n) - 1; (j) <= i; --i)
constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 60;

int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; cin >> n;
	vector<double> x(n), y(n);
	rep(i, 0, n) cin >> x[i] >> y[i];

	vector<int> idx(n);
	double num = 0.0;
	double denom = 0.0;
	iota(idx.begin(), idx.end(), 0);
	do {
		rep(i, 0, n - 1) {
			double tmp = 0.0;
			 tmp += (x[idx[i]] - x[idx[i + 1]]) * (x[idx[i]] - x[idx[i + 1]]);
			 tmp += (y[idx[i]] - y[idx[i + 1]]) * (y[idx[i]] - y[idx[i + 1]]);
			 tmp = sqrt(tmp);
			 num += tmp;
		}
		denom += 1.0;
	} while (next_permutation(idx.begin(), idx.end()));

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


Measured memory_bytes: 3820
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

const ll MOD = 1e9 + 7; 

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF_INT (1<<30)
#define INF_LL (1ll<<62)

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

int N,Ma,Mb,dp[50][500][500];

int main(){
    cin>>N>>Ma>>Mb;
    int a[N],b[N],c[N];
    rep(i,50){
        rep(j,500){
            rep(k,500){
                dp[i][j][k]=10000;
            }
        }
    }
    dp[0][0][0]=0;
    rep(i,N){
        cin>>a[i]>>b[i]>>c[i];
    }
    rep(i,N){
        rep(j,500){
            rep(k,500){
                dp[i+1][j][k] = min(dp[i+1][j][k],dp[i][j][k]);
                dp[i+1][a[i]+j][b[i]+k] = min(dp[i][j][k] + c[i], dp[i][a[i]+j][b[i]+k]);
            }
        }
    }

    int ans=10000000;
    repi(i,1,500)ans=min(dp[N][Ma*i][Mb*i],ans);
    if(ans<10000)out(ans);
    else out(-1);
    
    
}

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

namespace _169_a
{
    internal class Multiplication1
    {
        private static void Main(string[] args)
        {
            var ab = Console.ReadLine()?.Split(" ").Select(int.Parse).ToArray();
            if (ab == null) return;

            var a = ab[0];
            var b = ab[1];

            Console.WriteLine(a * b);
        }
    }
}

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

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { x.modm(y.modpow(mod - 2)); }

void main()
{
	auto S = RD!string;
	bool ans = true;

	{
		long l, r = S.length / 2 - 1;
		while (l < r)
		{
			if (S[l] != S[r])
				ans = false;
			++l; --r;
		}
	}
	{
		long l = S.length / 2 + 1, r = S.length - 1;
		while (l < r)
		{
			if (S[l] != S[r])
				ans = false;
			++l; --r;
		}
	}
	{
		long l = 0, r = S.length - 1;
		while (l < r)
		{
			if (S[l] != S[r])
				ans = false;
			++l; --r;
		}
	}

	writeln(ans ? "Yes" : "No");
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>
#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
using namespace std;
using ll = long long;
ll MOD = 1e9+7;


int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, h, w, a, b, cnt=0;
    cin >> n >> h >> w;
    REP(i, n){
        cin >> a >> b;
        cnt += (a >= h && b >= w ? 1: 0);
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int s = Integer.parseInt(scan.next());
		int m=0;
		int h=0;
		if(s>=60){
			m=s/60;
			s=s%60;
		}
		if(m>=60){
			h=m/60;
			m=m%60;
		}
			System.out.println(h+":"+m+":"+s);
		scan.close();
	}
}

Measured memory_bytes: 17284
N = gets.to_i
a = gets.split(" ").map(&:to_i)
s = 0
sum = a.inject(0){|a,b|a + b}
0.upto(a.size-2) do |i|
  sum -= a[i]
  s += a[i] * sum
end
puts s % (10**9 + 7)

Measured memory_bytes: 33756
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int R = sc.nextInt();
		int ans;
		if(N < 10){
			ans = R + (100 * (10 - N));
		}else{
			ans = R;
		}
		System.out.println(ans);
	}	
}

Measured memory_bytes: 21844
N, K = map(int, input().split())
V = list(map(int, input().split()))

ans = 0
for l in range(min(N, K) + 1):
    Mr = N + 1 if l != 0 else N
    for r in range(N - min(N, K) + l, Mr):
        lst = sorted(V[:l] + V[r:], reverse=True)
        s_lst = sum(lst)
        x = lst[-1]
        for _ in range(min(l + N - r, K - (l + N - r))):
            x = lst.pop()
            if x >= 0:
                break
            s_lst -= x
        ans = max(ans, s_lst)
print(ans)


Measured memory_bytes: 3064
from collections import deque
import statistics
import math
from collections import Counter
N=int(input())
x=[]
y=[]
for a in range(N):
    b,c=(int(xxx) for xxx in input().split())
    x.append(b)
    y.append(c)
sa=deque([[0,0]])
if N>1:
    for a in range(N):
        for b in range(N-a-1):
            sx=x[a]-x[a+b+1]
            sy=y[a]-y[a+b+1]
            sa.append([sx,sy])
    sa.remove([0,0])
    ans=[]
    nagasa=len(sa)
    for a in range(nagasa):
        xx,yy=sa[a]
        ss=sa.count([xx,yy])+sa.count([-xx,-yy])
        ans.append(ss)
    kotae=max(ans)
    print(N-kotae)

else:
    print(1)


Measured memory_bytes: 5268
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

void read();
template<typename First, typename... Rest> void read(First& first, Rest&... rest);
void write();
template<typename First, typename... Rest> void write(First first, Rest... rest);
template<typename T> void write_vec(vector<T>& v, char divider);

int main(){
    string S, T;
    read(S, T);
    int ans = 0;
    if(S[0] == T[0]) ans++;
    if(S[1] == T[1]) ans++;
    if(S[2] == T[2]) ans++;
    write(ans);
    return 0;
}

//配列以外の入力を受け取る
void read(){

}
template<typename First, typename... Rest>
void read(First& first, Rest&... rest){
    cin >> first;
    read(rest...);
}
//
//配列以外を出力する
void write(){

}
template<typename First, typename... Rest>
void write(First first, Rest... rest){
    cout << first << " ";
    write(rest...);
}
//
//配列を区切って出力する
template<typename T>
void write_vec(vector<T>& v, char divider){
    for(size_t i = 0; i < v.size(); i++){
        cout << v[i] << divider;
    }
}
//

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
using namespace std;
int main(){int n,m;cin >> n;int b[n-1];rep(i,0,n-1)cin>>b[i];m=b[0]+b[n-2];rep(i,0,n-2)m+=min(b[i], b[i+1]);cout << m << endl;return 0;}

Measured memory_bytes: 256
// A Better (than Naive) Solution to find all divisiors
#include <bits/stdc++.h>

#define ll  long long

using namespace std;
vector<ll>v;
void printDivisors(ll n)
{
	// Note that this loop runs till square root
	for (int i=1; i<=sqrt(n); i++)
	{
		if (n%i == 0)
		{
			// If divisors are equal, print only one
			if (n/i == i)

				v.push_back(i);

			else // Otherwise print both
				//printf("%d %d ", i, n/i);

                v.push_back(i);

                v.push_back(n/i);
		}
	}
}


int main()
{
	ll a,b,mn,mx;
	cin >> a >>  b;
	mn =min(a,b);
	mx = max(a,b);
	printDivisors(mn);
	sort(v.begin(),v.end());
	for(int i=0; i<v.size(); i++)
    {
        ll x = v[i]*mx;
        if(x%mn==0)
        {
            cout << x << endl;
            return 0;
        }

    }
	printDivisors(mn);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cstdlib>
#include <typeinfo>

using namespace std;

#define FOR(i,n) for(i=0;i<n;++i)
#define INF 1e9

int i,j;

int main(void){
    
    int n;
    cin>>n;
    cout<<n*800-(n/15*200);
    
    
    
    return 0;
    
}


Measured memory_bytes: 256
n,Q=map(int,input().split())
g=[[] for i in range(n)]
for _ in range(n-1):
  a,b=map(int,input().split())
  g[a-1].append(b-1)
  g[b-1].append(a-1)
depth=[-1]*n
depth[0]=0
q=[0]
while q:
  x=q.pop()
  for t in g[x]:
    if depth[t]==-1:
      depth[t]=depth[x]+1
      q.append(t)
cnt=[0]*n
for _ in range(Q):
  p,x=map(int,input().split())
  cnt[p-1]+=x
q=[0]
visited=[False]*n
while q:
  x=q.pop()
  visited[x]=True
  for t in g[x]:
    if not visited[t]:
      cnt[t]+=cnt[x]
      q.append(t)
print(*cnt)

Measured memory_bytes: 108544
#include <bits/stdc++.h>
using namespace std;
const int N = 5e3 + 1;
long long cs[N],ans;
int p[14] = {1},is[N],n,m,dp[200][14][N];
long long find(int l,int r){
	int dis = r - l;
	long long ret = 0;
	for(int i = 0;i < m;i++)
		ret+=max(dp[i][is[dis]][l],dp[i][is[dis]][r - p[is[dis]] + 1]);
	return ret;
}
void calc(int l,int r,int bl,int br){
	if(l > r)return;
	int mid = (l + r)/2,bst = bl,best;
	long long temp = 0,temp1 = 0,to = min(mid,br);
	for(;bst <= to;bst++){
		temp1 = find(bst,mid) - cs[mid - 1] + cs[bst - 1];
		if(temp < temp1)temp = temp1,best = bst;
	}
	ans = max(ans,temp);
	calc(l,mid - 1,bl,best);
	calc(mid + 1,r,best,br);
}
int main(){
	//freopen("readin.txt","r",stdin);
	scanf("%d%d",&n,&m);
	for(int i = 1;i < 14;i++)p[i] = p[i - 1]<<1;
	for(int i = 0,l = 0;i <= n;i++){
		while(l + 1 < 14 && p[l + 1] - 1 <= i)l++;
		is[i] = l;
	}
	for(int i = 1;i < n;i++)scanf("%lld",cs + i),cs[i]+=cs[i - 1];
	for(int i = 1;i <= n;i++)
		for(int j = 0;j < m;j++)
			scanf("%d",&dp[j][0][i]);
	for(int k = 0;k < m;k++)
		for(int i = 1;i < 14;i++)
			for(int j = 1;j <= n;j++)
				dp[k][i][j] = max(dp[k][i - 1][j],dp[k][i - 1][j + p[i - 1]]);
	calc(1,n,1,n);
	printf("%lld\n",ans);
}

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

using namespace std;
const int maxn = 1e5 + 1000;
const int mod = 1e9 + 7;
int s[maxn],t[maxn];
char str[maxn];
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie();
    int te;
    cin>>str;
    for(int i=0;str[i]!='\0';i++){
        if(str[i]=='A') te=1;
        else te=2;
        s[i+1]=s[i]+te;
    }
    cin>>str;
    for(int i=0;str[i]!='\0';i++){
        if(str[i]=='A') te=1;
        else te=2;
        t[i+1]=t[i]+te;
    }
    int n;
    int a,b,c,d;
    cin>>n;
    for(int i=0;i<n;i++) {
        cin>>a>>b>>c>>d;
        if(((s[b]-s[a-1])-(t[d]-t[c-1]))%3==0){
            cout<<"YES"<<endl;
        }
        else {
            cout<<"NO"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1536
if __name__ == "__main__":
    N = int(input())
    A = N*[0]
    B = N*[0]
    for i in range(N):
        A[i],B[i] = list(map(int,input().split()))

    buttons = 0

    for i in range(N-1,-1,-1):
            a = B[i] - (A[i]+buttons) % B[i]
            if a != B[i]:
                buttons += a

    print(buttons)



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

int enum_divisors(int N) {
    int c = 0;
    for (int i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            c++;
            if (N/i != i) c++;
        }
    }
    return c;
}

int main() {
    int N, M;
    cin >> N;
    int c = 0;
    for (int i = 1; i < N; i++) {
        M = N - i;
        c = c + enum_divisors(M);
    }
    cout << c << endl;
}

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

int main(){
    Init();
    ll n; cin >> n;
    vi a(n), b(n);
    rep(i, n){
        cin >> a[i];
        b[i] = a[i]-(i+1);
    }

    sort(all(b));
    ll median;
    // 偶数長の場合
    if(n%2 == 0) median = (b[(n/2)]+b[(n/2)-1])/2;
    // 奇数長の場合
    else median = b[(n-1)/2];

    ll ans = 0;
    rep(i, n) ans += abs(b[i]-median);
    cout << ans << endl;
}

Measured memory_bytes: 3328
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::iter::FromIterator;
use std::cmp::{max, min};

#[allow(unused_macros)]
macro_rules! vecs {
    ($init:expr; $($dim:expr);*) => {
        vecs!($($dim);* => $init)
    };
    ($head:expr; $($tail:expr);* => $init:expr) => {
        vec![vecs!($($tail);* => $init); $head]
    };
    ($head:expr => $init:expr) => {
        vec![$init; $head]
    };
}

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let n = scan.read::<usize>();
    let s = scan.chars();
    let mut dp = vecs![0;n+1;n+1];
    for i in (0..n).rev() {
        for j in (0..n).rev() {
            if s[i] == s[j] {
                let tmp = if i + 1 < n && j + 1 < n {dp[i+1][j+1]} else {0};
                dp[i][j] = tmp + 1;
            }
        }
    }

    let mut ret = 0;
    for i in 0..n { for j in 0..n {
        if i >= j {continue;}
        ret = max(ret, min(dp[i][j], j - i));
    }}
    
    println!("{}", ret);
}


// region template
#[allow(dead_code)]
fn iu(i: i64) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> i64 { i as i64 }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

#[allow(dead_code)]
fn alt<S, T>(v: Vec<S>) -> T where T: FromIterator<S> {
    v.into_iter().collect::<T>()
}

#[allow(dead_code)]
fn dup<S, T>(v: &[S]) -> T where T: FromIterator<S>, S: Clone {
    v.iter().cloned().collect::<T>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

Measured memory_bytes: 231676
using System;
using System.Collections.Generic;
using System.Linq;

public static class Program
{
    public static void Main(string[] args)
    {
        var nm = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var vals = new List<int[]>();
        for (int i = 0; i < nm[1]; i++)
        {
            var val = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            vals.Add(val.Where((value, index) => index != 0).ToArray());
        }
        var p = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var cnt = 0;
        for (int i = 0; i < Math.Pow(2, nm[0]); i++)
        {
            var ary = new bool[nm[0]];
            for (int j = 0; j < nm[0]; j++)
            {
                var y = (i >> j) & 1;
                ary[j] = y == 1;
            }
            var flg = vals.Select((v, x) => Check(ary, v, p[x])).ToArray();
            if (flg.Count(x => x) == nm[1])
            {
                cnt++;
            }
        }
        Console.WriteLine(cnt);
    }

    public static bool Check(bool[] ary, int[] val, int p)
    {
        var cnt = val.Count(x => ary[x - 1] == true);
        return cnt % 2 == p ? true : false;
    }
}

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

n,w=map(int,input().split())
VW=[list(map(int,input().split())) for _ in range(n)]

DP=[[0 for _ in range(w+1)] for _ in range(n+1)]
for i in range(n):
    for j in range(w+1):
        item=VW[i]
        DP[i+1][j]=max(DP[i][j],DP[i+1][j])
        if 0<=j+item[1]<=w:
            DP[i+1][j+item[1]]=max(DP[i+1][j+item[1]],DP[i][j]+item[0])

print(DP[-1][-1])


Measured memory_bytes: 25984
n=int(input())
rng = [[] for _ in range(n)]
for i in range(n):
  x,l=map(int,input().split())
  rng[i] = [x-l,x+l]
rng.sort(key=lambda y:y[1])
cnt=0
t_mx=-(10**10)
for i in range(n):
  if t_mx > rng[i][0]:
    cnt += 1
  else:
    t_mx = rng[i][1]
print(n-cnt)

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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    string a, b, c;
    cin >> a >> b >> c;
    cout << a[0] << b[1] << c[2] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cassert>
#include <string>
#include <cstring>
#include <bitset>
 
#define FOR(i, a, b) for(int i = a; i < (int) b; i++)
#define F0R(i, a) FOR (i, 0, a)
#define ROF(i, a, b) for(int i = a; i >= (int) b; i--)
#define R0F(i, a) ROF(i, a, 0)
#define GO(i, a) for (auto i : a)
 
#define rsz resize
#define eb emplace_back
#define pb push_back
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define f first
#define s second
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;

const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int ms[] = {+31, +29, +31, 30, +31, +30, +31, +31, +30, +31, +30, +31};

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;

int dp [N][2];
vvi g (N);

int add (int a, int b) {
  a += b;
  while (a >= MOD) a -= MOD;
  return a;
}

int mult (int a, int b) {
  i64 res = 1LL * a * b;
  if (res >= MOD) res %= MOD;
  return res;
}

void dfs (int node = 0, int p = -1) {
  bool is_leaf = true;
  GO (to, g[node]) {
    if (to != p) {
      dfs (to, node);
      is_leaf = false;
    }
  }
  if (is_leaf) {
    dp[node][0] = dp[node][1] = 1;
  } else {
    i64 res_a = 1, res_b = 1;
    GO (to, g[node]) {
      if (to == p) continue;
      res_a = mult (res_a, dp[to][0] + dp[to][1]);
      res_b = mult (res_b, dp[to][0]);
    }
    dp[node][0] = add (dp[node][0], res_a);
    dp[node][1] = add (dp[node][1], res_b);
  }
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  F0R (i, n - 1) {
    int st, et;
    cin >> st >> et;
    --st; --et;
    g[st].eb(et);
    g[et].eb(st);
  }
  dfs ();
  cout << add (0, dp[0][0] + dp[0][1]) << '\n';
  return 0;
}


Measured memory_bytes: 12032
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Main {

    public static void main( final String[] args ) {

	final Scanner stdin = new Scanner( System.in );

	final String[] colorStr = { "black", "blue", "lime", "aqua", "red", "fuchsia", "yellow", "white" };

	while ( true ) {

	    final String input = stdin.nextLine().trim();
	    if ( "0".equals( input ) ) {
		break;		    
	    }

	    int[] in = new int[3];
	    in[0] = Integer.parseInt( input.substring( 1, 3 ), 16 );
	    in[1] = Integer.parseInt( input.substring( 3, 5 ), 16 );
	    in[2] = Integer.parseInt( input.substring( 5, 7 ), 16 );
	    
	    int minIndex = -1;
	    int minD = Integer.MAX_VALUE;
	    for ( int i = 0; i < 8; i++ ) {
		final int[] color = makeColor( i );
		final int d = dist( color, in );
		if ( minD > d ){
		    minD = d;
		    minIndex = i;
		}
	    }
	    System.out.println( colorStr[minIndex] );
	}	
    }

    static int[] makeColor( int i ) {
	int[] ans = new int[3];
	int index = 2;
	while ( i > 0 ) {
	    ans[index] = ( i % 2 == 1 ? 0xff : 0 );
	    i /= 2;
	    index--;
	}
	return ans;
    }

    static int dist( int[] a, int[] b ) {
	int sum = 0;
	final int lim = min( a.length, b.length );
	for ( int i = 0; i < lim; i++ ) {
	    sum += ( a[i] - b[i] ) * ( a[i] - b[i] );
	}
	return sum;
    }    
}

Measured memory_bytes: 26204
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		PrintWriter pw=new PrintWriter(System.out);
		char[] cs=sc.next().toCharArray();
		if(cs.length==3) {
			int s=0,t=cs.length-1;
			while(s<t) {
				cs[s]^=cs[t];
				cs[t]^=cs[s];
				cs[s]^=cs[t];
				++s;--t;
			}
		}
		pw.println(String.valueOf(cs));
		pw.close();
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public int nextInt() {
    	return Integer.parseInt(next());
    }
    
    public long nextLong() {
    	return Long.parseLong(next());
    }
}

Measured memory_bytes: 21076
d = Array.new(4).map{Array.new(4, 0)}

3.times do |i|
  a, b = gets.chomp.split.map(&:to_i)
  d[a-1][b-1] = 1
  d[b-1][a-1] = 1
end

4.times do |i|
  4.times do |j|
    4.times do |k|
      if d[i][j] == 1
        if d[j][k] && i != k && j != k
          if d[k][[0, 1, 2, 3].select{|z| z!= i && z != j && z != k}.at(0)] == 1
            puts 'YES'
            exit
          end
        end
      end
    end
  end
end

puts 'NO'

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100

int n;
int A[100100];

int main() {
	cin >> n;
	rep(i, n)cin >> A[i];
	bool flag = true;
	int cnt = 0;
	while (flag) {
		flag = false;
		for (int j = n - 1; j >= 1; j--) {
			if (A[j] < A[j - 1]) {
				swap(A[j], A[j - 1]);
				cnt++;
				flag = true;
			}
		}
	}
	rep(i, n) {
		if (i == 0)cout << A[i];
		else cout << " " << A[i];
	}
	cout << endl;
	cout << cnt << endl;
}

Measured memory_bytes: 3088
N = int(input())
prime_list = [0] * (N+1)
cnt=0
for i in range(2, N + 1):
    cnt = 2
    copy=i
    while (cnt ** 2 <= copy):
        if (copy % cnt == 0):
            prime_list[cnt] += 1
            copy = int(copy / cnt)
            
        else:
            cnt += 1
    prime_list[copy] += 1
#ここまではok??　nまでの素因数を格納していく感じ!
cnt3 = 0
cnt5 = 0
cnt15 = 0
cnt25 = 0
cnt75 = 0
for i in range(1, N + 1):
    if (prime_list[i] >= 2):
        cnt3 += 1
    if (prime_list[i] >= 4):
        cnt5 += 1
    if (prime_list[i] >= 14):
        cnt15 += 1
    if (prime_list[i] >= 24):
        cnt25 += 1
    if (prime_list[i] >= 74):
        cnt75 += 1
#ここでは75=3*5*5だから各素因数が何個あるか取り出したいよね。これを必要なところだけ取っていく

#print(cnt75+ cnt25*(cnt3-1)+cnt15*(cnt5-1)+int((cnt5-1)*cnt5/2)*(cnt3-2))       
#こういうことなんだけど一つ一つ説明します笑

a = cnt75
#これはx^74となる数のこと
b = cnt25 * (cnt3 - 1)
#これはx^24*y^2となる数のことなんだけでcnt3にはxも含まれてるよね(というのも上で>=のかたちで数えてるから)
# だから自分の分を引かなきゃだめーって感じ!!
c=cnt15*(cnt5-1)
#これもおなじだよね、うん、、笑
d = int((cnt5-1)*cnt5/2)*(cnt3-2)
#ここも同じなんだけどまずx^4*y^4*z^2の形がほしいんだからcnt5の中から2つ欲しい、つまりnC2の関係を使ってもとめる、このあとz^2はcnt2のなかから取るんだけど
#この中には当然x,yがはいってるからその分の2を引いたものをかける感じ！！　これらをすべて足せばok!!笑

print(a+b+c+d)

Measured memory_bytes: 3064
class UnionFind:
    def __init__(self, n):
        self.root = [i for i in range(n + 1)]
        self.rank = [0] * (n + 1)

    def find(self, x):
        if self.root[x] == x:
            return x
        else:
            self.root[x] = self.find(self.root[x])
            return self.root[x]

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

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.root[x] = y
        else:
            self.root[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1


n, m = map(int, input().split())
uf = UnionFind(n)
for _ in range(m):
    x, y, z = map(int, input().split())
    uf.union(x, y)

for i in range(1, n + 1):
    uf.find(i)

n_tree = set(uf.root)
ans = len(n_tree) - 1
print(ans)


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

const int MAX = (int)1e5 + 9;

int A[MAX];
int n;

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

    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> A[i];
    }
    sort(A, A + n);
    vector<int> s;
    for(int i = n - 1; i > 0; i--) {
        if(A[i] == A[i - 1]) {
            i--;
            s.push_back(A[i]);
        }
    }
    if(s.size() <= 1)
        cout << 0;
    else
        cout << ((long long)s[0] * (long long)s[1]);

    return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,ssse3,tune=native")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
//using arr = array;
using pi = pair<ll, ll>;
using vi = vector<ll>;
using vpi = vector<pi>;
using ld = long double;
#include<bits/extc++.h>
using namespace __gnu_pbds;
using oset = tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>;
const int maxn = 404, mod = (119<<23)+1, lg = 19;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	cout << max(0, a-2*b) << '\n';
	return 0;
}


Measured memory_bytes: 256
// NK
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
#define vi vector<int>
#define vii vector<ii>
#define vll vector<ll>
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define psf push_front
#define pof pop_front
#define mkp make_pair
#define all(x) x.begin(), x.end()

const int MAXS = 2e3+5;
array<vi, MAXS> g;
array<int, MAXS> vis;
array<int, MAXS> ans;

void bfs(int u){
  queue<ii> BFS;
  BFS.push(ii(u, 0)); //node, dis
  vis[u]=1;
  while(!BFS.empty()){
    int auxu = BFS.front().first, w = BFS.front().second;
    BFS.pop();
    for (int i=0; i<g[auxu].size(); i++){
      int v = g[auxu][i];
      if (!vis[v]){
	vis[v]=1;
	BFS.push(ii(v, w+1));
	ans[w+1]++;
      }
    }
  }
}

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

  int n,x,y; cin>>n>>x>>y;
  for (int i=1; i<n; i++){
    g[i].eb(i+1);
    g[i+1].eb(i);
  }
  g[x].eb(y);
  g[y].eb(x);

  for (int i=1; i<=n; i++){
    vis.fill(0);
    bfs(i);
  }
  for (int i=1; i<n; i++) cout<<(ans[i]/2)<<'\n';

  return 0;
}


Measured memory_bytes: 384
import sys

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))


n = ri()
s = rr()
ans = s.count('R') * s.count('G') * s.count('B')
for i in range(n-2):
    for j in range(i+1, n-1):
        k = j + j - i
        if k < n:
            if s[k] != s[j] and s[j] != s[i] and s[k] != s[i]:
                ans -= 1
print(ans)








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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[100005];

int main()
{
    int N;
    cin >> N;
    ll odd = 0;
    REP(i, N)
    {
        cin >> A[i];
        if (A[i] % 2 == 1)
            odd++;
    }
    if (odd % 2 == 0)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

bool solve() {
  long long n, a, b, c, d; cin >> n >> a >> b >> c >> d;
  --n;
  if (a > b) swap(a, b);
  long long high = d*n;
  if (a+high < b) return false;
  long long mid = c*n;
  long long low = d*(n-1)-c;
  if (mid <= low) return true;
  long long k = (high-b+a)/(high-low);
  return high-k*(high-low) >= b-a && mid-k*(high-low) <= b-a;
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    puts(solve()?"YES":"NO");
  }
  return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>
int main(void){
    char N[5];
    scanf("%s",N);
    if(N[1]!=N[2]){
        printf("No\n");
    }
    else{
    if(N[0]!=N[1]&&N[3]!=N[1]){
        printf("No\n");
    }
    else{
        printf("Yes\n");
    }
    }
    return 0;
}


Measured memory_bytes: 128