akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef struct pair<int,int> P;
typedef long long ll;

ll dp[100][400];

int dp1[16002][3]={};
int dp2[16002][3]={};
ll c[200001]={};
int main() {
	string a,b;
	cin>>a>>b;
	int la=a.length();
	int lb=b.length();
	if(la>lb){
		cout<<"GREATER"<<endl;
	}else if(lb>la){
		cout<<"LESS"<<endl;
	}else{
		if(a>b){
			cout<<"GREATER"<<endl;
		}else if(b>a){
			cout<<"LESS"<<endl;
		}else{
			cout<<"EQUAL"<<endl;
		}
	}
//	char chr1[]="abcdefghijklmnopqrstuvwxyz";
//	char chr2[]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
//	for(int i=0;i<26;++i){
//		if(s1[0]==chr1[i])cout<<chr2[i];
//	}
//	for(int i=0;i<26;++i){
//		if(s2[0]==chr1[i])cout<<chr2[i];
//	}
//	for(int i=0;i<26;++i){
//		if(s3[0]==chr1[i])cout<<chr2[i];
//	}
//	cout<<endl;
//	int ls=s.length();
//
//	int m=0;
//	int a1=0;
//	int a2=0;
//	int a3=0;
//	int a0=0;
//	bool flg=true;
//	for(a1=1;(s[a1]==s[a1-1])&&(a1<ls);a1++);
//	m=a1-a0;
//	for(a2=a1+1;(s[a2]==s[a2-1])&&(a2<ls);a2++);
//	m=max(a2-a1,a1-a0);
//	if(a2==ls)flg=false;
//	for(a3=a2+1;a3<ls;a3++){
//		for(;(s[a3]==s[a3-1])&&(a3<ls);a3++);
//		m=max(m,((a2-a1)+min(a1-a0,a3-a2)));
//		a0=a1;
//		a1=a2;
//		a2=a3;
//	}
//	if(flg)m=max(m,((a2-a1)+min(a1-a0,a3-a2)));
//	cout<<m<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<stdio.h>
#include<map>
#include<queue>
#include<vector>
using namespace std;

typedef long long ll;

int main(){
	int n,k;
	cin>>n>>k;
	n=n*500;
	if(n>=k) cout<<"Yes";
	else cout<<"No"; 
	return 0;
}

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

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> C(N-1),S(N-1),F(N-1),ans(N);
    for (int i=0;i<N-1;i++) cin >> C[i] >> S[i] >> F[i];
    for (int i=0;i<N;i++){
        int t = 0;
        for (int j=i;j<N-1;j++){
            if (t < S[j]) t = S[j];
            else if (t%F[j]){
                t += F[j] - t%F[j];
            }
            t += C[j];
        }
        ans[i] = t;
    }
    for (int i=0;i<N;i++) cout << ans[i] << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int H,W,i,j,n;
    while(1){
        cin>>H>>W;
        if(H==0&&W==0){
            break;
        }
        for(i=0;i<H;i++){
            for(j=0;j<W;j++){
                if(i==0||j==W-1||j==0||i==H-1){
                    cout<<"#";
                }else{
                    cout<<".";
                }
            }
            cout<<endl;
        }
        cout<<endl;
        
    }
    
    return 0;
}


Measured memory_bytes: 2996
using System;

public class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int[] num = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
        int min = int.MaxValue;
 
        for(int i = 0; i < num.Length; i++)
        {
            int tmp = 0;
            while(num[i] % 2 == 0)
            {
                num[i] /= 2;
                tmp++;
            }
            min = Math.Min(min, tmp);
        }

        Console.WriteLine(min);
    }
}

Measured memory_bytes: 11092
import Data.List

main = do
  li <- getLine
  let [a,b] = map read $ words li
  let ans = compute a b
  print ans

compute :: Int -> Int -> Int
compute a b = succ $ length $ is (sub a) (sub b)

sub n = map head $ group $ primeFactors n

-- ordered intersection
is xxs@(x:xs) yys@(y:ys) =
  case compare x y of
    LT -> is xs yys
    EQ -> x : is xs ys
    GT -> is xxs ys
is _ _ = []

primes = 2 : 3 : 5 : sieve [(9,3),(10,5)] [7,9..]

{- (np,p)のリストと、奇数の列 -}
sieve ((q,p):qps) xxs@(x:xs) =
  case compare q x of
    LT -> sieve qps1 xxs
    EQ -> sieve qps1 xs
    GT -> x : sieve (insert (x+x,x) qps) xs
  where
    qps1 = insert (q+p,p) qps

primeFactors n = loop n primes
  where
    loop 1 _ = []
    loop n pps@(p:ps)
      | n `mod` p == 0 = p : loop (n `div` p) pps
      | p*p > n        = [n]
      | True           = loop n ps

