akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
 
int main()
{
    int n,b,f,r,v;
    int i,j,k;
    int x[4][3][10] = {0};
     
    scanf("%d",&n);
     
    for(i=0;i<n;i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        x[b-1][f-1][r-1] += v;
    }
     
    for(i=0;i<4;i++){
        for(j=0;j<3;j++){
            for(k=0;k<10;k++){
                printf(" %d",x[i][j][k]);
            }
            printf("\n");
        }
        if(i != 3)
        printf("####################\n");
    }
    return 0;
}
 



 

Measured memory_bytes: 612
import sys
def input():
    return sys.stdin.readline()[:-1]
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
l=[0]*100001
a=sum(A)
for i in A:
    l[i]+=1
for i in range(Q):
    b,c=map(int,input().split())
    a+=(c-b)*l[b]
    l[c]+=l[b]
    l[b]=0
    print(a)

Measured memory_bytes: 20876
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            var time = long.Parse(Console.ReadLine());
            var tmp = Console.ReadLine().Split(' ');
            var nums = new long[time];
            long all = 0;
            for(var i = 0; i < time; i++)
            {
                nums[i] = long.Parse(tmp[i]);
            }
            var countArr = new long[time];
            for(var i = 0; i < time; i++)
            {
                all += countArr[nums[i] - 1]++;
            }
            for(var k = 0; k < time; k++)
            {
                var ans = all - countArr[nums[k] - 1] + 1;
                Console.WriteLine(ans);
            }
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 35164
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;

string kai(int a){
  string c;
  while(a>=10){
    c+=(a%10)+'0';
    a/=10;
  }
  // cout<<a<<endl;
  if(a!=0)
  c+=a+'0';
  return c;
}

int main(){
  ll n,m; cin>>n>>m;
  ll ans;
  if(n==1&&m==1){
    ans=1;
  }else if(m==1){
    ans=n-2;
  }else if(n==1){
    ans=m-2;
  }else{
    ans=n*m-(2*n+2*(m-2));
    // ans=(n-2)*(m-2);
  }
  cout<<ans<<endl;

  return 0;

}


Measured memory_bytes: 256
/**
* হে প্রভু আমাকে জ্ঞান দান করুন ।
***/
#include <bits/stdc++.h>
#define debug(...)
#include <complex.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;


int32_t main() {
    ios::sync_with_stdio(false); cin.tie(0);
    string s;
    cin >> s;
    int n = (int)s.size();
    if(n == 1){
        cout << 1 << '\n';
        return 0;
    }
    ll ans = 0;
    string pv ="" , nw = "";
    pv += s[0];
    ans++;
    for(int i = 1 ;  i < n; i++){
        nw = s[i];
        if(pv == nw){
            assert(nw.size() == 1);
           if(i + 1 < n){
            pv += s[i + 1];
            i++;
           ans++;
           }
        }
        else{
            ans++;
            pv = nw;
        }
    }
    cout << ans << '\n';



    return 0;
}













Measured memory_bytes: 720
import sys
#input = sys.stdin.buffer.readline
from collections import defaultdict

def main():
    H,W = map(int,input().split())
    d = defaultdict(int)
    for _ in range(H):
        s = input()
        for st in s:
            num = ord(st)-ord("a")
            d[num] += 1
    
    use = list(d.values())
    m = [0,0,0]
    for num in use:
        m[0] += num//4
        num -= num//4*4
        m[1] += num//2
        m[2] += num%2

    if (H%2 == 0 and W%2 == 0):
        if H*W == 4*m[0]:
            print("Yes")
        else:
            print("No")
    elif (H*W)%2 == 1:
        if m[2] != 1:
            print("No")
        else:
            if m[0] >= ((H-1)*(W-1))//4:
                print("Yes")
            else:
                print("No")
    else:
        if m[2] != 0:
            print("No")
        else:
            if H%2 == 1:
                if m[1] <= W//2:
                    print("Yes")
                else:
                    print("No")
            else:
                if m[1] <= H//2:
                    print("Yes")
                else:
                    print("No")

if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
#define vcin(a) for(int i=0;i<(a).size();i++) cin>>(a)[i];
#define mod 1000000007

ll factorial(ll n)
{
    if(n==0)
        return 1;
        else
        {
            return (n% mod * factorial(n - 1) % mod)%mod;
        }
}

long long modpow(long long a, long long n)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll without_factorial(ll n,int k)
{
    ll res = 1;
    rep2(i,1,n+1)
    {
        if(i!=k)
        res =(res* i)%mod;
    }
    return res;
}

int main()
{
    int N;
    cin >> N;
    vll x(N),num(N-1);
    vll inv(N);
    rep(i,N)
    {
        inv[i] = modpow(i, mod - 2);
    }
    rep(i, N)
    {
        cin >> x[i];
    }
    num[0] = factorial(N - 1);
    ll sum = 0;
    rep2(i, 1, N - 1)
    {
        num[i] = (num[i - 1] + (num[0]*inv[i+1])%mod)%mod;
        sum =(sum +  ((x[i] - x[i-1])%mod)*(num[i-1]%mod))%mod;
    }
    sum = (sum + (x[N - 1] - x[N - 2]) % mod * (num[N - 2] % mod)) % mod;
    cout << sum;
 return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,n,cnt=0,h,w,i;
	scanf("%d %d %d",&n,&h,&w);
	for(i=0;i<n;i++)
	{
		scanf("%d %d",&a,&b);
		cnt+=min((int)(a/h),(int)(b/w));
	}
	printf("%d",cnt);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
    string s;
    cin >> s;
    bool flg = true;
    
    for (int i = 0; i < s.length(); ++i) {
        if ((i + 1) % 2 == 0) {
            if (s[i] == 'R') flg = false;
        }
        else {
            if (s[i] == 'L') flg = false;
        }
    }

    if (flg) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);

		long x=sc.nextLong();
		long y=sc.nextLong();

		long counter=1;

		while(true) {

			x*=2;

			if(y>x) {
				counter++;
			}else if(y==x) {
              	counter++;
				break;
			}else{
            	break;
            }

		}

		System.out.println(counter);

	}


}


