akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define hell 1000000007
#define hell1 1000000006
#define pb push_back
#define x first
#define y second
#define MAXL 100005
#define pll pair<ll,ll>
#define pii pair<int,int>
#define L LLONG_MAX
#define all(v) (v).begin(),(v).end()
#define tcFile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
using namespace std;
//vector<int>prime(15000005,0);
ll mM(ll a,ll b,ll p=hell){ll res = 0;if(a>=p)a %= p;while(b){if (b & 1ll)res = (res + a);if(res>=p) res%= p;a = (2 * a); if(a>=p)a%=p;b >>= 1ll;}return res;}
ll fpow(ll x,ll y,ll p=hell){if(x>=p)x=x%p;ll res=1;while(y){if(y&1ll)res*=x;if(res<0)res+=p;if(res>=p)res%=p;y=y>>1ll;x*=x;if(x<0)x+=p;if(x>=p)x%=p;}return res;}
ll inv(ll n,ll p=hell){return fpow(n,p-2,p);}
ll modmul(ll x,ll y,ll p = hell){if(x<0)x+=p;if(x>=p)x%=p;if(y<0)y+=p;if(y>=p)y%=p;return (x*y)%p;}
ll modadd(ll x,ll y,ll p = hell){if(x<0)x+=p;if(x>=p)x%=p;if(y<0)y+=p;if(y>=p)y%=p;ll temp=x+y;if(temp>=p)temp%=p;return temp;}
/*void sieve(){
    prime[0] = -1;
    prime[1] = 0;
    for(int i=2;i<=15000000;i++)
        if(!prime[i])
            for(int j=i;j<=15000000;j+=i)
            	if(!prime[j])
            		prime[j] = i;
}*/
int main(){
	ios
	int t = 1,tc = 0;
	//cin >> t;
	while(t--){
		int h ,w;
		cin >> h >> w;
		vector<vector<char>>mat(h, vector<char>(w));
		for (int i = 0; i < h; i++)
			for (int j = 0; j < w; j++)
				cin >> mat[i][j];
		vector<vector<ll>>dp(h, vector<ll>(w, 0));
		dp[0][0] = 1;
		for (int i = 0; i < h; i++)
			for (int j = 0; j < w; j++)
				if (mat[i][j] == '.' && ( i>0 || j>0)) {
					ll xc = 0, yc = 0;
					if (i-1 >= 0)
						xc = dp[i-1][j];
					if (j-1 >= 0)
						yc = dp[i][j-1];
					dp[i][j] = modadd(xc, yc);
				}
		cout << dp[h-1][w-1] << "\n";
	}
}


Measured memory_bytes: 12160
#include<iostream>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define INF 1e9
using namespace std;
typedef long long ll;

