akhauriyash/Code-Regression huggingface dataset:
//BROWNIE TK

#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;

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

#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()
#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en
#define le length()
#define mp make_pair
#define mt make_tuple
#define F first
#define S second

#define forz(i, n) for (int i = 0; i < n; i++)
#define forzm(i, m, n) for (int i = m; i < n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define rforzm(i, m, n) for (int i = n - 1; i >= m; i--)
#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define oset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define osetlli tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
#define ofk order_of_key
#define fbo find_by_order
using namespace std;

/*STD fucntions*/
lli power(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        //y must be even now
        y = y >> 1; //y=y/2
        x = (x * x) % p;
    }
    return res;
}
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
lli lcm(lli a, lli b)
{
    return a * b / gcd(a, b);
}
lli modi(lli a, lli m)
{
    // fermat little thm where m is prime
    return power(a, m - 2, m);
}
/*CODE BEGINS*/
int main()
{
    kira;
    int a,b;
    cin>>a>>b;
    cout<<max({a+b,a-b,a*b});
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

int X[15][15] = {0};
int Y[15][15] = {0};

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    
    int N;
    cin >> N;
    vector<int> A(N);
    for (int n = 0; n < N; ++n) {
        cin >> A[n];
        for (int a = 0; a < A[n]; ++a) {
            cin >> X[n][a] >> Y[n][a];
            --X[n][a];
        }
    }
    
    int Ret = 0;
    for (int i = 0; i < (1 << N); ++i) {
        bool b = true;
        int Temp = 0;
        for (int n = 0; n < N; ++n) {
            if (i & (1 << n)) {
                ++Temp;
                for (int a = 0; a < A[n]; ++a) {
                    if (Y[n][a] && !(i & (1 << X[n][a]))) {
                        b = false;
                        break;
                    } else if (!Y[n][a] && (i & (1 << X[n][a]))) {
                        b = false;
                        break;
                    }
                }
            }
            if (!b) {
                break;
            }
        }
        if (!b) {
            continue;
        }
        if (Temp > Ret) {
            Ret = Temp;
        }
    }
    cout << Ret << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.nextLine());
		String s = sc.nextLine();
		String[] spl = s.split(" ");
		Integer[] d = new Integer[N];
		for(int i = 0;i < N;i++){
			d[i] = Integer.parseInt(spl[i]);
		}
		sc.close();
		Arrays.sort(d,Collections.reverseOrder());
		System.out.println(d[(N/2) - 1] - d[N/2]);
	}
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
ll n,*dp,*a;

ll func(int i){
	
	if(dp[i]!=-1) return dp[i];
	if(i==0) return (dp[0] = a[i]/2 );
	else if(a[i]%2==0) return (dp[i]= a[i]/2 + func(i-1));
	else {
		if(a[i-1]%2!=0)return (dp[i]=(i>=2)?func(i-2)+(a[i]+a[i-1])/2 :(a[i]+a[i-1])/2 );
		else if(a[i-1]>0) {
			int t=(a[i-1]+a[i])/2;
			a[i-1]=1;
			return (dp[i]=func(i-1)+t);
		}
		else return (dp[i]=func(i-1)+(a[i]+a[i-1])/2);
	}
	//return 0;
}

void solve(){
	dp= new ll[n];
	FOR(i,n)dp[i]=-1;
	a=new ll[n];
	FOR(i,n) cin >> a[i];
	cout << func(n-1);
}

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

	return 0;
}

Measured memory_bytes: 6528
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
//void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll maxn = 100005;
const ll mm = 1e+18;
void solve()
{
    int n,m;
    cin>>n>>m;
    int x=0;
    rep0(i,m){
        int y;
        cin>>y;
        x+=y;
    }
    n-=x;
    if(n<0) n=-1;
    pr(n);
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //srand(time(0));
    //cin>>t;
    for(int _i=1;_i<=t;_i++){
        solve();
        //nx;
    }
    return 0;
}

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

template <class T> using V = vector<T>;

using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;


#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;