Measured memory_bytes: 21844
from sys import stdin, stdout,stderr
import time,math
from collections import defaultdict as dd, Counter
 
def pn(ob):stdout.write(str(ob))
def inp():return stdin.readline()
 
def main():
	x, k, d = map(int, inp().split())
	if(x < 0):
		x *= -1

	if(x >= k * d):
		print(x - k * d)
	else:
		n = x // d
		if(n % 2 == k % 2):
			print(x % d)
		else:
			print(abs(x - (n + 1) * d))
		
  
if __name__ == '__main__':
	main()
	
#n,m=map(int,input().split()) 
# for i in range(n):
#     t=int(stdin.readline()) # input using fast i/p method 
#     if t%m == 0:
#         stdout.write(str(t)+'\n') #input using fast o/p method
 
# take line of integers as input
# 	arr = list(map(int, inp().split()))

Measured memory_bytes: 9504
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
  int n;
  cin >> n;
  string a="0";
  int c=0;
  int p;
  for(int i=0;i<n;i++){
    p=0;
    while(1){
      if(a[p+c]=='0'){
	//	cout <<1;
	a[p+c]='+';
	break;
      }
      if(a[p+c]=='+'){
	//cout <<2;
	a[p+c]='-';
	p--;
	if(p+c<0){
	  c++;
	  a.insert(a.begin(),'+');
	  break;
	}
	else {
	  continue;
	}
      }
      if(a[p+c]=='-'){
	//cout << 3;
	a[p+c]='0';
	break;
      }
    }
  }
  cout << a<< endl;
  return 0;
}

      

Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 10007;
const ld PI = acosl(-1);

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

    int N;
    string c;
    cin >> N >> c;
    int ans = 0;
    int l = 0, r = N - 1;
    while (l < r) {
        if (c[l] == 'R')
            l++;
        else if (c[r] == 'W')
            r--;
        else
            l++, r--, ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3728
N,K = map(int,input().split())
List = list(map(int,input().split()))

def sm(lst, j, k):
  return lst[j+k]-lst[j]

def max(lst, k):
  sumlst = [0]
  for i in range(len(lst)):
    sumlst.append(sumlst[i]+lst[i])
  res = 0
  for i in range(N-k+1):
    if res < sm(sumlst, i, k):
      res = sm(sumlst, i, k)
  res = (res+k)/2
  return res

print(max(List, K))
    

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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p;

int a,b,c,d,e,k;
vector<int> v;

int main(){
  for(int i=0;i<5;i++){
    int tmp;
    cin >> tmp;
    v.push_back(tmp);
  }
  cin >> k;
  for(int i=0;i<5;i++){
    for(int j=i+1;j<5;j++){
      if(v[j]-v[i]>k){
        cout << ":(" << endl;
        return 0;
      }
    }
  }
  cout << "Yay!" << endl;
  return 0;

}

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

using namespace std;

typedef long long ll;

const ll MO=1e9+7;
ll qmi(ll a,ll b) {
	ll res=1;
	while(b!=0){
		if(b%2==1){
			res=res*a%MO;
		}
		a=a*a%MO;
		b/=2;
	}
	return res;
}

int main(){
	ll n;
	cin>>n;
	cout<<((qmi(10ll,n)-2*qmi(9ll,n)+qmi(8ll,n))%MO+MO)%MO;
	return 0;
}

Measured memory_bytes: 3620
from collections import Counter
import sys

sys.setrecursionlimit(10**6)

def fn(n):
    if n <= 1:
        return 0
    return n - 1 + fn(n-1)

N = int(input())
A = list(map(int, input().split()))

c = Counter(A)
kumi = 0
for k, v in c.items():
    kumi += fn(v)

for ai in A:
    print(kumi - (c[ai] - 1))


Measured memory_bytes: 181920
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cfloat>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int DX[] = {0, 1, 0, -1};
const int DY[] = {-1, 0, 1, 0};


//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

struct Food{
	string name;
	int w;
	int s;
	int id;
	Food(string name, int w, int s, int id): name(name), w(w), s(s), id(id) {};

	bool operator<(const Food& rhs) const{
		return id < rhs.id;
	}
};

double calc(vector<Food> & foods){
	int length= foods.size();
	int sum = 0;
	for(int i = length - 1; i >= 0; --i){
		int s = foods[i].s;
		if(s < sum) return DBL_MAX;
		sum += foods[i].w;
	}
	double d = 0, n = 0;
	REP(i, length){
		n += (i + 1) * foods[i].w;
		d +=foods[i].w;
	}
	return n / d;
}

int main(int argc, char const *argv[])
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;
	vector<Food> ans;
	while(cin >> n, n){
		vector<Food> foods;
		foods.reserve(n);
		string name;
		int w, s;
		REP(i, n){
			cin >> name >> w >> s;
			foods.emplace_back(name, w, s, i);
		}
		double min = DBL_MAX;
		do{
			double value = calc(foods);
			if(min > value){
				min = value;
				ans = foods;
			}
		}while(next_permutation(foods.begin(), foods.end()));
		REP(i, n)
			cout << ans[i].name << endl;
	};
	return 0;
}

