akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
long double t[105];
long double v[105];
int n;
long double sum[105];
int main() {
    //freopen("input.txt", "r", stdin);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> t[i];
    }
    for (int i = 1; i <= n; i++) {
        cin >> v[i];
    }
    sum[0] = 0;
    for (int i = 1; i <= n; i++) {
        sum[i] = sum[i - 1] + t[i];
    }
    v[n + 1] = 0;
    long double curv = 0;
    long double ans = 0;
    for (int i = 1; i <= n; i++) {
        if ((curv + t[i]) <= v[i]) {
            long double curr = t[i];
            for (int j = i + 1; j <= (n + 1); j++) {
                long double ran = sum[j - 1] - sum[i - 1];
                curr = min(curr, 0.5 * (v[j] + ran - curv));
            }
            ans += curv * curr + (curr * curr) / 2;
            ans += (curv + curr) * (t[i] - curr) - ((t[i] - curr) * (t[i] - curr)) / 2;
            curv = curv + curr - (t[i] - curr);
        }
        else {
            long double curr = t[i];
            for (int j = i + 1; j <= (n + 1); j++) {
                long double ran = sum[j - 1] - sum[i - 1];
                curr = min(curr, 0.5 * (v[j] + ran - curv));
            }
            if ((curv + curr) <= v[i]) {
                ans += curv * curr + (curr * curr) / 2;
                ans += (curv + curr) * (t[i] - curr) - ((t[i] - curr) * (t[i] - curr)) / 2;
                curv = curv + curr - (t[i] - curr);
            }
            else {
                curr = min((v[i] + t[i] - curv) / 2, curr);
                long double x = (curv + curr - v[i] + curr);
                long double y = v[i] - curv;
                ans += curv * y + (y * y) / 2;
                ans += (x - y) * v[i];
                ans += (t[i] - x) * v[i] - (t[i] - x) * (t[i] - x) / 2;
                curv = v[i] - (t[i] - x);
            }
        }
        //cout << v[i + 1] << ' ' << v[i] << ' ' << curv << '\n';
    }
    cout << fixed << setprecision(3) << ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int main(){
	int n,x;
	cin >> n >> x;
	vector<int> a(n+1);
	for (int i = 0; i < n; ++i)
	{
		cin >> a.at(i);
	}
	a.at(n) = x;
	vector<int> s(n);
	int d;
   if(n==1){
    cout << abs(a.at(0)-x) << endl;
  }

  else{
    sort(a.begin(),a.end());
	for (int i = 0; i <n; ++i)
	{
		s.at(i) = a.at(i+1) - a.at(i);
		if(i==0){
			d = s.at(i);
		}
		else{
			d = gcd(s.at(i),d);
			if(d==1){
				break;
			}
		}

	}
	cout << d << endl;
  }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
int64_t A,B,C,K;
  int64_t abc=0;
  int64_t abcd=0;
  cin >> A >> B >> C >> K;
  for (int i=0; i<A; i++)
  {
    if(abcd < K )
    {
    abc++;
    abcd++;
    }
    else
    {
      break;
    }
  }
  if(abcd < K )
  {
    for (int j=0; j<B; j++)
    {
      if(abcd < K )
      {
        abcd++;
      }

    }
  }
  if(abcd < K )
  {
    for (int k=0; k<C; k++)
    {
      if(abcd < K )
      {
        abc--;
        abcd++;
      }

    }
  }
  cout << abc << endl;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll inf = LONG_LONG_MAX / 2 - 1;
    ll v, e;
    cin >> v >> e;
    vector<vector<ll>> g(v, vector<ll>(v, inf));
    rep(i, v) g[i][i] = 0;
    rep(i, e) {
        ll s, t, d;
        cin >> s >> t >> d;
        g[s][t] = d;
    }
    rep(i, v) {
        rep(j, v) {
            rep(k, v) {
                if ((g[j][i] == inf) || (g[i][k] == inf)) continue;
                g[j][k] = min(g[j][k], g[j][i] + g[i][k]);
            }
        }
    }
    rep(i, v) {
        rep(j, v) {
            rep(k, v) {
                if ((g[j][i] == inf) || (g[i][k] == inf)) continue;
                if (g[j][k] > g[j][i] + g[i][k]) {
                    cout << "NEGATIVE CYCLE" << endl;
                    return 0;
                }
            }
        }
    }
    rep(i, v) {
        rep(j, v) {
            string val = (g[i][j] == inf) ? "INF" : to_string(g[i][j]);
            printf("%s%s", val.c_str(), (j == (v - 1)) ? "\n" : " ");
        }
    }
    return 0;
}



