akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>

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

int m[4] = {1000,100,10,1};
char c[4]= {'m','c','x','i'};

int toint(std::string str){
	int d=1;
	int sum = 0;
	rep(i,(int)str.size()){
		if('0' <=str[i] && str[i] <= '9'){
			d=str[i] - '0';
		}else{
			rep(j,4){
				if(c[j] == str[i]){
					sum += m[j] * d;
					d=1;
				}
			}
		}
	}
	return sum;
}

int main(){


	int N;
	int d;
	std::string str1, str2;
	std::cin >> N;
	while(N--){
		std::cin >> str1 >> str2;
		int sum = toint(str1) + toint(str2);
		rep(i,4){
			d = 0;
			while(sum >= m[i]){
				sum -= m[i];
				d++;
			}
			if(d>1)std::cout << d << std::flush;
			if(d>0)std::cout << c[i] << std::flush;
		}
		std::cout << std::endl;
	}
	return 0;
}

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

int main() {
  string s;
  int n;
  cin >> s;
  n = s.length();
  if (s[n-1] == '1' || s[0] == '0' || s[n-2] == '0') {
    cout << -1 << endl;
    return 0;
  }
  int repeat;
  if (n % 2 == 0) repeat = n/2;
  else repeat = (n-1) / 2;
  for (int i=0; i<repeat; i++) {
    if (s[i] != s[n-i-2]) {
      cout << -1 << endl;
      return 0;
    }
  }
  int current_node = 1;
  for (int i=1; i<repeat; i++) {
    if (s[i] == '1') {
      for (int j=current_node+1; j<=i+2; j++) {
        cout << current_node << " " << j << endl;
      }
      current_node = i+2;
    }
  }
  for (int i=current_node+1; i<=n; i++) {
    cout << current_node << " " << i << endl;
  }
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n,k;
  map<int,int>m;
  cin>>n>>k;
  r(i,k){
    int p;
    cin>>p;
    r(j,p){
      int x;
      cin>>x;
      m[x]=i;
    }
  }
  int sum=0;
  set<int>s;
  cin>>n;
  r(o,n){
    int p1,p2;
    cin>>p1>>p2;
    if(m[p1]==m[p2]){
      if(!s.count(p1)){
        s.insert(p1);
        sum++;
      }
      if(!s.count(p2)){
        s.insert(p2);
        sum++;
      }
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3108
import copy
n,m = map(int,input().split())
a = []
ans = dict()
for i in range(m):
    p,y = map(int,input().split())
    a.append((p,y))
adc = copy.deepcopy(a)
a.sort()
cnt = 1
for i in range(m-1):
    num = str(a[i][0]).zfill(6) + str(cnt).zfill(6)
    ans[a[i]] = num
    if a[i+1][0] != a[i][0]:
        cnt = 1
    else:
        cnt += 1
num = str(a[-1][0]).zfill(6) + str(cnt).zfill(6)
ans[a[-1]] = num
for i in range(m):
    print(ans[(adc[i][0], adc[i][1])])



Measured memory_bytes: 32668
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include "bits/stdc++.h"
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

int main() {
    int n,cnt=0;
    cin>>n;
    for(int i=1;i<n+1;i++){
        cnt+=i;
    }
    cout<<cnt<<"\n";

    
}

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

using namespace std;

#define all(x) begin(x), end(x)

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

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

    ll n;
    cin >> n;

    ll res = n * (n - 1) / 2;

    cout << res << '\n';
    
    return 0;
}


Measured memory_bytes: 256
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		String s = nextString();
		int ans =9999;
		for(int i=3;i<=s.length();i++){
			String tmp=s.substring(i-3,i);
			ans = Math.min(ans,Math.abs(753-Integer.parseInt(tmp)));
		}

		System.out.println(ans);

	}


	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 21076
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  int n;
  int x=0;
  int max=0;
  cin>>n;
  cin>>s;
  for(int i=0;i<n;i++){
  if(s[i]=='I') x++;
  else if(s[i]=='D') x--;

  if(max<x) max=x;
  }
  cout<<max<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n; cin >> n;
    vector<int> p(n);
    for (int &x : p) {
        cin >> x;
        x--;
    }
    int res = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (p[i] == i) {
            if (i == 0) {
                res++;
                continue;
            }
            int j = i - 1;
            if (j >= 0 && p[j] != j + 1) {
                swap(p[j], p[j + 1]);
                j--;
                res++;
            }
            if (j == i - 1) {
                res++;
                swap(p[i], p[i + 1]);
            }
        }
    }
    cout << res << "\n";
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
int main(){
  int N,M;
  cin>>N>>M;
  int P[M],Y[M];
  vector<int> A[N+1];
  rep(i,M){
    cin>>P[i]>>Y[i];
    A[P[i]].push_back(Y[i]);
  }
  rep(i,N) sort(all(A[i+1]));
  rep(i,M){
    int L=P[i];
    int R=lower_bound(all(A[L]),Y[i])-A[L].begin()+1;
    cout<<setfill('0')<<right<<setw(6)<<L;
    cout<<setfill('0')<<right<<setw(6)<<R<<endl;
  }
}

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