Measured memory_bytes: 1208
import java.util.*;
import java.util.TreeMap;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    // double A[] = new double[N];
    double ans = 0;
    ArrayList<Double> list = new ArrayList<>();
    for (int i = 0; i < N; i++) {
      list.add(sc.nextDouble());
    }
    while (!(list.size() == 1)) {
      Collections.sort(list);
      double total = 0;
      total = (list.get(0) + list.get(1)) / 2;
      list.remove(0);
      list.remove(0);
      list.add(total);
    }
    System.out.println(list.get(0));
  }
}


Measured memory_bytes: 25172
#include<bits/stdc++.h>
using namespace std;
int n,a[55],b[55],x; 
int main(){
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i],b[i]=a[i];
	sort(b+1,b+1+n);
	for(int i=1;i<=n;i++)
	    if(a[i]!=b[i]) x++;
	if(x==0||x==2) cout<<"YES";
	else cout<<"NO";
	return 0;
}

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

using namespace std;

class Node{
private:
 unsigned long nodeId;
 unsigned long timestampStart;
 unsigned long timestampFinish;
 vector<unsigned long> adjectNode;
public:
 Node()
       : timestampStart(0),
         timestampFinish(0){

  cin >> nodeId;
  unsigned long adjectNodeNum = 0;
  cin >> adjectNodeNum;

  adjectNode.assign(adjectNodeNum, 0);
 
  for(unsigned long adjectNode_i = 0; adjectNode_i < adjectNodeNum; ++adjectNode_i){
   cin >> adjectNode[adjectNode_i];
  }

 };

 bool isStampStart(){
  if(timestampStart == 0) return false;
  return true;
 };

 void stampStart(const unsigned long time){
  timestampStart = time;
 };

 void stampFinish(const unsigned long time){
  timestampFinish = time;
 };

 unsigned long getAdjectNodeNum(){
  return adjectNode.size();
 };

 unsigned long getAdjectNode(unsigned  long adjectNode_i){
  return adjectNode[adjectNode_i]-1;

 };

 void display(){
  cout << nodeId          << " ";
  cout << timestampStart  << " ";
  cout << timestampFinish << endl;
 };

protected:

};

class Graph{
private:
 vector<Node*> graph;

 void DepthFirstSearch(Node* node, unsigned long &time){
  ++time;
  node->stampStart(time);
  for(unsigned long adjectNode_i = 0, adjectNodeMax = node->getAdjectNodeNum(); adjectNode_i < adjectNodeMax; ++adjectNode_i){
   unsigned long nextNode = node->getAdjectNode(adjectNode_i);
   if(!graph[nextNode]->isStampStart()) DepthFirstSearch(graph[nextNode], time);

  }
  ++time;
  node->stampFinish(time);

 };
public:
 Graph(unsigned long nodeNum = 0)
       : graph(vector<Node*>(nodeNum, 0)){

   for(unsigned long node_i = 0; node_i < nodeNum; ++node_i){
    graph[node_i] = new Node();
   }

  };

 void DepthFirstSearch(){
  unsigned long time = 0;
  for(unsigned long node_i = 0, nodeMax = graph.size(); node_i < nodeMax; ++node_i){
   if(!graph[node_i]->isStampStart()) DepthFirstSearch(graph[node_i], time);
  }
  
 };

 void display(){
  for(unsigned long node_i = 0, numMax = graph.size(); node_i < numMax; ++node_i){
   graph[node_i]->display();
  }
 };
protected:

};


int main(){

 unsigned long nodeNum = 0; cin >> nodeNum;

 Graph graph(nodeNum);
 graph.DepthFirstSearch();
 graph.display();

 return 0;
};

Measured memory_bytes: 1200
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

#define rep(i,n)  for(int i = 0; i < (int)(n);    i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  std::string S; std::cin >> S;
  if ( S[2] == S[3] && S[4] == S[5] ) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define all(v) (v).begin(),v.end()
#define fi first
#define se second
set<string> c;
map<ll,ll> mp;
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
int main(){
int n;
cin>>n;
int n2=1<<n;
multiset<int> s;
vector<int> a(n2);
 for(int i=0;i<n2;i++){cin>>a[i];s.insert(a[i]);}
multiset<int> q;
sort(all(a));
q.insert(a.back());
s.erase(*s.find(a.back()));
for(int i=0;i<n;i++){
   multiset<int>  p=q;
    int si=n2-1;
    while(p.size()>0&&si>=0){
        /* for(auto itt:p){
            cout<<itt<<" ";
        } 
        cout<<endl;*/
        auto ite=s.find(a[si]);
        if(ite==s.end()){
            si--;
            continue;
        }
       // cout<<a[si]<<endl;
        auto it=p.upper_bound(a[si]);
        if(it!=p.end()){
            q.insert(a[si]);
            it=p.end();it--;
            p.erase(it);
            s.erase(ite);
        }
       si--;
    }
    if(p.size()>0){
        //cout<<*p.begin()<<endl;
        cout<<"No"<<endl;
        return 0;
    }
}
cout<<"Yes"<<endl;
}