Measured memory_bytes: 40188
def c_be_together(N, A):
    a_sum = sum(A)
    option = (a_sum // N, (a_sum + N - 1) // N)  # 平均値の小数切り捨て|切り上げ
    ans = min(sum([(a - opt)**2 for a in A]) for opt in option)  # コストを計算
    return ans

N = int(input())
A = [int(i) for i in input().split()]
print(c_be_together(N, A))

Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>

#define rep(i,n) for(int i = 0; i < n; i++)

typedef long long ll;

using namespace std;

const int INF = 1e9;
const int MOD = 1e9+7;
const double PI=3.14159265358979323846;

int main(){
  int N;
  ll D, A, ans=0, bomb_dam=0;
  cin >> N >> D >> A;
  vector<pair<ll,ll> > vp(N);
  rep(i,N) cin >> vp[i].first >> vp[i].second;
  sort(vp.begin(),vp.end());
  
  queue<pair<int,int> > qp;
  rep(i,N){
    while(!qp.empty() && qp.front().first < vp[i].first - 2 * D){
      bomb_dam -= qp.front().second;
      qp.pop();
    }
    vp[i].second -= bomb_dam;
    if(vp[i].second<=0) continue;
    ll bomb_num = (vp[i].second-1) / A + 1;
    bomb_dam += A * bomb_num;
    ans += bomb_num;
    qp.push(make_pair(vp[i].first, A * bomb_num));
  }
  cout << ans << endl;
}


Measured memory_bytes: 4224
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <list>
#include <numeric>
using namespace std;

long long combi(long long n, long long k) {
  if (n == k || k == 0)
    return 1;
  else {
    return combi(n - 1, k - 1) + combi(n - 1, k);
  }
}

long long gcd(int a, int b){
  if (a%b == 0){
    return(b);
  }
  else{
    return(gcd(b, a%b));
  }
}

int main(){    
  long long K,A,B;
  cin >> K >> A >> B;
  
  for(int i=A;i<=B;i++){
    if(i%K==0){
      cout << "OK" << endl;
      return 0;
    }
  }
  
  cout << "NG"  << endl;

}
 


Measured memory_bytes: 3596
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        s: Chars
    }
    let ps = s.iter().filter(|&&c| c == 'p').count();
    let ans = s.len() / 2 - ps;
    println!("{}", ans);
}


Measured memory_bytes: 2564
#include<stdio.h>
#include<string.h>
main(){
  int a=0,b=0,ab=0,o=0;
  int n;
  char s[3];
  while(scanf("%d,%s",&n,s)!=EOF){
    if(strcmp(s,"A")==0)a++;
    else if(strcmp(s,"B")==0)b++;
    else if(strcmp(s,"AB")==0)ab++;
    else o++;
  }

  printf("%d\n%d\n%d\n%d\n",a,b,ab,o);
  return 0;
}

Measured memory_bytes: 596
N = int(input())
T, A = map(int, input().split())
x_list = list(map(int, input().split()))
min_dif = 10**10
ans = 0
for i in range(N):
    dif = abs(T - x_list[i] * 0.006 - A)
    if min_dif > dif:
        min_dif = dif
        ans = i + 1
print(ans)

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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

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

constexpr long long mod = 1000000007;

#define rep(i, n) for (int i = 0; i < n; i++)

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

    int n;
    cin >> n;
    vi h(n);
    rep(i, n) cin >> h[i];

    int cnt = 0;
    int c = 0;
    while (c != n) {
        bool b = false;
        c = 0;
        for (int i = 0; i < n; i++) {
            if (h[i] != 0) {
                b = true;
                h[i]--;
            } else {
                if (b) {
                    cnt++;
                }
                b = false;
                c++;
            }

            if (i == n - 1) {
                if (b) {
                    cnt++;
                }
            }
        }
    }

    cout << cnt << endl;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  lli n;
  while (cin >> n) {
    lli a[n];
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }
    lli b[n];
    for (int i = 0; i < n; ++i) {
      int j = (i + 1) % n;
      b[i] = a[j] - a[i];
    }
    // for (int i = 0; i < n; ++i) cout << b[i] << ' '; cout << endl;
    lli sum = accumulate(a, a + n, 0LL);
    lli m = (n + 1) * n / 2;
    bool f = true;
    f = f && (sum % m == 0);
    lli k = sum / m;
    for (int i = 0; i < n; ++i) {
      b[i] -= k;
    }
    for (int i = 0; i < n; ++i) {
      f = f && (b[i] <= 0) && (b[i] % n == 0);
    }
    cout << (f ? "YES" : "NO") << endl;
  }
  return 0;
}


Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <math.h>
#include <time.h>
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <iterator>
#include <algorithm>

using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)

#define PI M_PI
#define INF 100000000

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<bool>> vvb;


int main()
{
	int N;
	cin >> N;
	vll a(N);
	rep(i, N) cin >> a[i];

	ll h = 0, w = 0;

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

	int ptr = a.size() - 1;
	while (ptr >= 0)
	{
		int cnt = 0;
		ll now = a[ptr];
		while (ptr >= 0 && now == a[ptr])
		{
			cnt++;
			ptr--;
		}

		if (cnt >= 4)
		{
			if (h == 0 && w == 0) h = w = now;
			else w = now;
			break;
		}
		else if (cnt >= 2)
		{
			if (h == 0) 
			{
				h = now;
			}
			else
			{
				w = now;
				break;
			}
		}
	}

	cout << h * w << endl;
	
	return 0;
}