typedef long long ll;
typedef pair<int, int> pii; 
const int N = 1e3+5, mod = 1e9+7;

int dir[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}}; // n - e - s - w
int  h,  w;  // height, width
int sh, sw;  // start 
int eh, ew;  // end 
int ans = -1;
int d[N][N];
char c[N][N];
bool m[N][N];

void bfs() {
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            d[i][j] = mod;
        }
    }

    m[sh][sw] = true;
    d[sh][sw] = 0;

    deque<pii> q;
    q.push_front({sh, sw});

    while (q.size()) {
        pii cur = q.front();
        int curX = cur.first;
        int curY = cur.second;

        if (curX == eh && curY == ew) {
            ans = d[curX][curY];
            return;
        }
       
        q.pop_front();
        for (int i = 0; i < 4; ++i) {
            int x = curX + dir[i][0];
            int y = curY + dir[i][1];
            if (x < 1 || x > h || y < 1 || y > w) {
                continue;
            }

            if (c[x][y] == '#') {
                m[x][y] = true;
            }

            if (c[x][y] == '.' && (!m[x][y] || d[x][y] > d[curX][curY])) {
                m[x][y] = true;
                d[x][y] = d[curX][curY];
                q.push_front({x, y});
            }
        }

        for (int i = -2; i <= 2; ++i) {
            for (int j = -2; j <= 2; ++j) {
                if (i == 0 && j == 0) {
                    continue;
                }
                
                int x = curX + i;
                int y = curY + j;
                if (x < 1 || x > h || y < 1 || y > w) {
                    continue;
                }

                if (c[x][y] == '.' && !m[x][y]) {
                    m[x][y] = true;
                    d[x][y] = d[curX][curY] + 1;
                    q.push_back({x, y});
                }
            }
        }
    }
    return;
}   

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    cin >> h >> w >> sh >> sw >> eh >> ew;
    
    for (int i = 1; i <= h; ++i) {
        for (int j = 1; j <= w; ++j) {
            cin >> c[i][j];
        }
    }
    
    bfs();
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9560
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

    int n;cin>>n;
    vector<pair<int,int>> v(n);
    rep(i,n)cin>>v[i].first>>v[i].second;
    sort(ALL(v));
    ll ans=v[0].first;
    rep(i,n-1){
        ans+=v[i+1].first-v[i].first;
    }
    ans+=v[n-1].second;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
import numpy as np
n = int(input())
h0 = [int(i) for i in input().split()]
h = np.zeros(n,dtype = int)
x = np.zeros(n,dtype = int)
#最小値
def minh(h,x):
  tmp1 = 100
  for i in range(n):
    if x[i] == 0:
      if h0[i] <= tmp1:
        tmp1 = h0[i]
  return tmp1
#水やり
def mizu(h,x,tmp):
  for i in range(n):
    if x[i] == 0:
      h[i] = tmp
    if h0[i] == tmp:
      x[i] = 1
#分割数
def bunnkatu(x):
  for i in range(n):
    if i == 0:
      if x[i] == 0:
        s = 1
      else:
        s = 0
    else:
      if x[i] == 0 and x[i-1] == 1:
        s += 1
  return s

def main():
  tmp = min(h0)
  ans = tmp
  mizu(h,x,tmp)
  while tmp < max(h0):
    tmp0 = minh(h,x)
    s = bunnkatu(x)
    mizu(h,x,tmp0)
    ans += s*(tmp0 - tmp)
    tmp = tmp0
  return ans

ans = main()
print(ans)

Measured memory_bytes: 19852
#include <stdio.h>

int main(void)
{
	int h,m,S,s;
	scanf("%d", &S);
	s = S % 60;
	h = S / 3600;
	m = (S / 60) % 60;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}

Measured memory_bytes: 592
#include <iostream>

using namespace std;

int N;

int main(int argc, char** argv) {
    cin >> N;
    int ans = 0;
    for (int i = 0; i <= N / 7; i++) if ((N - 7 * i) % 4 == 0) ans = 1;
    if (ans)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]
a_hash = [[False, False, False] for _ in range(3)]

for i in b:
    for ind, j in enumerate(a):
        if i in j:
            a_hash[ind][j.index(i)] = True

for i in a_hash:
    if all(i):
        print("Yes")
        exit()