Measured memory_bytes: 19712
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    int n;
    cin >> n;
    vi t(n), a(n);
    for (int i = 0; i < n; ++i) {
        cin >> t[i] >> a[i];
    }
    ll ta = t[0];
    ll ao = a[0];
    for (int i = 1; i < n; ++i) {
        if (ta * a[i] != ao * t[i]) {
            ll ng = 0, ok = 1000000000000000000 / max(a[i], t[i]);
            auto check = [&](ll mid) {
                if (mid * a[i] >= ao && mid * t[i] >= ta)
                    return true;
                else
                    return false;
            };
            while (ng != ok - 1) {
                ll mid = (ng + ok) / 2;
                if (check(mid))
                    ok = mid;
                else
                    ng = mid;
            }
            ta = ok * t[i];
            ao = ok * a[i];
        }
    }
    cout << ta + ao << "\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long a=sc.nextLong();
        long b=sc.nextLong();
        long c=sc.nextLong();
        long left=4*a*b;
        long right= (c-a-b)*(c-a-b);
        if (left < right && a+b<c) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

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

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
  int n;
  cin >> n;
  vector<ll> x(n),y(n),h(n);
  for(int i = 0; i < n; i++){
    cin >> x[i] >> y[i] >> h[i];
  }
  // if(n == 1){
  //   if(h[0] != 0){
  //     cout << x[0] << " " << y[0] << " " << h[0] << endl;
  //   }else{
  //     cout << x[0]+1 << " " << y[0] << " " << 1 << endl;
  //   }
  //   return 0;
  // }

  for(ll Cx = 0; Cx <= 100; Cx++){
    for(ll Cy = 0; Cy <=100; Cy++){
      ll H = -1;
      for(int i = 0; i < n; i++){
        if(h[i] != 0){
          H = h[i] + abs(x[i]-Cx) + abs(y[i]-Cy);
          break;
        }
      }
      for(int i = 0; i < n; i++){
        ll K = max(H - abs(x[i]-Cx) - abs(y[i]-Cy),(ll)0);
        if(K != h[i]) break;
        if(i == n-1){
          cout << Cx << " " << Cy << " " << H << endl;
          return 0;
        }
      }
    }
  }


  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
int main()
{
	int n;
	cin >> n;
	string s[2];
	cin >> s[0] >> s[1];
	ll ans = 0;
	int past;
	int i = 0;
	if(s[0][0]==s[1][0])
	{
		ans += 3;
		past=0;
		i  =1 ;
	}
	else
	{
		ans+=6;
		past = 1;
		i = 2;
	}

	while(i<n)
	{
		if(s[1][i]==s[0][i])
		{
			if(past)
			{

			}
			else
			{
				(ans*=2)%=MOD;
			}
			i++;
			past = 0;
		}
		else
		{
			if(past)
			{
				(ans*=3)%=MOD;
			}
			else
			{
				(ans*=2)%=MOD;
			}
			i+=2;
			past = 1;
		}
		
	}
	cout<<ans<<endl;

	
}

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