Measured memory_bytes: 1152
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Scanner;


public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic 
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        if(n>2){
            if(n%3<2&&n%3>0){
                System.out.println(n/3);
            }
            else{
                System.out.println(n/3);
            }
        }
        else{
            System.out.println("0");
        }
        
        
    }
}


Measured memory_bytes: 21716
#include <iostream>
using namespace std;
int main(void){
    int P[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin>>K;
    cout<<P[K-1]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pi pair<int, int>
#define l first
#define r second
#define pb push_back
#define all(x) x.begin(), x.end()

using namespace std;

const int maxn = 501;

int pr[maxn * maxn], sz[maxn * maxn];
int p[maxn * maxn], a[maxn][maxn];
int can[maxn][maxn], d[maxn][maxn];
bool kl[maxn][maxn];
int n;

int getp(int x) {
    if (pr[x] == -1) return x;
    return (pr[x] = getp(pr[x]));
}

void unions(int x, int y) {
    x = getp(x); y = getp(y);
    if (x == y) return;
    if (sz[x] < sz[y]) swap(x, y);
    if (sz[x] == sz[y]) ++sz[x];
    pr[y] = x;
}

void upd() {
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            d[i][j] = ((min(i, j) == 0 || max(i, j) == n - 1) ? 1 : -1);
    queue<pi> q;
    for (int i = 0; i < n; i++) {
        q.push({0, i});
        if (i) q.push({i, 0});
        q.push({n - 1, i});
        if (i < n - 1) q.push({i, n - 1});
    }
    while (!q.empty()) {
        int r = q.front().l,
            c = q.front().r;
        q.pop();
        if (r && d[r - 1][c] == -1) {
            q.push({r - 1, c});
            d[r - 1][c] = d[r][c] + 1;
        }
        if (c && d[r][c - 1] == -1) {
            q.push({r, c - 1});
            d[r][c - 1] = d[r][c] + 1;
        }
        if (r < n - 1 && d[r + 1][c] == -1) {
            q.push({r + 1, c});
            d[r + 1][c] = d[r][c] + 1;
        }
        if (c < n - 1 && d[r][c + 1] == -1) {
            q.push({r, c + 1});
            d[r][c + 1] = d[r][c] + 1;
        }
    }
}

void dfs(int r, int c) {
    if (r && d[r][c] + (!kl[r - 1][c]) < d[r - 1][c]) {
        d[r - 1][c] = d[r][c] + (!kl[r - 1][c]);
        dfs(r - 1, c);
    }
    if (c && d[r][c] + (!kl[r][c - 1]) < d[r][c - 1]) {
        d[r][c - 1] = d[r][c] + (!kl[r][c - 1]);
        dfs(r, c - 1);
    }
    if (r < n - 1 && d[r][c] + (!kl[r + 1][c]) < d[r + 1][c]) {
        d[r + 1][c] = d[r][c] + (!kl[r + 1][c]);
        dfs(r + 1, c);
    }
    if (c < n - 1 && d[r][c] + (!kl[r][c + 1]) < d[r][c + 1]) {
        d[r][c + 1] = d[r][c] + (!kl[r][c + 1]);
        dfs(r, c + 1);
    }
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 0; i < n * n; i++)
        cin >> p[i];
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++) {
            a[i][j] = i * n + j;
        }
    upd();
    int ans = 0;
    for (int i = 0; i < n * n; i++) {
        p[i]--; int r = p[i] / n, c = p[i] % n;
        --d[r][c];  ans += d[r][c]; kl[r][c] = 1;
        dfs(r, c);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 37024
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include<bits/stdc++.h>
 
using namespace std;
 
#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  f              first                 
#define  s              second
#define  endl           "\n"
#define  pb             push_back  
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";cout<<endl;
#define  deb1(a)        cout<<a<<endl;
#define  deb2(a,b)      cout<<a<<" "<<b<<endl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<endl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;            
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  unordered_map<ll,ll>  um;
typedef  vector<pll>           vpll;
 
const ll   N     =  5e5+5;
const ll   mod   =  1e9+7;
const ll   INF   =  1e18;
const int  INFi  =  0x7f7f7f7f;
 
ll test = 1, n, k;
vll pos, neg;
 
void solve(){
    cin>>n>>k;
    for(int i = 0; i < n; i++){
        ll x;
        cin>>x;
        if(x > 0) pos.pb(x);
        else neg.pb(-x);
    }
    sort(pos.rbegin(), pos.rend());
    sort(neg.rbegin(), neg.rend());
    ll ans = 1;
    if(pos.size() == 0){
        if(k&1) reverse(neg.begin(), neg.end());
        for(int i = 0; i < k; i++) ans = (ans*neg[i])%mod;
        if(k&1) ans = (mod-ans);
        deb1(ans%mod)
        return;
    }
    int i = 0, j = 0;
    if(k&1) ans = pos[0], i++, k--;
    for(int kk = 0; kk < k; kk += 2){
        if(i+1 == pos.size() and j+1 == neg.size()){
            ans = ans*pos[i]%mod*neg[j]%mod, i++, j++;
            ans = mod-ans;
        }
        else if(j+1 >= neg.size()) ans = ans*pos[i]%mod*pos[i+1]%mod, i += 2;
        else if(i+1 >= pos.size()) ans = ans*neg[j]%mod*neg[j+1]%mod, j += 2;
        else{
            ll x = pos[i]*pos[i+1], y = neg[j]*neg[j+1];
            if(x > y) ans = ans*(x%mod)%mod, i += 2;
            else ans = ans*(y%mod)%mod, j += 2;
        }
    }
    deb1(ans%mod)
}
 
int main(){
    fastio;
    //cin>>test;
    for(int i = 1; i <= test; i++){
        solve();
    }
}

Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
	int n;
	cin>>n;
	int a[n+1]={};
	for(int i=1;i<=n;i++)
	cin>>a[i];
	ll s[n+1]={};
	for(int i=1;i<=n;i++){
		s[i]=s[i-1]+a[i];
	}
	ll dp[n+1][n+1];
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			dp[i][j]=100000000000000;
		}
	}
	for(int i=1;i<=n;i++){
		if(i==1){
			for(int j=1;j<=n;j++){
				dp[j][j]=a[j];
			}
			continue;
		}
		for(int j=1;j<=(n-i+1);j++){
			for(int k=j;k<(j+i-1);k++){
				dp[j][j+i-1]=min(dp[j][j+i-1],s[j+i-1]-s[j-1]+dp[j][k]+dp[k+1][j+i-1]);
			}
		}
	}
	cout<<dp[1][n]-(s[n]-s[0]);
	return 0;
}