if a_hash[0][0] and a_hash[1][1] and a_hash[2][2]:
    print("Yes")
    exit()
elif a_hash[0][2] and a_hash[1][1] and a_hash[2][0]:
    print("Yes")
    exit()

for num in range(3):
    if a_hash[0][num] and a_hash[1][num] and a_hash[2][num]:
        print("Yes")
        exit()
print("No")

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

int main(){
	long long a,b,k,z=0;
	cin>>a>>b>>k;
	cout<<max(z,a-k)<<" "<<max(z,b-max(z,k-a))<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = 1e9;
const int MOD = 1000000007;

 
int main() {
        ll x;
        cin >> x;
        int a = x/500;
        x %= 500;
        int b = x/5;
        cout << a*1000 + b*5 <<endl;
        return 0;
}





Measured memory_bytes: 256
ToNode = Struct.new(:id, :weight)

_ = gets

$graph       = {}

while (line = gets)
  node_id, _, *nodes = line.split(' ').map(&:to_i)
  $graph[node_id] = nodes.each_slice(2).map{|id, weight| ToNode.new(id, weight)}
end

$visited_nodes = []



$start_node_id = 0
# Min Distance '0' to `key`
$weights = {$start_node_id => 0}
$visited_nodes.push($start_node_id)


loop do
  # Node which should be visited
  next_visit_node = nil
  min_weight = Float::INFINITY

  $visited_nodes.each{|node_id|
    to_nodes = $graph[node_id]
    w        = $weights[node_id]
    to_nodes.each{|n|
      if !$weights.has_key?(n.id)
        weight = w + n.weight
        if weight < min_weight
          min_weight = weight
          next_visit_node = {id: n.id, weight: weight}
        end
      end
    }
  }

  if next_visit_node.nil?
    break
  end

  $visited_nodes.push(next_visit_node[:id])
  $weights[next_visit_node[:id]] = next_visit_node[:weight]
end

$weights
  .sort_by{|k, v| k}
  .each{|node, weight|
    puts("#{node} #{weight}")
  }



Measured memory_bytes: 6968
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T> bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> ostream &operator<<(ostream &os, vector<T> v) {
    for (int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
    for (auto &e : t) {
        fill_v(e, v);
    }
};
struct BIT {
    vector<int> bit;
    BIT(int n) { bit.resize(n + 1); }
    void add(int k, int x) {
        for (++k; k < bit.size(); k += k & -k) {
            bit[k] += x;
        }
    }
    int sum(int k) {
        int res = 0;
        for (++k; k > 0; k -= k & -k) {
            res += bit[k];
        }
        return res;
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int k;
    cin >> k;
    int n = s.length();
    vector<vector<int>> id(26);
    for (int i = 0; i < n; i++) {
        id[s[i] - 'a'].push_back(i);
    }
    vector<int> idx(26);
    BIT bit(n + 1);
    string res;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 26; j++) {
            if (idx[j] == id[j].size()) {
                continue;
            }
            int s = id[j][idx[j]] + bit.sum(n - 1) - bit.sum(id[j][idx[j]]);
            if (s <= i + k) {
                k -= s - i;
                res.push_back('a' + j);
                bit.add(id[j][idx[j]], 1);
                idx[j]++;
                break;
            }
        }
    }
    cout << res << endl;
}



Measured memory_bytes: 5140
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;


int main() {
    cout << fixed << setprecision(10);
    
    ll N; cin >> N;

    if (N == 1) {
        cout << 0 << endl;
        return 0;
    }
    
    map<ll, int> m;

    ll a = 2;
    while (a*a <= N) {
        while (N % a == 0) {
            m[a] += 1;
            N /= a;
        }
        a += 1;
        // cout << N << " " << a << endl;
    }
    if (N != 1) {
        m[N] += 1;
    }
    int ans = 0;
    for (auto x: m) {
        // cout << x.first << " " << x.second << endl;
        int s = 1;
        while (x.second >= s) {
            ans += 1;
            x.second -= s;
            s += 1;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1e9 + 7;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
void spsp(vector<ll>&v) {
	for (int i = 0; i < v.size(); i++) {
		printf("%lld%s", v[i], (i == v.size() - 1 ? "\n" : " "));
	}
}
/*ll fact_[200000];
ll comb(ll x, ll y, ll mod = Mod) {
	if (!fact_[0]) {
		fact_[0] = 1;
		for (int i = 1; i < 200000; i++) {
			fact_[i] = fact_[i - 1] * i % mod;
		}
	}
	if (x < y) return 0;
	return mod_pow(fact_[x], mod, mod) *
		mod_pow(fact_[x - y], mod - 2, mod) % mod *
		mod_pow(fact_[y], mod - 2, mod) % mod;
}//xCy*/
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
int a[300000];
int c[300000];
signed main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	vector<int>b;
	for (int i = n; i > 0; i--) {
		int sum = 0;
		for (int j = 2 * i; j <= n; j += i) {
			sum += c[j];
		}
		if (a[i] != (sum % 2)) {
			b.push_back(i);
			c[i] = 1;
		}
	}
	cout << b.size() << endl;
	spsp(b);
}

Measured memory_bytes: 5364
N = int(input())
list = [0]*(N+1)
for i in range(1,100):  
    for j in range(1,100):
        a = i*i + j*j + i*j
        for k in range(1,100):
            a = i*i + j*j + k*k + i*j +j*k + i*k
            if a <= N:
                list[a] += 1
for i in range(1,N+1):
    print(list[i])

Measured memory_bytes: 9196
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <stdio.h>

int main(){
  int s,w;
  std::cin >> s >> w;
  if(s>w){
    std::cout << "safe";
  }else{
    std::cout << "unsafe";
  }
  
  return 0;
}

Measured memory_bytes: 3616
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text.RegularExpressions;
using System.Diagnostics;

//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    
    class Solve
    {
        const int mod = 1000000007;
        
        
        static void Main(string[] args)
        {

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            var p = Console.ReadLine().Split();
            string ab = p[0] + p[1];
            int N = int.Parse(ab);

            int rN = (int)Math.Sqrt(N);
            double RN = Math.Sqrt(N);

            Console.WriteLine(rN == RN ? "Yes" : "No");
            

            //Console.Out.Flush();

        }

        
    }

    public class Calculation
    {

    }

    public class Graph
    {
        
    }
}




Measured memory_bytes: 11092
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))};
// 
const main=()=>{
  let [n,m]=tnn(2),mr=tnn(m),dp=new Array(n+1),x=1000000007
  dp[n]=1;
  dp[n-1]=1;
  for(let j=0;j<mr.length;j++){
    dp[mr[j]]=0
    if(mr[j]==mr[j+1]-1){
      to(0)
      return
    }
  }
  for(let i=n-2;i>=0;i--){
    if(dp[i]!=0)dp[i]=(dp[i+1]+dp[i+2])%x
  }
  to(dp[0])
}
main()