#define INF (i64)(1e18)
#define MOD (i64)(1e9+7)
#define REP(i, n) for(i64 i = 0; i < (n); i++)
#define RREP(i, n) for(i64 i = (n)-1; i >= 0; i--)
#define RANGE(i, a, b) for(i64 i = (a); i < (b); i++)
#define RRANGE(i, a, b) for(i64 i = (b)-1; i >= (a); i--)
#define ALL(v) (v).begin(), (v).end()
#define SIZE(v) ((i64)(v).size())
template<class T> inline void chmax(T &a, const T &b) { if (a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if (a > b) a = b; }

struct ModInt {
  i64 val;
  ModInt() {
    val = 0;
  }
  ModInt(i64 a) {
    val = mod(a);
  }
  inline i64 get() {
    return val;
  }
  inline operator i64(void) {
    return get();
  }
  inline i64 mod(i64 a) {
    a %= MOD;
    if (a < 0) a += MOD;
    return a;
  }
  inline ModInt &operator+=(ModInt a) {
    val = mod(val + a.val);
    return *this;
  }
  inline ModInt &operator-=(ModInt a) {
    val = mod(val - a.val);
    return *this;
  }
  inline ModInt &operator*=(ModInt a) {
    val = mod(val * a.val);
    return *this;
  }
  inline ModInt &operator/=(ModInt a) {
    return *this *= a.inv();
  }
  inline ModInt operator+(ModInt a) {
    return ModInt(*this) += a;
  }
  inline ModInt operator-(ModInt a) {
    return ModInt(*this) -= a;
  }
  inline ModInt operator*(ModInt a) {
    return ModInt(*this) *= a;
  }
  inline ModInt operator/(ModInt a) {
    return ModInt(*this) /= a;
  }
  inline ModInt operator-(void) {
    return ModInt(0 - val);
  }
  inline bool operator==(ModInt a) {
    return val == a.val;
  }
  inline bool operator!=(ModInt a) {
    return val != a.val;
  }
  inline ModInt &operator+=(i64 a) {
    return *this += ModInt(a);
  }
  inline ModInt &operator-=(i64 a) {
    return *this -= ModInt(a);
  }
  inline ModInt &operator*=(i64 a) {
    return *this *= ModInt(a);
  }
  inline ModInt &operator/=(i64 a) {
    return *this /= ModInt(a);
  }
  inline ModInt operator+(i64 a) {
    return ModInt(*this) += a;
  }
  inline ModInt operator-(i64 a) {
    return ModInt(*this) -= a;
  }
  inline ModInt operator*(i64 a) {
    return ModInt(*this) *= a;
  }
  inline ModInt operator/(i64 a) {
    return ModInt(*this) /= a;
  }
  inline bool operator==(i64 a) {
    return val == mod(a);
  }
  inline bool operator!=(i64 a) {
    return val != mod(a);
  }
  inline ModInt pow(i64 n) {
    ModInt a(*this);
    ModInt res = 1;
    while (n) {
      if (n & 1) {
        res *= a;
      }
      n >>= 1;
      a *= a;
    }
    return res;
  }
  inline ModInt inv() {
    return pow(MOD - 2);
  }
};

int main() {
  string l;
  cin >> l;
  int n = SIZE(l);
  vector<ModInt> d1(n), d2(n);
  d1[0] = 1;
  d2[0] = 2;
  RANGE(k, 1, n) {
    if (l[k] == '0') {
      d1[k] = d1[k-1]*ModInt(3);
      d2[k] = d2[k-1];
    } else {
      d1[k] = d1[k-1]*ModInt(3)+d2[k-1];
      d2[k] = d2[k-1]*ModInt(2);
    }
  }
  cout << (d1[n-1]+d2[n-1]).val << endl;
  return 0;
}


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

int main(){
  int s,w;
  cin >> s >> w;
  if(s<=w) cout << "unsafe" << endl;
  else cout << "safe" << endl;
}


Measured memory_bytes: 3648
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector as V
import Debug.Trace
main :: IO ()
main = getLine >> readLine >>= print . solve

solve :: [Int] -> Int
solve (a : as) = maximum . take n . map mf $ zip cs ds
    where
        n = length $ a : as
        (b : bs) = reverse $ a : as
        vs = build a as
        rs = tail . reverse $ build b bs

        cs = head rs : vs
        ds = rs ++ [vs !! (n - 2)]

        mf (v, r) = gcd v r

        build p (x : xs) = p : build (gcd p x) xs
        build p _ = [p]


readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

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

using namespace std;

namespace {

    typedef double real;
    typedef long long ll;

    template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
        if (vs.empty()) return os << "[]";
        auto i = vs.begin();
        os << "[" << *i;
        for (++i; i != vs.end(); ++i) os << " " << *i;
        return os << "]";
    }
    template<class T> istream& operator>>(istream& is, vector<T>& vs) {
        for (auto it = vs.begin(); it != vs.end(); it++) is >> *it;
        return is;
    }

    int A, B, C, D, E, F;
    void input() {
        cin >> A >> B >> C >> D >> E >> F;
    }

    void solve() {
        int ans_water = 100 * A;
        int ans_sugar = 0;
        double ans_dens = 0;
        for (int a = 0; 100 * a * A <= F; a++) {
            for (int b = 0; 100 * a * A + 100 * b * B <= F; b++) {
                int s = 100 * a * A + 100 * b * B;
                int cand_water = s;
                int k = min(F - s, s * E / 100);
                vector<int> dp(k + 1, false);
                dp[0] = true;
                int cand_sugar = 0;
                for (int j = 1; j <= k; j++) {
                    if (j - C >= 0 && dp[j - C]) {
                        dp[j] = true;
                        cand_sugar = j;
                    }
                    if (j - D >= 0 && dp[j - D]) {
                        dp[j] = true;
                        cand_sugar = j;
                    }
                }
                double cand_dens = double(cand_sugar) / (cand_water + cand_sugar);
                if (ans_dens < cand_dens) {
                    ans_dens = cand_dens;
                    ans_water = cand_water;
                    ans_sugar = cand_sugar;
                }
            }
        }
        cout << ans_water + ans_sugar << " " << ans_sugar << endl;
    }
}

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



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    long long a, b, k;
    cin >> a >> b >> k;

    b -= min(b, max(0LL, k - a));
    a -= min(a, k);
    cout << a << ' ' << b << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;a++)
#define rl(a,b,c) for(int a=b;a>=c;a--)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
using namespace std;
const int MOD=1e9+7;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
LL  dp[2000+10][2000+10]/*separate i balls into j groups*/,dp2[2000+10][2000+10]/*push i boards into j empty places*/;
int main(){
	int n,k;
	scanf("%d %d",&n,&k);
	dp[0][0]=1;
	rb(i,1,k){
		rb(j,1,i){
			
			dp[i][j]=dp[i-1][j]+dp[i-1][j-1];
			dp[i][j]%=MOD;
//			cout<<dp[i][j]<<" ";
		}
//		cout<<endl;
	}
	dp2[0][0]=1;
	rb(i,1,n+1) dp2[1][i]=i;
	rb(i,2,n+1){
		rb(j,i,n+1){
			dp2[i][j]=dp2[i-1][j-1]+dp2[i][j-1];
			dp2[i][j]%=MOD;
//			cout<<dp2[i][j]<<" ";
		}
//		cout<<endl;
	}
	rb(i,1,k){
		if(i-1>n-k){
			printf("0\n");
			continue;
		}
		LL res=dp[k][i];
//		cout<<res<<"*1*"<<endl;
		res*=dp2[i][n-k+1] ;
//		cout<<res<<"*2*"<<endl;
		res%=MOD;
		printf("%lld\n",res);
	}
	
	return 0;
}

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

using namespace std;

