akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define inf 1e16
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define M 1000010

int main(){
	IOS;
	int a;cin>>a;
	string s;cin>>s;
	if(a<3200)cout<<"red";
	else cout<<s;
	
	return 0;
}



Measured memory_bytes: 256
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//                       _oo0oo_                         //
//                      o8888888o                        //
//                      88" . "88      ------ hzt1       //
//                      (| -_- |)                        //
//                      0\  =  /0                        //
//                    ___/`---'\___                      //
//                  .' \|     |// '.                     //
//                 / \|||  :  |||// \                    //
//                / _||||| -:- |||||- \                  //
//               |   | \  -  /// |     |                 //
//               | \_|  ''\---/''  |_/ |                 //
//               \  .-\__  '-'  ___/-. /                 //
//             ___'. .'  /--.--\  `. .'___               //
//          ."" '<  `.___\_<|>_/___.' >' "".             //
//         | | :  `- \`.;`\ _ /`;.`/ - ` : | |           //
//         \  \ `_.   \_ __\ /__ _/   .-` /  /           //
//     =====`-.____`.___ \_____/___.-`___.-'=====        //
//                       `=---='                         //
//                                                       //
//                                                       //
//     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~       //
//                                                       //
//                 God-He Bless All.                     //
//           This Code Will Never Explode.               //
//                                                       //
//                                                       //
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#include<vector>
#define pb push_back
#define mp make_pair
#define xx first
#define yy second
#define rep(i,a,b) for(int i=(a),i##_end_=(b);i<=i##_end_;i++)
#define dwn(i,a,b) for(int i=(a),i##_end_=(b);i>=i##_end_;i--)
using namespace std;
const int Size=1<<16;
char buffer[Size],*head,*tail;
inline char Getchar() {
    if(head==tail) {
        int l=fread(buffer,1,Size,stdin);
        tail=(head=buffer)+l;
    }
    if(head==tail) return -1;
    return *head++;
}
inline int read() {
    int x=0,f=1;char c=getchar();
    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=getchar()) x=x*10+c-'0';
    return x*f;
}
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=100010;
int n;
double d,x,ans;
int main() {
	n=read();d=read();x=read();	
	while(n) {
		ans+=(2*n-1)*0.5*x+d;
		d+=d/n+(0.5/n-1)*x;
		x+=x/n*2;
		d+=x;
		n--;
	}
	printf("%.12lf\n",ans);
	return 0;
}


Measured memory_bytes: 128
alpha = [str(chr(i)) for i in range(97,97+26)]

def main():
    S = list(raw_input())
    if S[0] != 'A':
        return 'WA'
    S.remove('A')
    flag = True
    for i in S[1:-1]:
        if i == 'C':
            flag = False
            S.remove('C')
            break;
    if flag:
        return 'WA'
    for i in S:
        if i not in alpha:
            return 'WA'
    return 'AC'

print main()

Measured memory_bytes: 2568
import math
from typing import List