Measured memory_bytes: 26700
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define double long double
using namespace std;
typedef pair<int, int> P;
const int INF = 1e9;
const double EPS = 1e-9;

int m, n;
double p[17][17];
double memo[1LL << 16][17];

double rec(int mask, int id){
    if(id == n) return 1.0;
    if(mask == 0) return 0.0;
    if(memo[mask][id] > -EPS) return memo[mask][id];
    double res = 0.0;
    rep(i, 0, m){
        if(!(mask & (1LL << i))) continue;
        double tmp = 0.0, now = 1.0;
        rep(j, id, n){
            // j番目に負けた場合
            tmp += now * (1 - p[i][j]) * rec(mask - (1LL << i), j);
            now *= p[i][j];
        }
        tmp += now;
        res = max(res, tmp);
    }
    return memo[mask][id] = res;
}

int main(){
    cin >> m >> n;
    rep(i, 0, m) rep(j, 0, n) cin >> p[i][j];
    rep(i, 0, 1 << m) rep(k, 0, n + 1) memo[i][k] = -1.0;
    double ans = 0.0;
    ans = rec((1LL << m) - 1, 0);
    printf("%.20Lf\n", ans);
}


Measured memory_bytes: 20652
// https://atcoder.jp/contests/abc131/tasks/abc131_d

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF (1e9)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
ll gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
ll lcm(long a, long b) { return a * b / gcd(a, b); }

//方針：（Cで割り切れる数）+（Dで割り切れる数） - CとDの最小公倍数で割り切れる数
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<PII> v;
    REP(i, n) {
        int t1, t2;
        cin >> t1 >> t2;
        v.push_back(PII(t2, t1));
    }
    sort(ALL(v));
    bool flag = true;
    ll now = 0;
    REP(i, n) {
        now += v[i].second;
        if (now > v[i].first) {
            flag = false;
            break;
        }
    }
    if (flag) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 2548
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;

namespace AtCoder_Beginner_Contest_131
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static void Main(string[] args)
        {
            var NL = Sarray();
            var N = NL[0];
            var L = NL[1];
            var sum = 0L;
            var nearzero = L;
            for (var i = 0; i < N; ++i)
            {
                sum += L + i;
                if (Math.Abs(L + i) < Math.Abs(nearzero))
                    nearzero = L + i;
            }
            WriteLine(sum - nearzero);
        }
    }
}