int solve(int N, vector<int>& hs)
{
    auto ans = 0;

    for (int i = 0; i < 100; ++i)
    {
        int L = 1;

        while (L <= N)
        {
            if (hs[L] == 0)
            {
                ++L;
                continue;
            }

            --hs[L];

            int R = L + 1; 

            while (hs[R] > 0)
            {
                --hs[R];
                ++R;
            }

            ++ans;
            L = R;
        }
    }

    return ans;
}
int main()
{
    int N;
    cin >> N;

    vector<int> hs(N + 2);

    for (int i = 1; i <= N; ++i)
        cin >> hs[i];

    cout << solve(N, hs) << '\n';

    return 0;
}


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

int main() {
  string s, t;
  cin >> s >> t;
  vector<string> ans;

  int l = s.size() - t.size() + 1;

  for (int i = 0; i < max(l, 0); i++) {
    string tmp = s;
    for (int j = 0; j < t.size(); j++) {
      if (i + j > s.size() - 1) break;
      if (tmp[i+j] == t[j] || tmp[i+j] == '?') tmp[i+j] = t[j];
      else break;
      if (j == t.size() -1) {
        for (int k = 0; k < tmp.size(); k++) {
        if(tmp[k] == '?') tmp[k] = 'a';
      }
      ans.push_back(tmp);
      }
    }
  }

  sort(ans.begin(), ans.end());
  if (ans.size() > 0) cout << ans[0] << endl;
  else cout << "UNRESTORABLE" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int a[1001];
int num[1001];
int main(){
	scanf("%d",&n);
	long long ans=1;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(a[i]%2==1)num[i]++;
		if((a[i]+1)%2==1)num[i]++;
		if((a[i]-1)%2==1)num[i]++;
		ans=ans*3;
	}
	long long sum=1;
	for(int i=1;i<=n;i++){
		sum*=num[i];
	}
	ans-=sum;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9+7LL;

int D = 365;
vector<int> c(26);
vector<vector<int>> s(D, vector<int>(26));

int score(vector<int> t){
    vector<int> last(26);

    ll sc = 0;
    rep(i, D){
        int n = t.at(i)-1;
        sc += s.at(i).at(n);
        last.at(n) = i+1;
        rep(j, 26){
            sc -= c.at(j) * (i - last.at(j) + 1);
        }
    }
    return sc;
}

int main() {
    cin >> D;
    rep(i, 26) cin >> c.at(i);
    rep(i, D){
        rep(j, 26){
            cin >> s.at(i).at(j);
        }
    }
    vector<int> t(D);
    rep(i, D) cin >> t.at(i);

    int M; cin >> M;
    vector<int> d(M);
    vector<int> q(M);
    rep(i, M){
        cin >> d.at(i);
        cin >> q.at(i);
    }

    rep(i, M){
        t.at(d.at(i)-1) = q.at(i);
        cout << score(t) << endl;
    }
}

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

#define all(x) (x).begin(), (x).end()
#define szof(x) int32_t((x).size())
#define str(x) to_string(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;

const ll MOD = 1e9 + 7;
const ll MOD998 = 998244353;
const int INF = 1e9;
const ll LLINF = 1e18;

mt19937_64 rng((uint) chrono::steady_clock::now().time_since_epoch().count());

template <class T>
T rnd(T l, T r) {
	return uniform_int_distribution<T>(l, r)(rng);
}

void run() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int &x : a) {
		cin >> x;
	}
	vector<bool> dp(k + 1);
	for (int i = 1; i <= k; i++) {
		for (int x : a) {
			if (i - x >= 0) {
				dp[i] = dp[i] || !dp[i - x];
			}
		}
	}
	cout << (dp[k] ? "First" : "Second") << "\n";
}

int32_t main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cout.precision(10); cout << fixed;
	int tests = 1;
	// cin >> tests;
	while (tests--) {
		run();
	}
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
	return 0;
}


Measured memory_bytes: 256
mfl, mce = math.floor, math.ceil
mmi, mma = math.min, math.max
bls, brs = bit.lshift, bit.rshift
SegTree = {}
SegTree.updateAll = function(self)
  for i = self.stagenum - 1, 1, -1 do
    cnt = bls(1, i - 1)
    for j = 1, cnt do
      self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])
    end
  end
end
SegTree.create = function(self, n, func, emptyvalue)
  self.func, self.emptyvalue = func, emptyvalue
  stagenum, mul = 1, 1
  self.stage = {{}}
  while mul < n do
    mul, stagenum = mul * 2, stagenum + 1
    self.stage[stagenum] = {}
  end
  self.stagenum = stagenum
  self.left_stage = {}
  for i = 1, n do
    sp, sz = 1, bls(1, stagenum - 1)
    while(i - 1) % sz ~= 0 do
      sp, sz = sp + 1, brs(sz, 1)
    end
    self.left_stage[i] = sp
  end
  self.sz_stage = {}
  tmp, sp = 1, stagenum
  for i = 1, n do
    if tmp * 2 == i then tmp, sp = tmp * 2, sp - 1 end
    self.sz_stage[i] = sp
  end
  for i = 1, n do self.stage[stagenum][i] = i end
  for i = n + 1, mul do self.stage[stagenum][i] = emptyvalue end
  self:updateAll()
end
SegTree.getRange = function(self, left, right)
  if left == right then return self.stage[self.stagenum][left] end
  stagenum = self.stagenum
  ret = self.emptyvalue
  while left <= right do
    stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])
    sz = bls(1, stagenum - stage)
    ret = self.func(ret, self.stage[stage][1 + brs(left - 1, stagenum - stage)])
    left = left + sz
  end
  return ret