int main() {
  
  ll n,k;
    ci(n>>k);
  st s;
    ci(s);
  if(s[k-1]=='A'){
  s[k-1]='a';
  }
  else if(s[k-1]=='B'){
    s[k-1]='b';
  }
  else{
    s[k-1]='c';
  }
co(s);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

const ll MAX_N = 100010;
vec bit(MAX_N,0);
ll sum(ll i){
    ll s = 0;
    while(i > 0){
        s += bit[i];
        i -= i & -i;
    }
    return s;
}
void add(ll i, ll x){
    while(i < MAX_N){
        bit[i] += x;
        i += i & -i;
    }
}

int main() {
    cin>>M>>A;
    ll ans = 0;
    reps(i,1,M+1){
        reps(j,22,A+1){
            ll d1 = j%10, d2 = j/10;
            if((d1 <= 1)) continue;
            if(d1*d2 == i) {
                //cout<<i<<' '<<j<<endl;
                ++ans;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
  int n;
  cin >> n;
  char c;
  bool flag = false;
  for(int i=0;i<n;i++) {
    cin >> c;
    if(c == 'Y') flag = true;
  }
  if(flag) cout << "Four" << endl;
  else cout << "Three" << endl;
}


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

#define dbg if(0)
using namespace std;
#define ll long long

int main(){
    int n;
    int stair[30+1];
    for(int i=0;i<=30;i++){
        stair[i]=0;
    }
    stair[0]=1;
    for(int i=0;i<=30;i++){
        if(i>0)stair[i]+=stair[i-1];
        if(i>1)stair[i]+=stair[i-2];
        if(i>2)stair[i]+=stair[i-3];
    }
    while(1){
        cin >> n;
        if (n==0)break;
        int ans=(stair[n]/10+364)/365;
        if (ans==0)ans++;
        cout <<ans<<endl;
    }

    return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
typedef long long ll;
const ll INF = 1e+18;
int N,M;

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(){
    cin >> N >> M;
    vector<int> A(M),B(M);
    rep(i,M){
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
    }
        
    UnionFind uf(N);
    ll cnt=0;
    ll a,b;
    vector<ll> ans(M);
    for(int i=M-1;i>=0;i--){
        ans[i]=((ll)N*(ll)(N-1))/2-cnt;
        a=uf.size(A[i]);
        b=uf.size(B[i]);
        if(uf.unite(A[i],B[i])) cnt+=a*b;
        
    }   
    rep(i,M) cout << ans[i] << endl;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>

using namespace std;

int main() {
    int X, t;

    cin >> X >> t;

    int ans = X - t;

    if (ans > 0) {
        cout << ans << endl;
    } else if ((ans == 0) || (ans < 0)) {
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){

    int n;
    cin>>n;
    if(n%1000==0){
        cout<<0<<endl;
        return 0;
    }
    cout<<1000-n%1000<<endl;






return 0;
}


Measured memory_bytes: 3616
import math
N,D = map(int,input().split())
X = []
c = 0
s = 0
for i in range(N):
    X.append(list(map(int,input().split()))) 
for l in range(N):
    # print(str(l) + "l")
    if l == N - 1:
        break
    for i in range(l+1,N):
        for j in range(D):
            s += abs(X[l][j] - X[i][j]) ** 2
        s = math.sqrt(s)
        if s % 1 == 0:
            c += 1
        # print(str(i) + "i")
        s = 0

print(c)




Measured memory_bytes: 9268
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    vector<int> v(3, 0);
    int a, b; cin >> a >> b;
    a--, b--;
    v[a] = 1;
    v[b] = 1;
    for(int i = 0; i < v.size(); i++) if(v[i] == 0) cout << i + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=10e9+7;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}

int main(void){
    ll N,total=0;
    cin>>N;
    vector<ll> A(N),C(N-1);
    rep(i,N) cin>>A.at(i);
    rep(i,N) {
        ll x;
        cin>>x;
        total+=x;
    }
    rep(i,N-1) cin>>C.at(i);
    
    rep(i,N-1){
        if(A.at(i+1)-A.at(i)==1) total+=C.at(A.at(i)-1);
    }
    cout<<total<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
// clang-format on

int AB, BC, CA;

int main(void)
{
  cin >> AB >> BC >> CA;
  cout << (AB * BC) / 2 << endl;
  return 0;
}


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

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    
    long long ans = 0;
    int cnt = 0;
    for (int i = 0; i != n; ++i)
    {
        if (s[i] == 'A')
            ++cnt;
        else if (i + 1 < n && s[i] == 'B' && s[i + 1] == 'C')
        {
            ans += cnt;
            ++i;
        }
        else
            cnt = 0;
    }
    
    cout << ans << '\n';
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		switch (a) {
		case 25:
		    System.out.println("Christmas");
		    break;
		case 24:
			System.out.println("Christmas Eve");
		    break;
		case 23:
			System.out.println("Christmas Eve Eve");
		    break;
		case 22:
			System.out.println("Christmas Eve Eve Eve");
		    break;
		default:
		    // 式の値がどのcaseの値とも一致しなかったときの処理
		}
		
	}
}


Measured memory_bytes: 23764
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

int main()
{
	int N, T,t,c;
	cin >> N >> T;
	vector<int> cost;
	for(int i(0);i<N;++i){
		cin >> c >> t;
		if(t <= T){
			cost.push_back(c);
		}
	}
	if(cost.size() == 0){
		cout << "TLE" << endl;
		return 0;
	}
	sort(begin(cost), end(cost));
	cout << cost[0] << endl;
	return 0;
}


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

int main(void) {
  int payment;
  int onecoin;
  int last;
  
  cin >> payment >> onecoin;
  last = payment % 500;
  
  if (last <= onecoin) {
  	cout << "Yes" << endl;
  }
  else {
  	cout << "No" << endl;
  }
}

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

namespace ABC087A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, a, b, c;
            x = int.Parse(Console.ReadLine());
            a = int.Parse(Console.ReadLine());
            b = int.Parse(Console.ReadLine());

            c = (x - a) % b;
            Console.WriteLine(c);
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 13140
(let* ((n (read))
    (l (read))
    (s (make-array n)))

    (dotimes (i n)
        (setf (aref s i) (read))
    )

    (setf s (sort s #'string<))
    
    (dotimes (i n)
        (format t "~(~A~)" (aref s i))
    )
)

Measured memory_bytes: 23756
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip	;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1<<30;
int main(){
	int n,m,h,k;
	while(cin>>n>>m>>h>>k,n){
		vi in(n);
		rep(i,n)cin>>in[i];
		vvi G(h);
		rep(i,m){
			int a,b;
			cin>>a>>b;
			G[b-1].pb(a-1);
		}
		vi t(n),tmp(n);
		vp T;
		rep(i,n)t[i]=i;
		rep(i,h)rep(j,G[i].size()){
//			cout<<i<<" "<<G[i][j]<<endl;
			swap(t[G[i][j]],t[G[i][j]+1]);
			T.pb(pii(t[G[i][j]],t[G[i][j]+1]));
		}
		rep(i,n)tmp[t[i]]=i;
		int out=0;
		rep(i,n)if(t[i]<k)out+=in[i];
		int OUT=out;
		rep(i,m){
			int s=T[i].first,r=T[i].second;
			if(s<k&&r<k||s>=k&&r>=k)continue;
			int sum=OUT;
			if(s<k)sum-=in[tmp[s]];else sum+=in[tmp[s]];
			if(r<k)sum-=in[tmp[r]];else sum+=in[tmp[r]];
			out=min(out,sum);
		}
		cout<<out<<endl;
	}
}

Measured memory_bytes: 2728
n = int(input())

def factorize(n: int) -> list:
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

print(f'{n}:', *(factorize(n)))


Measured memory_bytes: 5608
#include<queue>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MN 210000
using namespace std;

int read_p,read_ca;
inline int read(){
    read_p=0;read_ca=getchar();
    while(read_ca<'0'||read_ca>'9') read_ca=getchar();
    while(read_ca>='0'&&read_ca<='9') read_p=read_p*10+read_ca-48,read_ca=getchar();
    return read_p;
}
struct na{int l,r;}p[MN];
bool cmpl(na a,na b){return a.l==b.l?a.r>b.r:a.l<b.l;}
priority_queue<int,vector<int>,greater<int> > q,_q;
int n,m,mmh;
int main(){
    mmh=n=read();m=read();
    for (int i=1;i<=n;i++) p[i].l=read(),p[i].r=read();
    sort(p+1,p+1+n,cmpl);
    for (int i=1;i<=n;i++)
    if (p[i].l==q.size()) q.push(p[i].r),_q.push(q.top()),q.pop();else q.push(p[i].r),mmh--;
    for (int i=q.size()+1;i<=m&&!_q.empty();i++) if (_q.top()<=i) _q.pop(),mmh--;
    printf("%d\n",mmh);
}

Measured memory_bytes: 3320
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}

ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
	{
		return gcd(b, a % b);
	}
}
int a[100007], pos[100007];
void solve()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		pos[a[i]] = i;
	}
	for (int i = 1; i <= n; i++)
	{
		cout << pos[i] << " ";
	}
}
int main()
{
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

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

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl



int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int ma=min(b,d),mi=max(a,c);
    cout<<max(0,ma-mi)<<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)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int main(){
  int N;
  cin >> N;
  vector<int> d(N);
  set<int> s;
  REP(i, N){
    cin >> d[i];
    s.insert(d[i]);
  }
  cout << s.size() << endl;

  


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll N,A;
    cin >> N >> A;
    vector<ll> x(N);
    rep(i,N){
        cin >> x[i];
    }
    vector<vector<ll> > dp(N + 1, vector<ll>(2552));
    rep(i,N + 1){
        rep(j,2552){
            dp[i][j] = 0;
        }
    }
    dp[0][0] = 1;
    rep(i,N){
        for (ll j = N - 1; j >= 0; j--){
            for (ll k = 0; k <= 2500; k++){
                dp[j + 1][k + x[i]] = (dp[j + 1][k + x[i]] + dp[j][k]);
            }
        }
    }
    ll ans = 0;
    for (ll i = 1; i <= N; i++){
        ans += dp[i][A * i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 4272
N = int(input())
a = []
for x in range(N):
	i = x + 1
	S_i, P_i = input().split()
	a.append([S_i, int(P_i), i])
# print(a)
a = sorted(a, key=lambda x:(x[0],-x[1]))
for review in a:
	print(review[2])


Measured memory_bytes: 38256
// AOJ 1181
// Biased Dice

#include<iostream>
#include<vector>

#define MAX_X 151
#define MAX_Y 151
#define M (MAX_X / 2)



typedef struct dice
{
  int top, front, right, left, back, bottom, z;
}dice;

using namespace std;

void drop(dice d, vector< vector<dice> > &map, int x, int y)
{


  dice dd;
  int zz = d.z, xx = -1, yy = -1;
  for(int i = 6; i >= 4; i--)
    {
      if(d.front == i && map[y - 1][x].z < zz)
	{
	  dd.top = d.back, dd.bottom = d.front;
	  dd.right = d.right, dd.left = d.left;
	  dd.front = d.top, dd.back = d.bottom;
	  dd.z = map[y - 1][x].z;
	  xx = x, yy = y - 1;
	  break;
	}
      else if(d.right == i && map[y][x + 1].z < zz)
	{
	  dd.top = d.left, dd.bottom = d.right;
	  dd.right = d.top, dd.left = d.bottom;
	  dd.front = d.front, dd.back = d.back;
	  dd.z = map[y][x + 1].z;
	  xx = x + 1, yy = y;
	  break;
	}
      else if(d.back == i && map[y + 1][x].z < zz)
	{
	  dd.top = d.front, dd.bottom  = d.back;
	  dd.right = d.right, dd.left = d.left;
	  dd.front = d.bottom, dd.back = d.top;
	  dd.z = map[y + 1][x].z;
	  xx = x, yy = y + 1;
	  break;
	}
      else if(d.left == i && map[y][x - 1].z < zz)
	{
	  dd.top = d.right, dd.bottom = d.left;
	  dd.right = d.bottom, dd.left = d.top;
	  dd.front = d.front, dd.back = d.back;
	  dd.z = map[y][x - 1].z;
	  xx = x - 1, yy = y;
	  break;
	}
    }

  if(xx == -1 && yy == -1)
    {
      d.z++;
      map[y][x] = d;
      return ;
    }
  else
    drop(dd, map, xx, yy);
}

void init(vector< vector<dice> > &map)
{
  for(int i; i < MAX_X; i++)
    {
      for(int j; j < MAX_Y; j++)
	{
	  map[i][j].top = 0, map[i][j].bottom = 0;
	  map[i][j].right = 0, map[i][j].left = 0;
	  map[i][j].front = 0, map[i][j].back = 0;
	  map[i][j].z = 0;
	}
   } 
}



int main(void)
{
  int n;
  
  dice d;
  d.top = 4, d.bottom = 3;
  d.front = 6, d.back = 1;
  d.left = 2, d.right = 5;

  int arr[7][7];
  arr[1][2] = 4, arr[1][3] = 2, arr[1][4] = 5, arr[1][5] = 3;
  arr[2][1] = 3, arr[2][3] = 6, arr[2][4] = 1, arr[2][6] = 4;
  arr[3][1] = 5, arr[3][2] = 1, arr[3][5] = 6, arr[3][6] = 2;
  arr[4][1] = 2, arr[4][2] = 6, arr[4][5] = 1, arr[4][6] = 5;
  arr[5][1] = 4, arr[5][3] = 1, arr[5][4] = 6, arr[5][6] = 3;
  arr[6][2] = 3, arr[6][3] = 5, arr[6][4] = 2, arr[6][5] = 4;

  
  while(cin >> n, n)
    {
      int cnt[7] = {0};
      vector< vector<dice> > map(MAX_X, vector<dice>(MAX_Y));
      init(map);
      for(int i = 0; i < n; i++)
	{
	  int top, front;

	  cin >> top, cin >> front;

	  d.top = top, d.bottom = 7 - d.top;
	  d.right = arr[top][front], d.left = 7 - d.right;
	  d.front = front, d.back = 7 - d.front;

	  d.z = map[M][M].z;

	  drop(d, map, M, M);
	}
      for(int i = 0; i < MAX_X; i++)
	for(int j = 0; j < MAX_Y; j++)
	  cnt[map[i][j].top]++;

      for(int i = 1; i < 6; i++)
	cout << cnt[i] << " ";
      cout << cnt[6] << endl;
    }
  return 0;
}

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

int main(){

int D;
long long G;
cin >> D >> G;

vector<long long>p(D), c(D);
for(int i = 0; i < D; i++){ 
     cin >> p[i] >> c[i];
}

long long cnt = 10000;

for(int i = 0; i < (1 << D); i++){ 
         long long sum = 0;
         long long cnt2 = 0;
         for(int j = 0; j < D; j++){ 
            if(i & (1 << j)) {
                sum += 100 * (j + 1) * p[j] + c[j];
                cnt2 += p[j];
            }  
                 } 

         if(sum >= G) cnt = min(cnt, cnt2);
         else{
             for(int k = D - 1; k >= 0; k--){ 
                  if(i & (1 << k)) continue;
                  for(int l = 0; l < p[k]; l++){ 
                       if(sum >= G) break;
                       sum += 100 * (k + 1);
                       cnt2++;
                  }             
             }
         cnt = min(cnt, cnt2);
         }
}

cout << cnt << endl;
}

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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int count_left = 0;
    stack<char> st;
    for (char c : s) {
        if (c == ')' && !st.empty() && st.top() == '(') {
            st.pop();
            count_left--;
        } else {
            st.push(c);
            if (c == '(') count_left++;
        }
    }
    cout << string(st.size() - count_left, '(') << s << string(count_left, ')') << endl;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<numeric>
#include<vector>
#include<tuple>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
typedef long long ll;
const int MOD = 1e9 + 7;

int N, a[100],ans = 100000000;
int main(void)
{
	cin >> N;
	int mi = 100, ma = -100;
	FOR(i, 0, N) {
		cin >> a[i];
	}
	sort(a, a + N);
	FOR(i, a[0], a[N-1]+1) {
		int sum = 0;
		FOR(k, 0, N) {
			sum += (i - a[k])*(i - a[k]);
		}
		ans = min(sum, ans);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	int xs, xg, ys, yg;
	void run() {
		Scanner sc = new Scanner(System.in);
		xs = ys = 0;
		xg = sc.nextInt();
		yg = sc.nextInt();
		int N = sc.nextInt();
		for(int i = 0; i < N; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			switch(sc.nextInt()) {
			case 1 :
				xs = Math.max(x,xs);
				break;
			case 2 :
				xg = Math.min(x, xg);
				break;
			case 3 :
				ys = Math.max(y, ys);
				break;
			case 4 :
				yg = Math.min(y, yg);
			}
		}
		int area = (xg - xs) * (yg - ys);
		System.out.println(xg-xs < 0 || yg-ys < 0 ? 0 : area);
		sc.close();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 22100
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<map>
#include<queue>
#define For(i,j,k)	for(int i=j;i<=k;++i)
#define Dow(i,j,k)	for(int i=k;i>=j;--i)
#define ll long long
#define inf 1e9
using namespace std;
inline ll read()
{
	ll t=0,f=1;char ya=getchar();
	while(!isdigit(ya))	{if(ya=='-')	f=-1;ya=getchar();}
	while(isdigit(ya))	t=t*10+ya-'0',ya=getchar();
	return t*f;
}
inline void write(ll x){if(x<0)	{putchar('-');write(-x);return;}if(x>=10)	write(x/10);putchar(x%10+'0');}
inline void writeln(ll x){write(x);puts("");}
inline void write_p(ll x){write(x);putchar(' ');}
using namespace std;
int a[300005],b[300005],c[300005],d[300005];
int n,ans;
int main(){
	scanf("%d",&n);
	For(i,1,n)	scanf("%d",&a[i]);
	For(i,1,n)	scanf("%d",&b[i]);
	For(i,0,29){
		int s1=0,s2=0,sum=0;
		For(j,1,n)
			s1^=(a[j]>>i)&1,s2^=(b[j]>>i)&1;
		sum=(s1+s2)*n%2;
		if (i==0){
			ans+=sum;
			continue;
		}
		For(j,1,n)
			c[j]=a[j]&((1<<i)-1);
		For(j,1,n)
			d[j]=b[j]&((1<<i)-1);
		sort(c+1,c+n+1);
		sort(d+1,d+n+1);
		int r=n;
		For(j,1,n)
		{
			for (;d[r]+c[j]>=(1<<i);r--);
			sum^=(n-r)&1;
		}
		ans+=sum<<i;
	}
	printf("%d",ans);
}

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

int32_t f(int32_t n) {
    if (n < 10) {
        return n;
    } else {
        return n % 10 + f(n / 10);
    }
}

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

    int32_t m = 2147483647;
    for (int32_t i = 1; i <= n / 2; i++) {
        int32_t tmp = f(i) + f(n - i);
        if (tmp < m) {
            m = tmp;
        }
    }
    
    cout << m << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  int64_t A = -100000000000;
  vector<vector<int64_t>> memo(N, vector<int64_t>(2)); 
  for (int i = 0; i < N; i++) {
    int64_t X, L;
    cin >> X >> L;
    memo.at(i).at(0) = X + L;
    memo.at(i).at(1) = X - L;
    A = max(A, memo.at(i).at(1));
  }
  sort(memo.begin(), memo.end());
  int ans = 1;
  int64_t G = memo.at(0).at(0);
  for (int i = 0; i < N; i++) {
    if (memo.at(i).at(1) >= G) {
      G = memo.at(i).at(0);
      ans++;
    }
  }    
  cout << ans << endl;
}

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

using namespace std;

int main(){
	string n;
	string s;
	int cnt=0;
	cin >> n >> s;
	for(int i=0; i < n.length(); i++){
		if(n[i] != s[i]){
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3924
N=int(input())
W=[input() for _ in range(N)]

ex_list = []
for i in range(N):
    if W[i] in ex_list:
        print('No')
        break
    elif i == 0 or (i > 0 and W[i-1][-1] == W[i][0]):
        ex_list.append(W[i])
        continue
    else:
        print('No')
        break
else:
    print('Yes')

        


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

int main() {
  int N;
  cin >> N;
  int flag=0;
  
  // ここにプログラムを追記
  for(int i=0;i<N;i++){
    string s;
    cin>>s;
    if(s=="Y"){
      flag=1;
      break;
    }
  }
  if(flag==0){
  cout<<"Three"<<endl;
  }else{
    cout<<"Four"<<endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int n;
	while(cin >> n ,n){
		char table[128];
		rep(i,128)table[i] = i;
		rep(i,n){
			char a,b;
			cin >> a >> b;
			table[a] = b;
		}
		int m; cin >> m;
		rep(i,m){
			char c;
			cin >> c;
			putchar(table[c]);
		}
		puts("");
	}
}

Measured memory_bytes: 840
N=int(input())

c=list(input())


#c[1]=c[2]
sta=1
ans=0
for i in range(N):
    if(-sta+N<i):
        break
    if(c[i]=='W'):
        for j in range(sta,N):
            if(-j+N<=i):
                print(ans)
                exit()
                break
            if(c[-j]=='R'):
                temp=c[-j]
                c[-j]=c[i]
                c[i]=temp
                sta=j
                ans=ans+1
                break


print(ans)


Measured memory_bytes: 83040
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;

#define ll long long
#define ull unsigned long long
#define lld long double
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define vt vector
#define vll vt<ll>
#define pll pair<ll,ll>
#define vpll vt<pll>
#define vvll vt<vll>
#define all(v) v.begin(),v.end()
#define FOR(i,n) for(ll i=0;i<n;i++)
#define ffo(i,a,b) for(ll i=a;i<=b;i++)
#define rfo(i,a,b) for(ll i=a;i>=b;i--)
#define space cout<<"\n\n";
#define endl '\n'
template <typename T> using mxpq = priority_queue<T>;
template <typename T> using mnpq = priority_queue<T, vt<T>, greater<T>>;
#define fps(x,y) fixed<<setprecision(y)<<x
#define merg(a,b,c) set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.begin()))
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define go_t int testcases; cin>>testcases; ffo(caseno,1,testcases)

#define ctime auto start = high_resolution_clock::now()
#define etime auto stop = high_resolution_clock::now()
#define ptime auto z1z = duration_cast<microseconds>(stop-start); cout<<"Time elapsed : "<<z1z.count()<<" microseconds\n"

const ll mod = 1e9 + 7;
const ll N = 6e4 + 6;
const ll maxN = 1e5 + 5;
const ll MAX_SIZE = 2e6 + 6;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const double PI = 3.14159265359;

int dx[4] = { -1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
// up, right, down, left
//int dx [] = {+1,-1,+0,+0,-1,-1,+1,+1};///Eight Directions
//int dy [] = {+0,+0,+1,-1,+1,-1,-1,+1};///Eight Directions
//int dx[]={-2,-2,-1,1,-1,1,2,2};///Knight moves
//int dy[]={1,-1,-2,-2,2,2,-1,1};///Knight moves

ll powerM(ll x, ll y, ll M = mod) { // default argument
	ll v = 1; x = x % M; while (y > 0) {if (y & 1)v = (v * x) % M; y = y >> 1; x = (x * x) % M;} return v;
}

ll power(ll x, ll y) {
	ll v = 1; while (y > 0) {if (y & 1)v = v * x; y = y >> 1; x = x * x;} return v;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("in4.txt", "r", stdin);
	freopen("out1.txt", "w", stdout);
#endif
	FIO
	ll n;
	cin >> n;
	if (n == 1) {
		cout << 0;
	}
	else {
		ll tot = powerM(10, n);
		tot -= powerM(9, n);
		tot += mod;
		tot %= mod;
		tot -= powerM(9, n);
		tot += mod;
		tot %= mod;
		tot += powerM(8, n);
		tot %= mod;
		cout << tot << endl;
	}
	return 0;
}


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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    
    if (A == 5 && B == 5 && C == 7) {
        cout << "YES" << endl;
    }
    else if (A == 5 && B == 7 && C == 5) {
        cout << "YES" << endl;
    }
    else if (A == 7 && B == 5 && C == 5) {
        cout << "YES" << endl;
    }
    else cout << "NO";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0 ,-1};
int dp[105][100005] = {};
signed main() {
    int N,W;
    cin >> N >> W;
    for(int i = 1; i <= N; i++) {
        int w,v;
        cin >> w >> v;
        for(int j = 1; j <= W; j++) {
            if(j >= w) {
                dp[i][j] = max(dp[i-1][j],dp[i-1][j-w]+v);
            }
            dp[i][j] = max(dp[i][j],dp[i-1][j]);
        }
    }
    cout << dp[N][W] << endl;
}


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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



void _main() {
        int n; cin >> n;
        vector<int> a(n); cin >> a;
        sort(all(a));
        int sum = accumulate(all(a), 0);
        if (sum % 10 == 0) {
                for (int i = 0; i < n; i++) {
                        if ((sum - a[i]) % 10) {
                                sum -= a[i];
                                break;
                        }
                }
                if (sum % 10 == 0) sum = 0;
        }

        cout << sum;
}




signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int N, K, L;
vector<vi> cGraph;
vector<vi> tGraph;

vi cRep;
vi tRep;

vector<bool> cSeen;
vector<bool> tSeen;

vi cSize;
vi tSize;
vi bSize;

vi tFound;

void cdfs(int cur, int rep) {
	cRep[cur] = rep;
	for (int n : cGraph[cur]) if (!cSeen[n]) {
		cSeen[n] = true;
		cdfs(n, rep);
	}
}

map<int, int> occ;
void tdfs(int cur, int rep) {
	tFound.push_back(cur);
	occ[cRep[cur]]++;
	for (int n : tGraph[cur]) if (!tSeen[n]) {
		tSeen[n] = true;
		tdfs(n, rep);
	}
}
int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N >> K >> L;

	cGraph.resize(N); tGraph.resize(N);
	cRep.resize(N); tRep.resize(N); cSeen.resize(N); tSeen.resize(N); cSize.resize(N); tSize.resize(N); bSize.resize(N);

	F0R(i, K) {
		int a, b; cin >> a >> b; --a; --b;
		cGraph[a].push_back(b);
		cGraph[b].push_back(a);
	}
	F0R(i, L) {
		int a, b; cin >> a >> b; --a; --b;
		tGraph[a].push_back(b);
		tGraph[b].push_back(a);
	}

	F0R(i, N) if (!cSeen[i]) {
		cSeen[i] = true;
		cdfs(i, i);
	}

	F0R(i, N) if (!tSeen[i]) {
		occ = map<int, int> ();
		tFound = vi ();
		tSeen[i] = true;
		tdfs(i, i);
		for (int x : tFound) {
			bSize[x] = occ[cRep[x]];
		}
	}
	F0R(i, N) cout << bSize[i] << " ";
}

Measured memory_bytes: 24588
#![allow(non_snake_case,unused_imports)]
use std::io::Read;
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BinaryHeap;

struct UnionFind{
    P: Vec<usize>,
}

impl UnionFind {
    fn new(n:usize) -> UnionFind{
        UnionFind {P:(0..n).collect()}
    }
    fn get_parent(&mut self,n:usize) -> usize{
        if self.P[n] == n{ return n;}
        let p = self.P[n];
        self.P[n] = self.get_parent(p);
        self.P[n]
    }
    fn is_unite(&mut self,x:usize,y:usize) -> bool{
        self.get_parent(x)==self.get_parent(y)
    }
    fn merge(&mut self,x:usize,y:usize){
        if self.is_unite(x,y) {return;}
        let i = self.get_parent(x);
        let j = self.get_parent(y);
        self.P[j] = i;
    }
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let N:usize = iter.next().unwrap().parse().unwrap();
    let M:usize = iter.next().unwrap().parse().unwrap();
    let P = (0..N).map(|_| iter.next().unwrap().parse::<usize>().unwrap()-1).collect::<Vec<_>>();
    let mut T = UnionFind::new(N);
    for _ in 0..M{
        let x:usize = iter.next().unwrap().parse::<usize>().unwrap() -1;
        let y:usize = iter.next().unwrap().parse::<usize>().unwrap() -1;
        T.merge(x,y);
    }
    let ans = (0..N).filter(|&i| T.is_unite(i,P[i])).collect::<Vec<_>>().len();
    println!("{}",ans);
}

Measured memory_bytes: 10492
import java.util.*;
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 b = 1;
        for(int i=0; i< n; i++) {
            a[i] = sc.nextDouble();
            b = b*a[i];
        }
        double mo = 0;
        for(int j=0; j< n; j++){
            mo += b/a[j];
        }
        System.out.println(b/mo);

    }
}


Measured memory_bytes: 23252
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>
#include <vector>
#include <iomanip>

using namespace std;

int main(void) {
  int M, D;
  cin >> M >> D;
  int c = 0;
  for (int i = 1; i <= D; i++) {
    if ((i / 10) < 2 || (i % 10) < 2) {
      continue;
    }
    if ((i / 10) * (i % 10) <= M) {
      //cout << i << endl;
      c++;
    }
  }
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CHalfAndHalf solver = new CHalfAndHalf();
        solver.solve(1, in, out);
        out.close();
    }

    static class CHalfAndHalf {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt(), b = in.nextInt(), c = in.nextInt(), x = in.nextInt(), y = in.nextInt();
            int ans = 0;
            if (a + b > c * 2) {
                int ab = Math.min(x, y);
                ans += ab * c * 2;
                x -= ab;
                y -= ab;
            }
            if (a > c * 2) {
                ans += x * c * 2;
            } else {
                ans += x * a;
            }
            if (b > c * 2) {
                ans += y * c * 2;
            } else {
                ans += y * b;
            }
            out.println(ans);
        }

    }
}



Measured memory_bytes: 23892
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;

static const double EPS = 1e-8;

int main(){
  int total_regions;
  int total_live_days;
  int load_limit;
  int continuous_live_limit;
  while(~scanf("%d %d %d %d",
	       &total_regions,
	       &total_live_days,
	       &load_limit,
	       &continuous_live_limit)){
    if(total_live_days == 0
       && total_regions == 0
       && load_limit == 0
       && continuous_live_limit == 0) break;

    int benefits[16][31];
    for(int region=0;region<total_regions;region++){
      for(int day=0;day<total_live_days;day++){
	scanf("%d",&benefits[region][day] );
      }
    }
    int loads[16][31];
    for(int region=0;region<total_regions;region++){
      for(int day=0;day<total_live_days;day++){
	scanf("%d",&loads[region][day] );
      }
    }

    int dp[50][100][50]; //dp[day][load][count] := benefit

    memset(dp,0,sizeof(dp));

    for(int day=0;day<total_live_days;day++){
      for(int load=0;load<=load_limit;load++){
      	for(int c=0;c<=continuous_live_limit;c++){
	  dp[day+1][load][c] = max(dp[day][load][c],dp[day+1][load][c]);

	  for(int first_region=0;first_region<total_regions;first_region++){
	    for(int last_region=first_region;last_region<total_regions;last_region++){
	      int load_sum = 0;
	      int benefit_sum = 0;
	      int continuous_live = 0;
	      for(int region=first_region;
		  region <= last_region;
		  region++){
		if(benefits[region][day] == 0) break;

		load_sum += loads[region][day];
		benefit_sum += benefits[region][day];
		continuous_live++;
	      }
	  
	      if(continuous_live > 1){
		if(load+load_sum > load_limit) continue;
		dp[day+1][load+load_sum][c+1]
		  = max(dp[day+1][load+load_sum][c+1],
			dp[day][load][c] + benefit_sum);
	      }
	      else if(continuous_live == 1){
		if(load+load_sum > load_limit) continue;
		dp[day+1][load+load_sum][c]
		  = max(dp[day+1][load+load_sum][c],
			dp[day][load][c] + benefit_sum);
	      }
	    }
	  }
	}
      }
    }

    int res = 0;
    for(int load=0;load<=load_limit;load++){
      for(int continuous_live_days=0;
	  continuous_live_days<=continuous_live_limit;
	  continuous_live_days++){
	res = max(res,dp[total_live_days][load][continuous_live_days]);
      }
    }
    printf("%d\n",res);
  } 
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;
 
int main(){
  int n, a, b;
  cin >> n>> a >> b;
  cout << min(n*a, b) << endl;
  return 0;
}

Measured memory_bytes: 256