int main(){
	int n,k;
	cin>>n>>k;
	ll h[n];
	rep(i,n)cin>>h[i];
	sort(h,h+n);
	ll ans=INF;
	rep(i,n-k+1)ans=min(ans,h[i+k-1]-h[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 110;

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

int main(){
    string s;cin >> s;
    ll n = s.size();
    bitset<26> bs(0);
    vector<vector<ll>> vec(26,vector<ll>(1,-1));
    rep(i,n){
        bs[s[i]-'a'] = 1;
        vec[s[i] - 'a'].emplace_back(i);
    }
    ll ans = INF;
    rep(i,26)vec[i].emplace_back(n);
    rep(i,26){
        if(bs[i] == 0)continue;
        ll temp = 0;
        rep(j,vec[i].size()-1){
            chmax(temp, vec[i][j+1] - vec[i][j]);
        }
        chmin(ans,temp);
    }

    cout << ans-1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x=0):x((x%mod+mod)%mod){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
	mint operator+(const mint a) const { return mint(*this) += a;}
	mint operator-(const mint a) const { return mint(*this) -= a;}
	mint operator*(const mint a) const { return mint(*this) *= a;}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod-2);}
	mint& operator/=(const mint a) { return *this *= a.inv();}
	mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
	int n;
	cin>>n;
	vector<int> c(n);
	rep(i, n) cin>>c[i];

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

	mint cnt=0;
	mint pat2=mint(2).pow(n+n-1);//harf of all patterns
	// mint nc=pat2+(mint)(n-1)*pat2/2;//num of change pos
	mint tnc=mint(n)*pat2;//total num of change pos
	rep(i, n){
		int rem=n-i-1;
		mint nc=tnc-mint(rem)*pat2/2;
		cnt+= (mint)c[i]*nc;
		tnc-=pat2;
		// nc-=pat2;
	}

	cout<<cnt<<endl;
	return 0;
}


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

r = 0
xor = 0
total = 0
cnt = 0
for l in range(N):
    while r < N and total + A[r] == xor ^ A[r]:
        total += A[r]
        xor ^= A[r]
        r += 1

    cnt += r - l
    
    total -= A[l]
    xor ^= A[l]
print(cnt)

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

using namespace std;

string s;

int main () {
	cin >> s;
	if(s == "SUN") {
		cout << 7;
	}
	if(s == "MON") {
		cout << 6;
	}
	if(s == "TUE") {
		cout << 5;
	}
	if(s == "WED") {
		cout << 4;
	}
	if(s == "THU") {
		cout << 3;
	}
	if(s == "FRI") {
		cout << 2;
	}
	if(s == "SAT") {
		cout << 1 ;
	}
	return 0;
}

Measured memory_bytes: 256
import Control.Monad
import Data.Array.IO
import Data.IORef
dist a b c d = abs(a-c)+abs(b-d)
 
main = do
  [n,m] <- map read.words <$> getLine
  a <- newArray (1,n) 0 :: IO ( IOArray Int Int )
  b <- newArray (1,n) 0 :: IO ( IOArray Int Int )
  c <- newArray (1,m) 0 :: IO ( IOArray Int Int )
  d <- newArray (1,m) 0 :: IO ( IOArray Int Int )
  forM [1..n] $ (\i -> do 
    [ai,bi] <- map read . words <$> getLine
    writeArray a i ai
    writeArray b i bi
    return () )
  forM [1..m] $ (\j -> do 
    [cj,dj] <- map read . words <$> getLine
    writeArray c j cj
    writeArray d j dj
    return () )
  forM [1..n] $ ( \i -> do
    rmin <- newIORef (maxBound :: Int)
    rindex <- newIORef 0
    forM [1..m] $ ( \j -> do
      ai <- (readArray a i)
      bi <- (readArray b i)
      cj <- (readArray c j)
      dj <- (readArray d j)
      let distance = dist ai bi cj dj
      min <- readIORef rmin
      if min > distance then do
        writeIORef rmin distance
        writeIORef rindex j 
      else
        return () )
    index <- readIORef rindex
    print index )


Measured memory_bytes: 1020
# -*- coding: utf-8 -*-

if __name__ == '__main__':
    o = input()
    e = input()

    flg = True if len(o) > len(e) else False
    result = ""

    for i in range(len(e)):
        tmp = o[i] + e[i]
        result += tmp

    if flg:
        result += o[-1]

    print(result)


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

using namespace std;

typedef long long ll;

int main(){
	ios::sync_with_stdio(false);
	ll n, m;
	cin >> n >> m;
	if(m < n*2)
		cout << m/2 << endl;
	else
		cout << n + (m-2*n)/4 << endl;
	return 0;
}


Measured memory_bytes: 384
lists = list(map(int, input().split())) #１行の入力をi[0],i[1]というように空白で分けてを取得し、iに値を入れる
a = list(map(int, input().split())) #１行の入力をi[0],i[1]というように空白で分けてを取得し、iに値を入れる

ans = sum(a)
if ans <= lists[0]:
    print(lists[0]-ans)
else:
    print(-1)
    

Measured memory_bytes: 9880
#include<iostream>
#include<algorithm>
#include<cmath>
#define int long long
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define c(n) cout<<n<<endl;
signed main(){
	int a,b,c;
	cin>>a>>b>>c;
	c(a+b+c-max({a,b,c}))
}


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

int main(){
    int n,q,count,key,S[10000];
    count = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> S[i];
    }
    cin >> q;
    for(int i = 0; i < q; i ++){
        cin >> key;
        for(int j = 0; j < n; j++){
            if(key == S[j]){
                count ++;
                break;
                
            }
        }
    }
    cout << count << endl;
    
    return 0;
    
    
}


Measured memory_bytes: 3112
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
  
using namespace std;
  
void extgcd(int a,int b,int &x,int &y){
x=1,y=0;
  if(b!=0)extgcd(b,a% b,y,x),y-=(a/b)*x; 
}
  
int main(void){
  
  int a,b;
  
  cin >> a >> b;
  
int x,y;
  extgcd(a,b,x,y);
  cout << x << " " << y << endl;
  
  return 0;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<bool> oks(n + 1, true);
    rep(i, m)
    {
        int a;
        cin >> a;
        oks[a] = false;
    }

    long long MOD = 1000000007;

    long long dp[100010];
    rep(i, 100010) dp[i] = 0;

    dp[0] = 1;
    if (oks[1])
        dp[1] = 1;
    for (int i = 2; i <= n; i++)
    {

        if (oks[i - 1])
            dp[i] += dp[i - 1];
        if (oks[i - 2])
            dp[i] += dp[i - 2];

        dp[i] %= MOD;
    }

    cout << dp[n] << endl;
}

Measured memory_bytes: 1024
def linear_search(num, numlist):
    numlist.append(num)
    index = 0
    while index < len(numlist) and numlist[index] != num:
        index += 1
    numlist.pop(-1)
    if index == len(numlist):
        return False
    else:
        return True

if __name__ == '__main__':
    n = input()
    numlist1 = [int(num) for num in input().split()]
    m = input()
    numlist2 = [int(num) for num in input().split()]

    tot = 0
    for num in numlist2:
        if linear_search(num, numlist1):
            tot += 1
    print(tot)


Measured memory_bytes: 6556
#include<stdio.h>

int main(){
	int A, B, C, D;
	scanf("%d %d %d %d", &A, &B, &C, &D);
	int max = A * B;
	if(max < C * D){
		max = C * D;
	}
	printf("%d", max);
	return 0;
}

Measured memory_bytes: 128
import math
K = int(input())

def S_n(i):
    return sum(list(map(int, str(i))))

def snuke(n):
    return n / S_n(n)

j = 1
order = 1
for i in range(K):
    print(j)
    if snuke(j + 10**(order-1)) > snuke(j + 10**order):
        order += 1
    j += 10**(order-1)

Measured memory_bytes: 3188
n, l, r = map(int, input().split())

l -= 1
r -= 1

dist = [0] * 10000000

for a in range(n):
    for b in range(a+1, n):
        #print("from", a, "to", b)
        c = 9999999999
        c = min(c, b - a)
        #print(" dire", c)
        c = min(c, abs( abs(l - a) + abs(r - b) ) + 1 )
        dist[c] += 1