end
SegTree.update = function(self, idx, value)
  for i = self.stagenum - 1, 1, -1 do
    dst = brs(idx + 1, 1)
    rem = dst * 4 - 1 - idx
    self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])
    idx = dst
  end
end
SegTree.new = function(n, func, emptyvalue)
  obj = {}
  setmetatable(obj, {__index = SegTree})
  obj:create(n, func, emptyvalue)
  return obj
end

n, m = io.read("*n", "*n")
edge = {}
edgenum = {}
offset = {}
for i = 1, n do
  edge[i] = {}
  edgenum[i] = 0
  offset[i] = 0
end
inf = 1000000007
edgenum[n + 1] = inf
for i = 1, m do
  a, b = io.read("*n", "*n")
  edge[a][b], edge[b][a] = true, true
  edgenum[a] = edgenum[a] + 1
  edgenum[b] = edgenum[b] + 1
end
if m % 2 == 1 then
  print(-1)
  os.exit()
end
st = SegTree.new(n, function(a, b) return edgenum[a] < edgenum[b] and a or b end, n + 1)
for i = 1, n do
  src = st.stage[1][1]
  dsts = {}
  for dst, _u in pairs(edge[src]) do
    table.insert(dsts, dst)
  end
  if offset[src] == 1 then
    dst = dsts[#dsts]
    print(src .. " " .. dst)
    edgenum[dst] = edgenum[dst] - 1
    edge[dst][src] = nil
    st:update(dst)
    table.remove(dsts)
  end
  lim = mfl(#dsts / 2)
  for j = 1, lim * 2 do
    dst = dsts[j]
    print(src .. " " .. dst)
    edge[dst][src] = nil
    edgenum[dst] = edgenum[dst] - 1
    st:update(dst)
  end
  if #dsts % 2 == 1 then
    dst = dsts[#dsts]
    print(dst .. " " .. src)
    offset[dst] = (offset[dst] + 1) % 2
    edge[dst][src] = nil
    edgenum[dst] = edgenum[dst] - 1
    st:update(dst)
  end
  edgenum[src] = inf
  st:update(src)
end


Measured memory_bytes: 34524
import java.util.Scanner;

/**
 * https://abc045.contest.atcoder.jp/tasks/abc045_b
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		char[] A = sc.next().toCharArray();
		char[] B = sc.next().toCharArray();
		char[] C = sc.next().toCharArray();
		sc.close();
		
		int ia = 1;
		int ib = 0;
		int ic = 0;
		char current = A[0];
		String ans = null;
		while(ans==null){
			switch(current){
			case 'a':
				if(ia==A.length) ans = "A";
				else current = A[ia++];
				break;
			case 'b':
				if(ib==B.length) ans = "B";
				else current = B[ib++];
				break;
			case 'c':
				if(ic==C.length) ans = "C";
				else current = C[ic++];
				break;
			}
		}
		
		System.out.println(ans);
		
	}

}

Measured memory_bytes: 23760
//Writer: Aditya Singh
//Bleed Blue
#include <bits/stdc++.h>

using namespace std;

#pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define unm unordered_map<int,int>
#define pb emplace_back
#define nt _int128
#define PI 3.1415926535897932384626433
#define inf 1e18

const int N = 100005;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    // int t;cin>>t;while(t--)
    {
        int i, j, k, n, m, ans = 0, cnt = 0, sum = 0;
        string s, t;
        cin >> s >> t;
        n = t.size();
        if (s + t[n - 1] == t)
            puts("Yes");
        else
            puts("No");
    }
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
string a;
int main()
{
    cin>>a;
    bool flag1=false,flag2=false;
	for(int i=0;i<a.size();i++)
	{
		if(a[i]=='C')
			flag1=true;
		if(a[i]=='F')
			if(flag1)
			{
				cout<<"Yes"<<endl;
				exit(0);
			}
			else
				continue;
	}
	cout<<"No"<<endl;
    return 0;
}

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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
typedef pair<int, int> PR;

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define fr(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}

//cout<<""<<endl;
int main(){
 int N;cin>>N;
  vector<PR> R(N),B(N);
  rep(i,N){
    int a,b;cin>>a>>b;
    PR p =make_pair(b,a);
    R[i]=p;
  }
  rep(i,N){
    int a,b;cin>>a>>b;
    PR p =make_pair(a,b);
    B[i]=p;
  }
  sort(all(R));
  reverse(all(R));
  
  vb han(N);
  rep(i,N)han[i]=false;
  for(int i=0;i<N;i++){
    int k=10000,ind=1000;
    
    rep(j,N){
     if(han[j])continue;
     if(R[i].first<B[j].second){
        if(R[i].second<B[j].first){
          if(k>B[j].first){
            k=B[j].first;
            ind=j;
          }
        }
      }
    }
    if(ind!=1000)han[ind]=true;
  }
  int cnt=0;
  rep(i,N){
   if(han[i])cnt++; 
  }
  cout<<cnt<<endl;
}






Measured memory_bytes: 3636
#include<stdio.h>
#define MAX 100000

int partition(int K[], int n, int o, int W){
  int x, i, j, t;
  x = K[W];
  i = o-1;
  for (j=o;j<W;j++){
    if (K[j]<=x){
      i++;
      t=K[i];K[i]=K[j];K[j]=t;
    }
  }
  t=K[i+1];K[i+1]=K[W];K[W]=t;
  return i+1;
}
main(){
  int K[MAX], n, i, a;
  scanf("%d", &n);
  for (i=0;i<n;i++) scanf("%d", &K[i]);
  a = partition(K, n, 0, n-1);
  for (i=0;i<n;i++) {
    if ( i ) printf(" ");
    if ( i == a ) printf("[");
    printf("%d", K[i]);
    if ( i == a ) printf("]");
  }
  printf("\n");

  return 0;
}



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

int main() {
  long long H,W;

  cin >> H >> W;
  if(H == 1 || W == 1){
    cout << 1 << endl;
    return 0;
  }
  if(H*W%2 == 1){
    cout << H*W/2 + 1 << endl;
  }else{
    cout << H*W/2 << endl;
  }
  return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
using namespace std;

int Data[105],dp[105][2];
int N;

int main(){
    scanf("%d",&N);
    for(register int i=1;i<=N;++i)
        scanf("%d",&Data[i]);
    memset(dp,0x3f,sizeof(dp));
    dp[1][0]=0;
    dp[1][1]=1;
    for(register int i=2;i<=N;++i){
        if(Data[i]==Data[i-1]) dp[i][0]=dp[i-1][1];
        else dp[i][0]=min(dp[i-1][0],dp[i-1][1]);
        dp[i][1]=min(dp[i-1][0],dp[i-1][1])+1;
    }
    printf("%d\n",min(dp[N][0],dp[N][1]));
    //system("pause");
    return 0;
}

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

int main() {
  char c;
  cin >> c;
  
  if (c == 'a' or c == 'i' or 
      c == 'u' or c == 'e' or c == 'o')
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
}

Measured memory_bytes: 3560
def main():
  ## IMPORT MODULE
  #import sys

  #sys.setrecursionlimit(100000)
  #input=lambda :sys.stdin.readline().rstrip()

  #f_inf=float("inf")
  #MOD=10**9+7
  
  if 'get_ipython' in globals(): 
    ## SAMPLE INPUT
    a, b, c, k = 2, 1, 1, 3

  else:
    ##INPUT 
    #n = input()
    a, b, c, k = map(int, input().split())

  ## SUBMITION CODES HERE
  if k <= a:
    print(k)
 
  elif k <= a+b:
    print(a)
 
  elif k > a+b:
    print(a-(k-(a+b)))  

main()

Measured memory_bytes: 9164
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int yoko = scan.nextInt();
		int curtain = scan.nextInt();
		int re = yoko-curtain*2;

		System.out.println(re <= 0?0:re);

		scan.close();

	}

}


Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    string S, T;
    cin >> S >> T;
    int ans = T.size();
    for (int i = 0; i + T.size() < S.size() + 1; i++)
    {
        int tans = 0;
        for (int j = 0; j < T.size(); j++)
        {
            if (S[j + i] != T[j])
                tans++;
        }
        ans = min(ans, tans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<vector>
#include<cassert>
#include<set>
using namespace std;

#define sz(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
typedef long long ll;
//////////////////////

int const N = 1e5 + 41;

int l[N], r[N], n;
ll pref[N];
int tim;

ll getPref(int l, int r){
	ll ret = pref[r];
	if(l > 0) ret -= pref[l-1];
	return ret;
}

struct S{
	ll x, type, time;
	S(){};
	S(ll x, ll type, ll time) : x(x), type(type), time(time) {};
	bool operator<(const S &s) const {
		return getX() < s.getX();
	};

	ll getX() const {
		if(type == 0){
			return x - getPref(time+1, tim);
		}else{
			return x + getPref(time, tim-1);
		}
	}
};

multiset<S> lp, rp;

ll getLast(multiset<S> &ms){
	multiset<S> :: iterator it = ms.end();
	--it;
	return ((*it).getX());
}

ll getFirst(multiset<S> &ms){
	auto it = ms.begin();
	return (*it).getX();
}

void solve(){
	cin >> n;
	rep(i, 0, n) cin >> l[i] >> r[i];
	rep(i, 0, n) pref[i] = (r[i] - l[i] + (i > 0 ? pref[i-1] : 0));
	ll ans = 0;

	lp.insert(S(l[0], 0, 0));
	rp.insert(S(l[0], 1, 0));
	rep(i, 1, n){
		tim = i;
		if(l[i] >= getLast(lp) && l[i] <= getFirst(rp)){
			lp.insert(S(l[i], 0, i));
			rp.insert(S(l[i], 1, i));
		}else if(l[i] >= getFirst(rp)){
			ans += (l[i] - getFirst(rp));
			S tmp = (*rp.begin());
			tmp.x = tmp.getX();
			tmp.type = 0;
			tmp.time = i;
			rp.erase(rp.begin());
			lp.insert(tmp);
			rp.insert(S(l[i], 1, i));
			rp.insert(S(l[i], 1, i));
		}else{
			ans += (getLast(lp) - l[i]);
			auto it = lp.end();
			--it;
			S tmp = (*it);
			tmp.x = tmp.getX();
			tmp.type = 1;
			tmp.time = i;
			lp.erase(it);
			rp.insert(tmp);
			lp.insert(S(l[i], 0, i));
			lp.insert(S(l[i], 0, i));
		}
	}

	cout << ans << endl;
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();

	return 0;
}

Measured memory_bytes: 14336