Measured memory_bytes: 13396
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n;
    cin >> n;
    while(n --){
        int a;
        cin >> a;
        if(a % 2) continue;
        if((a % 3)&&(a % 5)){
            cout <<"DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
    return 0;

}

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

int main() {
    int n, k, m;
    while (cin >> n >> k >> m, m--, n) {
        vector<int> stone(n, 0);
        for (int i = 0; i < n; i++) stone[i] = i + 1;

        int pos = m;
        while (stone.size() > 1) {
            stone.erase(stone.begin() + pos);
            pos--;
            pos = (pos + k) % stone.size();
        }
        cout << stone[0] << endl;
    }
    return 0;
}


Measured memory_bytes: 3048
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        String s = stdin.next();
        int x = stdin.nextInt();
        int y = stdin.nextInt();

        int[] t = Arrays.stream(s.split("T")).mapToInt(String::length).toArray();
        int[] vx = IntStream.range(0, t.length).filter(i -> i % 2 == 0).map(i -> t[i]).toArray();
        int[] vy = IntStream.range(0, t.length).filter(i -> i % 2 != 0).map(i -> t[i]).toArray();

        if (ok(vx, x, true) && ok(vy, y, false)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    public static boolean ok(int[] v, int z, boolean first) {
        Set<Integer> s = new HashSet<>();
        s.add(0);
        for (int i = 0; i < v.length; i++) {
            int d = v[i];
            if (i == 0 && first) {
                s = s.stream().flatMap(x -> Stream.of(x + d)).collect(Collectors.toSet());
            } else {
                s = s.stream().flatMap(x -> Stream.of(x + d, x - d)).collect(Collectors.toSet());
            }
        }
        return s.contains(z);
    }
}

Measured memory_bytes: 271376
using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
        string[] input = ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        int ab = int.Parse(input[2]);
        int x = int.Parse(input[3]);
        int y = int.Parse(input[4]);
        
        int xa = x*a;
        int yb = y*b;
        int total=xa+yb;
        int maxxy = Max(x,y);
        int minxy = Min(x,y);
        if(total > ab*maxxy*2){
            total = ab*maxxy*2;
        }
        if(minxy == x){
            if(total > (ab*minxy*2) + (b*(y-x)) ){
                total = (ab*minxy*2) + (b*(y-x));
            }
        }else if(minxy == y){
            if(total > (ab*minxy*2) + (a*(x-y)) ){
                total = (ab*minxy*2) + (a*(x-y));
            }
        }
        WriteLine(total);
    }
}

Measured memory_bytes: 13140
N, X = map(int, input().split())
m_s = [0]*N
used_X = 0
min_m = 10e5+1
for i in range(N):
    m = int(input())
    m_s[i] = m
    used_X += m
    if m < min_m:
        min_m = m