for k in range(1, n):
    print(dist[k])


Measured memory_bytes: 120540
import collections
n,x,y = map(int,input().split())

disList = []
for i in range(1,n):
    for j in range(i+1,n+1):
        dis = min(abs(j-i), abs(x-i) +1 + abs(j-y),abs(y-i) + 1 + abs(j-x))
        disList.append(dis)

c = collections.Counter(disList)
cList = list(c.values())
for i in range(n-1):
    if(i < len(cList)):
        print(cList[i])
    else:
        print(0)


Measured memory_bytes: 67788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  ll m = max(a, max(b, c)), ans = m;
  for(int i = 0; i < k; i++){
    ans *= 2;
  }
  ans += a + b + c - m;
  cout << ans << endl;
  return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  // The height of towers
  vector<int> H(999);
  H.at(0) = 1;
  for (int i=1; i<999; i++) {
    H.at(i) = H.at(i-1)+(i+1);
  }
  int answer = H.at(b-a-2)-a;
  cout << answer << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  string s; cin >> s;
  int a = 700;
  if(s.at(0) =='o') a+=100;
  if(s.at(1) =='o') a+=100;
  if(s.at(2) =='o') a+=100;
  
  cout << a;
}


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

using namespace std;
typedef long long LL;
typedef pair<int,int> P;
const int Max_Num=100010;

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> A[Max_Num];
  rep(i,N){
    int a, b;
    cin >> a >> b;
    a--;
    A[a].emplace_back(b);
  }
  priority_queue<int> q;
  int ans=0;
  rep(i,M){
    rep(j,A[i].size()) q.emplace(A[i][j]);
    if(!q.empty()){
      int B=q.top();
      q.pop();
      ans+=B;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5632
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(){
  int n,p;
  int check=0;;
  int count=1;

  scanf("%d",&n);
  int a[n];
  scanf("%d",&p);
  check=p;
  for(int i=1;i<n;i++){
    scanf("%d",&p);
    if(check>=p){
      count++;
      check=p;
    }

  }

  printf("%d\n",count);

  return 0;
}


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

int main() {
    ll N;
    cin >> N;

    int ans = 0;
    for (ll i = 2; i*i <= N; ++i) {
        int x = 0;
        int y = 1;
        while(N%i == 0) {
            x++;
            N /= i;
        }
        while(x >= y) {
            x -= y;
            ans++;
            y++;
        }
    }

    if (N > 1) ans++;
    cout << ans << endl;

    return 0;
}


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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  rep(i,n-2) {
    if (s.substr(i,3) == "ABC") ++ans;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    long long H;
    long N;
    short tmp;
    
    scanf("%ld %ld", &H, &N);
    
    while(N>0)
    {
        scanf("%hd ", &tmp);
        H = H - tmp;
        N--;
    }
    
    if(H > 0)
    {
        printf("No");
    }
    else
    {
        printf("Yes");
    }

    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>

int main(){
	char str[201], t[101], p[101];

	scanf("%s", str);
        scanf("%s", p);
	strcpy(t, str);
	strcat(str, t);

	if (strstr(str, p) == NULL) printf("No\n");
	else printf("Yes\n");

	return 0;
}

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

int main() {
    int H,N;
    cin>>H>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A.at(i);
    }
    int ans=H;
    for(int i=0;i<N;i++){
        ans-=A.at(i);
    }
    if(ans<=0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

 
int main(void){
	
	int N, K;
	
	cin >> N >> K;
	
	ll h[1000010];
	
	rep(i, N)
		cin >> h[i];
	
	ll dp[101000];

	rep(i, 101000)
		dp[i] = INF;

	dp[0] = 0;

	rep(i, N)
		for(int j=1; j<=K; j++)
			chmin(dp[i+j], dp[i] + abs(h[i] - h[i+j]));

	cout << dp[N-1] << endl;
	
	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
    int n ,t;
    cin >> n >> t;
    int T[200005];
    for(int i = 0; i < n; i++){
        cin >> T[i];
    }
    int ans = 0;

    for(int i = 0; i < n-1; i++){
        if(T[i+1] - T[i] <= t){
            ans += T[i+1] - T[i];
        }
        else if(T[i+1] - T[i]> t){
            ans += t;
        }
    }
    ans += t;
    cout << ans << endl;

}

Measured memory_bytes: 1024
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, X);
    IN(ll, K);
    IN(ll, D);
    X = abs(X);
    ll m = X / D;
    // DUMP(m);
    if (K <= m)
    {
        X -= K * D;
    }
    else
    {
        X -= m * D;
        K -= m;
        if (K & 1)
        {
            X -= D;
        }
    }
    OUT(abs(X));
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int a[505][505];
int main(void){
	int H,W;
	cin >> H >> W;
	for(int i=0;i<H;i++)for(int j=0;j<W;j++)cin >> a[i][j];
	int ans = 0;
	vector<tuple<int,int,int,int>>v;
	for(int i=0;i<H;i++){
		if(i%2==0){
			for(int j=0;j<W;j++){
				if(a[i][j]%2!=0){
					if(j==W-1){
						if(i!=H-1){
							a[i][j]--;
							a[i+1][j]++;
							ans ++;
							v.push_back(make_tuple(i+1,j+1,i+1+1,j+1));
						}else{
						}
					}else{
						a[i][j]--;
						a[i][j+1]++;
						ans ++;
						v.push_back(make_tuple(i+1,j+1,i+1,j+1+1));
					}
				}
			}
		}else{
			for(int j=W-1;j>=0;j--){
				if(a[i][j]%2!=0){
					if(j!=0){
						a[i][j]--;
						a[i][j-1]++;
						ans ++;                                     
						v.push_back(make_tuple(i+1,j+1,i+1,j-1+1));
					}else{
						if(i!=H-1){
							a[i][j]--;
							a[i+1][j]++;
							ans++;
							v.push_back(make_tuple(i+1,j+1,i+1+1,j+1));
						}else{
						}
					}
				}
			}
		}
	}
	cout << ans << endl;
	for(int i=0;i<ans;i++){
		cout << get<0>(v[i]) << " " << get<1>(v[i]) << " " << get<2>(v[i]) <<" " << get<3>(v[i]) << endl;
	}
}

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

#define MAXN 505

int g[MAXN][MAXN];

void go(int L, int R, int c) {
	if(L == R) return;
	
	int mid = L + (R-L)/2;
	go(L, mid, c+1);
	go(mid+1, R, c+1);
	for(int i = L; i <= mid; i++) {
		for(int j = mid+1; j <= R; j++) {
			g[i][j] = c;
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	
	go(0, n-1, 1);
	
	for(int i = 0; i < n-1; i++) {
		for(int j = i+1; j < n; j++) {
			cout << g[i][j] << ' ';	
		}
		cout << '\n';
	}
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
int n;
LL a[N],s;
int main() {
  ios::sync_with_stdio(false);
  cin>>n;
  for(int i=1;i<=n;i++)cin>>a[i],s^=a[i];
  LL x=a[1],y=a[2];
  s^=a[1]^a[2];
  // (x-ans) ^ (y+ans) =s;
  // dx ^ dy=s 
  // max ->dy
  // (dx+dy-s)=2*(dx&dy)
  LL d=x+y-s;
  if(d&1 || d<0 || d/2>x || (d/2)&s)return cout<<-1,0;
  d>>=1;
  LL ans=d;
  for(int i=45;i>=0;i--){
    if(!(1ll<<i & d)){
        LL nx=ans|1ll<<i;
        if(nx<=a[1]){
            if(s&1ll<<i){
                ans|=1ll<<i;
            }
        }
    }
  }
  if(!ans)cout<<-1<<'\n';
  else cout<<a[1]-ans<<'\n';
  return 0;
}

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

int main() {
    string s;
    cin >> s;
    map<char,int> cnt;
    for (char c : s) {
        cnt[c] += 1;
    }
    i64 n = s.size();
    i64 res = n * (n - 1) / 2 + 1;
    for (pair<char,int> e : cnt) {
        res -= i64(e.second) * (e.second - 1) / 2;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 640
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define pb push_back
# define len(x) ((int)(x).size())
using namespace std;
string yesno(bool b) { return b ? "yes" : "no"; }
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
#define Cin(Type, ...) Type __VA_ARGS__; _cin(__VA_ARGS__)
#define Cinv(Type, xs, n) vector<Type> xs(n); rep(i, n) cin >> xs[i]
void Print() { cout << endl; }
template <class Head, class... Tail> void Print(Head&& head, Tail&&... tail) { cout << head; if (sizeof...(tail) != 0) cout << " "; Print(forward<Tail>(tail)...); }
template <class Type> void Print(vector<Type> &vec) { for (auto& a : vec) { cout << a; if (&a != &vec.back()) cout << " "; } cout << endl; }
template <class Type> void Print(vector<vector<Type>> &df) { for (auto& vec : df) { Print(vec); } }

set<int> solve(const int n, const vector<int>& A)
{
    set<int> res;
    rep (bit, 1 << n)
    {
        int sum = 0;
        rep (i, n)
        {
            if (bit & (1 << i))
            {
                sum += A[i];
            }
        }

        res.insert(sum);
    }

    return res;
}

int main()
{
    Cin(int, n);
    Cinv(int, A, n);
    Cin(int, q);
    set<int> memo = solve(n, A);
    while (q--)
    {
        Cin(int, m);
        Print(yesno(memo.find(m) != memo.end()));
    }

    return 0;
}



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

int n, m, q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> A) {
  if (A.size() == n+1) {
    int now = 0;
    rep(i,q) {
      if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
    }
    ans = max(ans, now);
    return;
  }

  A.push_back(A.back());
  while (A.back() <= m) {
    dfs(A);
    A.back()++;
  }
}

int main() {
  cin >> n >> m >> q;
  a = b = c = d = vector<int>(q);
  rep(i,q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  dfs(vector<int>(1,1));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3640
import java.util.*;

public class Main {
    private static Scanner scanner;

    public static int[] inputIntArray(int n) {
        int[] res = new int[n];
        for (int i = 0; i < n; ++i) {
            res[i] = scanner.nextInt();
        }

        return res;
    }
    
    public static class Pair<A, B> {
        public A left;
        public B right;

        public Pair(A a, B b) {
            this.left = a;
            this.right = b;
        }
    }
    
    public static class Value {
        int y, x, v;
        
        public Value(int y, int x, int v) {
            this.y = y;
            this.x = x;
            this.v = v;
        }
    }

    public static boolean run() {
        int w = scanner.nextInt();
        int h = scanner.nextInt();
        
        if(w == 0)
            return false;
        
        int[][] vert = new int[h][w];
        int[][] hori = new int[h][w];
        boolean[][] reached = new boolean[h][w];
        
        for(int i = 0; i < h; ++i) {
            for(int j = 0; j < w - 1; ++j) {
                vert[i][j] = scanner.nextInt();
            }

            if(i == h - 1)
                continue;

            for(int j = 0; j < w; ++j) {
                hori[i][j] = scanner.nextInt();
            }
        }
        Queue<Value> que = new ArrayDeque<>();
        
        que.add(new Value(0, 0, 1));
        
        while(!que.isEmpty()) {
            Value pos = que.poll();
            
            if(reached[pos.y][pos.x])
                continue;
            
            reached[pos.y][pos.x] = true;
            
            if(pos.y == h - 1 && pos.x == w - 1) {
                System.out.println(pos.v);
                
                return true;
            }
            
            if(pos.x < w - 1 && vert[pos.y][pos.x] == 0) {
                que.add(new Value(pos.y, pos.x + 1, pos.v + 1));
            }
            if(pos.x > 0 && vert[pos.y][pos.x - 1] == 0) {
                que.add(new Value(pos.y, pos.x - 1, pos.v + 1));
            }
            if(pos.y < h - 1 && hori[pos.y][pos.x] == 0) {
                que.add(new Value(pos.y + 1, pos.x, pos.v + 1));
            }
            if(pos.y > 0 && hori[pos.y - 1][pos.x] == 0) {
                que.add(new Value(pos.y - 1, pos.x, pos.v + 1));
            }
        }
        
        System.out.println(0);
        return true;
    }

    public static void main(String args[]) {
        scanner = new Scanner(System.in);
        
        while(run());
    }
}


Measured memory_bytes: 68660
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cstring>
#include<climits>
#include<cfloat>
#include<cmath>
#include<map>
#include<complex>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define DBL(x) ((x)*(x))

typedef unsigned int uint;
typedef long long ll;

using namespace std;

void print(int s){
  int h = s/(60*60);
  s%=(60*60);
  int m = s/60;
  s%= 60;
  printf("%02d:%02d:%02d\n",h,m,s);
}

int main(){
  int h,m,s;
  while(cin>>h>>m>>s, h+m+s>=0){
    int sum  = h*60*60 + m*60 + s;
    int rest = 120*60 - sum;
    print(rest); print(rest*3);
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;
import java.util.ArrayDeque;
import java.util.Deque;

class Main {
	public static void main (String [] args) {
		Scanner scan = new Scanner (System.in);
		final int n = scan.nextInt();
		StringBuilder sb = new StringBuilder();
		
		// 両端キュー
		Deque<String> array = new ArrayDeque<String>();
		
		for (int i = 0; i < n; i++) {
			final String ord = scan.next();
			final String number;
			
			switch (ord) {
			case "insert":
				number = scan.next();
				array.addFirst(number);
				break;
			case "delete":
				number = scan.next();
				array.remove(number);
				break;
			case "deleteFirst":
				array.removeFirst();
				break;
			case "deleteLast":
				array.removeLast();
			break;
			}
			
		}
		scan.close ();
		
		sb.append(array.removeFirst());
		
		while (!array.isEmpty()) {
			sb.append(" ").append(array.getFirst());
			array.removeFirst();
		}
		
		System.out.println(sb);
	}
}



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

int main(){
    int N; cin >> N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    int x=0;
    sort(A.begin(),A.end());
    for(int i=0;i<N-1;i++){
        if(A[i]==A[i+1]){
            cout << "NO" << endl;
            x=1;

            break;
        }
    }
    if(x==0){
        cout << "YES" << endl;
    }
}


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

using namespace std;

int main()
{
	string S , T;
	while(getline(cin , S))
	{
		for(size_t i = 0; i < 26; i++)
		{
			for(auto &x : S)if('a' <= x&&x <= 'z')if(++x > 'z')x -= 26;
			stringstream SS;
			SS << S;
			vector<string>VS;
			bool f = false;
			while(SS >> T)
			{
				if(T == "the" || T == "this" || T == "that" || T == "ths." || T == "this." || T == "that.")
				{
					cout << S << endl;
					f = true;
					break;
				}
			}
			if(f)break;
		}
	}
}

Measured memory_bytes: 1200
$unit{"JPY"} = 1;
$unit{"BTC"} = 380000.0;

$r = 0;
while(<>){
	chomp;
	next if($. == 1);
	@line = split(/ /, $_);
	$r += $line[0] * $unit{$line[1]};
}

print "$r\n";


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000           // 2000000000
#define LINF 1000000000000000000 // 9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979

//.size()はunsigned int　0-1をするとオーバーフローする

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

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

int main(void) {
    int n;
    int now=0;
    int a;

    cin>>n;
    vector< pair<int,int> > pa(n);
    FOR(i,0,n-1){
        cin>>a;
        pa[i].first=a;
        pa[i].second=i+1;
    }
    sort(pa.begin(),pa.end());
    FOR(i,0,n-1){
        cout<<pa[i].second;
        if(i==n-1){
            cout<<endl;
        }else{
            cout<<" ";
        }
    }
}


Measured memory_bytes: 1664
from sys import stdin
import math
input = stdin.readline

a, b, h, m = map(int, input().split())

ha = h * 30 + m * 0.5
ma = m * 6

aa = ha - ma

if aa < -180:
    aa += 360
elif aa > 180:
    aa = 360 - aa
else:
    aa = abs(aa)

bb = aa * math.pi / 180
cc = a * a + b * b - 2 * a * b * math.cos(bb)

print(cc ** (1/2))

Measured memory_bytes: 9516
a = [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]

K = int(input())

print(a[K-1])

Measured memory_bytes: 38384
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmin(T& a, T b) {
    if (a >= b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;   
}

int main() {
    int a,b,c;
    cin>>a>>b>>c;
    vector<int> vec(a);
    rep(i,a){
        vec.at(i)=0;
    }
    vector<int> svec(c);
    rep(i,c){
        cin>>svec.at(i);
    }
    rep(i,c){
        int s=svec.at(i)-1;
        vec.at(s)++;
    }
    rep(i,a){
        if(vec.at(i)+b-c>0){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
}





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

int main(){
 int n,cnt=0;
 cin >> n;
 
 for(int i=1; i<n; i++){
   for(int j=1; j<=n/i; j++){
     if(i*j<n) cnt++;
   }
 }
  
  cout << cnt << endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) {
	if (a<b) { return gcd(b, a); }
	else if (a%b) { return gcd(b, a%b); }
	else { return b; }
}
int main() {
	ll H, W;
	cin >> H >> W;
	char c[110][110];
	for (ll i = 0; i < H; i++) {
		for (ll j = 0; j < W; j++) {
			cin >> c[i][j];
		}
	}
	for (ll i = 0; i < H; i++) {
		for(ll j=0; j<W; j++){
          cout<<c[i][j];}
      		cout<<endl;
      for(ll j=0; j<W; j++){
          cout<<c[i][j];
      }
          cout<<endl;
    }
}








Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ii pair<int,int>
#define INF 1000000100
#define M 1000000007ll
#define INFLL 1000000000000000010ll
#define UQ(x) (x).resize(distance((x).begin(),unique(all((x)))))
#define mid(x,y) (((x)+(y))>>1)

int n,x[200005],y[200005];
vector<ii> o2,o;
vector<int> h,l;
int pr[200005];
int main() {
	scanf("%d",&n);
	int vmin=INF,vmax=-1;
	for (int i=0;i<n;i++) {
		scanf("%d%d",&x[i],&y[i]);
		if (x[i]>y[i]) swap(x[i],y[i]);
		vmax=max(vmax,y[i]);
		vmin=min(vmin,x[i]);
	}
	int rmin=vmax;
	int bmax=vmin;
	for (int i=0;i<n;i++) {
		rmin=min(rmin,y[i]);
		bmax=max(bmax,x[i]);
	}
	ll ans=(ll)(vmax-rmin)*(ll)(bmax-vmin);

	for (int i=0;i<n;i++) {
		if (x[i]==vmin && y[i]==vmax) {
			//special
			printf("%lld\n", ans);
			return 0;
		}
		if (x[i]==vmin) {
			l.pb(y[i]);
		} else if (y[i]==vmax) {
			h.pb(x[i]);
		} else {
			o2.pb(mp(x[i],y[i]));
		}
	}
	sort(all(l));
	sort(all(h));
	sort(all(o));
	UQ(o);

	int bmin=min(h[0],l[0]);
	bmax=max(h.back(),l.back());

	for (ii p:o2) {
		bmax=max(bmax,p.first);
		bmin=min(bmin,p.second);
	}

	for (ii p:o2) {
		if (p.first<bmin && p.second>bmax) {
			o.pb(p);
		}
	}
	int cl=bmax-bmin;
	if (!o.empty()) {
		int cur=bmax-o[0].first;
		sort(all(o));
		pr[0]=o[0].second;
		for (int i=1;i<sz(o);i++) {
			pr[i]=max(pr[i-1],o[i].second);
		}
		for (int i=1;i<sz(o);i++) {
			cur=min(cur,max(bmax,pr[i-1])-o[i].first);
		}
		cl=cur;
	}
	ans=min(ans,(ll)cl*(ll)(vmax-vmin));
	printf("%lld\n", ans);
}

Measured memory_bytes: 3956
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N, M, C;
ll B[25];

int main() {
	scanf("%lld %lld %lld", &N, &M, &C);
	for(int i = 0; i < M; i++) {
		scanf("%lld", &B[i]);
	}
	ll mat[25][25];
	for(int i = 0; i < N; i++) {
		for(int j = 0; j < M; j++) {
			scanf("%lld", &mat[i][j]);
		}
	}
	ll cnt = 0;
	ll sum = 0;
	for(int i = 0; i < N; i++) {
		sum = 0;
		for(int j = 0; j < M; j++) {
			sum += mat[i][j] * B[j];
		}
		if((sum += C) > 0) {
			// cout << sum << " ";
			cnt++;
		}
	}
	printf("%lld\n", cnt);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>                                                        
#define scan1(a) scanf("%d",&a);                                                
#define scan2(a,b) scanf("%d %d",&a,&b);                                        
#define loop(i,j) for(int i=0;i<j;i++)                                          
typedef long long ll;                                                           
using namespace std;                                                            
                                                                                
int main()                                                                      
{                                                                               
  int N,K;                                                                      
  scan2(N,K);                                                                   
  int v[N];                                                                     
  loop(i,N) scan1(v[i]);                                                        
  sort(v,v+N);                                                                  
  int mi=INT_MAX;                                                               
  loop(i,N-K+1){                                                                
    mi=min(mi,abs(v[i]-v[i+K-1]));                                              
  }                                                                             
  printf("%d\n",mi);                                                            
  return 0;                                                                     
}                     

Measured memory_bytes: 640
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int[] l = new int[n];
		for(int i = 0; i < n; i++){
			l[i] = sc.nextInt();
		}
		int ans = 1;
		int sum = 0;
		int i = 0;
		for(i = 0; sum <= x && i < n; i++){
			ans++;
			sum=sum+l[i];
		}
		if(sum > x){
			ans--;
		}
		System.out.print(ans);
	}
}


Measured memory_bytes: 21844
#define d for(x=0;x<N;x++){for(y=0;y<N;y++
c,m[10][10],x,N;main(y){for(;scanf("%d",&N),N;){d)m[x][y]=(x+y)*(x-~y)/2+1+(x+y&1?x:y);}printf("Case %d:\n",++c);d)printf("%3d",x+y<N?m[x][y]:N*N+1-m[N+~x][N+~y]);puts("");}}exit(0);}

Measured memory_bytes: 620
n = int(input())
p = [int(input()) for _ in range(n)]

# 数列を並び替えたとき、元のインデクス位置が単調増加となる区間は取り出し不要
# n - 最長区間を引いたものが最短手数となる
p_with_index = list(sorted(enumerate(p), key=lambda x : x[1]))
max_inc_span = 1
span = 1
for i in range(1, n):
    if p_with_index[i-1] < p_with_index[i]:
        span += 1
        max_inc_span = max(max_inc_span, span)
    else:
        span = 1

print(n - max_inc_span)

Measured memory_bytes: 40504
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE

//-----CODE------//
void solve(void)
{ 
  int K,A,B;
  cin>>K>>A>>B;
  for (int i = A; i < B+1; i++)
  {
    if(i%K ==0)
    {
      cout<<"OK"<<endl;
      return;
    }
  }
  cout<<"NG"<<endl;
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 3688
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
 
using namespace std;
using namespace __gnu_pbds;

template<typename T, typename comp>
using ordered_set = tree<T, null_type, comp, rb_tree_tag, tree_order_statistics_node_update>;
 
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define f first
#define s second
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for (int i = (b) - 1; i >= (a); --i)
#define FILL(a, b) memset(a, b, sizeof a)
#define ALL(a) a.begin(), a.end()
#define SZ(a) ((int)a.size())
#define bitc(n) __builtin_popcount(n)
#define MAGIC0 mt19937 rnd(time(0)); //rnd()
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
 
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = 1LL * INF*INF;
const int MAX = 1e6 + 7;
const double PI = acos(-1.);
const double EPS = 1e-7;
const int MAXN = 2 * 1007;


int main()
{
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	vector<pair<PII, int>> vec;
	FOR(i, 0, n)
	{
		int x, y;
		cin >> x >> y;
		vec.PB({{x, y}, 0});
	}
	FOR(i, 0, n)
	{
		int x, y;
		cin >> x >> y;
		vec.PB({{x, y}, 1});
	}
	sort(ALL(vec));

	set<int> kek;
	int ans = 0;
	FOR(i, 0, 2*n)
	{
		int t = vec[i].s;
		if (t == 0)
		{
			kek.insert(vec[i].f.s);
		}
		else
		{
			int mx = -1, p = 0;
			for(auto el : kek)
			{
				if (mx < el && el < vec[i].f.s)
				{
					mx = el;
				}
			}
			if (mx == -1) continue;
			kek.erase(mx);
			++ans;
		}
	}

	cout << ans << "\n";
	
  	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fup(i,a,b) for(int i=a;i<=b;++i)
#define fdw(i,a,b) for(int i=a;i>=b;--i)
#define sync ios::sync_with_stdio(false);cin.tie(0)
#define cl(a) memset(a,0,sizeof(a))
#define gcd __gcd
#define fi first
#define se second
#define pb push_back
#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
//ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
//ll ksm(ll a,ll b,ll mod){ll ans=1;a%=mod;for(;b;b>>=1){if(b&1) ans=ans*a%mod;a=a*a%mod;}return ans;}
//ll oula(ll n){ ll res=n;for(ll i=2;i*i<=n;i++){if(n%i==0){ res=res-res/i;while(n%i==0) n/=i;}}if(n>1) res=res-res/n;return res;}
//bool MRT(ll x){if(x==2)return true;fup(i,1,50){ll now=rand()%(x-2)+2;if(ksm(now,x-1,x)!=1)return false;}return true;}
//void shai(int n)fup(i,2,n){if(isprime[i]){v.push_back(i);for(int j=2*i;j<=10000;j+=i)isprime[j]=0;}}//"埃氏筛筛选素数"
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
const double eps=1e-7;
const int N = 1e6 + 10;
char s[N];
int dp[N][2];
int main()
{
    sync;
    cin>>s;
	int n = strlen(s);
	dp[0][1] = 1;
	for(int i = 1; i <= n; i++)
	{
		dp[i][0] = min(dp[i-1][0],dp[i-1][1]+1)+(s[i-1]-'0');
		dp[i][1] = min(dp[i-1][0],dp[i-1][1]-1)+(10-(s[i-1]-'0'));
	}
	cout<<min(dp[n][0],dp[n][1]+1)<<endl;
    return 0;
}


Measured memory_bytes: 9088
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>
   
using namespace std;

#define mod 1000000007

int main()
{
    int v, e;
    cin >> v >> e;
    int graph[15][15], edgenum[15] = {};
    for(int i = 0; i < v; i++){
        for(int j = 0; j < v; j++){
            graph[i][j] = mod;
        }
    }
    int weightsum = 0;
    for(int i = 0; i < e; i++){
        int s, t, d;
        cin >> s >> t >> d;
        graph[s][t] = min(graph[s][t], d);
        graph[t][s] = min(graph[t][s], d);
        weightsum += d;
        edgenum[s]++;
        edgenum[t]++;
    }
    vector<int> oddnode;
    for(int i = 0; i < v; i++){
        if(edgenum[i] % 2 == 1) oddnode.push_back(i);
    }
    int oddnum = oddnode.size();
    for(int k = 0; k < v; k++){
        for(int i = 0; i < v; i++){
            for(int j = 0; j < v; j++){
                graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
            }
        }
    }
    // cout << weightsum << endl;
    // for(int i = 0; i < oddnum; i++){
    //     cout << oddnode[i] << " ";
    // }
    // cout << endl;
    int result[1 << 15] = {};
    for(int i = 0; i < oddnum; i++){
        result[(1 << i)] = -1;
    }
    for(int i = 0; i < (1 << oddnum); i++){
        if(result[i] == -1) continue;
        for(int j = 0; j < oddnum; j++){
            for(int k = j + 1; k < oddnum; k++){
                if((i & (1 << j)) != 0 || (i & ((1 << k))) != 0) continue;
                int news = oddnode[j], newt = oddnode[k];
                int tmp = (i | (1 << j) | (1 << k));
                // cout << i << " " << result[i] << " " << j << " " << k << " " << graph[news][newt]  << endl;
                if(graph[news][newt] != mod && tmp != i){
                    if(result[tmp] == 0) result[tmp] = result[i] + graph[news][newt];
                    else result[tmp] = min(result[tmp], result[i] + graph[news][newt]);
                }
            }
        }
        // cout << i << " " << result[i] << endl;
    }
    cout << weightsum + result[(1 << oddnum) - 1] << endl;
    return 0;
}

Measured memory_bytes: 3280
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

#include "bits/stdc++.h"
using namespace std;

int main() {
	long long int N, M;
	cin >> N >> M;

	if (2 * N >= M) {
		cout << M / 2 << endl;
	}
	else {
		long long int K = M - 2 * N;
		cout << N + K / 4 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn=2e5+5;

int main()
{
    ios::sync_with_stdio(false);
    int n;cin>>n;
    int t;
    int sum1=0,sum2=0;
    for(int i=0;i<n;i++)
    {
        cin>>t;
        if(t%2==0)
        {
            sum1++;
            if(t%4==0)
                sum2++;
        }
    }
    sum1-=sum2;
    if(sum1%2!=0) sum1--;
    //cout<<sum1<<endl;
    if((n-sum1)/2<=sum2)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
ll rand_int(ll l, ll r) //[l, r]
{
    static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
    return uniform_int_distribution<ll>(l, r)(gen);
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
const int maxn=2e6+7;
const int mod=1e9+7;
ll fac[maxn];
ll invfac[maxn];
ll quick(ll a,ll b)
{
    ll ret=1;
    while(b)
    {
        if(b&1) ret=ret*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ret;
}
inline ll C(int n,int m)
{
    if(m>n) return 0;
    return fac[n]*invfac[m]%mod*invfac[n-m]%mod;
}
int main()
{
    fac[0]=1;
    for(int i=1;i<maxn;i++) fac[i]=fac[i-1]*i%mod;
    invfac[maxn-1]=quick(fac[maxn-1],mod-2);
    for(int i=maxn-2;i>=0;i--) invfac[i]=invfac[i+1]*(i+1)%mod;
    int r1,c1,r2,c2;
    cin>>r1>>c1>>r2>>c2;
    ll cur=C(r1+c1,r1);
    ll ans=cur;
    int l=r1,r=r1;
    for(int i=r1+c1+1;i<=c2+r2;i++)
    {
        int nr=r,nl=l;
        if(r<r2) nr++;
        if(i>r1+c2) nl++;
        cur=(cur*2)%mod;
        if(nr>r&&nl==l)
            cur=(cur+C(i-1,l-1)+C(i-1,nr))%mod;
        else if(nl==l&&nr==r)
            cur=(cur+C(i-1,l-1)-C(i-1,r)+mod)%mod;
        else if(nr>r&&nl>l){
            cur=(cur+C(i-1,nr)-C(i-1,l)+mod)%mod;
        }
        else if(nr==r&&nl>l)
            cur=(cur-(C(i-1,l)+C(i-1,r))%mod+mod)%mod;
        else assert(false);
        ans=(ans+cur)%mod;
        l=nl,r=nr;
        //dbg(i,cur);
    }
    print(ans);

}

Measured memory_bytes: 31488
#include<stdio.h>
int main(){
  int H[99999],W[99999];
  int i,j,k;
    for (i=0; i<99999; i++) {
    H[i] = 0;
    W[i] = 0;
    }
  for (i=0; i<99999; i++) {
    scanf("%d %d",&H[i],&W[i]);
    if(H[i]==0 && W[i]==0){
      break;
    }
  }
  for (i=0; i<99999; i++) {
    if (H[i]==0 && W[i]==0){ break;}
    for(k=0;k<H[i];k++){
      for(j=0;j<W[i];j++){
        if(k==0 || k==H[i]-1 || j==0 || j==W[i]-1) {
          printf("#");
        }
        else{
          printf(".");
        }
      }
        printf("\n");
    }
   printf("\n");
  }
  return 0;
}

Measured memory_bytes: 1352