Measured memory_bytes: 3392
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        String t = in.next();
        System.out.println(minimumChar(t, s));
    }

    static int minimumChar(String S1, String S2) {
        int n = S1.length();
        int m = S2.length();
        int ans = Integer.MAX_VALUE;
        for (int i = 0; i < m - n + 1; i++) {
            int minRemovedChar = 0;
            for (int j = 0; j < n; j++) {
                if (S1.charAt(j) != S2.charAt(i + j)) {
                    minRemovedChar++;
                }
            }
            ans = Math.min(minRemovedChar, ans);
        }
        return ans;
    }
}


Measured memory_bytes: 35572
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <algorithm>
#define fin(i,n) for (int i = 0; i < (int)(n); i++)
#define fin2(i,j,m,n) fin(i,m) fin(j,n)
using namespace std;

template <typename T> bool contains(vector<T> list, T value) {
	for (T tmp : list) if (tmp == value) return true;
	return false;
}

int cnt = 0;
int n, m;
map<int, set<int>> linkList;

void dfs(vector<int> path) {

	if (path.size() == n) {
		cnt++;
		return;
	}

	set<int> nextList = linkList[path.back()];
	for (int next : nextList) {
		if (contains(path, next)) continue;

		path.push_back(next);
		dfs(path);
		path.pop_back();
	}
}