Measured memory_bytes: 1536
K,A,B= map(int,input().split())

ans = 1
if (B-A) <= 2:
  ans += K

else:
  if B - A <=2:
    ans += K
  else:
    ans += A - 1
    if (K-(A-1)) % 2 == 0:
      ans += (((K-(A-1))//2)) * (B - A)
    else:
      ans += (((K-(A-1))//2)) * (B - A) + 1

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
const double EPS=1e-10;
typedef pair<int,int>P;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int x,y;
int main(){
	cin>>x>>y;
	if((4*x-y)%2==0&&4*x-y>=0&&((4*x-y)/2<=x)){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

const int MAXV=2222;
int V,match[MAXV];
vector<int> G[MAXV];
bool used[MAXV];
void add_edge(int u,int v){G[u].push_back(v);}
bool dfs(int v){
  used[v]=1;
  for(int i=0;i<G[v].size();i++){
    int u=G[v][i],w=match[u];
    if(w<0||(!used[w]&&dfs(w))){
      match[v]=u;
      match[u]=v;
      return 1;
    }
  }
  return 0;
}
int bipartite_matching(){
  int res=0;
  memset(match,-1,sizeof(match));
  for(int v=0;v<V;v++){
    if(match[v]<0){
      memset(used,0,sizeof(used));
      if(dfs(v))res++;
    }
  }
  return res;
}

void Main() {
  int n;
  cin >> n;
  V=2*n;
  P a[n],b[n];
  rep(i,n) cin >> a[i].F >> a[i].S;
  rep(i,n) cin >> b[i].F >> b[i].S;
  rep(i,n) {
    rep(j,n) {
      if(a[i].F<b[j].F&&a[i].S<b[j].S) add_edge(i,j+n);
    }
  }
  pr(bipartite_matching());
}

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


Measured memory_bytes: 384
import sys

sys.setrecursionlimit(5001)
MOD = 10 ** 9 + 7

n = int(input())
links = [set() for _ in range(n)]
for line in sys.stdin.readlines():
    x, y = map(int, line.split())
    x -= 1
    y -= 1
    links[x].add(y)
    links[y].add(x)

double_factorial_odd = [0] * (n // 2)
prev = 1
for i in range(n // 2):
    prev = double_factorial_odd[i] = (2 * i + 1) * prev % MOD


def dfs(v, p):
    ret = [0, 1]
    for u in links[v]:
        if u == p:
            continue
        res = dfs(u, v)
        lt, ls = len(ret), len(res)
        mrg = [0] * (lt + ls - 1)
        for i in range(1 - lt % 2, lt, 2):
            c = ret[i]
            for j in range(1 - ls % 2, ls, 2):
                mrg[i + j] = (mrg[i + j] + c * res[j]) % MOD
        ret = mrg

    if len(ret) % 2 == 1:
        ret[0] = -sum(pattern * df % MOD for pattern, df in zip(ret[2::2], double_factorial_odd)) % MOD

    return ret


print(MOD - dfs(0, -1)[0])


Measured memory_bytes: 152668
// G++ MACRO.CPP -STD=C++17
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision; // cpp_int
 
#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>
 
#define pb(a) push_back(a)
#define mp make_pair



int main(){
  CIN(n,m);VC2(m,a,b);
  REP(i,m){a[i]--;b[i]--;}
  S s;
  REP(i,m)
    if(a[i]==0||b[i]==0){
      s.insert(b[i]);
      s.insert(a[i]);
    }
  REP(i,m){
    if(s.count(a[i])&&b[i]==n-1)
      EN(POSSIBLE);
    if(s.count(b[i])&&a[i]==n-1)
      EN(POSSIBLE);

  }
  EN(IMPOSSIBLE);

  return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int x, y;

const int MAX = 1000000;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++) {
        fac[i] = fac[i-1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod/i) % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
    }
}

long long COM(int n, int k) {
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

int main() {
    cin >> x >> y;
    COMinit();
    int k, l;
    bool flg = false;
    int judge = 2*x - y;
    if(judge >= 0 && judge % 3 == 0) {
        l = judge / 3;
        int check = x - 2*l;
        if(check >= 0) {
            k = check;
            flg = true;
        }
    }

    if(flg) {
        int les, gre;
        if(k > l) {
            les = l; gre = k;
        }else {
            les = k; gre = l;
        }

        int total = les + gre;
        long long ans = COM(total, les);
        cout << ans << endl;
    }else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 23680
package main

// ---------- template start ----------
import (
	"fmt"
	"os"
	"strconv"
	"bufio"
	"strings"
)

var (
	sc = bufio.NewScanner(os.Stdin)
)

func bordersInt(in_map [][]int, invalid int) [][]int{
	H, W := len(in_map), len(in_map[0])
	out_map := make([][]int, H+2)
	for h:=0; h<H+2; h++ {
		out_map[h] = make([]int, W+2)
		for w:=0; w<W+2; w++ {
			out_map[h][w] = invalid
		}
	}
	for h:=0; h<H; h++{
		for w:=0; w<W; w++{
			out_map[h+1][w+1] = in_map[h][w] 
		}
	}
	return out_map
}

func bordersString(in_map [][]string, invalid string) [][]string{
	H, W := len(in_map), len(in_map[0])
	out_map := make([][]string, H+2)
	for h:=0; h<H+2; h++ {
		out_map[h] = make([]string, W+2)
		for w:=0; w<W+2; w++ {
			out_map[h][w] = invalid
		}
	}
	for h:=0; h<H; h++{
		for w:=0; w<W; w++{
			out_map[h+1][w+1] = in_map[h][w] 
		}
	}
	return out_map
}

func scanIntLine(len int) []int{
	arr := make([]int, len)
	for i:=0; i<len; i++{
		sc.Scan()
		tmp, err := strconv.Atoi(sc.Text())
		if err == nil{
			arr[i] = tmp
		}
	}
	return arr
}

func scanStringLine(len int) []string{
	arr := make([]string, len)
	for i:=0; i<len; i++{
		sc.Scan()
		arr[i] = sc.Text()
	}
	return arr
}

func scanIntSplit(len int) []int{
	arr := make([]int, len)
	sc.Scan()
	for i, v := range strings.Split(sc.Text(), " "){
		tmp, err := strconv.Atoi(v)
		if err == nil{
			arr[i] = tmp
		}
	}
	return arr
}

func maxInt(arr... int) int {
	max := -10000007
	for _, v := range arr {
		if max < v {
			max = v
		}
	}
	return max
}

func minInt(arr... int) int {
	min := 10000007
	for _, v := range arr {
		if min > v {
			min = v
		}
	}
	return min
}

type Merger func(a, b int) int

type BIT struct {
	n int
	data []int
	merge Merger
}

func (bit *BIT) update(k, w int) {
	for i:=k; i<=bit.n; i += i&-i {
		bit.data[i] = bit.merge(bit.data[i], w)
	}
}

func (bit *BIT) query(k int) int {
	ret := 0
	for i:=k; i>0; i -= i&-i {
		ret = bit.merge(ret, bit.data[i])
	}
	return ret
}

func initBIT(a []int, m Merger) *BIT {
	n := len(a)
	bit := &BIT{n : n, data : make([]int, n+1), merge : m}
	for i, v := range a {
		bit.update(i+1, v)
	}
	return bit
}

type UFTree struct {
	data []int
}

func (uft *UFTree) root(x int) int {
	if uft.data[x] == x {
		return x
	} else {
		uft.data[x] = uft.root(uft.data[x])
	}
	return uft.data[x]
}

func (uft *UFTree) same(x, y int) bool {
	return uft.root(x) == uft.root(y)
}

func (uft *UFTree) unite(x, y int) {
	x = uft.root(x)
	y = uft.root(y)
	if x == y {
		return
	}
	uft.data[x] = y
}

func initUFTree(n int) *UFTree {
	uft := &UFTree{data : make([]int, n)}
	for i:=0; i<n; i++ {
		uft.data[i] = i
	}
	return uft
}

// ---------- template end ----------


func main(){
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	var (
		N, M, C, cnt, ans int
		B []int
		A [][]int
	)
	fmt.Scan(&N, &M, &C)
	B = scanIntSplit(M)
	A = make([][]int, N)
	for i:=0; i<N; i++ {
		A[i] = scanIntSplit(M)
	}
	for i:=0; i<N; i++ {
		ans = C
		for j:=0; j<M; j++ {
			ans += A[i][j]*B[j] 
		}
		if ans > 0 {
			cnt++
		}
	}
	fmt.Println(cnt)
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int s,f;
    s=max(a,c);
    f=min(b,d);
    if(f-s<0)s=f;
    cout<<f-s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp make_pair
#define sz(x) ((int)(x).size())
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
#define MOD ((int)1e9 + 7)
#define atoi(x) ((x)-'0')
#define int ll
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

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

int n, a, b, minv[3] = { LLONG_MAX, LLONG_MAX, LLONG_MAX }, maxv[3] = { LLONG_MIN, LLONG_MIN, LLONG_MIN };

signed main() {
	fastio;
	cin >> n;
	FOR(i, n) {
		cin >> a >> b;
		minv[0] = min(minv[0], a + b);
		maxv[0] = max(maxv[0], a + b);
		minv[1] = min(minv[1], a - b);
		maxv[1] = max(maxv[1], a - b);
		minv[2] = min(minv[2], b - a);
		maxv[2] = max(maxv[2], b - a);
	}
	cout << max(maxv[0] - minv[0], max(maxv[1] - minv[1], maxv[2] - minv[2]));
}

Measured memory_bytes: 3640
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N;
    cin >> N;
    bool ok = true;
    for (ll i = 0; (1 << i) <= 1e5; i++) {
        if (N == (1 << i)) {
            ok = false;
        }
    }
    if (!ok) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

    vector<pair<ll, ll>> ans;
    ans.push_back({ 1, 2 });
    ans.push_back({ 2, 3 });
    ans.push_back({ 3, N + 1 });
    ans.push_back({ N + 1, N + 2 });
    ans.push_back({ N + 2, N + 3 });

    for (ll i = 4; i < N; i += 2) {
        //N + 1につける
        ans.push_back({ N + 1, i });
        ans.push_back({ i, i + 1 });
        ans.push_back({ N + 1, N + i + 1 });
        ans.push_back({ N + i + 1, N + i });
    }

    if (N % 2 == 0) {
        //Nを最左ビットとそれ以外に分ける
        ll x = 1;
        while (x < N) {
            x *= 2;
        }
        x /= 2;
        ll y = N ^ x ^ 1;
        // N -> x -> N + 1 -> y -> Nと通れば良い
        ans.push_back({ N, x });
        ans.push_back({ N + N, (y == 3 ? y :N + y) });
    }

    assert(ans.size() == 2 * N - 1);
    for (const auto& p : ans) {
        cout << p.first << " " << p.second << endl;
    }
}

Measured memory_bytes: 6252
# abc177_d.py
class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]

N, M = map(int,input().split())
uf = UnionFind(N)

for i in range(M):
    A, B = map(int,input().split())
    uf.Unite(A, B)
M = 0
for i in range(N):
    cnt = uf.Count(i)
    if cnt>M:
        M = cnt

print(M)

Measured memory_bytes: 14564
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int n,k;
int sum = 1;
int solve(){
    for(int i=0 ; i<n ; i++){
        sum += min(sum, k);
    }
    return sum;
}
int main(){
    cin >> n >> k;
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int a,b;
  scanf( "%d%d",&a,&b);
  if(a<b){
    printf("a < b\n");
  }else if(a>b){
    printf("a > b\n");
  }else if(a=b){
    printf("a == b\n");
  }
  return 0;
}


Measured memory_bytes: 2704
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	X := nextInt()
	Xrem := X % 100
	var cnt int
	for i := 0; i <= 100; i++ {
		for j := 0; j <= 50; j++ {
			for k := 0; k <= 33; k++ {
				for l := 0; l <= 25; l++ {
					for m := 0; m <= 20; m++ {
						if i+2*j+3*k+4*l+5*m == Xrem {
							cnt = i + j + k + l + m
							if X/100 >= cnt {
								fmt.Println(1)
							} else {
								fmt.Println(0)
							}
							return
						}
					}
				}
			}
		}
	}
	fmt.Println(0)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}

// ここから拝借
// https://shoman.hatenablog.com/entry/2020/02/25/185456
// Stackは[]intのエイリアス
type Stack []int

// Push adds an element
func (s *Stack) Push(v int) {
	*s = append(*s, v)
}

// Pop removes the top element and return it
func (s *Stack) Pop() (int, error) {
	if s.Empty() {
		return 0, fmt.Errorf("stack is empty")
	}

	v := (*s)[len(*s)-1]
	*s = (*s)[:len(*s)-1]
	return v, nil
}

// Peek returns the top value
func (s *Stack) Peek() (int, error) {
	if s.Empty() {
		return 0, fmt.Errorf("stack is empty")
	}

	return (*s)[len(*s)-1], nil
}

// Size returns the length of stack
func (s *Stack) Size() int {
	return len(*s)
}

// Empty returns true when stack is empty
func (s *Stack) Empty() bool {
	return s.Size() == 0
}

// NewStack generates stack
func NewStack() *Stack {
	s := new(Stack)
	return s
}


Measured memory_bytes: 1808
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 924844033;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int six(int x) {
	int res = 0;
	while (x) {
		res += x % 6; x /= 6;
	}
	return res;
}
int main() {
	int n; cin >> n;
	int mi = six(n); int cnt = 0;
	rep(i2, 9) {
		rep(i3, 9) {
			rep(i4, 9) {
				rep(i5, 9) {
					rep(i6, 9) {
						int sum = i2 * 9 + i3 * 81 + i4 * 729 + i5 * 6561 + i6 * 59049;
						if (sum > n)continue;
						mi = min(mi, six(n - sum) + i2 + i3 + i4 + i5 + i6);
					}
				}
			}
		}
	}
	cout << mi << endl;
	return 0;
}

Measured memory_bytes: 256
/*5_3 hightierra*/
#include <stdio.h>
#define LIMIT 100

int main(void){
    int row,col,i,j,rowjudge[LIMIT]={0},coljudge[LIMIT]={0};
    char matrix[LIMIT][LIMIT];
    scanf("%d %d",&row,&col);

    // 初期化
    for(i=0; i<LIMIT; i++){
        for(j=0; j<LIMIT; j++){
            matrix[i][j]='\0';
        }
    }

    // 入力
    for(i=0; i<row; i++){
        for(j=0; j<col; j++){
            scanf(" %c",&matrix[i][j]);
        }
    }

    // 各行、各列に黒が１つでもあるかを判別
    for(i=0; i<row; i++){
        for(j=0; j<col; j++){
            if(matrix[i][j]=='#'){
                rowjudge[i]=1;
            }
        }
    }
    for(j=0; j<col; j++){
        for(i=0; i<row; i++){
            if(matrix[i][j]=='#'){
                coljudge[j]=1;
            }
        }
    }

    // 黒が１つでもある行と列の重なる要素のみを出力
    for(i=0; i<row; i++){
        for(j=0; j<col; j++){
            if(rowjudge[i]==1 && coljudge[j]==1){
                printf("%c",matrix[i][j]);
            }
        }
        if(rowjudge[i]==1){
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 128
n = gets.to_i
lr = []
mx = -Float::INFINITY # maximum of L
mn = Float::INFINITY # minimum of R
n.times do
  # [l, r)
  l, r = gets.split.map(&:to_i)
  l -= 1
  mx = l if l > mx
  mn = r if r < mn
  lr << [l, r]
end

ans = 0
lr.each do |l, r|
  tmp = [0, mn - mx].max + r - l
  ans = tmp if tmp > ans
end
t = []
n.times do |i|
  a = [0, mn - lr[i][0]].max
  b = [0, lr[i][1] - mx].max
  t << [b, -a]
end
t.sort!
w = Float::INFINITY
n.times do |i|
  z = t[i]
  zb = -z[1]
  if (i != 0)
    ans = w + z[0] if w + z[0] > ans
  end
  w = zb if w > zb
end
p ans


Measured memory_bytes: 17032
function main()
  
  (A,B) = map(x -> parse(Float64,x), split(readline()))
  
  check = false
  
  for i in 1:10^3
    
    if floor(i * 0.08) == A && floor(i * 0.1) == B
      check = true
      println(i)
      break
    end
    
  end
  
  if check == false
    println(-1)
  end
  
end

main()

Measured memory_bytes: 111768
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>

using namespace std;

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  string s;
  cin >> s;
  if (s[0] == '9' || s[1] == '9'){
    cout << "Yes\n";
  }
  else{
    cout << "No\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<stack>
#include<iostream>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define MOD 1000000007
#define vec(a) vector<int>a
using namespace std;

bool isPalindrome(string str)
{
	ll i,j,k,l,n;
	l=str.length();
	for(i=0;i<l/2;i++)
	{
		if(str[i]==str[l-i-1])
			continue;
		else
			return 0;
	}
	return 1;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
		ll n,i,j,k;
		cin>>n>>i>>j;
		cout<<min(n*i,j)<<"\n";
		return 0;
}
	

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

N, K, Q = map(int,input().split())
A = [int(input()) for _ in range(Q)]

point=[0]*(N+1)
for i in range(Q):
    point[A[i]]+=1

for i in range(1,N+1):
    point[i] = K-(Q-point[i])

for i in range(1,N+1):
    if point[i]>0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 49500
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

const int MAXN = 500 + 100;

int n, m, N, M, rev;
int s[MAXN][MAXN];

void no()
{
	cout << "No" << endl;
	exit(0);
}

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	cin >> n >> m >> N >> M;

	if(n % N == 0 && m % M == 0)
		no();

	if(n % N == 0)
		swap(n, m), swap(N, M), rev ^= 1;

	for(int i = 1; i <= n; i++)
		if(i % N == 0)
		{
			for(int j = 1; j <= m; j++)
				s[i][j] = -10000 * (N - 1) - 1;
		}
		else
		{
			for(int j = 1; j <= m; j++)
				s[i][j] = 10000;
		}

	cout << "Yes" << endl;
	if(!rev)
	{
		for(int i = 1; i <= n; i++)
		{
			for(int j = 1; j <= m; j++)
				cout << s[i][j] << ' ';
			cout << endl;
		}
	}
	else
	{
		for(int i = 1; i <= m; i++)
		{
			for(int j = 1; j <= n; j++)
				cout << s[j][i] << ' ';
			cout << endl;
		}
	}



	return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;


int main(){
  ll x,y;
  cin >> x >> y;
  
  if(x==1 && y==1){ cout << 1 << endl; return 0; }
  if(x==1 || y==1){ cout << x+y-3 << endl; return 0; }
  cout << (x-2)*(y-2) << endl;
  return 0;
}


Measured memory_bytes: 256
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int hoge[100005];
int main()
{
  int n, a, ans = 0, m = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
  {
    scanf("%d", &a);
    m = MAX(m, a);
    hoge[a + 1]++;
    hoge[a]++;
    hoge[a + 2]++;
  }
  for (int i = 0; i <= m; i++)
  {
    ans = MAX(ans, hoge[i]);
  }
  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 512
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    S = list(input().split("T"))
    gx, gy = map(int, input().split())

    to_X = 0
    init_x = len(S[0])
    S.pop(0)
    X, Y = [], []
    for s in S:
        X.append(len(s)) if to_X else Y.append(len(s))
        to_X ^= 1

    now_x = {init_x}
    for x in X:
        tmp = set()
        for prev_x in now_x:
            tmp.add(prev_x + x)
            tmp.add(prev_x - x)
        now_x = tmp

    now_y = {0}
    for y in Y:
        tmp = set()
        for prev_y in now_y:
            tmp.add(prev_y + y)
            tmp.add(prev_y - y)
        now_y = tmp

    print("Yes" if gx in now_x and gy in now_y else "No")


if __name__ == '__main__':
    resolve()


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

string s,c;

int main(){
    cin>>s;
    c=s;
    reverse(s.begin(),s.end());
    for(int i=0;i<s.length();i++){
        if(s[i]=='p') s[i]='q';
        else if(s[i]=='q') s[i]='p';
        else if(s[i]=='b') s[i]='d';
        else if(s[i]=='d') s[i]='b';
    }
    if(s==c) cout<<"Yes"<<"\n";
    else cout<<"No"<<"\n";
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int x, a, b;
  cin >> x >> a >> b;
  if(abs(x - a) < abs(x - b)) {
    cout << "A" << endl;
  }else {
    cout << "B" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

using namespace std;
int n;

void solve(){
    vector<string> f(n);
    for(int i=0;i<n;i++) cin >> f[i];
    
    int l=0,r=0;
    int ans = 0;
    for(int i=0;i<n;i++){
        if(i+1 >= n) break;
        if(f[i] == "lu" and f[i+1] == "ru") ans++;
        else if(f[i] == "ru" and f[i+1] == "lu") ans++;
        else if(f[i] == "ld" and f[i+1] == "rd") ans++;
        else if(f[i] == "rd" and f[i+1] == "ld") ans++;
    }
    cout << ans << endl;
}

int main(){
    while(1){
        cin >> n;
        if(n==0) break;
        solve();
    }
}



Measured memory_bytes: 3144
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
using ull =unsigned long long;
const ll INF =1001001001;

//10億7。　　　100000007

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}


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

int A;
  cin>>A;
  int ans=0;
  ans=A*800-A/15*200;
  cout<<ans<<endl;
  

  
  
}



Measured memory_bytes: 256
n = int(input())
satisfy = 0
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
for i in range(n-1):
    if a[i]+1 == a[i+1]:
        satisfy += c[a[i]-1]
satisfy += sum(b)
print(satisfy)

Measured memory_bytes: 3064
A,B,C,D=list(input())
op=["+", "-"]
for op1 in op:
  for op2 in op:
    for op3 in op:
      s="{}{}{}{}{}{}{}".format(A,op1,B,op2,C,op3,D)
      if eval(s)==7:
        print("{}=7".format(s))
        exit()

Measured memory_bytes: 38384
/* Bismillahir Rahmanir Rahim */

#include <bits/stdc++.h>

#define rep(i, n)	for(int i=0;i<n;i++)
#define repn(i, n)	for(int i=1;i<=n;i++)
#define set(i, n)	memset(i, n, sizeof(i))

#define mx		100007
#define pb		push_back
#define inf 	(1 << 30)

#define f	first
#define s 	second

using namespace std;

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

ll n, t, a[mx], ax[mx];

int main(){
	scanf("%lld %lld", &n, &t);
	repn(i, n) scanf("%lld", &a[i]);
	t /= 2;
	for(int i=n;i>=1;i--) ax[i] = max(a[i], ax[i+1]);
	int ret = 0;
	vector<int>pos;
	for(int i=1;i<=n;i++){
		ll tot = ax[i] - a[i];
		if(tot == ret){
			ret = tot;
			pos.push_back(i);
		}
		else if(tot > ret){
			ret = tot;
			pos.clear();
			pos.push_back(i);
		}
	}
	map<ll, ll>mp;
	for(auto u : pos) mp[ ax[u] ] = 1;

	ret = 0;

	repn(i, n){
		ret += mp[a[i]];
	}
	cout << ret << endl;


	return 0;
}


Measured memory_bytes: 8192