def calc_divisors(n):
    divisors = [1, n]

    for i in range(2, int(math.sqrt(n))+1):
        if n % i == 0:
            divisors.append(i)
            divisors.append(n // i)

    return sorted(divisors)


def prime_factorize(n: int) ->List[int]:
    prime_factors = []
    divisors = calc_divisors(n)[1:]

    for i in divisors:
        while True:
            div, mod = divmod(n, i)
            if mod == 0:
                prime_factors.append(i)
                n = div
            else:
                break
        if n == 1:
            break
    return prime_factors


def main():
    n = int(input())
    prime_factors = prime_factorize(n)
    print("{}: {}".format(n, ' '.join(map(str, prime_factors))))


main()


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

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

void solve() {

    ll a;
    cin >> a;

    cout << a + (a * a) + (a * a * a) << "\n";

}

int main()
{
    fastio;
    // T
    solve();
    //code
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;


ll  f(ll H){//攻撃回数をかぞえる再帰関数fを用意
if (H ==1){
    return 1;
}
else {
    return 2*f(floor(H/2))+1;
}
}
int main()
{
ll H;

    
  
    cin >> H;
  
    cout << f(H) << endl;
  
 
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
int N;
char arr[101];
using namespace std;
int main()
{
	cin >> N>>arr;
	int i;
	int a = 0;
	for (i = 0; i < N - 2; i++)
	{
		if (arr[i] == 'A' && arr[i + 1] == 'B' && arr[i + 2] == 'C')
			a++;
	}
	cout << a;
}

Measured memory_bytes: 256
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	ll N; cin >> N;
	vector<pair<ll, ll> > v(N);
	rep(i, N){
		ll a, b; cin >> a >> b;
		v[i] = {a, b};
	}

	sort(ALL(v));

	pair<ll, ll> p = v[v.size()-1];
	cout << p.first + p.second << endl;

	return 0;
}


Measured memory_bytes: 4796
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a=0,n,x[1005],y[1005];
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x[i]>>y[i];
		a=a+(y[i]-x[i]+1);
	}
	cout<<a<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
int main(){
    int n,m,x;
    cin>>n>>m>>x;
    vector<int> a(m);
    rep(i,m){
        cin>>a[i];
    }
    int le=0,ri=0;
    rep(i,m){
        if(a[i]<x){
            le++;
        }
        else{
            ri++;
        }
    }
    cout<<min(le,ri)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;

const int MN = 2e5+5;
const int MOD = 1e9+7;
const int INF = 1e9;

bool ask(ll N)
{
	cout << "? " << N << "\n";
	fflush(stdin);
	char c;
	cin >> c;
	return c=='Y';
}

int main()
{
    //ios_base::sync_with_stdio(0),cin.tie(0);
    ll t[10];
    t[0] = 1;
    int X = 1;
    for(int i=1; i<=9; i++) t[i] = t[i-1]*10;
    for(int i=1; i<=9; i++){
    	if(ask(t[i])) X++;
    	else break;
    }
    if(X==10){
        for(int i=8; i>=0; i--){
            if(ask(t[i]+1)) continue;
            cout << "! " << t[i+1];
            exit(0);
        }
        cout << "! " << 1;
        exit(0);
    }
    int ans = 0;
    for(int i=X-1; i>=0; i--){
    	int s=0, e=9;
    	if(i==X-1) s = 1;
    	while(s<e){
    		int m = (s+e+1)/2;
    		if(ask((t[i]*m+ans)*10-1)) e = m-1;
    		else s = m;
    	}
    	ans += s*t[i];
    }
    cout << "! " << ans << '\n';
}


Measured memory_bytes: 596
s = int(input())

def f(n):
    if n%2 == 0:
        return n//2
    else:
        return n*3+1

A = [s]
ans = 1

while True:
    ans += 1
    num = f(A[-1])
    if num in A:
        print(ans)
        break
    else:
        A.append(num)


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

using namespace std;

typedef long long ll;

#define newline cout<<"\n"
#define deb(x) cout<<#x<<" "<<x<<endl;

template<typename... T>
void read(T&... args){
    ((cin>>args), ...);
}

template<typename... T>
void write(T... args){
    ((cout<<args<<" "), ...);
}

void printarr(vector<int> &v){
    for(int x: v){
        cout<<x<<" ";
    }
    newline;
}

const int MOD = 1e9+7;
const int nax = 1e7+7;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    
    int n, q; cin>>n>>q;
    string s; cin>>s;

    vector<int> v(n, 0);

    for(int i=1; i<n; i++){
        if(s[i]=='C'){
            if(s[i-1]=='A'){
                v[i]=1;
            }
        }
    }

    for(int i=1; i<n; i++){
        v[i]+=v[i-1];
    }

    // printarr(v);

    int l, r;

    while(q--){
        cin>>l>>r;
        l--;r--;
        cout<<v[r]-v[l]<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3852
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int h,w;
  cin >> h >> w;
  string s[h];
  rep(i,h) cin >> s[i];
  int dw[4] ={1,0,-1,0};
  int dh[4] ={0,1,0,-1};
  int ans=0;
  
  rep(shi,h)rep(swi,w){//st
      if(s[shi][swi]=='#') continue;
      queue<tuple<int,int,int> > qu;
      int dp[h][w];
      rep(i,h)rep(j,w)dp[i][j]=INT_MAX/4;

      qu.push(make_tuple(shi,swi,0));
      while(!qu.empty()){
	auto tu=qu.front();qu.pop();
	int hi = get<0>(tu);
	int wi = get<1>(tu);
	int dist = get<2>(tu);
	if(dp[hi][wi]<=dist) continue;
	dp[hi][wi]=dist;
	rep(di,4){
	  int nh=hi+dh[di];
	  int nw=wi+dw[di];
	  //  cout << nh << " " << nw << endl;
	  if(nh>=0 && nw>=0 && nh<h && nw<w && s[nh][nw]!='#'){

	    if(dp[nh][nw]>dist+1){

	      qu.push(make_tuple(nh,nw,dist+1));	      
	    }
	  }
	}
      }
      rep(ehi,h)rep(ewi,w){
	if(dp[ehi][ewi]!=INT_MAX/4) ans = max(ans,dp[ehi][ewi]);
      }
      //      cout << "ans hi wi " << ans << " "<< shi << " " << swi << endl;
  }
  cout << ans << endl;
  



  
  return 0;
    

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define MAX 20000005
#define fastcin  ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;


int n, m, x;
int cost[15], v[15][15], a[15];
int ans;
	
void solve(int i, int sum){
	
	if(i > n){
		bool f = true;
		for(int j=0; j<m; j++){
			if(a[j] < x){
				f = false;
				break;
			}
		}
		if(f) ans = min(ans, sum);
		return;	
	}
	
	for(int j=0; j<m; j++) a[j]+= v[i][j];
	solve(i+1, sum+cost[i]);
	
	for(int j=0; j<m; j++) a[j] -= v[i][j];
	solve(i+1, sum);
	
	return;
}

int main(){

	fastcin
	
	cin >> n >> m >> x;
	
	for(int i=0; i<n; i++){
		cin >> cost[i];
		for(int j=0; j<m; j++) cin >> v[i][j];
	}
	
	ans = MAX;
	solve(0, 0);	
	
	if(ans != MAX) cout << ans << endl;
	else cout << -1 << endl;
	
	return 0;
}
	



Measured memory_bytes: 3656
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);


    int H, W;
    cin >> H >> W;

    int K;
    cin >> K;

    vector<string> M(H);
    for (int i = 0; i < H; ++i) {
        cin >> M[i];
    }

    vector<pair<int,int>> blacks;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (M[i][j] == '#') {
                blacks.emplace_back(i, j);
            }
        }
    }

    vector<bool> HF(H, false);
    vector<bool> WF(W, false);

    auto ok = [&] (int I, int J) {
        int res = 0;
        fill(HF.begin(), HF.end(), false);
        fill(WF.begin(), WF.end(), false);
        for (int i = 0; i < H; ++i) {
            if ((I >> i) & 1) {
                HF[i] = true;
            }
        }
        for (int j = 0; j < W; ++j) {
            if ((J >> j) & 1) {
                WF[j] = true;
            }
        }

        for (auto& p : blacks) {
            int x = p.first, y = p.second;
            if (!HF[x] && !WF[y]) {
                ++res;
            }
        }
        return res;
    };

    int res = 0;
    for (int i = 0; i < (1 << H); ++i) {
        for (int j = 0; j < (1 << W); ++j) {
            if (ok(i, j) == K) {
                ++res;
            }
        }
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;
typedef long long LL;
const int N = 1e5+100, M = 2*N,mod = 1e9+7;

LL dp[N][2];  //0是黑色， 1是白色
int n;
int h[N],e[M],ne[M],idx;

void add(int a,int b){
    e[idx] = b, ne[idx] = h[a],h[a] = idx++;
}

void dfs(int u,int fa = 0){   //，fa是u的父节点
    dp[u][0] = dp[u][1] = 1;
    for(int i = h[u]; ~i; i = ne[i]){
        int j = e[i];
        if(fa == j) continue;  //防止绕圈
        dfs(j,u);
        dp[u][0] = (dp[u][0] * dp[j][1])%mod;
        dp[u][1] = (dp[u][1] * (dp[j][0] + dp[j][1])%mod)%mod;
    }
    
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n;
    memset(h,-1,sizeof h);
    for(int i = 0; i<n-1; i++){
        int a,b;
        cin>>a>>b;
        add(a,b);
        add(b,a);
    }
    
    dfs(1);
    LL ans = (dp[1][0] + dp[1][1])%mod;
    
    cout<<ans;
    return 0;
}

Measured memory_bytes: 12056
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        String s = sc.next();
        int junni = 1;
        int bjunni = 1;
        int noCnt = 0;

        for (int i = 1; i < n + 1; i++) {
            String si = String.valueOf(s.charAt(i - 1));
            junni = i - noCnt;
            if (junni > a + b) {
                System.out.println("No");
                continue;
            }
            if ("a".equals(si)) {
                System.out.println("Yes");
                continue;
            }
            if ("b".equals(si) && bjunni <= b) {
                System.out.println("Yes");
                bjunni++;
                continue;
            }
            System.out.println("No");
            noCnt++;
        }

        sc.close();
    }
}

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