int main()
{
	 cin >> n >> m;
	
	fin(i, n) {
		set<int> tmp;
		linkList.insert(make_pair(i + 1, tmp));
	}

	fin(i, m) {
		int a, b; cin >> a >> b;
		linkList.at(a).insert(b);
		linkList.at(b).insert(a);
	}

	vector<int> path;
	path.push_back(1);

	dfs(path);

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#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 _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi   = vec<int>;
using vvi  = vec<vi>;
using vvvi = vec<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int n, k; cin >> n >> k;
  vi h(n);
  rep(i,n) cin >> h[i];
  int cnt = 0;
  rep(i,n){
    if(h[i]>=k) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3676
void solve();

int main() {
	solve();
	return 0;
}

//////////////////////////////////////////////////
//////////////////////////////////////////////////
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <limits.h>
#include <math.h>
#include <iomanip>
using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;

vector<int> A;
vector<int> store;
int ans = 0;

void solve() {
	int N;
	cin >> N;
	A.resize(N + 1); store.resize(N + 1,0);
	for (int n = 1; n <= N; n++)cin >> A[n];
	for (int n = N; n >= 1; n--) {
		int old = store[n];
		store[n] = (A[n] + old) % 2;
		ans += store[n];
		if(n != 1)store[1] += store[n];
		for (int m = 2; m * m <= n; m++) {
			if (n % m == 0) {
				store[m] += store[n];
				if(m != n/m)store[n / m] += store[n];
			}
		}
	}
	cout << ans << endl;
	for (int n = 1; n <= N; n++) {
		if (store[n] == 1)cout << n << endl;
	}
	return;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	cout << s[0] << s.size()-2 << s[s.size()-1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const ll MOD = 1e9 + 7;
// return a^b in O(log b)
ll mypow(ll a, ll b){
    if (b == 0)
        return 1;
    ll tmp = mypow(a, b / 2);
    if (b % 2)
        return (((tmp * tmp) % MOD) * a) % MOD;
    else
        return (tmp * tmp) % MOD;
}

long long comb2(int n, int k){
    static bool init = false;
    static vector<ll> frc(200001, 1), inv(200001, 1);
    if(!init){
        init = true;
        REP(i, 200000){
            frc[i + 1] = (frc[i] * (i + 1)) % MOD;
            inv[i + 1] = mypow(frc[i + 1], static_cast<long long>(MOD - 2));
        }
    }
    if(k == n) return 1;
    if (k < 0 || n < k) return 0;
    long long res = (((frc[n] * inv[k]) % MOD) * inv[n - k]) % MOD;
    return res;
}

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

    ll n;
    cin >> n;
    vll a(n + 1);
    map<ll, ll> mp;
    ll d;
    REP(i, n + 1){
        cin >> a[i];
        mp[a[i]]++;
        if(mp[a[i]] == 2) d = a[i];
    }
    ll edge = 0, c = 0;
    REP(i, n + 1){
        if(a[i] == d){
            c++;
            continue;
        }
        if(c == 0 || c == 2) edge++;
    }

    for(int k = 1; k <= n + 1; k++){
        ll res = comb2(n + 1, k) - comb2(edge, k - 1) + MOD;
        res %= MOD;
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 11392
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <deque>
#define pb push_back
#define mod 1000000007
#define all(x) x.begin(),x.end()
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,ll> pll;

int g[55][55];
int h,w;

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

void iro(int x,int y){
  int tmp=0;
  for(int i=0;i<8;i++){
    if(g[x+dx[i]][y+dy[i]]==-1) tmp++;
  }
  g[x][y]=tmp;
}

int main(void){
  cin>>h>>w;
  char c;
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cin>>c;
      if(c=='.') g[i][j]=0;
      else g[i][j]=-1;
    }
  }
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      if(g[i][j]==-1) continue;
      iro(i,j);
    }
  }
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      if(g[i][j]==-1) cout<<"#";
      else cout<<g[i][j];
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <string>
#include <bits/stdc++.h>
#include <set>    
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,h[100005];
ll dp[100005];
#define ALL(v)  (v).begin(),(v).end()
std::set<long long> st;
 
    /*  ペア関連
    //vector<pair<long long, long long> > pairs(N);
    for(long long i=0; i<N; i++){
        long long a, b;
        cin >> a >> b;
        pairs[i] = make_pair(a, b);
    }
    
    //sort(pairs.begin(), pairs.end(),greater<pair<int,int> >());
	sort(pairs.begin(), pairs.end());
    */
 
 	//stack<int> sta;   
    //queue<int> que;
 
 
int main(){
	
	long long N,M,K;
	string s;
    
	std::cin >> N;
    //std::cin >> N >> M;
    //std::cin >> N >> M >> K;
    
    
	std::vector<long long> v(1000001);
	//std::vector<long long> w(N);
    //std::cin >> s;
    int work;
    work=0;
    
    // 配列入力
    v[1]=N;
    st.insert(v[1]);
    long long i;
    i=2;
    while(i!=1000001){
		if(v[i-1]%2==0){
			v[i]=v[i-1]/2;
		}
		else{
			v[i]=3*v[i-1]+1;
		}
		if(st.find(v[i])==st.end()){
			st.insert(v[i]);
		}
		else{
			printf("%lld",i);
			return 0;
		}
		i++;
	}
	
	/*
	for(long long i=0; i<N; i++){
		std::cin >> w[i];
	}
	*/
	
	
	//ソート
    //std::sort(v.begin(),v.end());//昇順ソート
    //std::sort(v.begin(),v.end(),std::greater<long long>());//降順ソート
    //std::sort(w.begin(),w.end());//昇順ソート
    //std::sort(w.begin(),w.end(),std::greater<long long>());//降順ソート
    int sum,sum1;
	sum=0;
	sum1=0;
	int flg,flg1,cnt,cnt1;
	flg=0;
	flg1=0;
	cnt=0;
	cnt1=0;
	int max;
	int max1;
	max=0;
	max1=0;
	
    /*
	for(long long i=0; i<N; i++){
		
	}
	*/
	
	//文字列入力
	/*
	for(long long i=0; i<s.length(); i++){
		
		if(s[i]!='1'){
	}
	*/
    if(1){
    	printf("%d",st.size());
    	//puts("Yes");
    	//文字列の出力
    	//std::cout << s.size << std::endl;
	}
	else{
		//puts("No");
	}
	return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
using ll = long long; constexpr int inf = INT_MAX / 2; constexpr ll infl = 1LL << 60;
template<class T>void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T>void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T>void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T>void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T>T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }

void _main() {
  int X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  vector<ll> A(X), B(Y), C(Z);
  rep(i, 0, X) cin >> A[i];
  rep(i, 0, Y) cin >> B[i];
  rep(i, 0, Z) cin >> C[i];
  sort(all(A), greater<ll>());
  sort(all(B), greater<ll>());
  sort(all(C), greater<ll>());

  vector<ll> ans;
  rep(i, 0, X) rep(j, 0, Y) rep(k, 0, Z) {
    if ((i+1) * (j+1) * (k+1) > K) break;
    ans.push_back(A[i]+B[j]+C[k]);
  }
  sort(all(ans), greater<ll>());

  rep(i, 0, K) cout << ans[i] << endl;
}

Measured memory_bytes: 1404
#include <stdio.h>

int main(void)
{
    char c[2][4];

    for (int i = 0; i < 2; i++) {
        scanf("%s", c[i]);
    }

    if (c[0][0] == c[1][2] && c[0][1] == c[1][1] && c[0][2] == c[1][0]) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }

    return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}



	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int y=sc.nextInt();

		for(int i=0; i<=n; i++) {
			for(int j=0; j<=n; j++) {
				if(i+j>n)continue;
				int k=n-(i+j);
				if(10000*i + 5000*j + 1000*k == y) {
					System.out.println(i+" "+j+" "+k);
					sc.close();
					return;
				}
			}
		}
		System.out.println("-1 -1 -1");
		sc.close();
	}
}


Measured memory_bytes: 39316
#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);

    ll N,X,Y; cin >> N >> X >> Y;

    for (int k = 1;k < N;k++){
        ll ans = 0;
        for (int i = 1;i < N;i++){
            if(i+k <= X){
                ans++;
            }else if(i < X){
                ll a = i+k;
                ll b = Y-(k-(X-i+1));
                if(a < b) ans += 2;
                else if(a == b) ans ++;
                ll c = Y+(k-(X-i+1));
                if(c <= N && c != b) ans++;
                
            }else if(i < Y){
                ll a = i+k;
                if(k-(i-X+1) >= 0){
                    ll b = Y-(k-(i-X+1));
                    ll c =  Y+(k-(i-X+1));
                    if(a < b) ans += 2;
                    else if(a == b) ans++;
                    if(a>c){if(a <= N) ans++;}
                    else if(b != c && c <= N) ans++;
                }else{
                    if(a <= N) ans++;
                }
            }else{
                if(i+k <= N) ans++;
            }
            //cout << ans << endl;
        }
        //cout  << endl;
        cout << ans << endl;
    }

    return 0;

}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, a, r;

