akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
//const long long MOD = 998244353;
const long long INF_LL = 1e18+11; const int INF_int = 1e9+11;
#define ll long long
#define mp std::make_pair
#define rep(i,n) for(int i = 0;i<n;i++)
#define lrep(i,n) for(long long i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
#define Debug_Output_ALL(a) for(auto x:a) cout << x << " ";cout << endl;
//@brief GCD(a,b)
template <typename T>
T gcd(T a,T b){
    if(a<b) swap(a,b);
    while(a%b!=0) a=a%b,swap(a,b);
    return b;
}
int main(){
    int x;
    cin >> x;
    int ans = (360*x)/gcd(360,x);
    ans/=x;
    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const ll oo = 1e18;
const int mod = 1e9+7;
const int maxn = 3030;

ll dp[maxn][maxn];

int main(){
	int n;
	string s;
	cin>>n>>s;
	dp[1][1] = 1;
	for(int i=2;i<=n;i++){
		ll cur = 0;
		if(s[i-2] == '<'){
			for(int j=1;j<=i;j++){
				dp[j][i] = (dp[j][i] + cur) % mod;
				cur = (cur + dp[j][i-1]) % mod;
			}
		}else{
			for(int j=i;j>=1;j--){
				cur = (cur + dp[j][i-1]) % mod;
				dp[j][i] = (dp[j][i] + cur) % mod;
			}
		}
	}
	ll ans = 0;
	for(int i=1;i<=n;i++)
		ans = (ans + dp[i][n]) % mod;
	cout << ans << endl;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



string s;
void solve(){
	cin >> s;
	int n = s.size();
	if(n == 26){
		for(int i = n-1; i > 0; i--){
			if(s[i] > s[i-1]){
				for(int j = 0; j < i-1; j++){
					cout << s[j];
				}
				char c = 'z';
				for(int j = i; j < n; j++){
					if(s[j] > s[i-1]) c = min(c, s[j]);
				}
				cout << c << endl;
				return;
			}
		}
		cout << -1 << endl;
		return;
	}
	else{
		bool use[26] = {};
		for(int i = 0; i < n; i++){
			use[s[i]-'a'] = 1;
		}
		for(int i = 0; i < 26; i++){
			if(!use[i]){
				s += (char)('a'+i);
				cout << s << endl;
				return;
			}
		}
	}
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


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

#define N 1005
#define MP make_pair
typedef long long LL;
const int mod = 1e9 + 7;


int main()
{
	//freopen("in.txt", "r", stdin);
	
	int d[5] = {0};
	for (int i = 1; i <= 3; ++i)
	{
		int a, b;
		cin >> a >> b;
		++d[a], ++d[b];
		if (d[a] >= 3 || d[b] >= 3) return puts("NO"), 0;
 	}
 	puts("YES");
	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++)

const int P = 1000000007;
int n;

int main(){
  cin >> n;
  long long int pow = 1;
  for(int i = 1; i <= n; i++){
    pow *= i;
    //cout << pow <<" ";
    pow %= P;
  }
  
  cout << pow << endl;
  return 0;
}

Measured memory_bytes: 256
/*
*/

//#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-8
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 400031;

string st;
int cnt[N];

int get_lcp(string a,string b){
	for (int i=0;i<a.size();i++){
		if (a[i]!=b[i])
			return i;
	}
	return -1;
}

int main(){
//	freopen("apache.in","r",stdin);
//	freopen("apache.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
//	cin.tie(0);

	cin>>st;
	if (st.size()==26){
		string st2=st;
		int ok=next_permutation(st2.begin(),st2.end());
		if (!ok){
			cout<<-1<<endl;
		}
		else
		{
			int cp=get_lcp(st,st2);
			for (int i=0;i<=cp;i++)
				cout<<st2[i];
			cout<<endl;
		}
	}
	else
	{
		for (int i=0;i<st.size();i++){
			cnt[st[i]]=1;
		}
		cout<<st;
		for (int i='a';i<='z';i++){
			if (cnt[i]==0){
				cout<<char(i)<<endl;
				break;
			}
		}
	}

//	cin.get(); cin.get();
	return 0;
}


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

int main()
{
	priority_queue <double,vector<double>,greater<double> > q;
	int n;
	cin >> n;
	double x;
	for(int i = 0;i < n;i++){
		cin >> x;
		q.push(x);
	}
	
	while(q.size() > 1){
		double a = q.top();q.pop();
		double b = q.top();q.pop();
		q.push((a+b)/2);
	}
	
	cout << q.top() << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<ll> a(n);
    REP(i,n) cin >> a[i];
    sort(a.begin(), a.end(), greater<>());

    deque<ll> dq, ans;
    REP(i,n) dq.push_back(a[i]);

    ll t = dq.front(); dq.pop_front();
    ll b = dq.back(); dq.pop_back();

    ans.push_front(t);
    ans.push_back(b);
    bool last_one = false;

    while (dq.size() > 1) {
        t = dq.front(); dq.pop_front();
        b = dq.back(); dq.pop_back();
        ll at = ans.front(); ll ab = ans.back();
        ll tmp1 = abs(t-at)+abs(b-ab);
        ll tmp2 = abs(t-ab)+abs(b-at);
        if (tmp1 < tmp2) {
            swap(t,b);
        }
        ans.push_front(t);
        ans.push_back(b);
    }
    
    if (dq.size() == 1) {
        ll one = dq.front(); dq.pop_front();
        ll at = ans.front(); ll ab = ans.back();
        ll tmp1 = abs(one-at); ll tmp2 = abs(one-ab);
        if (tmp1 > tmp2) ans.push_front(one);
        else ans.push_back(one);
    }

    ll cnt = 0ll;
    ll x = ans.front(); ans.pop_front();
    while (!ans.empty()) {
        ll y = ans.front(); ans.pop_front();
        cnt += abs(x-y);
        x = y;
    }
    
    cout << cnt << endl;

    return 0;
}

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

//imos法を用いました。

int record[30][100001];

int main() {

    int n,C;

    cin >> n >> C;

    int s,t;
    int c;

    for(int i=0;i<n;i++){
        cin >> s >> t >> c;
        c--;
        record[c][s-1]++;
        record[c][t]--;
    }

    for(int i=0; i<C; i++) {
        for (int j = 1; j < 100001; j++) {
            record[i][j] += record[i][j-1];
        }
    }

    for(int i=0; i<C; i++) {
        for (int j = 1; j < 100001; j++) {
            if(record[i][j]>1){//同じチャンネルで同時放送はないため用いている録画機は常に1である。
                record[i][j] = 1;
            }
        }
    }

    int ans = 0;

    for(int i=0; i<100001;i++){
        int tmp_ans = 0;
        for(int j=0; j<C; j++){
            tmp_ans += record[j][i];
        }
        ans = max(ans,tmp_ans);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11904
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



int main(){
  
  int H,A;cin>>H>>A;
  cout << (H-1)/A+1 << endl;

}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
H = [0] + list(map(int, input().split()))
INF = 10**18
dp = [[INF] * (N+1) for _ in range(N+1)]
dp[0][0] = 0
for i in range(1, N+1):
    for j in range(1, N+1):
        for k in range(i):
            dp[j][i] = min(dp[j][i], dp[j-1][k] + max(0, H[i] - H[k]))
print(min(dp[N-K]))

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

int main(){

    int totalPack = 3;
    std::vector<int> pack(totalPack);

    for (int i=0; i<totalPack; i++) {
        std::cin >> pack[i];
    }

    std::sort(pack.begin(), pack.end());
    int maxPackNumber = pack[2];
    if (maxPackNumber == (pack[0] + pack[1])) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

typedef pair<int, int> P;
int main(){
    int n;
    cin>>n;
    int a[3]={100,10,1};
    rep(i,3){
        if(n/a[i]==1){
            cout<<9;
        }
        else{
            cout<<1;
        }
        n=n%a[i];
    }
    cout<<endl;
}


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

using namespace std;

int main(){
    int N,Oddnum=0,Evennum=0;
    cin>>N;
    int A[N];
    for(int i=0;i<N;i++)cin>>A[i];
    for(int i=0;i<N;i++){
        if(A[i]%2==0){
            Evennum++;
        }else{
            Oddnum++;
        }
    }
    if(Oddnum%2==1){
        cout<<"NO"<<endl;
    }else{
        cout<<"YES"<<endl;
    }
    return 0;
}

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

#define fi first
#define se second
#define pb push_back

const int N = 8080;

using namespace std;

int n , m;
int cnt , ans , sum  , a;
string s , s1;
int main()
{
        ios_base::sync_with_stdio(false);

        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    cin >> n >> m >> a >> cnt;
   ans += min(n , cnt) * 1 , cnt -= min( n , cnt );
    cnt -= min( m , cnt );
   ans += min(a , cnt) * -1 , cnt -= min( a , cnt );
   cout << ans << endl;
}



Measured memory_bytes: 3652
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0)
#define ull unsigned ll
#define uint unsigned
#define pai pair<int,int>
#define pal pair<ll,ll>
#define IT iterator
#define pb push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);++i)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);--i)
#define endl '\n'
#define ll long long
int main()
{
    int x,y,z;
    cin>>x>>y>>z;
 	int timess ;
  	cin >> timess;
  	if(y ==0 || z== 0){
    	cout<<"No"<<endl;
      return 0;
    }
  	int time1 = 0 ;
  	int time2 = 0;
  	while(y<= x){
    	y = y*2;
          time1++;
    }
  while(z <= y){
    z=z*2;
    time2++;
  	}
  if(time1 + time2 <= timess){
  	cout<<"Yes"<<endl;
    return 0;
  }else {
  cout<<"No"<<endl;
    return 0;
  }
}


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

using namespace std;

#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)
#define VIN(VECTOR,n)\
REP(CNT,n){\
	lli TMP;\
	cin>>TMP;\
	VECTOR.push_back(TMP);\
}

int main(){

	string str;
	lli n;

	cin>>str;
	cin>>n;

	lli flag=0;
	lli cnt=-1;
	REP(i,n){
		if(str.at(i)!='1'){
			flag=1;
			cnt=i;
			break;
		}
	}
	if(flag==0)cout<<"1"<<endl;
	else cout<<str.at(cnt)<<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);
        String n = sc.next();
        String[] ns1 = n.split("");
        List<String> s = Arrays.asList(ns1);
        List<String> kotae = new ArrayList<>();
        int x = 0;
        int y = 0;
        int z = 0;
        for(int i = 0; i < s.size(); i++){
            if (s.get(i).equals("1")){
                kotae.add("9");
            }
            else if(s.get(i).equals("9")){
                kotae.add("1");
            }
        }
        if(kotae.size() == 1){
            z = Integer.parseInt(kotae.get(0)) * 1;
        }
        else if(kotae.size() == 2){
            y = Integer.parseInt(kotae.get(0)) * 10;
            z = Integer.parseInt(kotae.get(1)) * 1;
        }
        else if(kotae.size() == 3){
            x = Integer.parseInt(kotae.get(0)) * 100;
            y = Integer.parseInt(kotae.get(1)) * 10;
            z = Integer.parseInt(kotae.get(2)) * 1;
        }

        System.out.println(x + y + z);
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ld a,b,x;
    cin>>a>>b>>x;
    ld ans;
    if(a*a*b<=2*x) ans=atan(2*(a*a*b-x)/(a*a*a));
    else ans=atan((b*b*a)/(2*x));
    ans=ans*180/PI;
    cout<<fixed<<setprecision(10)<<ans;
}

Measured memory_bytes: 3816
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

/*** MOD CALCULATION ***/

const int MOD = 1e9+7;
const int MAX = 1'000'005;

ll addM(ll a, ll b){
	return ((a % MOD) + (b % MOD)) % MOD;
}

ll mulM(ll a, ll b){
	return ((a % MOD) * (b % MOD)) % MOD;
}

ll powM(ll a, ll b){
	if(b == 0) return 1;
  	else if(b == 1) return a % MOD;
  	else if(b%2==0) return mulM(powM(a, b/2), powM(a, b/2));
  	else return mulM(a, mulM(powM(a, (b-1)/2), powM(a, (b-1)/2)));
}

// b^{-1} = b^{p-2} (mod p)
// a/b = a*b^{p-2} (mod p)
ll divM(ll a, ll b){ 
  	return mulM(a, powM(b, MOD-2));
}

// n!, (n!)^{-1} のテーブル作成
ll fac[MAX], finv[MAX], inv[MAX];
void COMBinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    rep3(i,2,MAX-1){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COMB(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

/*** MOD CALCULATION ここまで ***/

ll binom(int x, int y){
    // y が小さいとき
    // x! / {y!(x-y)!} = P(x,y)/y!
    ll res = 1;
    rep3(i, 1, y){
        res = mulM(res, x-y+i);
    }
    res = mulM(res, finv[y]);
    return res;
}
    
void Main(){
    int n, a, b;
    cin >> n >> a >> b;
    COMBinit();
    
    ll ans = powM(2, n);
    ans = addM(ans, MOD - 1);
    ans = addM(ans, MOD - binom(n, a));
    ans = addM(ans, MOD - binom(n, b));
    
    cout << ans << endl;
    return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 27100
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  long sum=1;
  vector<long> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
    if(A.at(i)==0){
      cout<<0<<endl;
      return 0;
    }
  }
  for(int i=0;i<N;i++){
  	if(A.at(i)>1000000000000000000/sum){
      cout<<-1<<endl;
      return 0;
    }
    sum=sum*A.at(i);
  }
  cout<<sum<<endl;
}

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

using namespace std;

void fastio() {
	cin.tie(nullptr);
	cin.sync_with_stdio(false);
}

using LL = long long;
using LD = long double;

const LL MOD = 1e9+7;
const LL INF = LLONG_MAX;
const LL N = 1e6+1;

int main() {
	fastio();
	
	LL n, m, k;
	cin >> n >> m >> k;

	vector<vector<LL>> g(n, vector<LL>(m, 0));

	for (LL i = 0; i < k; ++i) {
		LL x, y, v;
		cin >> x >> y >> v;
		g[x-1][y-1] = v;
	}

	vector<vector<vector<LL>>> dp(n+1, vector<vector<LL>> (m+1, vector<LL>(4, 0)));

	for (LL i = 0; i < n; ++i) {
		for (LL j = 0; j < m; ++j) {
			dp[i+1][j+1][1] = max({dp[i+1][j][0] + g[i][j], dp[i+1][j][1], dp[i][j+1][3] + g[i][j]});
			dp[i+1][j+1][2] = max({dp[i+1][j][1] + g[i][j], dp[i+1][j][2], dp[i][j+1][3] + g[i][j]});
			dp[i+1][j+1][3] = max({dp[i+1][j][2] + g[i][j], dp[i+1][j][3], dp[i][j+1][3] + g[i][j]});
		}
	}

	cout << dp[n][m][3] << "\n";

}

Measured memory_bytes: 707172
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <string>
using namespace std;
#define ll long long int

int main(void)
{
	int a, b, d, g, count = 0;
	string S, T, U;
	map<char, int> mp;
	for (int i = 0;i < 4;i++)
	{
		char S;
		std::cin >> S;
		mp[S]++;
	}

	if (mp.size() != 2)
	{
		cout << "No" << endl;
		return 0;
	}
	else
	{
		for (auto itr = mp.begin();itr != mp.end();itr++)
		{
			if (itr->second != 2)
			{
				cout << "No" << endl;
				return 0;
			}
		}
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
const int inf = 1000000000; // 10^9


int main() {
	int N;
	cin >> N;
	vector<int> X(N);
	rep(i, N) cin >> X[i];
	int ans = inf;
	for (int i = 1; i <= 100; i++) { // L やR の計算が不要
		int cost = 0;
		rep(j, N) cost += (X[j] - i) * (X[j] - i);
		ans = min(ans, cost);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3628
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<Double> al= new ArrayList<>();
		
		int x, h;
		
		while(true) {
			x = sc.nextInt();
			h = sc.nextInt();
			
			if(x == 0 && h == 0)	break;
			
			al.add(x * x +  x * Math.sqrt(x * x + h * h * 4));
		}
		
		for(double i : al) {
			System.out.println(i);
		}
	}
}

Measured memory_bytes: 25904
import math
line = input()
line1 = line.split(" ")

#for i in line1:
  #  line1[i] = int(i)

adis = line1[0]
bdis = line1[1]
cdis = line1[2]
count = line1[3]

AB = abs(abs(int(bdis)) - abs(int(adis)))
BC = abs(abs(int(cdis)) - abs(int(bdis)))
#AB = abs(AB)


if int(AB) <= int(count) and int(BC) <= int(count):
    print("Yes")
elif abs(abs(int(cdis)) - abs(int(adis))) <= int(count):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import java.util.*;
import java.io.*;


public class Main {

    static long divCeil(long x, long y){
        return (x+y-1)/y;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int T = 5;
        long N = sc.nextLong();
        long[] capacity = new long[T];
        for(int t=0; t<T; t++) capacity[t] = sc.nextLong();

        int bottleNeck = 0;
        for(int t=1; t<T; t++) if(capacity[t]<capacity[bottleNeck]) bottleNeck=t;

        System.out.println(divCeil(N, capacity[bottleNeck]) + T-1);




    }
}


Measured memory_bytes: 23764
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

bool f[1000001];

int main()
{
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; ++i)
  {
    cin >> v[i];
  }
  int ans = 0;
  for (int i = 0; i < 100; ++i)
  {
    bool f = 0;
    for (int j = 0; j < n; ++j)
    {
      if (v[j] > i)
      {
        f = 1;
      }
      else
      {
        if (f)
        {
          ans++;
          f = 0;
        }
      }
    }
    if (f)
      ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(long long i = 0; i < (long long)(N); i++)
#define repr(i,N) for(long long i = (long long)(N) - 1; i >= 0; i--)
#define rep1(i,N) for(long long i = 1; i <= (long long)(N) ; i++)
#define repr1(i,N) for(long long i = (N) ; (long long)(i) > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vs = V<string>;
using vd = V<double>; using vvi = V< V<int> >; using vvl = V< V<> >;
template<typename T>using heap = priority_queue< T , V<T> , greater<T> >;
constexpr int inf = 1001001001; constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

using P = pair<int,int>; using vp = V<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
//////////


void solve(){
  
  map<P , int> m;
  ini(N);

  rep1(i , N){
    int tail = i % 10;
    int head = [&](){
      int j = i;
      while(j >= 10) j /= 10;
      return j;
    }();
    //trc(head , tail);
    m[P(head , tail)]++;
  }

  ll ans = 0;
  rep1(i , 9) rep1(j , i){
  // trc(i , j , m[P(i , j)] , m[P(j , i)]);
    ans += 1LL * m[P(i , j)] * m[P(j , i)] * (1 + (i != j));
  }
  out(ans);
  

}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int K = sc.nextInt();
		long ans = 0, st = 1, end = 1, x = 0, y = 1;
		int s = 0, t = 0;
		for(int i = 1; i < S.length(); i++) {
			if(S.charAt(i) == S.charAt(i-1))
				st++;
			else {
				s = i-1;
				break;
			}
		}
		for(int i = S.length()-1; i > 0; i--) {
			if(S.charAt(i) == S.charAt(i-1))
				end++;
			else {
				t = i;
				break;
			}
		}
		if(st == end && st == S.length()) {
			System.out.println(st*K/2);
			return;
		}
		for(int i = s+1; i < t; i++) {
			if(S.charAt(i) == S.charAt(i-1))
				y++;
			else {
				x += y / 2;
				y = 1;
			}
			if(i == t-1)
				x += y/2;
		}
		ans += x*K;
		if(S.charAt(0) == S.charAt(S.length()-1)) {
			ans += (st+end)/2*(K-1);
			ans += st/2;
			ans += end/2;
		}
		else {
			ans += st/2*K;
			ans += end/2*K;
		}
		System.out.println(ans);
		
	}

}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
void dip(vector<long long> B)
{
   for(auto x:B)
   {
   	 cout<<x<<" ";
   }
   cout<<"\n";
}
main()
{
	int n;
	cin>>n;
	vector<long long> A(n);
	vector<long long> B(n);
	vector<long long> C(n);
	for(int i=0;i<n;i++)cin>>A[i];
	for(int i=0;i<n;i++)cin>>B[i];
	for(int i=0;i<n;i++)cin>>C[i];

	sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    vector<long long> B2(n);
    for(int i=0;i<n;i++)
    {
    	B2[i]=lower_bound(A.begin(), A.end(), B[i])-A.begin();
    }
    

    vector<long long> pref(n);
    pref[0]=B2[0];
    for(int i=1;i<n;i++)
    {
    	pref[i]=pref[i-1]+B2[i];
    }


    long long ans=0;
    for(int i=0;i<n;i++)
    {
    	int k=lower_bound(B.begin(), B.end(), C[i])-B.begin();
        
        if(k!=0)
       {
           ans+=pref[k-1];
        }
    }

    cout<<ans;
	
}

Measured memory_bytes: 4224
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
// #include<boost/multiprecision/cpp_int.hpp>
// namespace multiprecisioninteger = boost::multiprecision;
// using cint=multiprecisioninteger::cpp_int;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;++i)
#define bFor(i,b,a) for(i=b,--i;i>=(ll)a;--i)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define brep1(i,N) bFor(i,N,1)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
#define matoutput(v) do{for(auto outimat:v)output(outimat);}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

int main(){
  // startupcpp();
  ll i,j,N,T,ans=0;
  cin>>N>>T;
  vec dp(30,T+1),z;
  pvec v;
  while(N--){
    cin>>i>>j;
    if(i)v.eb(i,j);
    else z.eb(++j);
  }
  dp[0]=0;
  sort(all(v),[](datas l,datas r){
    return l.first*(r.second+1)>r.first*(l.second+1);
  });
  for(auto x:v)brep1(i,30){
    chmin(dp[i],(x.first+1)*(dp[i-1]+1)+x.second);
  }
  vsort(z);
  z.eb(T+1);
  rep1(i,z.size()){
    z[i]+=z[i-1];
  }
  rep(i,30){
    if(dp[i]>T)break;
    j=0;
    while(dp[i]+z[j]<=T)++j;
    chmax(ans,i+j);
  }
  print(ans);
}

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

using namespace std;

typedef long long ll;

int main(){
	ll t;
    t=1;
  	while(t--){
      ll n,l;
      cin>>n>>l;
      string a[n];
      for(int i=0;i<n;i++){
        cin>>a[i];
      }
      sort(a,a+n);
      
      for(int i=0;i<n;i++){
        cout<<a[i];
      }
      cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
using DataStructures
const double = Float64
const int = Int64

parseint(x) = parse(int, x)
readint() = map(parseint, split(readline()))

function main()
  N = readint()[1]
  d = readint()

  sort!(d)
  a = d[N÷2]
  b = d[N÷2 + 1]
  println(b-a)
  
end



main()

Measured memory_bytes: 198552
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();
		
		Set<Character> set = new HashSet<Character>();
		boolean flag = true;
		for(int i = 0;i < S.length();++i) {
			if(set.contains(S.charAt(i))) {
				flag = false;
				break;
			} else {
				set.add(S.charAt(i));
			}
		}
		if(flag)
			System.out.println("yes");
		else
			System.out.println("no");
	}
}


Measured memory_bytes: 23764
#include<iostream>
#include<algorithm>
using namespace std;
struct Card{
    char mark;
    int number;
};
struct Card A[100001],B[100001];
int n,v; char c;
void merge(struct Card A[],int left,int mid,int right){
    int n1=mid-left,n2=right-mid; 
    struct Card L[50001],R[50001];
     for(int i=0;i<n1;i++)L[i]= A[left+i];
     for(int i=0;i<n2;i++)R[i]=A[mid+i];
     L[n1].number=R[n2].number=2000000000;
     int i=0,j=0;
     for(int k=left;k<right;k++){
         if(L[i].number<=R[j].number){A[k]=L[i++];}
         else{ A[k]=R[j++];}
     }
}
void mergeSort(struct Card A[],int left,int right){
    int mid;
    if(left+1<right){
        mid=(left+right)/2;
        mergeSort(A,left,mid);
        mergeSort(A,mid,right);
        merge(A,left,mid,right);
    }
}
int partition(struct Card A[],int p,int r){
    struct Card x=A[r]; int i=p-1;
    for(int j=p;j<r;j++){
        if(A[j].number<=x.number){
            i++;
            swap(A[i],A[j]);
        }
    }
   swap(A[i+1],A[r]);
    return i+1;
}
void quicksort(struct Card A[],int p,int r){
    if(p<r){
        int q=partition(A,p,r);
        quicksort(A,p,q-1);
        quicksort(A,q+1,r);
    }
}
int main(){
    bool equal=true;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>c>>v;
        A[i].mark=B[i].mark=c;
        A[i].number=B[i].number=v;
    }
    mergeSort(B,0,n);
    quicksort(A,0,n-1);
    for(int i=0;i<n;i++){
        if(A[i].mark!=B[i].mark) equal=false;
    }
    if(equal) cout<<"Stable"<<endl;
    else cout<<"Not stable"<<endl;
    for(int i=0;i<n;i++) cout<<A[i].mark<<" "<<A[i].number<<endl;
    return 0;
}


Measured memory_bytes: 5308
//ABC107B_Grid_Compression
#include <iostream>
#include<algorithm>
using namespace std;

int main() {
    int H, W;
    cin >> H >> W;
    char a[H][W];

    for (int i = 0;i < H;i++){
        for(int j = 0; j < W;j++){
            cin >> a[i][j];
        }
    }

    char b[H][W];
    bool flag;
    int k = 0;

    for (int i = 0;i < H;i++){
        flag = true;
        for(int j = 0; j < W;j++){
            if(a[i][j] == '#'){
                flag = false;
            }
        }
        if (!flag){
            for(int l = 0; l < W; l++){
                b[k][l] = a[i][l];
            }
            k++;
        }
    }

    int K = k;
    char c[K][W];
    int l = 0;

    for(int j = 0; j < W ; j ++){
        flag = true;
        for(int i = 0; i < K; i++){
            if (b[i][j] == '#'){
                flag = false;
            }
        }

        if(!flag){
            for (int q = 0; q < K; q++){
                c[q][l] = b[q][j];
            }
            l++;
        }
    }

    int L = l;
    for(int i = 0; i < K;i++){
        for(int j = 0; j < L ;j++){
            cout << c[i][j];
        }
        cout << endl;
    }
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    double W, H, x, y;
    cin >> W >> H >> x >> y;
    int ans;
    if(x == W/2.0 && y == H/2.0){
      ans = 1;
    }else{
      ans = 0;
    }
    cout << H*W/2.0 << " " << ans << endl;
    return 0;
}

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


typedef pair<int,int> pii;

typedef vector<int> vint;
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define F first
#define S second
#define mkp make_pair
int h,w;
pair<pii,int> foo1(vector<string> &v){
	string vec=">v<^";
	rep(i,v.size()){
		rep(j,v[i].size()){
			rep(k,4){
				if(v[i][j]==vec[k]){
					v[i][j]='.';
					return mkp(pii(i,j),k);
				}
			}
		}
	}
	return mkp(pii(-1,-1),-1);
}
bool check(int a,int b){
	if(0<=a&&a<h&&0<=b&&b<w) return true;
	return false;
}
void mainmain(){
	int n;
	cin>>n;
	rep(o,n){
		if(o) cout<<endl;
		cin>>h>>w;
		vector<string> v(h);
		rep(i,h) cin>>v[i];
		string s;
		int t;
		cin>>t>>s;
		int dd[]={0,1,0,-1,0};// >,v,<,^
		pair<pii,int> pos=foo1(v);
		string DRUL="RDLU";
		//SRSSRRUSSR
		rep(i,s.size()){
			// cout<<pos.F.F<<" "<<pos.F.S<<" "<<pos.S<<endl;
			// rep(j,h) cout<<v[j]<<endl;
			// cout<<endl;
			if(s[i]=='S'){
				int y=pos.F.F;
				int x=pos.F.S;
				y+=dd[pos.S];
				x+=dd[pos.S+1];
				while(check(y,x)){
					if(v[y][x]=='#') break;
					if(v[y][x]=='*'){
						v[y][x]='.';
						break;
					}
					y+=dd[pos.S];
					x+=dd[pos.S+1];
				}
			}
			else{
				rep(j,4){
					if("RDLU"[j]==s[i]){
						pos.S=j;
					}
				}
				int ny=pos.F.F+dd[pos.S];
				int nx=pos.F.S+dd[pos.S+1];
				if(check(ny,nx)&&v[ny][nx]=='.'){
					pos.F=pii(ny,nx);
				}
			}
		}
		v[pos.F.F][pos.F.S]=">v<^"[pos.S];
		rep(i,h){
			cout<<v[i]<<endl;
		}
	}
}


signed main() {
	ios_base::sync_with_stdio(false);
  	cout<<fixed<<setprecision(0);
    mainmain();
}

Measured memory_bytes: 1212
N, K  = map(int,input().split())
L =list(map(int,input().split()))
Lzero = list(filter(lambda x:x==0,L))
Lright = list(filter(lambda x:x>0,L))
Lleft = list(map(lambda x:abs(x),filter(lambda x:x<0,L)))[::-1]
K -= len(Lzero)
if K <= 0:
    print(0)
    quit()

dis = []
if len(Lright) == 0:
    print(Lleft[K-1])
    quit()
if len(Lleft) == 0:
    print(Lright[K-1])
    quit()
try :
    dis.append(Lright[K-1])
    dis.append(Lleft[K-1])
except:
    pass


for i in range(len(Lright)):
    remain = K
    if i+1 >K:
        break
    elif i+1 == K:
        dis.append(Lright[i])
        break
    d = 2*Lright[i]
    remain -= (i+1)
    try :
        d += Lleft[remain-1]
        dis.append(d)
    except:
        pass
for i in range(len(Lleft)):
    remain = K
    if i+1 >K:
        break
    elif i+1 == K:
        dis.append(Lleft[i])
        break
    d = 2*Lleft[i]
    remain -= (i+1)
    try:
        d += Lright[remain-1]
        dis.append(d)
    except:
        pass
print(min(dis))


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

int main() {
    int N,num;
    cin >> N;

    for (int i = 1; i <= N; i += 2) {
        int count = 0;
        for (int j = 1; j <= i; j++) {
            if (i % j == 0) {
                count++;
            }
        }
        if (count == 8) {
            num++;
        }
    }

    cout << num << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws Exception {
        String line = readLine();
        StringTokenizer st = new StringTokenizer(line, " ");
        Integer n = Integer.parseInt(st.nextToken());	/* 胃袋耐久期間 */
//        Integer a = Integer.parseInt(st.nextToken());	/* 賞味期限期間 */
//        Integer b = Integer.parseInt(st.nextToken());	/* 購入してから食べた日まで */

        /* 賞味期限までに食べた場合 */
        if ( n > 999) {
        	System.out.println("ABD");

        /* 胃袋耐久期間中に食べた場合 */
//        }else if ( (a + x) >= b) {
//        	System.out.println("safe");

        /* 胃袋耐久期間を超えて食べた場合 */
        }else {
        	System.out.println("ABC");
        }

    }

    private static String readLine() throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        return br.readLine();
    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  ll N;
  cin >> N;
  vll s(N);
  ll sum = 0;
  priority_queue<ll, vector<ll>, greater<ll>> que;
  for(int i = 0; i < N; i++){
    int s;
    cin >> s;
    sum += s;
    que.push(s);
  }
  if(sum % 10 != 0){
    cout << sum << endl;
    return 0;
  }
  bool flag = false;
  while(!que.empty()){
    ll x = que.top(); que.pop();
    if(x % 10 != 0){
      sum -= x;
      flag = true;
      break;
    }
  }
  if(flag) cout << sum << endl;
  else cout << 0 << endl;
  
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll a(n), b(n), c(n);
  rep(i,n) cin>>a[i], a[i]*=-1;
  rep(i,n) cin>>b[i];
  rep(i,n) cin>>c[i];
  
  vsort(a);
  vsort(b);
  vsort(c);
  
  ll ans=0;
  rep(i,n){
    ans+=(a.end()-upper_bound(all(a),-b[i]))*(c.end()-(upper_bound(all(c),b[i])));
  }
  cout<<ans<<endl;
}

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

N, M = map(int, input().split())
A_list = list(map(int, input().split()))
BC_list = [list(map(int, input().split())) for i in range(M)]

usable_number_list = []

BC_list_C_sort_rev = sorted(BC_list, key=lambda x: x[1], reverse=True)

for BC in BC_list_C_sort_rev:
    for i in range(BC[0]):
        usable_number_list.append(BC[1])
    if len(usable_number_list) > N:
        break
while len(usable_number_list) < N:
    usable_number_list.append(0)
usable_number_list = usable_number_list[:N]

A_list_sort = sorted(A_list)

output = 0
for i in range(N):
    if A_list_sort[i] > usable_number_list[i]:
        output += A_list_sort[i]
    else:
        output += usable_number_list[i]
        
print (output)

Measured memory_bytes: 34492
N,A,B = map(int,input().split())
S = input()

ans = []
inout = out = 0
for c in S:
    if c=='a':
        if inout < A+B:
            inout += 1
            ans.append('Yes')
        else:
            ans.append('No')
    elif c=='b':
        if inout < A+B and out < B:
            inout += 1
            out += 1
            ans.append('Yes')
        else:
            ans.append('No')
    else:
        ans.append('No')
print(*ans, sep='\n')

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

using namespace std;

int main() {
  long long s, c;
  cin >> s >> c;
  long long ans = 0;
  ans = min(s, c / 2);
  s -= ans;
  c -= ans * 2;
  cout << ans + c / 4 << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define bug(args ...) cerr << __LINE__ << ">> ", err(new istringstream(string(#args)), args), cerr << '\n'
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define M_PI 3.14159265358979323846
#define MOD 1000000007
#define int ll
typedef unsigned long long BITMASK; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<double, double> pdd; typedef pair<long long, long long> pll; typedef cc_hash_table<int, int, hash<int>> intHashTable;
struct custom_hash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } };
inline int powMod(int a, int b) { int x = 1; while (b > 0) { if (b&1) x = (x*a) % MOD; a = (a*a) % MOD; b >>= 1; } return x; }
inline int multiply(int x, int y) { return ((x % MOD) * (y % MOD)) % MOD; }
inline int divide(int x, int y) { return ((x % MOD) * powMod(y % MOD, MOD-2)) % MOD; }
inline int ceil(int a, int b) { return (a+b-1)/b; }
int gcd (int a, int b) { while (b) { a %= b; swap(a, b); } return a; }
int lcm (int a, int b) { return a / gcd(a, b) * b; }
int inverseMod(int a, int m) { a = a % m; for (ll x = 1; x < m; x++) if ((a * x) % m == 1) return x; return -1; }
void err(istringstream *iss) {} template<typename T, typename ... Args> void err(istringstream *iss, const T &_val, const Args & ... args) { string _name; *iss >> _name; if (_name.back()==',') _name.pop_back(); cerr << _name << " = " << _val << "; ", err(iss, args ...); }
int str_replace(string& str, const string& from, const string& to, int limit = -1) { if(from.empty()) return 0; size_t start_pos = 0; int cnt = 0; while((start_pos = str.find(from, start_pos)) != std::string::npos) { str.replace(start_pos, from.length(), to); start_pos += to.length(); cnt++; if (cnt == limit) break; } return cnt; }
template<int D, typename T> struct vec : public vector<vec<D - 1, T>> { static_assert(D >= 1, "Vector dimension must be greater than zero!");  template<typename... Args> vec(int n = 0, Args... args) : vector<vec<D - 1, T>>(n, vec<D - 1, T>(args...)) { } }; template<typename T> struct vec<1, T> : public vector<T> { vec(int n = 0, T val = T()) : vector<T>(n, val) { }};

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int s, w; cin >> s >> w;
    if (w >= s) cout << "unsafe\n";
    else cout << "safe\n";
    return 0;
}

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

int main()
{
	int n;
	cin >> n;
	vector<string> ss(n);
	for (auto &&s : ss)
	{
		cin >> s;
	}

	map<string, int> cnt;
	for (auto &&s : ss)
	{
		cnt[s]++;
	}

	int maxi = 0;
	for (auto &&p : cnt)
	{
		maxi = max(maxi, p.second);
	}

	vector<string> ret;
	for (auto &&p : cnt)
	{
		if (p.second == maxi)
		{
			ret.emplace_back(p.first);
		}
	}

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

	for (auto &&r : ret)
	{
		cout << r << endl;
	}

	return 0;
}

Measured memory_bytes: 28404
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

int main() {
  string S;
  cin >> S;
  int A = 0;
  int C = 0;
  int small = 0;

  int N = S.size();
  rep(i, N) {
    if (S[i] == 'A' && i == 0)
      A++;
    else if (S[i] == 'C' && 2 <= i && i <= N - 2)
      C++;
    else if ('a' <= S[i] && S[i] <= 'z')
      small++;
  }
  if (A == 1 && C == 1 && small == N - 2) {
    cout << "AC" << endl;
  } else {
    cout << "WA" << endl;
  }
}

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

using namespace std;

//ifstream fin ("contest.in");
//ofstream fout ("contest.out");

int n, m, np;
bool a[10][10];
char c;

void fil (int i, int j)
{
    if (a[i][j] == 0 || i < 1 || j < 1 || i > n || j > m)return;
    a[i][j] = 0;

    if (a[i + 1][j] == 1 && a[i][j + 1] == 1)
    {
        np = 1;
        return;
    }
    fil(i + 1, j);
    fil(i, j + 1);
}
int main()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            cin >> c;
            if (c == '#')a[i][j]=1;
        }
    }

    fil(1, 1);
    int ok =0;
    for (int i = 1; i <= n; i ++)
        for (int j = 1; j <= m; j++)
            if (a[i][j] == 1)ok = 1;

    if (np == 1)ok = 1;
    if (ok == 1)cout << "Impossible";
    else cout << "Possible";
    return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        h: i64,
        a: i64,
    }
    let mut d = h/a;
    let m = h%a;
    if (m != 0) {
        d += 1;
    }
    
    println!("{}", d);
}


Measured memory_bytes: 4352