akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF 1000000000 //
#define LINF (ll)4000000000000000000 //
#define MOD (ll)1000000007
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898
#define NP(v) next_permutation(v.begin(),v.end())

//------------------------------------------------------

int main() {
    int h, w;
    cin >> h >> w;
    int cnt = 0;

    rep(i, h) {

        rep(j, w) {
            char a;
            cin >> a;
            if (a == '#') cnt++;
        }
    }

    cout << (cnt == h + w - 1 ? "Possible" : "Impossible") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000000000

void assign_all(vector<int> &ans,vector<int> &num,vector<int> &vertex){
	while(num.size()!=0&&vertex.size()!=0){
		ans[vertex.back()] = num.back();
		num.pop_back();
		vertex.pop_back();
	}
}

int main(){
	
	int N;
	cin>>N;
	
	vector<vector<int>> E(N,vector<int>());
	for(int i=0;i<N-1;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		E[a].push_back(b);
		E[b].push_back(a);
	}
	
	vector<int> dis(N,1000);
	dis[0] = 0;
	queue<int> Q;
	Q.push(0);
	
	while(Q.size()!=0){
		int u = Q.front();
		Q.pop();
		for(int i=0;i<E[u].size();i++){
			int v = E[u][i];
			if(dis[v]!=1000)continue;
			dis[v] = dis[u]^1;
			Q.push(v);
		}
	}
	vector<vector<int>> num(3,vector<int>());
	vector<vector<int>> vertex(2,vector<int>());
	for(int i=1;i<=N;i++){
		num[i%3].push_back(i);
		vertex[dis[i-1]].push_back(i-1);
	}
	
	
	vector<int> ans(N,-1);
	
	if(vertex[0].size()<=num[0].size())assign_all(ans,num[0],vertex[0]);
	if(vertex[1].size()<=num[0].size())assign_all(ans,num[0],vertex[1]);
	assign_all(ans,num[1],vertex[0]);
	assign_all(ans,num[2],vertex[1]);
	
	for(int i=0;i<3;i++){
		for(int j=0;j<2;j++){
			assign_all(ans,num[i],vertex[j]);
		}
	}
	
	for(int i=0;i<N;i++){
		if(i!=0)cout<<' ';
		cout<<ans[i];
	}
	cout<<endl;
	
	
	return 0;
}

Measured memory_bytes: 17652
<?php
  fscanf(STDIN,"%d%d",$n,$d);
  for($i=0;$i<$n;$i++){
    $input = preg_split("/ /",trim(fgets(STDIN)));
    for($j=0;$j<$d;$j++){
      $x[$i][$j] = $input[$j];
    }
  }
  $count = 0;
  for($i=0;$i<$n-1;$i++){
    for($j=$i+1;$j<$n;$j++){
      $score = 0;
      for($k=0;$k<$d;$k++){
        $score += ($x[$j][$k]-$x[$i][$k])*($x[$j][$k]-$x[$i][$k]);
      }
      if(ctype_digit(strval(sqrt($score)))){
        $count++;
      }
    }
  }
  echo($count);

Measured memory_bytes: 3828
require 'pp'

###################

# inputType = :singleLine
inputType = :l2Lines
# inputType = :nLines
  
def main(query)
  ret = []
  n, ls = query
  
  ls = tois(ls.chomp.split(' '))

  count = 0
  r = 0.upto(ls.size-1).to_a
  r.combination(3).uniq.each { | a,b,c |
    aa,bb,cc = [ls[a],ls[b],ls[c]].sort { | x,y | y <=> x}
    #    p [[a,b,c], [aa,bb,cc]]
    #    p [a,b,c]
    if (aa < bb+cc && aa != bb && aa != cc && bb != cc) then
      #      p [a,b,c]
      count = count + 1
    end
  }

  ret.push count.to_s
  
  return ret
end

###################

TEST=false

def tois(l)
  l.map { | x | x.to_i}
end

def ppp(msg, val)
  if (TEST) then
    print msg
    pp val
  end
end

target = nil
if (ARGV.size == 0) then
  f = STDIN
end
if (ARGV.size > 0) then
  f = open(ARGV[0])
end
if (ARGV.size > 1) then
  target = ARGV[1].to_i
end

t = 1
ng = []
while true
  if (inputType == :singleLine) then
    a = f.gets
    if ! a then
      exit
    end
    a.chomp!
    query = a
  elsif (inputType == :l2Lines) then
    a = f.gets
    if ! a then
      exit
    end
    a.chomp!
    b = f.gets.chomp
    query = [a,b]
  elsif (inputType == :nLines) then
    a = f.gets
    if ! a then
      exit
    end
    n = a.chomp.to_i
    query = n.map { | i |
      f.gets.chomp
    }    
  end
  
  aa = f.gets
  if ! aa then
    r = main(query) 
    r.each { | x | puts x }
    exit
  elsif ( aa.chomp == "---") then
    oks = []
    while true
      s = f.gets.chomp
      if (s == "---") then
        break
      end
      oks.push s
    end

    if (target == nil || t == target) then
      if target then
        TEST = true
      end

      puts "--- " + t.to_s + " ---"
      r = main(query)    

      if r.join('\n') == oks.join('\n') then
        puts "RESULT:"
        r.each { | x | puts x }
        puts "OK"
      else
        puts "RESULT:NG"
        r.each { | x | puts x }
        puts "NG!!!!!!!!!"
        ng.push t
      end
    end
  end
  t = t + 1
end
puts "---"
puts "NG targes = " + ng.to_s


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

typedef long long ll;


ll choose(ll a, ll b){
    ll ans = 1;
    for(int i=0; i<a; i++) 
	ans *= i+1;
    for(int i=0; i<b; i++) 
	ans /= i+1;
    for(int i=0; i<a-b; i++) 
	ans /= i+1;
    return ans;
}

int main () {
    ll n;cin >> n;
    map<char,ll> idx;
    idx['M'] = 0;
    idx['A'] = 1;
    idx['R'] = 2;
    idx['C'] = 3;
    idx['H'] = 4;
    ll m[5]={};
    for(int i=0; i<n; i++) {
	string s; cin >> s;
	if(idx.find(s[0]) != idx.end() )
	    m[idx[s[0]]]++;
    }
    ll ans = 0;
    for(int i=0; i<5; i++) {
	for(int j=i+1; j<5; j++) {
	    for(int k=j+1; k<5; k++) {
		ans += m[i]*m[j]*m[k];
	    }
	}
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#![allow(dead_code)]
#![allow(unused_imports)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
use ascii::{AsciiChar, AsciiStr, AsciiString};
use indexmap::IndexMap;
use itertools::*;
use libm::*;
use num::*;
use ordered_float::OrderedFloat;
use permutohedron::LexicalPermutation;
use proconio::marker::{Bytes, Chars};
use proconio::{fastout, input};
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::mem::swap;

fn main() {
    input!(n:usize, a:[usize;n]);
    let mut ans = 0;
    for (i, x) in a.into_iter().enumerate() {
        if i % 2 == 0 && x % 2 == 1 {
            ans += 1;
        }
    }
    println!("{}", ans)

}


Measured memory_bytes: 2076
MOD = int(1e9)+7

def fact(n):
    res = 1
    for x in range(1, n+1):
        res *= x
        res %= MOD
    return res
        

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

if abs(N - M) >= 2:
    print(0)
elif N == M:
    print((2 * fact(N) * fact(N)) % MOD)
else:
    print((fact(N)*fact(M)) % MOD)


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

int main() {
  vector<char> S(3);
  int counter = 0;
  
  rep(i,3){
    cin >> S.at(i);
    if(S.at(i) == 'A')
      counter++;
  }
  
  if(counter == 1 || counter == 2)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
int main()
{
    int n;

    std::cin >> n;
    std::array<std::string, 100000> S;
    int64_t ac = 0;
    int64_t tle = 0;
    int64_t wa = 0;
    int64_t re = 0;
    for (int i = 0; i < n; ++i) {
        std::cin >> S[i];
    }
    for (int i = 0; i < n; ++i) {
        if (S[i] == "AC") {
            ac += 1;
        }
        if (S[i] == "WA") {
            wa += 1;
        }
        if (S[i] == "RE") {
            re += 1;
        }
        if (S[i] == "TLE") {
            tle += 1;
        }
    }
    std::cout << "AC x " << ac << std::endl;
    std::cout << "WA x " << wa << std::endl;
    std::cout << "TLE x " << tle << std::endl;
    std::cout << "RE x " << re << std::endl;
}


Measured memory_bytes: 6760
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

signed main(){
    int n, t;
    cin >> n >> t;
    vector<int> h(n);
    rep(i, 0, n) cin >> h[i];
    int ans = 0;
    int next = 0;
    rep(i, 0, n){
        if(next > h[i]){
            ans -= next - h[i];
        }
        ans += t;
        next = h[i] + t;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)


int main() {
  int n;
  cin >> n;
  vector<int> n1, n2;
  rep(i, n){
      int num; cin >> num;
      if(i % 2 == 0) n1.push_back(num);
      else n2.push_back(num);
  }
  if(n % 2 == 0){
      reverse(all(n2));
      rep(i, n2.size()) cout << n2[i] << " ";
      rep(i, n1.size()) cout << n1[i] << " ";
  } else{
      reverse(all(n1));
      rep(i, n1.size()) cout << n1[i] << " ";
      rep(i, n2.size()) cout << n2[i] << " ";
  }
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
int sum[214514],kei[214514];
signed main(){
	int n,cost;
	cin>>n>>cost;
	vector<int> pos;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		pos.pb(x);
	}
	reverse(pos.begin(), pos.end());
	sum[0] = 0;
	for(int i=1;i<=n;i++){
		sum[i] = sum[i-1] + pos[i-1];
	}
	kei[1] = 5;
	for(int i=2;i<=n;i++){
		kei[i] = 1+2*i;
	}
	int ans = -1;
	for(int k=1;k<=n;k++){	// goes and returns k times
		int num = n/k;
		if(n%k)num++;
		int tmp = 0;
		int cur = 0;
		for(int i=1;i<=num;i++){
			tmp += kei[i] * ( sum[min(cur+k,n)] - sum[cur] );
			cur += k;
		}
		tmp += cost * ( n + k );
		//cout<<k<<" "<<tmp<<endl;
		if( tmp < ans || ans < 0 )ans = tmp;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5488
#include<iostream>
#include<algorithm>
using namespace std;
const int N=1e5+5;
int ar[N],ar1[N];
int main(){
	int n,m,i,j,k,step;
	cin>>n>>m;
	for(i=1;i<=m;i++){
		cin>>ar[i];
	}
	sort(ar+1,ar+1+m);
	step=ar[m]-ar[1];
	for(i=1;i<m;i++){
		ar1[i]=ar[i+1]-ar[i];
	}
	sort(ar1+1,ar1+m);
//	for(i=1;i<m;i++){
//		cout<<ar1[i]<<endl;
//		//ar1[i]=ar[i+1]-ar[i];
//	}
	for(i=m-1,j=1;j<=n-1;i--,j++){
		if(i<1){
			break;
		}
		step-=ar1[i];
	}
	cout<<step;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define pi pair<ll,ll>
using namespace std;
int main(){
	//	freopen("in.txt","r",stdin);
	int N,M;
	ll BN = 1;
	ll BM = 1;
	ll ans = 1;
	scanf("%d%d",&N,&M);
	if(abs(N-M)>=2){
		printf("0\n");
		return 0;
	}
	for (int i = 2; i <= N; ++i)
	{
		ans *= i;
		ans %= mod;
	}
	for (int i = 2; i <= M; ++i)
	{
		ans *= i;
		ans %= mod;
	}
	if(N==M){
		ans *= 2;
		ans %= mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,ll> P;
typedef tuple<int,int,int> TP;
constexpr int INF = 2e9;
struct UnionFind{
  vector<int> data;
  int __size;
  UnionFind(int sz) {
  data.assign(sz, -1);
  __size = sz;
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);//親は負でサイズを保存
    __size--;
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  bool same(int x, int y){
    return find(x) == find(y);
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }

  int union_count() {
    return (__size);
  }
};

int dx[] = {0,1};
int dy[] = {1,0};
int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  map<int,ll> cnt;
  UnionFind uf(h * w);
  auto calc = [&](int i, int j){
    for (int k = 0; k < 2; k++) {
      int x = i + dx[k], y = j + dy[k];
      if (x >= h || y >= w) continue;
      if (uf.same(i * w + j, x * w + y)) continue;
      if (s[x][y] != s[i][j]) uf.unite(i * w + j, x * w + y);
    }
  };
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      calc(i, j);
    }
  }
  ll res = 0;
  rep(i,h) rep(j,w) if (s[i][j] == '#') cnt[uf.find(i * w + j)]++;
  rep(i,h) rep(j,w) if (s[i][j] == '#') res += (uf.size(i * w + j) - cnt[uf.find(i * w + j)]);
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 12628
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>

#define rep(i,n) for((i)=0;i<(int)(n);i++)
#define max(a,b) (a < b ? b : a)
#define min(a,b) (a > b ? b : a)

using namespace std;

int pow2(int n) {
	int a = 1;
	for (int i = 0; i < n; i++)a *= 2;
	return a;
}

int main() {
	int i, j, k;
	const int inf = 1000000000;
	int K[5000];
	rep(i, 5000)K[i] = inf;
	K[0] = 0;
	int N, M;
	cin >> N >> M;
	rep(i, M) {
		int a, b;
		k = 0;
		cin >> a >> b;
		rep(j, b) {
			int tmp;
			cin >> tmp;
			tmp = pow2(N - tmp);
			k = k | tmp;
		}
		K[k] = min(K[k], a);
	}
	int n = pow2(N);
	for (int i = 2; i < n; i++) {
		for (int j = 1; j < i; j++) {
			K[i | j] = min(K[i] + K[j], K[i | j]);
		}
	}
	if (K[n - 1] == inf)cout << "-1";
	else cout << K[n - 1];
	return 0;

}


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  string b;
  cin >> b;

  map<string, string> m;
  m["A"] = "T";
  m["T"] = "A";
  m["C"] = "G";
  m["G"] = "C";

  cout << m[b] << endl;

  return 0;
}


Measured memory_bytes: 256
line = gets.split
n = line[0].to_i
m = line[1].to_i
r = line[2].to_i

if n*m > r
    puts 0
else
    ans = 1
    r -= n*m
    for i in n..n+r-1 do
        ans *= i
    end
    for i in 1..r do
        ans /= i
    end
    puts ans
end

Measured memory_bytes: 12124
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using Item = pair<ll, ll>;
int main() {
  ll N, M;
  cin >> N >> M;
  vector<Item> items(N);
  for(ll i = 0; i < N; ++i) {
    cin >> items[i].first >> items[i].second;
  }
  sort(items.begin(), items.end());
  ll ans = 0;
  ll m = M;
  for(auto item : items) {
    auto n = min(m, item.second);
    m -= n;
    ans += n * item.first;
    if(m == 0) {
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>

using namespace std;

int main(){
  int y,m,d; char a,b;
  cin>>y>>a>>m>>b>>d;
  
  if(m<5) cout << "Heisei"<<endl;
  else cout<<"TBD"<<endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
#define ll long long
#define umap unordered_map
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up
ll M=1e9+7;
int quick_pow(int x,int p){
    int a=1,po=x;
    while(p){
        if(p&1)  a=1ll*a*po%M;
        po=1ll*po*po%M;p>>=1;
    }
    return a;
}

//This is nCr
int nCr(int n, int r){
    r=min(r, n-r);
    ll a=1, b=1;
    rep(i, r){a*=n-i;a%=M;}
    rep2(i, r){b*=i;b%=M;}
    b=quick_pow(b, M-2);
    a*=b;a%=M;
    return a;
}
//Start from Here
int main(){
    int n, a, b;
    cin>>n>>a>>b;
    int ans;
    ans=quick_pow(2, n)-1;
    ll a1=1, b1=1;
    ll a2=1, b2=1;
    a=nCr(n,a);
    b=nCr(n, b);
    ans-=a+b;
    ans=mod(ans, M);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>
#include<numeric>

using namespace std;
typedef long long ll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
const int INF = 1e9+1;


int main() {

    int a,b;
    cin >> a >> b;
    if (a >= 10 || b >= 10) {
        cout << "-1" << endl;
    } else {
        cout << a * b << endl;
    }


    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define endl "\n"
#define goat() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL))
typedef long long ll;

int main() {
	goat();
	ll n, i, x, y, z, c = 0;
	cin >> n;
	unordered_map<ll, ll>mp;
	for (x = 1; x <= 100; x++) {
		for (y = 1; y <= 100; y++) {
			for (z = 1; z <= 100; z++) {
				ll s = 0;
				s += x * x;
				s += y * y;
				s += z * z;
				s += x * y;
				s += y * z;
				s += x * z;
				mp[s]++;
			}
		}
	}
	for (i = 1; i <= n; i++) {
		cout << mp[i] << endl;
	}
}

Measured memory_bytes: 5000
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

bool used[1000];

int main(){
    int n;
    pii red[1000], blue[1000];
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
        scanf("%d%d", &red[i].second, &red[i].first);
    sort(red, red+n);
    for(int i = 0; i < n; i++)
        scanf("%d%d", &blue[i].first, &blue[i].second);
    sort(blue, blue+n);
    int x=n-1;
    int ans=0;
    
/*printf("\n\n");
    for(int i = 0; i < n; i++)
        printf("%d %d\t", red[i].second, red[i].first);
//printf("\n\n");
    for(int i = 0; i < n; i++)
        printf("%d %d\t", blue[i].first, blue[i].second);
printf("\n\n");*/
    for(int i = 0; i < n; i++){
        for(int j = n-1; j >= 0; j--){
            if(!used[j] && red[j].second < blue[i].first && red[j].first < blue[i].second){
        //printf("%d %d\t", blue[i].first, blue[i].second);
        //printf("%d %d\n", red[j].second, red[j].first);
                ans++;
                used[j] = true;
                break;
            }
        }
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 256
import math
from bisect import bisect_right
N, D, A = map(int, input().split())  # N体のモンスター, 爆弾の範囲D, 爆弾の威力A
XH = []
X = []
for _ in range(N):
    x, h = map(int, input().split())
    XH.append((x, math.ceil(h/A)))  # 座標と必要な爆弾の個数を格納する
    X.append(x)  # こっちは座標のみ, あとで座標を二分探索するときに使う
# 座標でソートする
XH.sort()
X.sort()
T = [0]*(N+1)
now = 0
ans = 0
for i in range(N):
    x, h = XH[i]
    now -= T[i]
    if now >= h:
        continue
    else:
        T[bisect_right(X, x+D*2)] += h - now
        ans += h - now
        now = h
print(ans)


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

int main()
{
 
  unsigned long a, b, r, x, tmp;
 
  cin >> a >> b;
 
  x = a * b;

  if(a < b){
    tmp = a;
    a = b;
    b = tmp;
  }

  r = a % b;
  while(r != 0){
    a = b;
    b = r;
    r = a % b;
  }
  cout << x/b <<endl;
}

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

using ll = long long;

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

template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

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

    int N, K; cin >> N >> K;
    vector<int> A(N); cin >> A;

    vector<ll> sum;
    ll all_or = 0;
    rep(i, N) {
        ll s = 0;
        for (int j = i; j < N; j++) {
            s += A[j];
            sum.push_back(s);
            all_or |= s;
        }
    }

    ll ans = 0;
    for (ll b = (1LL << 41); b > 0; b >>= 1) {
        if (!(all_or & b)) continue;
        int c = 0;
        ll pat = (ans | b);
        rep(i, sum.size()) {
                if ((sum[i] & pat) == pat) {
                    c++;
                }
        }
        if (c >= K) {
            ans |= b;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 6512
#include <iostream>
#include <cmath>
 
using namespace std;
 
#define EPS 1e-8
 
struct Point {
    double x,y;
    Point(double x = 0.0, double y = 0.0) : x(x),y(y) {}
    Point operator + (Point p){ return Point(x+p.x,y+p.y); }
    Point operator - (Point p){ return Point(x-p.x,y-p.y); }
    Point operator * (double a){ return Point(x*a,y*a); }
    Point operator / (double a){ return Point(x/a,y/a); }
    double abs(){ return sqrt(norm()); }
    double norm(){ return x*x + y*y; }
};
 
double dot(Point a,Point b){ return a.x*b.x+a.y*b.y; }
double cross(Point a,Point b){ return a.x*b.y-a.y*b.x; }
 
int ccw(Point p0,Point p1,Point p2)
{
    Point a = p1-p0;
    Point b = p2-p0;
    if (cross(a,b) > EPS) return 1;
    if (cross(a,b) < -EPS) return -1;
    if (dot(a,b) < -EPS) return 2;
    if (a.norm() < b.norm()) return -2;
    return 0;
}
 
struct Segment {
    Point p1,p2;
    Segment(){}
    Segment(Point p1,Point p2) : p1(p1),p2(p2) {}
};
 
bool intersectSS(const Segment &s,const Segment &t)    
{
    return (ccw(s.p1,s.p2,t.p1)*ccw(s.p1,s.p2,t.p2) <= 0) && 
	(ccw(t.p1,t.p2,s.p1)*ccw(t.p1,t.p2,s.p2) <= 0);
}
 
Point getCrossPoint(Segment s, Segment t)
{
    Point b = t.p2 - t.p1;
    double d1 = abs(cross(b,s.p1-t.p1));
    double d2 = abs(cross(b,s.p2-t.p1));
    double d = d1 / (d1 + d2);
    return s.p1+(s.p2-s.p1)*d;
}
 
double getArea(Point a, Point b, Point c)
{
    return fabs(a.x*(b.y-c.y)+b.x*(c.y-a.y)+c.x*(a.y-b.y))/2;
}
 
Segment s[3];
void solve()
{
    Point p1 = getCrossPoint(s[0],s[1]);
    Point p2 = getCrossPoint(s[1],s[2]);
    Point p3 = getCrossPoint(s[2],s[0]);
    double S = getArea(p1,p2,p3);
    if (S >= 1900000) {
	cout << "dai-kichi" << endl;
    } else if (S >= 1000000) {
	cout << "chu-kichi" << endl;
    } else if (S >= 100000) {
	cout << "kichi" << endl;
    } else if(S > 0) {
	cout << "syo-kichi" << endl;
    } else {
	cout << "kyo" << endl;
    }
}
 
int main()
{
    while (true) {
	cin >> s[0].p1.x >> s[0].p1.y >> s[0].p2.x >> s[0].p2.y;
	if (!s[0].p1.x && !s[0].p1.y && !s[0].p2.x && !s[0].p2.y) break;
	for (int i = 0; i < 2; i++) {
	    cin >> s[i+1].p1.x >> s[i+1].p1.y >> s[i+1].p2.x >> s[i+1].p2.y;
	}
	if (intersectSS(s[0],s[1]) && intersectSS(s[1],s[2]) && intersectSS(s[2],s[0])) {
	    solve();
	} else {
	    cout << "kyo" << endl;
	}
    }
    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	string s,t;cin>>s>>t;
	int a[26]={},b[26]={};
	rep(i,s.size()) a[s[i]-'a']++;
	rep(i,t.size()) b[t[i]-'a']++;

	sort(a,a+26);
	sort(b,b+26);

	rep(i,26){
		if(a[i]!=b[i]) {
			cout<<"No"<<"\n";
			return 0;
		}
	}

	cout<<"Yes"<<"\n";
}

Measured memory_bytes: 776
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;



int main(void) {
    ll n;
    cin>>n;
    bool isOk = true;
    ll nx = 0,ny = 0,nt = 0;
    rep(i,n){
        ll t,x,y;
        cin>>t>>x>>y;
        ll dist = abs(x-nx)+abs(y-ny);
        ll tim = t-nt;
        if(tim < dist) isOk = false;
        else{
            if(tim%2 == 0 && dist%2 == 1) isOk = false;
            if(tim%2 == 1 && dist%2 == 0) isOk = false;
        }
        nt = t;
        nx = x;
        ny = y;
    }
    if(isOk) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <string>

using namespace std;

int main() {
	for (;;) {
		int x;
		int y;
		cin >> x >> y;
		if (x == 0 && y == 0) break;
		if (x > y) {
			int a = x;
			int x = y;
			int y = a;
			cout << x << " " << y << endl;
		}
		else {
			cout << x << " " << y << endl;
		}
	}
	return 0;
}



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





int main(){
    int N,result=0;
    cin>>N;
    map<string,int> S;
    for(int i=0;i<N;i++){
        string s;
        cin>>s;
        if(!(S.count(s))){
            S[s]=1;
            result++;
        }
        
    }
    cout<<result<<endl;
}

Measured memory_bytes: 19124
#include <iostream>
#include <cmath>
#include <string>
#include <string.h>
#include <cstdlib>
#include <iomanip>
#include <stdio.h>

using namespace std;

int gcd(int x,int y){
  int t,d,nx,ny;
  if(x==y)
    return x;
  if(x<y){
    t=x;
    x=y;
    y=t;
  }
  nx=x;
  ny=y;
  d=nx%ny;
  for(;;){
    if(x%d==0&&y%d==0)
      return d;
    nx=ny;
    ny=d;
    d=nx%ny;
  }
}

int main(){
  int x,y;

  scanf("%d %d",&x,&y);

  printf("%d\n",gcd(x,y));
}


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

int main() {
  int a, b, tmp, cnt = 1;
  cin >> a >> b;
  
  tmp = a;
  if (a < b) {
    while (1) {
      tmp += (a - 1);
      cnt++;
      if (tmp >= b) {
        break;
      }
    }
  } else if (b == 1) {
    cnt = 0;
  }
  
  cout << cnt << endl;
}

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

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    a = [int(e) for e in lines[0].split(" ")][0]
    b = [int(e) for e in lines[1].split(" ")][0]

    return (a, b)


def solve(a, b):

    answers = [1,2,3]
    answers.remove(a) 
    answers.remove(b) 
    

    return answers[0]


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <climits>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#define MAX 100
#define INFTY 1<<30 // 2^30
using namespace std;
typedef long long llong;
static const int NIL = -1;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim()
{
  int u, minv;
  int d[MAX], p[MAX], color[MAX];

  for(int i = 0; i < n; i++)
  {
    d[i] = INFTY;
    p[i] = NIL;
    color[i] = WHITE;
  }

  d[0] = 0;
  while(1)
  {
    minv = INFTY;
    u = NIL;
    for(int i = 0; i < n; i++)
    {
      if(minv > d[i] && color[i] != BLACK)
      {
        u = i;
        minv = d[i];
      }
    }
    if(u == NIL) break;
    color[u] = BLACK;
    for(int v = 0; v < n; v++)
    {
      if(color[v] != BLACK && M[u][v] != INFTY)
      {
        if(d[v] > M[u][v])
        {
          d[v] = M[u][v];
          p[v] = u;
          color[v] = GRAY;
        }
      }
    }
  }
  int sum = 0;
  for(int i = 0; i < n; i++)
  {
    //cerr << p[i] << endl;
    if(p[i] != NIL) sum += M[i][p[i]];
  }
  return sum;
}


int main()
{
  cin >> n;
  for(int i = 0; i < n; i++)
  {
    for(int j = 0; j < n; j++)
    {
      int e; cin >> e;
      M[i][j] = (e == NIL) ? INFTY : e;
      //cerr << M[i][j] << endl;
    }
  }
  cout << prim() << endl;
  return 0;
}

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

namespace CSharpSample01
{
    

    class Program
    {


        

        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);
            int C = int.Parse(input[2]);

            int ans = Math.Max(0, C - (A - B));

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  int N;
  cin >> N;
  int S = N/100;
  int ans = 0;
  if((N/10)-S*10 < S){
    ans = S*100 + S*10 + S;
  }else if((N/10)-S*10 == S){
    if(N - (N/10-(S*10))*10 - S*100 <= S){
      ans = S*100 + S*10 + S;
    }else{
      ans = (S+1)*100 + (S+1)*10 + S+1;
    }
  }else{
    ans = (S+1)*100 + (S+1)*10 + S + 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    int N;
    cin>>N;
    int k = N%10;
    if(k == 2 ||k == 4 ||k == 5 ||k == 7 ||k == 9){
        cout<<"hon"<<endl;
    }else if(k == 3){
        cout<<"bon"<<endl;
    }else{
        cout<<"pon"<<endl;
    }
    return 0;
}


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

signed main() {
	int N,K;
	cin>>N>>K;
	vector<int>mon(N);
	for(int i=0;i<N;i++)cin>>mon[i];
	sort(mon.begin(),mon.end());
	reverse(mon.begin(),mon.end());
	if(N<=K){
		cout<<0<<endl;
	}
	else{
		int ans=0;
		for(int i=K;i<N;i++){
			ans+=mon[i];
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

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

namespace C___Forbidden_List
{
    public class Program
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine();
            var b = Console.ReadLine();
            Console.WriteLine(DoMain(a, b));
        }

        public static int DoMain(string a, string b)
        {
            var c = a.Split(" ").Select(x => int.Parse(x)).ToList();
            var x = c[0];
            var n = c[1];
            if (n == 0)
            {
                return x;
            }

            var p = b.Split(" ").Select(x => int.Parse(x)).ToList();

            List<int> hundredList = new List<int>();
            for (int i = 0; i <= 101; i++)
            {
                hundredList.Add(i);
            }

            List<int> unhundredList = new List<int>();

            foreach (var item in hundredList)
            {
                if (!p.Contains(item))
                {
                    unhundredList.Add(item);
                }
            }

            List<int> diffList = new List<int>();
            foreach (var item in unhundredList)
            {
                diffList.Add(Math.Abs(x - item));
            }

            var min = diffList.Min();

            if (!p.Contains(x - min))
            {
                return x - min;
            }
            else
            {
                return x + min;
            }
        }
    }
}


Measured memory_bytes: 28432
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
    static Scanner input = new Scanner(System.in);
    private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);

    private static void solve() {
        
        int n = input.nextInt();
        int m = input.nextInt();

        int[] a = arrayInput(n);
        int[] b = arrayInput(m);
        
        Map<Integer, Integer> map = new HashMap<>();
        
        for (int v : a) {
        map.put(v, 1); // the appear of element
        }
        for (int v : b) {
            if (map.containsKey(v)) {
                map.put(v, 2);   
            } else {
                map.put(v, 1);
            }
        }
        
        List<Integer> and = new ArrayList<>();
        List<Integer> or = new ArrayList<>(map.keySet());
        for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
        if (entry.getValue() == 2) {
            and.add(entry.getKey());
        }
        }
        Collections.sort(and);
        Collections.sort(or);
        
        out.println(and.size() + " " + or.size());
        for (int v : and) {
        out.println(v);
        }
        for (int v : or) {
        out.println(v);
        }
    }

    public static void main(String[] args) {
        solve();
        out.flush();
    }
    

    private static int[] arrayInput(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
        a[i] = input.nextInt();
        return a;
    }
}



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

using namespace std;


int main()
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for (auto& x : a) {
		cin >> x;
	}
	sort(a.begin(), a.end());
	int64_t ans1 = 0;
	int64_t ans2 = 0;
	auto ps1 = a.begin();
	auto pf1 = --a.end();
	auto ps2 = a.begin();
	auto pf2 = --a.end();
	for (int i = 1; i < n - 1; i += 2) {
		ans1 += 2 * *pf1--;
		ans2 -= 2 * *ps2++;
		int j = i + 1;
		if (j < n - 1) {
			ans1 -= 2 * *ps1++;
			ans2 += 2 * *pf2--;
		}
	}
	ans1 += (n & 1 ? -*pf1 : *pf1) - *ps1;
	ans2 += (n & 1 ? *ps2 : -*ps2) + *pf2;
	cout << max(ans1, ans2) << endl;
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#define lop(i, n) for(i=0; i<n; i++)

int main()
{
	int n, i, min=200001, cnt=0;
	int p[200000];
	
	scanf("%d", &n);
	lop(i, n){
		scanf("%d", &p[i]);
	}
	
	lop(i, n){
		if(min>p[i]){ cnt++; min=p[i]; }
	}
	
	printf("%d", cnt);
	
return 0;
}

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

int A[55];
int main()
{
	int n, m; cin >> n >> m;
	for (int i = 0; i < m; ++i)
	{
		int a, b; cin >> a >> b;
		A[a]++;
		A[b]++;
	}
	for (int i = 1; i <= n; ++i)
		cout << A[i] << endl;
}



Measured memory_bytes: 3620
import bisect

A,B,Q = map(int, input().split())

S = [int(input()) for _ in range(A)]
T = [int(input()) for _ in range(B)]

X = [int(input()) for _ in range(Q)]

INF = float("inf")
"""
SやTについて、ある地点をスタート地点に選んだ時に取りうる行動は、SとTそれぞれについて現在値の東西のどちらに向かうかと、SとTどちらを先に行くか。
なのでそれら全通りについてためせばおK
"""
for x in X:
    sw = se = 0
    tw = te = 0
    idx_s = bisect.bisect_left(S, x)
    idx_t = bisect.bisect_left(T, x)

    if idx_s == len(S):
        se = INF
        sw = S[-1]
    elif idx_s == 0:
        sw = INF
        se = S[0]
    else:
        se = S[idx_s]
        sw = S[idx_s - 1]

    if idx_t == len(T):
        te = INF
        tw = T[-1]
    elif idx_t == 0:
        tw = INF
        te = T[0]
    else:
        te = T[idx_t]
        tw = T[idx_t - 1]
        
    a = abs(x-se) + abs(se-tw) if se != INF or tw != INF else 5* 10**10
    b = abs(x-tw) + abs(tw-se) if se != INF or tw != INF else 5* 10**10
    c = abs(x-sw) + abs(sw-te) if sw != INF or te != INF else 5* 10**10
    d = abs(x-te) + abs(te-sw) if sw != INF or te != INF else 5* 10**10
    print(min(
        a, 
        b, 
        c, 
        d,
        max(abs(x-sw), abs(x-tw)),
        max(abs(x-se), abs(x-te))))
    """
    print("--------")
    print(se,tw)
    print((
        abs(x-se) + abs(se-tw), 
        abs(x-tw) + abs(tw-se), 
        abs(x-sw) + abs(sw-te), 
        abs(x-te) + abs(te-sw),
        max(abs(x-sw), abs(x-tw)),
        max(abs(x-se), abs(x-te))))
    """



Measured memory_bytes: 16160
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main() {

    fast

    int t;
   // cin>>t;
   // while(t--){

    int a,b;
    cin>>a>>b;
    if(b==1)
    {
        cout<<0;
        return 0;
    }

    int ans=1;
    int add=a-1;

    while(a<b){
        a+=add;
        ans++;
    }

    cout<<ans;
 //   cout<<endl;
  //  }




	return 0;
}

/*
ll  modularExponentiation(ll x,ll n,ll M)
{

    ll result=1;

    while(n>0)
    {

	if(n%2==1)

 result=(result*x)%M;

  x=(x*x)%M;

  n=n/2;

}

  return result;
}



*/


Measured memory_bytes: 256
//
// Created by yamunaku on 2020/05/10.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    //CFS;
    int n;
    cin >> n;
    vector<string> s(n);
    int l = 0, r = 0;
    vector<pair<int, int>> pl, pr;
    int mm = 0;
    rep(i, n){
        cin >> s[i];
        int lv = 0;
        int bt = 0;
        for(auto &c:s[i]){
            if(c == '('){
                l++;
                lv++;
            }else{
                r++;
                lv--;
            }
            bt = min(bt, lv);
        }
        if(lv > 0){
            pl.push_back({-bt, lv});
        }else if(lv < 0){
            pr.push_back({-bt + lv, -lv});
        }else{
            mm = min(mm, bt);
        }
    }
    if(l != r){
        CNO;
        return 0;
    }
    sort(all(pl));
    sort(all(pr));
    int now = 0;
    for(auto &p:pl){
        if(now < p.first){
            CNO;
            return 0;
        }
        now += p.second;
    }
    now = 0;
    for(auto &p:pr){
        if(now < p.first){
            CNO;
            return 0;
        }
        now += p.second;
    }
    if(now < -mm){
        CNO;
        return 0;
    }
    CYES;
    return 0;
}

Measured memory_bytes: 42520
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,v[25],c[25],ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
	cin>>v[i];
	for(int i=0;i<n;i++)
	cin>>c[i];
	for(int i=0;i<n;i++)
	if(v[i]-c[i]>0)
	ans+=v[i]-c[i];
	cout<<ans;
	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ii, null_type,less<ii>, rb_tree_tag,tree_order_statistics_node_update>
#define graph vector<vi>
#define Mod 1000000007
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main()
{
    fastio;
//	#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r" , stdin);
//    freopen("output.txt", "w" , stdout);
//    #endif
    
		
		int n, k, d, x;
		cin >> n >> k;
		unordered_map<int,int> umap;
		rep_a(i,1,n + 1)
			umap[i] = 0;
			
		rep(i, k) {
			cin >> d;
			rep(j, d) {
				cin >> x;
				umap[x]++;
			}
		}
		int count = 0;
    	for (auto it = umap.begin(); it != umap.end(); it++)
    		if (it->second == 0)
    			count++;
    			
    	cout << count << "\n";
	//code
	return 0;
}


Measured memory_bytes: 3628
h, w = map(int, input().split())
c = []
for _ in range(h):
    c.append(list(input()))
d = [[""] * w for x in range(h * 2)]
for i in range(h):
    for j in range(w):
        d[i * 2][j] = c[i][j]
        d[i * 2 + 1][j] = c[i][j]
for i in d:
    print("".join(i))


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

using namespace std;

int main(){
	int n,w,h;
	cin >> n >> w >> h;
	pair<int,int> temp(0,0);
	vector< pair<int,int> > line(n,temp),column(n,temp);
	vector<pair<int,int> >::iterator it;
	for(int i = 0; i < n; i++){
		int x,y,r;
		cin >> x >> y >> r;
		int xs=x-r,xg=x+r,ys=y-r,yg=y+r;
		column[i].first = xs;
		column[i].second = xg;
		line[i].first = ys;
		line[i].second = yg;
	}

	sort(column.begin(), column.end() );
	sort(line.begin(), line.end() );
	
	bool flagx=true,flagy=true;
	int x=0,y=0;
	for(int i = 0; i < n; i++){
		int xs,xg;
		xs = column[i].first;
		xg = column[i].second;
		if(xs > x){
			flagx = false;
			if(!flagy){
				break;
			}
		}
		else{
			if(xg > x){
				x = xg;
			}
		}
		int ys,yg;
		ys = line[i].first;
		yg = line[i].second;
		if(ys > y){
			flagy = false;
			if(!flagx){
				break;
			}
		}
		else{
			if(yg > y){
				y = yg;
			}
		}
	}
	if(x < w){
		flagx = false;
	}
	if(y < h){
		flagy = false;
	}

	if(flagx || flagy)cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 4416
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#define ll long long

using namespace std;

int main(){
    vector<int> A(3,0);
    cin >> A[0] >> A[1] >> A[2];
    sort(A.rbegin(),A.rend());
    cout << A[0]*10+A[1]+A[2] << endl;
    return 0;
}


Measured memory_bytes: 256
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
a_=[0]
for i in range(len(a)):
  a_.append(a_[-1]+a[i])
b_=[0]
for i in range(len(b)):
  b_.append(b_[-1]+b[i])
ans=[0]
a_now=0
b_now=m
for i in range(n+1):
  k_=k-a_[i]
  while b_[b_now]>k_:
    b_now+=-1
    if b_now==-1:
      b_now=0
      break
  if a_[i]+b_[b_now]<=k:
    ans.append(i+b_now)
print(max(ans)) 


Measured memory_bytes: 148092
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

use std::cmp::min;

fn main() {
    let n: usize = read();
    let mut sa = 0;
    let mut bs = 0;
    let mut bsa = 0;
    let mut ans = 0;
    for _ in 0..n {
        let s: String = read();
        let c: Vec<char> = s.chars().collect();
        let l = c.len();
        for i in 1..l {
            if c[i - 1] == 'A' && c[i] == 'B' {
                ans += 1;
            }
        }
        if c[0] == 'B' {
            if c[l - 1] == 'A' {
                bsa += 1;
            } else {
                bs += 1;
            }
        } else if c[l - 1] == 'A' {
            sa += 1;
        }
    }

    if sa > 0 || bs > 0 {
        ans += bsa + min(sa, bs);
    } else if bsa > 0 {
        ans += bsa - 1;
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.*;
class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int r = sc.nextInt();
    int g = sc.nextInt();
    int b = sc.nextInt();
    int sum = r*100+g*10+b;
    if(sum%4==0)System.out.println("YES");
    else System.out.println("NO");
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int a,b;
  cin >> a >> b;
  int c = min(a,b);
  int d = max(a,b);
  rep(i,d) {
    cout << c;
  }
  cout << endl;
  return 0;
}

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

using namespace std;

int main() {
	while (true) {
		int N;
		cin >> N;
		if (N == 0) {
			break;
		}
		
		vector<int> member[N];
		for (int i = 0; i < N; i++) {
			int M;
			cin >> M;
			for (int j = 0; j < M; j++) {
				int p;
				cin >> p;
				member[i].push_back(p);
			}
			sort(member[i].begin(), member[i].end());
		}
		vector<int> leak;
		int K;
		cin >> K;
		for (int i = 0; i < K; i++) {
			int l;
			cin >> l;
			leak.push_back(l);
		}
		sort(leak.begin(), leak.end());
		
		int ans = -1;
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < (int)leak.size(); j++) {
				if (!(binary_search(member[i].begin(), member[i].end(), leak[j]))) {
					goto nextmember;
				}
			}
			if (ans != -1) {
				ans = -1;
				goto end;
			} else {
				ans = i + 1;
			}
		nextmember:
			int a;
		}
	end:
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1268