print(N+((X-used_X)//min_m))

Measured memory_bytes: 3060
N = int(input())
dictionary = {}
for i in range(N):
    S = input()
    if S not in dictionary.keys():
        dictionary[S] = 1
    else:
        dictionary[S] += 1


value_max = max(dictionary.values())

max_list = []
for k, v in dictionary.items():
    if v == value_max:
        max_list.append(k)

max_list.sort()
for i in max_list:
    print(i)

Measured memory_bytes: 32096
#include<iostream>
using namespace std;
int n,t,s,f,sum;
int main(void){
  while(cin>>t&&t){
    cin>>n;
    sum=0;
    for(int i=0;i<n;i++){
      cin>>s>>f;
      sum+=(f-s);
    }
    if(sum>=t){
      cout<<"OK"<<endl;
    }else{
      cout<<t-sum<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3072
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
//#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	double x;
	cin >> x;

	std::cout << std::fixed;
	std::cout << std::setprecision(7) << pow(x,3)/27; 
}

Measured memory_bytes: 256
class ModComb
  def initialize(max, mod)
    @mod = mod
    @fac = Array.new(max + 1)
    @finv = Array.new(max + 1)
    @inv = Array.new(max + 1)
    @fac[0] = @fac[1] = 1
    @finv[0] = @finv[1] = 1
    @inv[1] = 1
    (2..max).each do |i|
      @fac[i] = @fac[i - 1] * i % @mod
      @inv[i] = @mod - @inv[@mod % i] * (@mod / i) % @mod
      @finv[i] = @finv[i - 1] * @inv[i] % @mod
    end
  end

  def comb(n, k)
    return 0 if n < k
    return 0 if n < 0 || k < 0
    @fac[n] * (@finv[k] * @finv[n - k] % @mod) % @mod
  end
end

N = gets.to_i
table = Hash.new { 0 }
s_list = N.times.map { gets.chomp.chars }
s_list.each do |s|
  table[s.sort] += 1
end

ans = 0
comb = ModComb.new(N, 67280421310721)
table.each do |k, v|
  next if v == 0
  ans += comb.comb(v, 2)
end
puts ans


Measured memory_bytes: 100476
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define vpll vector <pll>
#define pb push_back
#define f(i,a,n) for(ll i=a;i<n;i++)
const ll N=2e5;

int main()
{
    ll k;
    cin>>k;
    string s;
    cin>>s;
    if(s.length()<=k)
        cout<<s;
    else
    {
        for(int i=0;i<k;i++)
            cout<<s[i];
        cout<<"...";
    }
    return 0;
}



Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;

int INF=1000007;
typedef pair<int,int> P;
int main(){
  int H,W;
  cin>>H>>W;
  int field[H][W];
  char A[W];
  queue<P> que;
  for(int i=0;i<H;++i){
    cin>>A;
    for(int j=0;j<W;++j){
      field[i][j]=INF;
      if(A[j]=='#'){
        field[i][j]=0;
        que.push(P(i,j));
      }
    }
  }
  int ans=0;
  int dx[4]={1,0,-1,0};
  int dy[4]={0,1,0,-1};
  while(que.size()){
    P p=que.front();
    que.pop();
    for(int i=0;i<4;++i){
      int nx=p.first+dx[i];
      int ny=p.second+dy[i];
      if(0<=nx && nx<H && 0<=ny && ny<W){
        if(field[nx][ny]==INF){
          field[nx][ny]=field[p.first][p.second]+1;
          if(ans<field[nx][ny]){
            ans=field[nx][ny];
          }
          que.push(P(nx,ny));
        }
      }
    }
  }
cout<<ans<<"\n";
return 0;
}

Measured memory_bytes: 12304
N, M = map(int, input().split())
H = [int(i) for i in input().split()]
path = []
total = N
good = [1]*N
for i in range(M):
    new = [int(j) for j in input().split()]
    path.append(new)
    if H[new[0]-1] <= H[new[1]-1]:
        if good[new[0]-1] == 1:
            good[new[0]-1] = 0
            total -= 1
    if H[new[1]-1] <= H[new[0]-1]:
        if good[new[1]-1] == 1:
            good[new[1]-1] = 0
            total -= 1
print(total)

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

using namespace std;

int main(void){
  int n, d;
  vector<int> v;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> d;
    v.push_back(d);
  }
  sort(v.begin(), v.end(), greater<int>());
  int a=0, b=0;
  bool flag = true;
  for(int i = 0; i < n; i++){
    if(flag)
      a += v[i];
    else
      b += v[i];
    flag = !flag;
  }
  cout << a-b << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;
class Main
{
  	public static String fiftyfifty(String S)
    {
  		if(S.charAt(0) == S.charAt(3) && S.charAt(1) == S.charAt(2) && S.charAt(0) != S.charAt(1))
          return "Yes";
      	else if(S.charAt(0) == S.charAt(1) && S.charAt(2) == S.charAt(3) && S.charAt(1) != S.charAt(2))
          return "Yes";
      	else if(S.charAt(0) == S.charAt(2) && S.charAt(1) == S.charAt(3) && S.charAt(1) != S.charAt(2))
          return "Yes";
      	else
          return "No";
          
    }
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String output = fiftyfifty(S);
      	System.out.println(output);
	}
}

Measured memory_bytes: 21844
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  vector<ll> a;
  bool flag = false;;
  rep(i, n){
    ll x;
    cin >> x;
    a.pb(x);
    if(x % 2 == 1)flag = true;
  }
  if(flag)cout << "first" << endl;
  else cout << "second" << endl;
	return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int n,a[110],b[110],i,j,ans,save;
int main(){
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    for(i=1;i<=n;i++){
        scanf("%d",&b[i]);
    }
    for(i=2;i<=n;i++){
        a[i]+=a[i-1];
        b[i]+=b[i-1];
    }
    for(i=1;i<=n;i++){
        save=0;
        save+=a[i];
        save+=b[n];
        save-=b[i-1];
        ans=max(ans,save);
    }
    cout << ans;
}


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

int main()
{
	int r, d, x;

    cin >> r >> d >> x;

    REP(i, 10) {
        int x_tmp;
        x_tmp = r*x - d;
        cout << x_tmp << endl;
        x = x_tmp;
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
  string s,t;
  int n;
  cin >> n >> s >> t;
  for(int i=0;i<n;i++){
      cout << s.at(i);
      cout << t.at(i);
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
//shivamkr21
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
int main()
{
  int a,p=0;
  cin>>a;
  int ar[4];
  for(int i=0;i<4;i++)
  {
    ar[i]=a%10;
    a=a/10;
  }
  if(ar[0]==ar[1])
  {
    p=1;
  }
  else if(ar[2]==ar[1])
  {
    p=1;
  }
  else if(ar[2]==ar[3])
  {
    p=1;
  }
  if(p==1)
    cout<<"Bad";
  else
    cout<<"Good";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    ll a0, a1, b0, b1;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;

        ll a = x + y;
        ll b = x - y;

        if (i == 0) {
            a0 = a1 = a;
            b0 = b1 = b;
        } else {
            a0 = min(a0, a);
            a1 = max(a1, a);
            b0 = min(b0, b);
            b1 = max(b1, b);
        }
    }

    cout << max(a1 - a0, b1 - b0) << endl;

    return 0;
}

Measured memory_bytes: 3628
#include<cstdio>
#include<algorithm>
using namespace std;
inline int read()
{
	int x;char c;
	while((c=getchar())<'0'||c>'9');
	for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=x*10+c-'0';
	return x;
}
#define MN 200000
#define MOD 1000000007
int c[MN+5],w[MN+5],f[MN+5],p[MN+5],b[MN+5],s[MN+5];
int gf(int k){return f[k]?f[k]=gf(f[k]):k;}
bool cmp(int a,int b){return gf(a)<gf(b);}
inline int inv(int x)
{
	int y=MOD-2,r=1;
	for(;y;y>>=1,x=1LL*x*x%MOD)if(y&1)r=1LL*r*x%MOD;
	return r;
}
int main()
{
	int n,x,y,i,p1=0,p2=0,ans=1;
	n=read();x=read();y=read();
	for(i=1;i<=n;++i)c[i]=read(),w[i]=read(),b[i]=i,
		!p[c[i]]||w[i]<w[p[c[i]]]?p[c[i]]=i:0,!p1||w[i]<w[p1]?p1=i:0;
	for(i=1;i<=n;++i)if(c[i]!=c[p1])!p2||w[i]<w[p2]?p2=i:0;
	for(i=1;i<=n;++i)
	{
		if(w[i]+w[p[c[i]]]<=x&&gf(i)!=gf(p[c[i]]))f[gf(i)]=gf(p[c[i]]);
		if(c[i]!=c[p1]){if(w[i]+w[p1]<=y&&gf(i)!=gf(p1))f[gf(i)]=gf(p1);}
		else if(p2&&w[i]+w[p2]<=y&&gf(i)!=gf(p2))f[gf(i)]=gf(p2);
	}
	sort(b+1,b+n+1,cmp);
	for(i=x=1;i<=n;i=x)
	{
		for(x=i;gf(b[x])==gf(b[i]);++x)
			ans=1LL*ans*(x-i+1)%MOD*inv(++s[c[b[x]]])%MOD;
		for(x=i;gf(b[x])==gf(b[i]);++x)--s[c[b[x]]];
	}
	printf("%d",ans);
}

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

using namespace std;
typedef long long ll;
const ll INF = 1e12;
// const ll MOD = 1e9 + 7;
const ll MOD = 2019;

int main(){
    ll L, R;
    cin >> L >> R;
    R = min(R, L + 2019);

    ll mvv = INF;
    for (ll i = L; i < R; i++) {
        for (ll j = i + 1; j <= R; j++) {
            mvv = min(mvv, i * j % 2019);
        }
    }
    cout << mvv << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
typedef long long ll;
struct dat {
    int a,r,c;
    bool operator<(const dat x)const {
        return a>x.a;
    }
}p[N];
int n,h,w,fa[N<<1],vl[N<<1];
ll ans;
int find(int u) {
    return fa[u]==u?u:fa[u]=find(fa[u]);
}
void ut(int u,int v) {
    int fu=find(u),fv=find(v);
    if(fu!=fv) {
        fa[fu]=fv;
        vl[fv]+=vl[fu];
    }
}
int main() {
    scanf("%d%d%d",&n,&h,&w);
    for(int i=1;i<=h+w;i++) fa[i]=i,vl[i]=1;
    for(int i=1;i<=n;i++) {
        scanf("%d%d%d",&p[i].r,&p[i].c,&p[i].a);
        p[i].c+=h;
    }
    sort(p+1,p+n+1);
    for(int i=1;i<=n;i++) {
        ut(p[i].c,p[i].r);
        int f=find(p[i].c);
        // printf("fa[%d]=%d %d\n",f,vl[f],p[i].a);
        if(vl[f]>=1) {
            vl[f]--;
            ans+=(ll)p[i].a;
        }
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 8216
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

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

int main() {
  ll N;
  cin >> N;
  vector<P> reds(N);
  vector<P> blues(N);

  for (int i = 0; i < N; i++) {
    cin >> reds[i].first >> reds[i].second;
  }

  for (int i = 0; i < N; i++) {
    cin >> blues[i].first >> blues[i].second;
  }

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

  int ans = 0;
  for (size_t i = 0; i < blues.size(); i++) {
    size_t index;
    bool pairSucc = false;
    for (size_t j = 0; j < reds.size(); j++) {
      if(reds[j].first < blues[i].first && reds[j].second < blues[i].second){
        if(!pairSucc){
          pairSucc = true;
          index = j;
        } else if(reds[j].second > reds[index].second) {
          index = j;
        }
      }
    } // j
    if(pairSucc){
      reds.erase(reds.begin()+index, reds.begin()+index+1);
      ans++;
    }
  } // i

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n,temp,cnt,flag;
	while(cin >> n){
		int k=0;
		int a[n];

		while(k!=n){
			cin >> a[k];
			k++;
		}
		cnt=0;
		flag=1;
		while(flag){
			flag=0;
			for(int i=0;i<n-1;i++){
				if(a[i]>a[i+1]){
					temp=a[i+1];
					a[i+1]=a[i];
					a[i]=temp;
					cnt++;
					flag=1;
				}
			}
		}

	
		int l=0;
		while(l!=n-1){
			cout << a[l] << " ";
		l++;
		}
		cout << a[n-1]<< endl;
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 3044
from functools import reduce

p = 10 ** 9 + 7
n, a, b = map(int, input().split())

def cmb(n, r, p):
    r = min(n - r, r)
    if r == 0:
        return 1
    numer = reduce(lambda x, y: (x * y) % p, range(n, n - r, -1))
    denom = reduce(lambda x, y: (x * y) % p, range(1, r + 1))
    return (numer * pow(denom, p - 2, p)) % p

ans = pow(2, n, p) - 1
ans -= (cmb(n, a, p) + cmb(n, b, p))
print(ans % p)

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

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

  int p[5000];
  for(int i=0; i<n; i++){
    cin >> p[i];
  }

  int min_sum = 200000;

  for(int I=0; I<=p[0]; I++){
    int q[5000];
    for(int i=0; i<n; i++){
      q[i]=p[i];
    }

    int sum = I;
    q[0] -= I;

    for(int i=0; i<=n-2; i++){
      if(q[i]<=0){
        continue;
      }

      sum += q[i]*2;
      q[i+1] -= q[i];
    }

    if(q[n-1]>0){
      sum += q[n-1];
    }
    min_sum = min(min_sum, sum);
  }
  cout << min_sum << endl;
  return 0;
}



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

int main() {
    int X,Y;
    
    cin >> X >> Y;
    
    bool flg = false;
    for ( int i = 0; i <= X; ++i){
        int feet = i * 2 + (X-i) * 4;
        if ( feet == Y ){
            flg = true;
        }
    }
    
    if (flg) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}



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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

std::ostream &operator<<(std::ostream &dest, __int128_t value) {
  std::ostream::sentry s(dest);
  if (s) {
    __uint128_t tmp = value < 0 ? -value : value;
    char buffer[128];
    char *d = std::end(buffer);
    do {
      --d;
      *d = "0123456789"[tmp % 10];
      tmp /= 10;
    } while (tmp != 0);
    if (value < 0) {
      --d;
      *d = '-';
    }
    int len = std::end(buffer) - d;
    if (dest.rdbuf()->sputn(d, len) != len) {
      dest.setstate(std::ios_base::badbit);
    }
  }
  return dest;
}


signed main(){

  int n;
  cin>>n;
  vector<ll> a(n);
  cin>>a;
  sort(begin(a),end(a));

  __int128_t res = 1;
  __int128_t limit = 1e18;
  rep(i,n){
    if(a[i]==0){
      cout<<0<<endl;
      return 0;
    }
    res *= a[i];
    if(res>limit){
      cout<<-1<<endl;
      return 0;
    }
  }
  cout<<(res)<<endl;

}

Measured memory_bytes: 4048
// @samaranand
//
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define F first
#define S second
//#define biGinf 9e+18
#define int64 long long
#define VI vector < int >
#define VII vector < vector < int > >
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define inpv(v) for(auto &x:v) cin>>x
#define otpv(v) for(auto &x:v) cout<<x<<nwl
#define otpv2(v) for(auto &x:v) cout<<x<<" "
#define pii pair < int , int >
#define CASES int tt;cin>>tt; while(tt--)
#define for0(i,n) for(int i=0; i<n; i++)
#define sz size()
//const string yo = "YES", no = "NO";
const int inf = 2e9 + 7;
//const long long biGinf = 9e+18;
const char nwl = '\n';

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	//ur code
	int n;
	cin >> n;
	string s;
	cin >> s;
	if (s.sz <= n )
		cout << s;
	else {
		for (int i = 0; i < n; i++)
			cout << s[i];
		cout << "...";
	}
	return 0;
}

Measured memory_bytes: 3588