int main() {
	cin >> n;
	rep(i,n) {
		cin >> a;
		r += (a%2==0);
	}
	cout << (int)pow(3,n) - (int)pow(2,r) << ln;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main ()
{
    ll a=0,b=0,n,k;
    cin>>n>>k;
    if(n>k && n%k==0)
    {
        cout<<0;
        return 0;
    }
    else if(n>k &&  n%k!=0)
    {
        ll t;
        t=n%k;
        cout<<k-t;
        return 0;
    }
    else
    {
        while(b<=a)
    {
        a=n;
        n=abs(n-k);
        b=n;
    }
    
    
    cout<<a;
    return 0;}
}


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

using namespace std;

typedef long long ll;

int main(){
ll N,M; cin >> N >> M;
  vector<pair<ll,ll>> AB(N);
  for(int i = 0 ; i < N; i++){
    cin >> AB[i].first >> AB[i].second;}
  sort(AB.begin(),AB.end());
  
  ll sum = 0; ll cnt = 0; int i = 0;
  while(cnt < M){
    sum += AB[i].first * AB[i].second;
    cnt += AB[i].second;  i++;}
   
  sum -= AB[i-1].first*( cnt - M);
  
  cout << sum << endl; return 0;}
  
  


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

int N,A[100010],L[100010],R[100010];

int main(){
    cin>>N;
    for(int i=1;i<=N;i++){
        cin>>A[i];
    }
    for(int i=1;i<=N;i++){
        L[i]=__gcd(L[i-1],A[i]);
    }
    for(int i=N;i>=1;i--){
        R[i]=__gcd(R[i+1],A[i]);
    }
    int max=0;
    for(int i=1;i<=N;i++){
        if(max<__gcd(L[i-1],R[i+1]))max=__gcd(L[i-1],R[i+1]);
    }
    cout<<max<<endl;
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int h[100010];
    for(int i=1;i<=n;i++){
        cin>>h[i];
    }
    int mem[100010]={};
    int cost[100010]={};
    cost[1]=0;
    cost[2]=abs(h[2]-h[1]);
    for(int i=3;i<=n;i++){
        int vmin=1000000000;
        for(int j=1;j<=k&&j<i;j++){
            vmin=min(vmin,cost[i-j]+abs(h[i]-h[i-j]));
        }
        cost[i]=vmin;
    }
    cout<<cost[n]<<"\n";
    return(0);
}

Measured memory_bytes: 4412
#include <cstdio>

inline int readin(){
	int x=0,c;
	for (;(c=getchar())<'0'||c>'9';);
	for (;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+c-48;
	return x;
}

char s[233][233];
bool p[233],q[233];

int main(){
	int h=readin(),w=readin();
	for (int i=1;i<=h;i++) scanf("%s",s[i]+1);
	for (int i=1;i<=h;i++){
		for (int j=1;j<=w;j++) if (s[i][j]!='.') p[i]=1;
	}
	for (int i=1;i<=w;i++){
		for (int j=1;j<=h;j++) if (s[j][i]!='.') q[i]=1;
	}
	for (int i=1;i<=h;p[i]?puts(""):0,i++)
		for (int j=1;j<=w;j++) if (p[i]&&q[j]) putchar(s[i][j]);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define Sekai_No_Owari return 0
#define rep(i, n) for(int i=0; i<n; i++)

using namespace std;
typedef long long ll;
void chmax(int & a, int b) { if (a <= b) a = b; }

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

	int res = 0, pre = 0, tmp = 0;
	int h;
	rep(i, n) {
		scanf("%d", &h);
		if (h <= pre) tmp++;
		else tmp = 0;

		chmax(res, tmp);
		pre = h;
	}

	cout << res << endl;

	Sekai_No_Owari;
}

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

using namespace std;


const int INF = 100000000;

void solve() {
    int N, M, X; cin >> N >> M >> X;
    vector<int> C(N);
    vector<vector<int>> A(N, vector<int>(M));

    for (int i = 0; i < N; i++) {
        cin >> C[i];
        for (int j = 0; j < M; j++) {
            cin >> A[i][j];
        }
    }

    int ans = INF;
    for (int bit = 0; bit < (1<<N); bit++) {
        vector<int> score(M);
        int cost = 0;
        for (int i = 0; i < N; i++) {
            if (bit & (1<<i)) {
                cost += C[i];
                for (int j = 0; j < M; j++) {
                    score[j] += A[i][j];
                }
            }
        }

        bool flag = true;
        for (int i = 0; i < M; i++) {
            if (score[i] < X) {
                flag = false;
                break;
            }
        }

        if (flag) ans = min(ans, cost);
    }

    if (ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}


int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int d = sc.nextInt();
    int g = sc.nextInt();
    int[] pronums = new int[d + 1];
    int[] bons = new int[d + 1];
    for(int i = d; i >= 1; i--){
      pronums[i] = sc.nextInt();
      bons[i] = sc.nextInt();
    }
    
    // no problem in input
    
    int min = 1000;
    int sum;
    int num;
    for(int i = 0; i < (1 << d); i++){
      sum = 0;
      num = 0;
      for(int j = 0; j < d; j++){
        if((i >> j & 1) == 1){
          sum += 100 * (d - j) * pronums[j + 1]+ bons[j + 1];
          num += pronums[j + 1];
        }
      }
      if(sum >= g){
        min = Math.min(min, num);
        continue;
      }
      for(int j = 0; j < d ; j++){
        if((i >> j & 1) == 0){
          if((double)(g - sum) / ((d - j) * 100) > pronums[j + 1] - 1){
            break;
          }else{
            num += ((g - sum) + ((d - j) * 100) - 1) / ((d - j) * 100);
            min = Math.min(min, num);
          }
        }
      }
    }
    System.out.println(min);
  }
}

Measured memory_bytes: 23764
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;

#define DE 1
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define ALL(s) (s).begin(),(s).end()
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define EACH(i,s) for (typeof((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl

template<class T1, class T2> ostream& operator<<(ostream &s, pair<T1,T2> P){return s<<'<'<<P.first<<", "<<P.second<<'>';}
template<class T> ostream& operator<<(ostream &s, vector<T> P) {s<<"{ ";for(int i=0;i<P.size();++i){if(i>0)s<<", ";s<<P[i];}return s<<" }"<<endl;}
template<class T1, class T2> ostream& operator<<(ostream &s, map<T1,T2> P) {s<<"{ ";for(typeof(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<'<'<<it->first<<"->"<<it->second<<'>';}return s<<" }"<<endl;}



int N;
int cost[10][10];
map<vint,int> dp;
map<vint,bool> seen;

int main() {
    //freopen( "/Users/macuser/Documents/Programming/Contest/input.in", "r", stdin );
    
    while (cin >> N) {
        int c;
        memset(cost, 0, sizeof(cost));
        for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) {
            cin >> c;
            cost[i+1][j+1] = c;
        }
        
        vint start(N);
        for (int i = 0; i < N; ++i) start[i] = i+1;
        
        dp.clear();
        seen.clear();
        dp[start] = 0;
        seen[start] = true;
        priority_queue<pair<int,vint>, vector<pair<int,vint> >, greater<pair<int,vint> > > que;
        que.push(MP(0,start));
        
        while (!que.empty()) {
            vint now = que.top().SE;
            int nowcost = que.top().FI;
            que.pop();
            
            if (dp[now] < nowcost) continue;
            
            for (int i = 0; i < N; ++i) {
                for (int j = i+1; j < N; ++j) {
                    vint nnow = now;
                    swap(nnow[i], nnow[j]);
                    int dist = dp[now] + cost[now[i]][now[j]];
                    
                    if (!seen[nnow]) {
                        que.push(MP(dist,nnow));
                        dp[nnow] = dist;
                        seen[nnow] = true;
                    }
                    else {
                        if (dist < dp[nnow]) {
                            dp[nnow] = dist;
                            que.push(MP(dist,nnow));
                        }
                    }
                }
            }
            
            //cout << now << " : " << dp[now] << endl;
        }
        
        int res = 0;
        EACH(it,dp) res = max(res, it->SE);
        
        cout << res << endl;
    }
    
    return 0;
}


Measured memory_bytes: 15552
#include<iostream>
#include<queue>
using namespace std;
#define White 0
#define Black 1
#define MAX 100
struct Queue {
	int color, deep, relate[MAX],roots,id;
};
Queue Q[MAX];
int main() {
	int n, u, k, v;
	cin >> n;
	queue<int> q;
	for (int i = 0; i < n; i++) {
		Q[i].color = White;
		Q[i].deep = -1;
	}
	for (int i = 0; i < n; i++) {
		cin >> u>>k;
		Q[u - 1].id = u;
		Q[u - 1].roots = k;
		if (i == 0) {
			Q[u - 1].deep = 0;
			Q[u - 1].color = Black;
			q.push(u);
		}
		if (k != 0) {
			for (int i = 0; i < k; i++) {
				cin >> v;
				Q[u - 1].relate[i]= v;
			}
		}
	}
	while (!q.empty()) {
		int s = q.front();
		for (int i = 0; i < Q[s - 1].roots; i++) {
			int nakami = Q[s - 1].relate[i];
			if (Q[nakami - 1].color == White) {
				q.push(Q[nakami - 1].id);
				Q[nakami - 1].deep = Q[s - 1].deep + 1;
				Q[nakami - 1].color = Black;
			}
        }
		q.pop();
	}
	for (int i = 0; i < n; i++) {
		cout << Q[i].id << " " << Q[i].deep << endl;
	}

}


Measured memory_bytes: 3124
def resolve():
    n = int(input())
    a = list(map(int, input().split()))

    q = int(input())
    num_table = [0] * 100010

    for ai in a:
        num_table[ai] += 1

    ans = sum(a)

    for _ in range(q):
        bi, ci = map(int, input().split())
        ans += num_table[bi] * (ci - bi)
        num_table[ci] += num_table[bi]
        num_table[bi] = 0
        print(ans)
        
resolve()

Measured memory_bytes: 20848
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

bool f[100010];
int dp[100010];
bool vis[100010];

int solve(int x)
{
    if (vis[x])
        return dp[x];
    vis[x] = true;
    if (f[x])
        return dp[x] = 0;
    if (x == 0)
        return dp[x] = 1;
    if (x >= 2)
        return dp[x] = (solve(x - 1) + solve(x - 2)) % mod;
    return dp[x] = solve(x - 1);
}

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

    int n, m;
    cin >> n >> m;
    rep(i, m)
    {
        int a;
        cin >> a;
        f[a] = true;
    }
    cout << solve(n) << endl;
}

Measured memory_bytes: 4352
#include<stdio.h>

long long N,M;
long long a[2000],b[2000],c[2000];
long long d[1001];
long long neg[1001];

long long main(){
	
	scanf("%lld%lld",&N,&M);
	for(long long i=0;i<M;i++){
		scanf("%lld%lld%lld",&a[i],&b[i],&c[i]);
		c[i]*=-1;
	}
	
	for(long long i=2;i<=1000;i++)d[i]=99999999999999999;

	for(int j=0;j<N*2;j++){
		for(long long i=0;i<M;i++){
		
			if(neg[a[i]]==1)neg[b[i]]=1;
			if(d[a[i]]!=99999999999999999 && d[b[i]]>d[a[i]]+c[i]){
				d[b[i]]=d[a[i]]+c[i];
				if(j>=N)neg[b[i]]=1;
			}
		}
	}
	if(neg[N])printf("inf\n");
	else printf("%lld",-d[N]);
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Main {

    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        int i = 0;
        try {
            while (i < 50 && (str = br.readLine()) != null) {
                String[] s = str.split(" ", 0);
                int x = Integer.parseInt(s[0]);
                int y = Integer.parseInt(s[1]);
                int a = x;
                int b = y;
                if (0 < x && 0 < y && x < 2000000001 && y < 2000000001) {
                    if (x < y) {
                        int z = x;
                        x = y;
                        y = z;
                    }
                    while (y > 0) {
                        int r = x % y;
                        x = y;
                        y = r;
                    }
                    int G = x;
                    int aa = a/G;
                    int bb = b/G;
                    int L = aa*bb*G;
                    System.out.println(G + " " + L);
                    i++;
                }
            }
        } catch (IOException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;

ll N, T;
vll t;

void solve()
{
    cin >> N >> T;
    t = vll(N); REP(i, N) cin >> t[i];

    ll ans = 0;
    FOR(i, 0, N-1)
    {
       ans += min(t[i+1]-t[i], T); 
    }
    ans += T;

    cout << ans << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();

    return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;

//https://beta.atcoder.jp/contests/agc028/tasks/agc028_a

public class Program_AGC028_A // ←Class名変更！！
{
    public static void Main(string[] args)
    {
        var st = Console.ReadLine();
        var s = Console.ReadLine();
        var t = Console.ReadLine();

        var l = Lcm(s.Length, t.Length);
        var x = new Dictionary<long, char>();

        for (int i = 0; i < s.Length; i++)
        {
            var pos = i * (l / s.Length) + 1;
            x[pos] = s[i];
        }


        for (int i = 0; i < t.Length; i++)
        {
            var pos = i * (l / t.Length) + 1;
            if (x.ContainsKey(pos))
            {
                if (x[pos] != t[i])
                {
                    Console.WriteLine(-1);
                    return;

                }
            }
        }

        Console.WriteLine(l);
    } // Main



    //最小公倍数 least common multiple
    public static long Lcm(int a, int b)
    {
        //return a * b / Gcd(a, b) ;
        return (a  / Gcd(a, b)) * b;
    }

    //ユークリッドの互除法
    public static long Gcd(long a, long b)
    {
        if (a < b) return Gcd(b, a); // 引数を入替えて自分を呼び出す

        while (b != 0)
        {
            var temp = a % b;
            a = b;
            b = temp;
        }

        return a;
    }

}     // Class




Measured memory_bytes: 20832
a=input().split(' ')
a[0]=int(a[0])
a[1]=int(a[1])
a[2]=int(a[2])
a[3]=int(a[3])
a[4]=int(a[4])
b=(a[0]*60)+a[1]
c=(a[2]*60)+a[3]
print((c-b)-a[4])

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    ll n; cin >> n;
    string s; cin >> s;
    map<char,int> mp;
    //for(char c='a';c<='z';c++) mp[c] = 0;
    for(int i=0;i<n;i++) mp[s[i]]++;

    ll ans=1;
    for(char c = 'a';c <= 'z';c++){
        if(mp[c]==0) continue;
        ans *= mp[c]+1;
        ans %= mod;
    }
    cout << ans-1 << endl;
}


Measured memory_bytes: 512
#include <stdio.h>

int find_max(int sort[5], int start);

int main(void)
{
	int i, j;
	int n;
	int t;
	int sort[5];
	int max;
	
	for (i = 0; i < 5; i++){
		scanf("%d", &sort[i]);
	}
	
	for (i = 0; i < 5; i++){
		max = find_max(sort, i);
		{
			int tmp = sort[max];
			sort[max] = sort[i];
			sort[i] = tmp;
		}
	}
	for (i = 0; i < 5; i++){
		printf("%d", sort[i]);
		if (i == 4){
			printf("\n");
		}
		else {
			printf(" ");
		}
	}
	
	return (0);
}

int find_max(int sort[5], int start)
{
	int i;
	int max;
	
	max = start;
	for (i = start + 1; i < 5; i++){
		if (sort[max] < sort[i]){
			max = i;
		}
	}
	return (max);
}

Measured memory_bytes: 600
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cout << setprecision(10) << setiosflags(ios::fixed);
	while(true){
		int n, w;
		cin >> n >> w;
		if(n == 0 && w == 0){ break; }
		vector<int> hist(11);
		for(int i = 0; i < n; ++i){
			int v;
			cin >> v;
			++hist[v / w];
		}
		int m = 0, h = 0;
		for(int i = 0; i < 11; ++i){
			if(hist[i] > 0){ m = i; }
			h = max(h, hist[i]);
		}
		double answer = 0.01;
		for(int i = 0; i <= m; ++i){
			const double g = static_cast<double>(m - i) / m;
			answer += g * hist[i] / h;
		}
		cout << answer << endl;
	}
	return 0;
}

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

int main() {
  string s;
  int k;
  cin >> s >> k;
  int n = s.size();

  vector<vector<vector<int>>> dp(n + 1, vector<vector<int>>(k + 2, vector<int>(2)));
  dp[0][0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < k + 1; j++) {
      if (s[i] - '0' == 0) {
        dp[i + 1][j][0] += dp[i][j][0];
      } else {
        dp[i + 1][j][1] += dp[i][j][0];
        dp[i + 1][j + 1][1] += (s[i] - '0' - 1) * dp[i][j][0];
        dp[i + 1][j + 1][0] += dp[i][j][0];
      }
      dp[i + 1][j][1] += dp[i][j][1];
      dp[i + 1][j + 1][1] += 9 * dp[i][j][1];
    }
  }
  cout << dp[n][k][0] + dp[n][k][1] << endl;
}


Measured memory_bytes: 256
#include <iostream>
using i64 = long long;

int main() {
  int n;
  std::cin >> n;

  int x = 0;
  for (int i = 0; i < n; i++) {
    int a, k;
    std::cin >> a >> k;
    while (!(a < k || a % k == 0)) {
      const int d = (a + k - 1) / k;
      const int diff = a % k;
      a -= (diff + d - 1) / d * d;
    }
    x ^= a / k;
  }

  std::cout << (x ? "Takahashi" : "Aoki") << std::endl;

  return 0;
}


Measured memory_bytes: 256
/**  ~*BISMILLAHIR RAHMANIR RAHIM*~  **/

#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second

typedef long long intl;
typedef pair<int, int> pii;

const int MX = 212;
int n;
pii P[MX];

struct Hopcroft_Karp {
    int N, M, match[MX], dist[MX];
    vector<int> G[MX];

    Hopcroft_Karp( int nn, int mm ) {
      N = nn, M = mm;
      memset(match, 0, sizeof match);
    }
    bool bfs() {
      queue<int> Q;
      for(int i=1; i<=N; i++) {
        if( !match[i] ) dist[i] = 0, Q.push(i);
        else dist[i] = INT_MAX;
      }
      dist[0] = INT_MAX;

      while( !Q.empty() ) {
        int u = Q.front(); Q.pop();
        if( !u ) continue;
        for(int v : G[u]) {
          if( dist[match[v]]==INT_MAX ) {
            dist[match[v]] = dist[u]+1;
            Q.push(match[v]);
          }
        }
      }
      return dist[0]!=INT_MAX;
    }
    bool dfs( int u ) {
      if( u ) {
        for(int v : G[u]) {
          if( dist[match[v]]==dist[u]+1 ) {
            if( dfs( match[v] ) ) {
              match[u] = v;
              match[v] = u;
              return true;
            }
          }
        }
        dist[u] = INT_MAX;
        return false;
      }
      return true;
    }
    int maximum_match() {
      int matching = 0;
      while( bfs() ) {
        for(int i=1; i<=N; i++) {
          if( !match[i] && dfs( i ) ) matching++;
        }
      }
      return matching;
    }

};

int main() {
  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  cin>>n;
  for(int i=1; i<=2*n; i++) {
    cin>>P[i].F>>P[i].S;
  }
  Hopcroft_Karp BPM(n, n);
  for(int i=1; i<=n; i++) {
    for(int j=n+1; j<=2*n; j++) {
      if( P[i].F<P[j].F && P[i].S<P[j].S ) {
        BPM.G[i].push_back(j);
      }
    }
  }
  int res = BPM.maximum_match();
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
using System;
 
namespace Test
{
     
    class MainClass
    {
        public static void Main(string[] args)
        {
            var inputs = Array.ConvertAll(Console.ReadLine().Split(),double.Parse);
            var x1 = inputs[0];
            var y1 = inputs[1];
            var x2 = inputs[2];
            var y2 = inputs[3];
 
            var lineX = Math.Abs(x2 - x1);
            var lineY = Math.Abs(y2 - y1);
            var result = Math.Sqrt(Math.Pow(lineX, 2) + Math.Pow(lineY, 2));
 
            Console.WriteLine(result);
        }
    }
}

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

string s;

int main(){
    cin >> s;
    int flg = 0;
    for(int i = 0; i < s.size(); ++ i){
        if(flg && s[i] == 'F') return puts("Yes"), 0;
        if(s[i] == 'C') flg = 1;
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e18);
const ll mod = ll(1e9+7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
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 dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,1,-1};

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans % mod;
}

struct UnionFind {
    vector<ll> par;
    vector<ll> rank;
    vector<ll> Size;
    UnionFind(ll n) {
        init(n);
    }
 
    void init(ll n) {
        par.resize(n + 1); rank.resize(n + 1); Size.resize(n + 1);
        rep0(i, n + 1){
            par[i] = i;
            rank[i] = 0;
            Size[i] = 1;
        }
    }
 
    ll root(ll x) {
        if (par[x] == x) return x;
        else return par[x] = root(par[x]);
    }
 
    bool same(ll x, ll y) {
        return root(x) == root(y);
    }
 
    bool merge(ll x, ll y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        Size[x] += Size[y];
        return true;
    }
 
    ll size(ll x){
        return Size[root(x)];
    }
};

//modの値の確認をすること
int main(){
    ll n,m;
    cin >> n >> m;
    UnionFind u(n);
    rep0(i, m){
        ll a,b;
        cin >> a >> b;
        u.merge(a, b);
    }
    if(u.size(2) > u.size(1)){
        rep1(i, n)if(u.root(i) == i && !u.same(i,1))u.merge(2, i);
    }else{
        rep1(i, n)if(u.root(i) == i && !u.same(i,2))u.merge(1, i);
    }
    pf(u.size(1) * (u.size(1) - 1) / 2 + u.size(2) * (u.size(2) - 1) / 2 - m);
    return 0;
}


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

#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int N; cin >> N;

    while (N != 0) {
        if (N%10==9) {
            Yes(); return 0;
        }
        N /= 10;
    }
    Yes(false);
}


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

typedef long long ll;
const int Maxn = 1e5;
const int Mod = 998244353;

int N;
char s[Maxn * 3 + 5];

int main() {
#ifdef LOACL
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	scanf("%d", &N);
	scanf("%s", s + 1);
	int R = 0, G = 0, B = 0, RG = 0, RB = 0, GB = 0;
	int ans = 1;
	for(int i = 1; i <= N * 3; i++) {
		if(s[i] == 'R') {
			if(GB) {
				ans = 1LL * ans * GB % Mod;
				GB--;
			} else if(G) {
				ans = 1LL * ans * G % Mod;
				G--, RG++;
			} else if(B) {
				ans = 1LL * ans * B % Mod;
				B--, RB++;
			} else R++;
		} else if(s[i] == 'G') {
			if(RB) {
				ans = 1LL * ans * RB % Mod;
				RB--;
			} else if(R) {
				ans = 1LL * ans * R % Mod;
				R--, RG++;
			} else if(B) {
				ans = 1LL * ans * B % Mod;
				B--, GB++;
			} else G++;
		} else {
			if(RG) {
				ans = 1LL * ans * RG % Mod;
				RG--;
			} else if(R) {
				ans = 1LL * ans * R % Mod;
				R--, RB++;
			} else if(G) {
				ans = 1LL * ans * G % Mod;
				G--, GB++;
			} else B++;
		}
	}
	for(int i = 1; i <= N; i++)
		ans = 1LL * ans * i % Mod;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 512