int main()
{
    int a, b, c, d;
    cin>>a>>b>>c>>d;

    if((a+b) == (c+d))
        cout<<"Balanced";
    else if((a+b) > (c+d))
        cout<<"Left";
    else if((a+b) < (c+d))
        cout<<"Right";
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long a[100001];

int main() {
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;

    for (int i = 1; i <= n; i++)
        cin >> a[i];

    long long ans = 0;
    for (int i = 1; i <= n+1; i++)
        ans += abs(a[i] - a[i-1]);

    for (int i = 1; i <= n; i++)
        cout << ans - abs(a[i] - a[i-1]) - abs(a[i] - a[i+1])
            + abs(a[i+1] - a[i-1]) << endl;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define READ freopen("in.txt","r",stdin)
#define WRITE freopen("out.txt","w",stdout);
#define pb push_back
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define sf(x) scanf("%d",&x)
#define sf2(x,y) scanf("%d %d",&x,&y)
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sl2(x,y) scanf("%lld %lld",&x,&y)
#define sl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sd(x) scanf("%lf",&x);
#define pii pair<int,int>
#define pLL pair<long long,long long>
#define pDB pair<double,double>
#define ff first
#define sn second
#define PRINT_CASE  printf("Case %d: ",tc++)
#define PRINT_CASENL  printf("Case %d:\n",tc++)
#define mx 100005
#define lnd tree[ind<<1]
#define rnd tree[(ind<<1)+1]
#define cnd tree[ind]
#define lndp b,(b+e)>>1,(ind<<1)
#define rndp ((b+e)>>1)+1,e,(ind<<1)+1
#define IN(a,x,y) (a>=x && a<=y)
#define popcountL __builtin_popcountll
#define popcount __builtin_popcount
/// int other=mask^((1<<n)-1);
typedef long long ll;
typedef long long int lln;
ll INF=1<<28;
//typedef long long lld;
const double pi=acos(-1.0);
int fx[]={1,-1,0,0}; //direction array
int fy[]={0,0,1,-1};
int dir[4][2]={1,0,-1,0,0,-1,0,1};
const long double EPS=1e-7;
//#define INF 10000
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/gcd(a,b)*b;
}
//struct compare
//{
//  bool operator()(const int& l, const int& r)
//  {
//      return l>r;
//  }
//};

bool cmp(int a, int b)
{
    return a<b;
}
int on(int mask,int st)
{
    return mask|(1<<st);
}
int off(int mask,int st)
{
    return mask&(~(1<<st));
}
bool check(int mask,int st)
{
    return mask&(1<<st);
}
ll inf=1e18;
ll mod=1e9+7;
//ll mod=993344777;
const int sz=300005;

int main(void)
{
//    READ;
    int n,k;
    sf2(n,k);
    n=(n+1)/2;
    if(n>=k)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}


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

#define ALL(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0, __##i##_length = (n); i < __##i##_length; i++)
#define rep_reverse(i, n) for (ll i = (n)-1; 0 <= i; i--)
#define FOR(i, from, to) for (ll i = (from), __##i##_end = (to); i < __##i##_end; i++)
#define FOR_REVERSE(i, from, to) for (ll i = (to)-1, __##i##_end = (from); __##i##_end <= i; i--)
#define foreach(e, v) for (const auto e : (v))
#define vfree(v) std::vector<int>().swap(v)
#define DEBUG(x) cout << #x << " = " << (x) << endl

using namespace std;
typedef int64_t ll;
typedef vector<ll> llv;
typedef vector<llv> llvv;
constexpr ll ll_max = numeric_limits<ll>::max();

int main()
{
  ll N, H;
  cin >> N >> H;
  llv A(N);
  llv B(N);
  rep(i, N)
  {
    cin >> A[i] >> B[i];
  }

  ll a = -1000;
  rep(i, N) if (a < A[i])
      a = A[i];
  sort(ALL(B));
  auto b = B.rbegin();
  ll cnt = 0;
  while (b != B.rend() && 0 < H && a < *b)
  {
    H -= *(b++);
    cnt++;
  }

  cout << cnt + ((max(H,ll(0)) + a - 1) / a) << endl;

  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
	int n;
	int v;
	int i,j;
	int s,d;
	int A[1000]={0};
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>A[i];
	}
	for(i=1;i<=n;i++){
		v=A[i];
		j=i-1;
		while(j>=0&&A[j]>v){
			A[j+1]=A[j];
			j--;
			A[j+1]=v;
		}
		for(s=1;s<=n;s++){
			cout<<A[s];
			if(s<n){
				cout<<" ";
			}
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3096
x = input()
list = x.split()
list_i = [float(s) for s in list]

p1x = list_i[0]
p1y = list_i[1]
p2x = list_i[2]
p2y = list_i[3]

kyori1 = p2x - p1x
kyori2 = p2y - p1y
kyori3 = kyori1 ** 2 + kyori2 ** 2


ans = kyori3 ** 0.5
ans = float(ans)

print(ans)


Measured memory_bytes: 5628
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
double add(double a,double b)
{
	if(abs(a+b)<eps*(abs(a)+abs(b)))return 0;
	return a+b;
}

struct P
{
	double x,y;
	P() {}
	P(double x,double y) : x(x),y(y){}
	P operator + (P p)
	{
		return P(add(x,p.x),add(y,p.y));
	}
	P operator - (P p)
	{
		return P(add(x,-p.x),add(y,-p.y));
	}
	P operator * (double d)
	{
		return P(x*d,y*d);
	}
	double dot(P p)
	{
		return add(x*p.x,y*p.y);
	}
	double det(P p)
	{
		return add(x*p.y,-y*p.x);
	}
	double len()
	{
		return sqrt(x*x+y*y);
	}
};
double dist(P a,P b)
{
	return (a-b).len();
}
P A,B,C,I,ab,ai,ah;
double a,b,c,IA,IB,IC,s,r,ra,rb,rc;
int main()
{
	while(1)
	{
		scanf("%lf %lf %lf %lf %lf %lf",&A.x,&A.y,&B.x,&B.y,&C.x,&C.y);
		if(A.x+A.y+B.x+B.y+C.x+C.y==0)break;
		a = dist(B,C); b = dist(A,C); c = dist(A,B);
		s = (a+b+c)/2.0;
		I = (A*a+B*b+C*c)*(1.0/(a+b+c));
		IA = dist(I,A); IB = dist(I,B); IC = dist(I,C);
		ab = B-A; ai = I-A;
		ah = ab*(ab.dot(ai)/ab.len()/ab.len());
		r = (ai-ah).len();
		ra = r*(s-r-(IB+IC-IA))/2.0/(s-a);
		rb = r*(s-r-(IC+IA-IB))/2.0/(s-b);
		rc = r*(s-r-(IA+IB-IC))/2.0/(s-c);
		printf("%f %f %f\n",ra,rb,rc);
	}
	return 0;
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
using namespace std;
inline int_fast64_t read(){int_fast64_t x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
inline string read_s(){string s="";char c=getchar();while(c<'!'||c>'~'){c=getchar();}while(c>='!'&&c<='~'){s+=c;c=getchar();}return s;}
void Main(){
    int N = read();
    vector<int> A(N), B(N, 0);
    for (auto& a:A) {
        a = read();
    }
    for (int i = N-1; i >= 0; i--) {
        for (int j = i*2+1; j<N; j += i+1) {
            B[i] += B[j];
        }
        B[i] %= 2;
        B[i] = B[i] != A[i] ? 1 : 0;
    }
    int sum = accumulate(B.begin(), B.end(), 0), tmp;
    tmp = sum;
    printf("%d\n", sum);
    for (int i = 0; i<N; i++) {
        if (B[i]) {
            printf("%d", i+1);
            if (--tmp) printf(" ");
        }
    }
    if (sum) printf("\n");
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

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

int main(){
    string S;
    cin >> S;
    int result = 0 ;
    for(int i=0; i < S.length(); i++){
        if (S[i] == '+'){
            result++;
        }
        else if(S[i] == '-'){
            result--;
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 3580
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 1; i <= 9; ++i)
            {
                for (int j = 1; j <= 9; ++j)
                {
                    Console.WriteLine(i + "x" + j + "=" + (i * j));
                }
            }
        }
    }
}

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

using ll = long long;

ll f(ll b, ll n) {
	if (n < b) return n;
	return f(b, n / b) + n % b;
}

int main() {
	ll n, s;
	cin >> n >> s;

	for (ll b = 2; b * b <= n; b++) {
		if (f(b, n) == s) {
			cout << b << endl;
			return 0;
		}
	}

	ll ans = n == s ? (s + 1) : -1;
	for (ll x = 1; x * x <= n - s; x++) {
		if ((n - s) % x != 0) continue;

		ll b = (n - s) / x + 1,
		   y = s - x;

		if (1 <= x and x < b and 0 <= y and y < b) {
			ans = ans < 0 ? b : min(ans, b);
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


def main():
    h,w = mi()

    if(h==1 or w==1):
        print(1)
    elif h%2 ==0:
        print((h//2) *w)
    elif w%2 ==0:
        print((w//2) *h)
    
    else:
        ans = (h-1)*(w-1)//2 + (h//2) + (w//2) +1
        print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long   // aaaaaaaaaaaaaaaaaa
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define SIZE(buff) (sizeof(buff)/sizeof(buff[0]))
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<pair<int,int>> VPII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
void chmin(int64_t& a, int64_t b){
    a = min(a, b);
}
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
template<typename T, typename U>ostream& operator << (ostream& os, pair<T, U>& pair_var)
{os << "(" << pair_var.first << ", " << pair_var.second << ")";return os;}
// head
int q,m,n,k,res,tmp,tmp2,tmp3;
int a[100001] = {};
int b[100010] = {};
int ans[100010] = {};
deque<PII> que;
string s;

#define N 100008
class BIT {
  int n;
  ll data[N];

public:
  BIT(int n) : n(n) {
    for(int i = 0; i < n+2; ++i) data[i] = 0;
  }
  void add(int k, ll x) {
    while(k <= n) {
      data[k] += x;
      k += k & -k;
    }
  }

  ll get(int k) {
    ll s = 0;
    while(k) {
      s += data[k];
      k -= k & -k;
    }
    return s;
  }
};

signed main() {
	cin.tie(0);
    ios::sync_with_stdio(false);
	std::cin >>n;
  int sum = 0;
	rep(i,0,n){
		cin>>a[i];
    sum += a[i];
	}
  BIT bit(n);
  BIT bit2(n);
  VPII c;
	rep(i,0,n){
		c.pb({a[i],i+1});
	}
  sort(allr(c)); 
  rep(i,0,n){
    PII d = c[i];
    b[d.se-1] =   bit.get(n) - bit.get(d.se) -(bit2.get(n) - bit2.get(d.se))*d.fi;
    bit.add(d.se,d.fi);
    bit2.add(d.se,1);
  }
  rep(i,0,n){
    if(b[i] == 0){ans[i] = sum; break;}
    if (sum > b[i]) {ans[i] = sum - b[i]; sum = b[i];}
  }
  rep(i,0,n) cout<<ans[i]<<endl;
}

Measured memory_bytes: 6768
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
  ll h,w;
  cin >> h >> w;
  
  if( h==1 || w == 1) cout << 1;
  else if( (h%2 != 0) && (w%2 != 0) ) cout << (h*w+1)/2;
  else cout << h*w/2;
}


Measured memory_bytes: 256
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (k : _) <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    ls = iterate nextLunlun [] :: [[Int]]
    l = map unsafeDigitToChar . reverse . head . drop k $ ls :: String
  putStrLn l

nextLunlun :: [Int] -> [Int]
nextLunlun [] = [1]
nextLunlun (d : []) | d < 9     = [succ d]
nextLunlun (d : ds@(d' : _)) | d < d' || d == d' && d' < 9 = succ d : ds
nextLunlun (_ : ds) | d' == 0   = 0 : ds'
                    | otherwise = pred d' : ds'
  where
    ds'@(d' : _) = nextLunlun ds

unsafeDigitToChar :: Int -> Char
unsafeDigitToChar = toEnum . (+ 48)

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 9596
n,a,b=map(int,input().split())
tmp=list(map(int,input().split()))
x0=tmp[0]
x=[i-x0 for i in tmp]
ans=0
for i in range(n-1):
    if (x[i+1]-x[i])*a<=b:
        ans+=(x[i+1]-x[i])*a
    else:
        ans+=b

print(ans)

Measured memory_bytes: 63596
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <sstream>
using namespace std;

#define REP(i,a,n) for(i=a; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define foreach(it,x) for(typeof(x.begin()) it=x.begin(); it!=x.end(); it++)

int parse(string s){
    int i,j,x;
    int n = s.length();

    //cout << s << endl;

    x = 0;
    for(i=n-1; i>=0; i--){
        if( s[i] == '(' ) x++;
        if( s[i] == ')' ) x--;
        if( x == 0 && (s[i] == '+' || s[i] == '-') ) break;
    }

    if( i == -1 ){
        x = 0;
        for(i=n-1; i>=0; i--){
            if( s[i] == '(' ) x++;
            if( s[i] == ')' ) x--;
            if( x == 0 && (s[i] == '*' || s[i] == '/') ) break;
        }
    }

    if( i == -1 ){
        for(j=0; j<n; j++) if( !('0' <= s[j] && s[j] <= '9') ) break;
        if( j == n ){ // number
            return atoi(s.c_str());
        }
        // ()
        return parse(s.substr(1,s.length()-2));
    }
    else{
        int a = parse(s.substr(0,i)), b = parse(s.substr(i+1));
        switch(s[i]){
        case '+': return a + b;
        case '-': return a - b;
        case '*': return a * b;
        case '/': return a / b;
        }
    }
}

int main(){
    int T;
    string in;

    cin >> T;
    while( T-- ){
        cin >> in;
        cout << parse(in.substr(0,in.length()-1)) << endl;
    }

    return 0;
}

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

long result=0;

void dfs(string s,int pos,long sum){
  int length=s.size();
  long num;
  string tmp;
  for(int i=pos+1;i<=length;i++){
    tmp=s.substr(pos,i-pos);
    num=strtol(tmp.c_str(),0,10);
    dfs(s,i,sum+num);
  }
  if(pos==length){
    result+=sum;
  }
}

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

  cin>>s;
  
  dfs(s,0,0);

  cout<<result<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <string>
#include <map>


#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;


int main(void){

double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
	while(!cin.eof()){
		cin >> xa1 >> ya1 >> xa2 >> ya2;
		cin >> xb1 >> yb1 >> xb2 >> yb2;
		if( cin.eof()  ) break;
		
		string ans = "YES";
		if(xa1>xb2 || ya1>yb2 || xa2<xb1 || ya2<yb1) ans = "NO";
		
		cout << ans << endl;
	}
	return 0;
	
	
}

Measured memory_bytes: 1224
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""

n,k = m()

a = l()

a.sort()

mina = []

pra = []

for i in range(len(a)):
	if a[i] >= 0:
		pra.append(a[i])
	else:
		mina.append(a[i])

lp = len(pra)

lm = len(mina)
ans = 1
if lp == 0:
	if k % 2 != 0:
		for i in range(0,k,2):
			if i == k-1:
				i = -(1+i)
				ans *= mina[i]
			else:
				i = -(1+i)
				ans *= (mina[i]*mina[i-1]) % mod
			ans %= mod
		print(ans % mod)
	else:
		for i in range(0,k,2):
			ans *= (mina[i]*mina[i+1]) % mod
			ans %= mod
		print(ans % mod)
elif lp == 1:
	if n == k:
		ans *= pra[0]
		for i in range(0,lm,2):
			if i == lm-1:
				i = -(1+i)
				ans *= mina[i]
			else:
				i = -(1+i)
				ans *= (mina[i]*mina[i-1]) % mod
			ans %= mod
		print(ans % mod)
	else:
		if k % 2 == 0:
			for i in range(0,k,2):
				ans *= (mina[i]*mina[i+1]) % mod
				ans %=  mod
			print(ans % mod)
		else:
			ans *= pra[0] 
			for i in range(0,k-1,2):
				ans *= (mina[i]*mina[i+1]) % mod
				ans %=  mod
			print(ans % mod)
else:
	cp = lp-1
	cm = 0
	
	for _ in range(k):
		if cp != -1 and cm != lm:
			if abs(mina[cm]) <= pra[cp]:
				if cp == 0:
					if (k-lp) % 2 == 0:
						cp -= 1
					else:
						cm += 1
				else:
					cp -= 1
			else:
				if cm == lm-1:
					if lm % 2 == 0:
						cm += 1
					else:
						cp -= 1
				else:
					
					cm += 1
		elif cp != -1:
			cp -= 1
		elif cm != lm:
			cm += 1
			
		else:
			break
	if cm % 2 != 0:
		if cp == lp-1:
			cp -= 1
			cm -= 1

		else:
			if cp != -1 and cm != lm:
				if pra[cp]*pra[cp+1] <= -mina[cm]*-mina[cm-1]:
					cp += 1
					cm += 1
				else:
					cp -= 1
					cm -= 1
			elif cp != -1:
				cp -= 1
				cm -= 1
			elif cm != lm:
				cp += 1
				cm += 1

	ii = -2
	for i in range(0,cm,2):
		if i == cm-1:
			ii = i
			continue
		ans *= (mina[i] * mina[i+1]) % mod
		ans %= mod
	for i in range(lp-1,cp,-1):
		ans *= pra[i] % mod
		ans %= mod
	if ii == cm-1:
		ans *= mina[ii]
		ans %= mod

		
	print(ans)






Measured memory_bytes: 104700
from collections import deque
H,W=map(int,input().split())
S=[input() for i in range(H)]
ans=0
for i in range(H):
    for j in range(W):
        if S[i][j]=="#":
            continue
        st=(i,j)
        q=deque([st])
        dx=[1,-1,0,0]
        dy=[0,0,1,-1]
        dist=[[-1 for j in range(W)] for i in range(H)]
        dist[st[0]][st[1]]=0
        while(len(q)>0):
            r=q.popleft()
            x,y=r
            for k in range(4):
                nx=x+dx[k]
                ny=y+dy[k]
                if 0<=nx<H and 0<=ny<W:
                    if dist[nx][ny]==-1 and S[nx][ny]==".":
                        dist[nx][ny]=dist[x][y]+1
                        q.append((nx,ny))
        tmp=max([max(i) for i in dist])
        ans=max(tmp,ans)
print(ans)


Measured memory_bytes: 47964
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
int main() {
	char a[55][55] = {};
	ll dx[8] = { 1,1,0,-1,-1,-1,0,1 }, dy[8] = { 0,1,1,1,0,-1,-1,-1 }, h, w;
	cin >> h >> w;
	ll cnt = 0;
	for (int i = 1; i <= h; i++)for (int j = 1; j <= w; j++)cin >> a[i][j];
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			if (a[i][j] == '.') {
				for (int k = 0; k < 8; k++) {
					if (a[i + dx[k]][j + dy[k]] == '#')cnt++;
				}
				cout << cnt;
				cnt = 0;
			}
			else cout << '#';
		}
		cout << endl;
	}
	return 0;
}

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

bool isSettable(vector<pair<int,int>> queens , pair<int,int>nextpos){
  rep(i, queens.size()){
    if(queens[i].first == nextpos.first || queens[i].second == nextpos.second) return false;
    if(abs(queens[i].first-nextpos.first)==abs(queens[i].second-nextpos.second)) return false;
  }
  return true;
}

int main(){
  int k,r,c;
  cin >> k;
  stack<vector<pair<int,int>>> stack;
  vector<pair<int,int>> now;
  vector<pair<int,int>> ans={};
  rep(i,k){
    cin >> r >> c;
    now.push_back(make_pair(r,c));
  }
  stack.push(now);
  while(!stack.empty()){
    now = stack.top(); stack.pop();
    if(now.size()>=8){
      ans=now;
      break;
    }
    rep(i,8)rep(j,8){
      pair<int,int> nextpos = make_pair(i,j);
      if(isSettable(now,nextpos)){
        vector<pair<int,int>> next = now;
        next.push_back(nextpos);
        stack.push(next);
      }
    }
  }

  // rendering
  bool board[8][8];
  rep(i,8)rep(j,8) board[i][j] = false;

  rep(i,ans.size()) board[ans[i].first][ans[i].second] = true;
  rep(i,8){
    rep(j,8){
      cout << ((board[i][j])? "Q":".") ;
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3112
/*input
9
W 3
B 1
B 4
W 1
B 5
W 9
W 2
B 6
W 5
B 3
W 8
B 9
W 7
B 2
B 8
W 4
W 6
B 7
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back

#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)

#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

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

int raise(int a,int n,int m = MOD){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= raise(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

const int N = 2001;
int dp[N][N];
int a[2*N];
int pos[2][N];
int hehe[2*N];
int color[2*N];
int before[2*N][N];
int n;

int whatif(int color,int keepwhere,int placed){
	//cout << color << " " << keepwhere << " " << placed << endl;
	int ind = pos[color][keepwhere];
	int samecolor = hehe[ind];
	int deserve = before[ind][placed];
	//cout << ind << " " << samecolor << " " << deserve << endl;
	return ind-samecolor-deserve-1;
}

void solve(){
  	cin >> n;
  	RE(i,2*n){
  		char o;int x;cin >> o >> x;
  		//cout << (bool)(o == 'B') << " " << x << endl;
  		pos[o == 'B'][x] = i;
  		a[i] = x;
  		color[i] = (o == 'B');
  	}
  //	cout << pos[1][1] << endl;
  	int inv = 0;
  	RE(i,2*n){
  		RE(j,i-1){
  			if(color[j] == color[i]){
  				inv += a[i]<a[j];
  				hehe[i]++;
  				continue;
  			}
  			before[i][a[j]] = 1;
  		}
  		RE(j,n){
  			before[i][j] += before[i][j-1];
  		}
  	}
  	dp[0][0] = 0;
  	//dp[1][0] = whatif(0,1,0);
  	//dp[0][1] = whatif(1,1,0);
  	REP(i,n+1){
  		REP(j,n+1){
  			if(i+j == 0)continue;
  			int case1 = INF;
  			int case2 = INF;
  			if(i)case1 = dp[i-1][j]+whatif(0,i,j);
  			if(j)case2 = dp[i][j-1]+whatif(1,j,i);
  			dp[i][j] = min(case1,case2);
  		}
  	}
  	RE(i,n){
  		RE(j,n){
  	//		cout << i << " " << j << " " << dp[i][j] << endl;
  		}
  	}
  	cout << dp[n][n]+inv;
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
  return 0;
}

Measured memory_bytes: 94208
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main()
{
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> ds(n);
    for (auto& d : ds) {
        cin >> d;
    }
    sort(ds.begin(), ds.end());
    auto it = unique(ds.begin(), ds.end());
    cout << distance(ds.begin(), it) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int l=sc.nextInt();
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		int d=sc.nextInt();
		int j=a/c,m=b/d;
		if(a%c!=0)j+=1;
		if(b%d!=0)m+=1;
		if(j>=m)System.out.println(l-j);
		else System.out.println(l-m);
	}
}

Measured memory_bytes: 17180
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define _GLIBCXX_DEBUG
int main()
{
    ll a,b,k;
    cin>>a>>b>>k;
    if(k<=a)cout<<a-k<<' '<<b<<endl;
    else if(a<k&&k<=a+b)cout<<0<<' '<<a+b-k<<endl;
    else if(a+b<k)cout<<0<<' '<<0<<endl;
}

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

int main(){
    int m,d,n=0;
    cin>>m>>d;
    int d1=d/10,d2=d%10;
    for(int i=2;i<d1;i++){
        for(int j=2;j<10;j++){
            for(int k=4;k<=m;k++)
            if(k==i*j)n++;
        }
    }
    for(int j=2;j<=d2;j++){
        for(int k=4;k<=m;k++)
        if(k==d1*j)n++;
    }
    cout<<n<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.1415926535897932
#define _GLIBCXX_DEBUG
#define MOD 1000000007;
using namespace std;
long long GCD(long long A,long long B){
  if(B==0){
    return A;
  }
  else{
    return GCD(B,A%B);
  }
}
long long LCM(long long A,long long B){
  long long g=GCD(A,B);
  return A/g*B;
}
long long num_size(long long X){
  long long ans=0;
  while(true){
    if(X==0){
      break;
    }
    else{
      X/=10;
      ans++;
    }
  }
  return ans;
}
int main() {
  long long A,B,C;
  cin>>A>>B>>C;
  
  if(4*A*B<(C-A-B)*(C-A-B)&&C>A+B){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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

int prime(int n) {
    if (n == 2) return 1;
    if (n % 2 == 0) return 0;
    for (int i = 3; i <= n / i; i += 2) {
        if (n % i == 0) return 0;
    }
    return 1;
}

int main() {

    int C[1000000] = {0};
    for (int i = 2; i < 1000000; ++i) {
        C[i] = prime(i);
    }
    for (int i = 2; i < 1000000; ++i) {
        C[i] += C[i - 1];
    }

    int n;
    while (cin >> n) {
        cout << C[n] << endl;
    }

    return 0;
}

Measured memory_bytes: 5072
h,w=map(int,input().split())
n=int(input())
a=list(map(int,input().split()))
ret=[["0" for i in range(w)]for j in range(h)]
x=0
y=0
for i in range(n):
    for j in range(a[i]):
        ret[y][x]=str(i+1)
        if y&1:
            if x==0:
                y+=1
            else:
                x-=1
        else:
            if x==w-1:
                y+=1
            else:
                x+=1
for i in range(h):
    print(" ".join(ret[i]))

Measured memory_bytes: 3700
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp) % MOD;
  } else {
    return (n * POW(n, m - 1)) % MOD;
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll K;
  cin >> K;
  vector<ll> A(K, 0);
  REP(i, K) cin >> A[i];
  ll m = 2;
  ll M = 2;
  bool ok = true;

  RREP(i, K) {
    if (i == K - 1 && A[i] != 2) {
      ok = false;
      break;
    }
    if (A[i] > m)
      m = A[i];
    else if (A[i] < m) {
      m = (ll)ceil((double)m / A[i]) * A[i];
    }
    M = ((M / A[i]) + 1) * A[i] - 1;
    if (m > M) {
      ok = false;
      break;
    }
    // cout << m << "," << M << endl;
  }
  if (ok) {
    cout << m << " " << M << endl;
  } else {
    cout << -1 << endl;
  }

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
using ll = long long;
 
int main() {
  int d, t, s;
  cin >> d >> t >> s;
  if(d<=t*s) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3628