akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<queue> 
#include<bits/stdc++.h>
using namespace std;

int main() {
	  int n;
	  cin>>n;
	  int a[n][3];
	  for(int i=0;i<n;i++)
	  cin>>a[i][0]>>a[i][1]>>a[i][2];
	 // int dp[n][3];
	  
	//  memset(dp,0,sizeof(dp));
	  for(int i=1;i<n;i++){
	      for(int j=0;j<3;j++)
	      a[i][j]=a[i][j]+max(a[i-1][(j+1)%3],a[i-1][(j+2)%3]);
	  }
	 int ans=max(a[n-1][0],max(a[n-1][1],a[n-1][2]));
	 cout<<ans<<endl;
	  
	  	   return 0;
	 }


Measured memory_bytes: 4780
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    ll K, A, B;
    cin >> K >> A >> B;
    int num = A - 1;
    int cnt = K - (A - 1);
    cout << max(K + 1, A + (cnt / 2) * (B - A) + cnt % 2) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100001],b[100002];
int q;
void init()
{
  for(int i=2;i<=100000;i++)
  {
    for(int j=2*i;j<=100000;j+=i)
    {
      if(a[j]==-1)
      {
        a[j]=0;
      }
    }
  }
}
void itit()
{
  for(int i=2;i<=100000;i++)
  {
    if(a[i]==-1&&a[(i+1)/2]==-1&&i%2==1)
    {
      b[i]=b[i-1]+1;
    }
    else
    b[i]=b[i-1];
  }
}
int main()
{
  int n,m;
  cin>>q;
  memset(a,-1,sizeof(a));
  init();
  itit();
  for(int i=1;i<=q;i++)
  {
    cin>>n>>m;
    cout<<b[m]-b[n-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int a[2][600][600],dx[8]={-1,-1,-1,0,1,1,1,0},dy[8]={-1,0,1,-1,1,0,-1,1};
map<int,P> ma[2];
int n,u,v,m,cu,cv,INF=1<<28;
int c[100001];
bool ck(int x,int y) {
  if(x<0 || x>=n || y<0 || y>=n) return false;
  return true;
}

bool check(int z, int k) {
  if(ma[k].count(z)==0) return false;
  int x=ma[k][z].first,y=ma[k][z].second;
  a[k][x][y]=1;
  for(int i=0; i<4; i++) {
    if(n==1 && i) break;
    int cnt=1,nx=x,ny=y;
    for(int j=0; j<n; j++) {
      nx+=dx[i],ny+=dy[i];
      if(!ck(nx,ny)) break;
      if(a[k][nx][ny]) cnt++;
      else break;
    }
    nx=x,ny=y;
    for(int j=0; j<n; j++) {
      nx+=dx[i+4],ny+=dy[i+4];
      if(!ck(nx,ny)) break;
      if(a[k][nx][ny]) cnt++;
      else break;
    }
    if(cnt==n) {
      if(!k) cu++;
      else cv++;
    }
  }
  if(!k) {
    if(cu>=u) return 1;
    return 0;
  } else {
    if(cv>=v) return 1;
    return 0;
  }
}

int main() {
  memset(a,0,sizeof(a));
  ma[0].clear();ma[1].clear();
  cu=0;cv=0;
  cin >> n >> u >> v >> m;
  for(int k=0; k<2; k++) {
    for(int i=0; i<n; i++) {
      for(int j=0; j<n; j++) {
	int x;
	cin >> x;
	ma[k][x]=P(j,i);
      }
    }
  }
  int U=INF,V=INF;
  for(int i=0; i<m; i++) cin >> c[i];
  for(int i=0; i<m; i++) {
    if(check(c[i],0)) U=i;
    if(check(c[i],1)) V=i;
    if(U!=INF || V!=INF) break;
  }
  if(U<V) cout << "USAGI" << endl;
  else if(U>V) cout << "NEKO" << endl;
  else cout << "DRAW" << endl;
  return 0;
}

Measured memory_bytes: 22124
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv,  digitDP//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal ,RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007; ll INF = 1LL << 60; ll ans = 0; ll z = 0, o = 1;
vl flag; vll path; vl D;
//***********//
int main() {
	cin >> N;
	vl A(N), B(N);
	ll sum1 = 0, sum2 = 0;
	for (i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
		if (N % 2 == 0) {
			A[i] *= 2;
			B[i] *= 2;
		}
	}
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	if (N % 2 == 0) {
		ll P = (A[N / 2] + A[N / 2 - 1]) / 2;
		ll Q = (B[N / 2] + B[N / 2 - 1]) / 2;
		cout << Q - P + 1;
	}
	else {
		ll P = A[N / 2];
		ll Q = B[N / 2];
		cout << Q - P + 1;
	}
}

Measured memory_bytes: 6360
#include <iostream>

int main() {
  long long N, A, B;
  std::cin >> N >> A >> B;

  long long div = N / (A + B);
  long long mod = N % (A + B);

  long long ans = div * A + std::min(mod, A);

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i]>>y[i];
typedef long long int ll;
using namespace std;

int main(){
	int n,k; cin >>n >>k;
	int ans=1;
	ans*=k*pow(k-1,n-1);
	cout << ans <<endl;
} 


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

// Shrotening
#define fst first
#define snd second
#define pb push_back
#define mp make_pair

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;


int n;
VI w(301);
VI2 memo(301, VI(301));

int dp(int l, int r) {
    if(l == r) return 0;
    if(r-l == 1) return (std::abs(w[l]-w[r]) <= 1) ? 2 : 0;
    if(memo[l][r] != -1) return memo[l][r];

    int ans = 0;
    if(std::abs(w[l]-w[r]) <= 1) {
        int res = dp(l+1, r-1);
        if(res == r-l-1) {
            ans = 2 + res;
        }
    }
    for(int i=l; i<r; ++i) {
        ans = std::max(ans, dp(l, i) + dp(i+1, r));
    }
    return memo[l][r] = ans;
}

int main() {
    while(std::cin >> n, n != 0) {
        REP(i, n) {
            std::cin >> w[i];
        }
        memo.assign(301, VI(301, -1));
        std::cout << dp(0, n-1) << std::endl;
    }
}


Measured memory_bytes: 3272
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M -9223372036854775807
typedef pair<ll,ll> P;
ll dp[501][10001],man[10001];
P box[501];
int main(void){
	ll i,j,k,m,n,sum,jj,mx,flg;
	cin>>m>>n;
	for(i=1;i<=m;i++) cin>>man[i];
	sort(man+1,man+m+1,greater<ll>());
//	for(i=1;i<=m;i++) cout<<man[i]<<endl;
	for(i=1;i<=n;i++) cin>>box[i].second>>box[i].first;
	sort(box+1,box+n+1);
//	for(i=1;i<=n;i++) cout<<box[i].second<<' '<<box[i].first<<endl;
	for(i=0;i<=n;i++){
		for(j=0;j<=m;j++) dp[i][j]=M;
	}
	dp[0][0]=0;
	for(i=0;i<n;i++){
		for(j=0;j<=m;j++){
			if(dp[i][j]!=M){
				dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
				jj=j+box[i+1].second;
				sum=0; flg=0;
				for(k=j+1;k<=jj;k++){
					if(k>m){
						flg=1;
						break;
					}
					sum+=man[k];
				}
				if(flg==1) jj=m;
				sum=sum-box[i+1].first;
				dp[i+1][jj]=max(dp[i+1][jj],dp[i][j]+sum);
			}
		}
	}
/*	for(i=0;i<=n;i++){
		for(j=0;j<=m;j++) cout<<dp[i][j]<<' ';
		cout<<endl;
	}*/
	mx=0;
	for(i=0;i<=m;i++)mx=max(mx,dp[n][i]);
	cout<<mx<<endl;
	return 0;
}

Measured memory_bytes: 42368
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)
 
int main() {
  string s;
  cin >> s;
  int n = s.size();
  vector<int> res(n);
 
  int cnt = 0;
  char curr = 'R';
  int last_idx = 0;
 
  rep(i, n) {
    char c = s[i];
    if (curr == 'R') {
      if (c == 'R') {
        ++cnt;
      } else {
        res[i] += cnt / 2;
        res[i - 1] += (cnt + 1) / 2;
        last_idx = i;
        curr = 'L';
        cnt = 1;
      }
    } else {
      if (c == 'L') {
        ++cnt;
      } else {
        res[last_idx - 1] += cnt / 2;
        res[last_idx] += (cnt + 1) / 2;
        curr = 'R';
        cnt = 1;
      }
    }
  }
  res[last_idx - 1] += cnt / 2;
  res[last_idx] += (cnt + 1) / 2;
 
  rep(i, n - 1) {
    cout << res[i] << " ";
  }
  cout << res[n - 1] << endl;
}

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

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

    string S1, S2;
    cin >> S1 >> S2;
    if (S1[0] == S2[2] && S1[1] == S2[1] && S1[2] == S2[0]) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}
int main() {
  ll n,a,b;
  cin >> n >> a >> b;
  ll ans;
  if(abs(a-b) % 2 == 0){
    ans = abs(a-b) / 2;
  }else{
    tmp1 = (a-1 + b - 1 + 1)/2;
    tmp2 = (n-a + n-b + 1)/2;
    ans = min(tmp1,tmp2);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
typedef long long ll; 
using namespace std;
int main(){
    ll a,b,c;
    cin>>a>>b>>c;
   ll p[3]={a,b,c};
   sort(p,p+3);
   if(p[2]%2==0){
       cout<<0<<endl;
   }
   else
   {
       ll sum=p[1]*p[0];
       cout<<sum<<endl;
   }
   
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int X, Y, min, max;
	cin >> X >> Y;
	min = X * 2;
	max = X * 4;
	if(Y % 2 != 0 || Y < min || Y > max)
	{
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;


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

  ll X,Y,Z;
  cin >> X>>Y>>Z;

  ll ans ;


  cout << Z<<" "<<X<<" " <<Y << endl;



}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m;
int k;
int x,y,z;
int ans;
int main(){
	cin>>x>>y>>z>>n>>m;
	k=min(n,m);
	if(x+y<=z*2){
		cout<<x*n+y*m;
		return 0;
	}
	ans+=k*2*z;
	n-=k;
	m-=k;
	if(n){
		if(x<=z*2)ans+=x*n;else ans+=2*z*n;
	}
	else{
		if(y<=z*2)ans+=y*m;else ans+=2*z*m;
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <vector>

using namespace std;

int main() {
  vector<int> mountains;
  for (int i = 0; i < 10; i++) {
    int mountain;
    scanf("%d", &mountain);
    mountains.push_back(mountain);
  }
  sort(mountains.begin(), mountains.end(), greater<int>());
  for (int i = 0; i < 3; i++) {
    printf("%d\n", mountains[0]);
    mountains.erase(mountains.begin());
  }
}

Measured memory_bytes: 2688
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
#include <iostream>
using namespace std;

int main()
{
    int K, N;
    cin >> K >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    A.push_back(A.at(0)+K);
    
    int sum = 0;
    for (int i = 0; i < N; i++) {
        sum = max(sum, A.at(i+1) - A.at(i));
    }
    
    int ans = K - sum;
    cout << ans << endl;
}


Measured memory_bytes: 1792
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        x: i128,
        k: i128,
        d: i128,
    }
    let x = x.abs();
    if x >= k * d {
        println!("{}", (x - k * d));
    } else {
        let z = x / d;
        let y = x - z * d;
        if (k - z) % 2 == 0 {
            println!("{}", y);
        } else {
            println!("{}", (y - d).abs());
        }
    }
}


Measured memory_bytes: 2140
import itertools
import copy
H,W,K = (int(i) for i in input().split())

a = [[0 for j in range(6)] for i in range(6)]

for i in range(H):
    s = input()
    for j in range(W):
        if s[j] == ".":
            a[i][j] = 0
        else:
            a[i][j] = 1

result = 0
for row in a:
    result += sum(row)

HH = range(H)
WW = range(W)

resH = [()]
resW = [()]
for n in range(1,len(HH)+1):
    for conb in itertools.combinations(HH, n):
        resH.append(list(conb)) 
for n in range(1,len(WW)+1):
    for conb in itertools.combinations(WW, n):
        resW.append(list(conb)) 

ko = 0
for i in resH:
    for j in resW:
        b = copy.deepcopy(a)
        p = itertools.product(i, j)
        for ii in i:
            for jj in range(W):
                b[ii][jj] = 0
        for jj in j:
            for ii in range(H):
                b[ii][jj] = 0

        result = 0
        for row in b:
            result += sum(row)
        if result == K:
            ko += 1

print(ko)




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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    int n, k; cin >> n >> k;
    int ans = 0;
    rep(i, n) {
        int h; cin >> h;
        if(h >= k) ans++;
    }
    cout << ans << '\n';
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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 (b<a) { a=b; return true; } return false; }

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n,t;
    cin>>n>>t;
    ll ans=max(0LL,n-t);
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define llinf 1e17
#define nllinf -4e18
 
#define vll vector<ll>
#define sll set<ll>
#define pll pair<ll,ll> 
#define vpll vector<pair<ll,ll > >
 
#define repup(a,b,i) for(i=a;i<=b;i++)
#define repdown(a,b,i) for(i=b; i>=a; i--)
#define repupx(a,b,i,x) for(i=a;i<=b;i+=x)
	
#define repit(v,it) for(it=v.begin(); it!=v.end(); it++)
#define itall(v) v.begin(),v.end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define fr first
#define sc second
 
#define err(n) cout<<n<<" ";
#define t1 cout<<",";
 
ll MOD= 1e9 +7;


int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll i,j,k;

ll n;cin>>n;
double dp[n+5];
repup(0,n+4,i)dp[i]=1;
double p[n];repup(0,n-1,i)cin>>p[i];

repup(0,n-1,i){
	dp[i+1]=dp[i]*p[i];
	repdown(1,i,j){
		dp[j]= dp[j]*(1-p[i])+ dp[j-1]*p[i];
	}
	dp[0]*=(1-p[i]);
	
}
double ans=0;
repup(n/2+1, n,i){
	ans+=dp[i];
}
cout<<setprecision(10);
cout<<ans;
}

Measured memory_bytes: 256
from itertools import chain
n,m=map(int,input().split())
a=[0]*(n)
b=[0]*(n)
for i in range(n):
  b[i]=list(map(int,input().split()))
for i in range(n):
  a[i]=b[i][1:]
ans=0
c=[e for p in a for e in p]
for j in range(1,m+1):
  if c.count(j)==n:
    ans+=1
print(ans)

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int a, b;
  cin >> a >> b;
  cout << max({a + b, a - b, a * b}) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#define pai 3.1415926535

int main(void) {
	char S[11];
	scanf("%s", S);
	int count1 = 0;
	int count2 = 0;
	for (int i = 0; i < strlen(S); i++) {
		if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
			count1++;
			if (count1 > count2) {
				count2 = count1;
			}
		}
		else {
			count1 = 0;
		}
	}
	printf("%d", count2);

	return 0;
}




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

#define LL long long

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    LL m, cnt = 0, sum = 0, d, c; cin >> m; 
    while(m--) {
        cin >> d >> c;
        sum += d * c, cnt += c;
    }    
    cout << (cnt - 1) + (sum-1) / 9;
}

Measured memory_bytes: 3604
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

#[allow(dead_code)]
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn input<T: FromStr>(&mut self) -> T {
        self.read().unwrap()
    }

    fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.input()).collect()
    }

    fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}
trait BinarySearch<T> {
    // key 以上の値が最初に現れる index を返す
    fn lower_bound(&self, &T) -> usize;
    // key より大きい値が最初に現れる index を返す
    fn upper_bound(&self, &T) -> usize;
}
use std::cmp::Ordering;
impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound(&self, key: &T) -> usize {
        let mut ng = -1;
        let mut ok = self.len() as i64;
        while (ok - ng).abs() > 1 {
            let mid = (ok + ng) / 2;
            match key.cmp(&self[mid as usize]) {
                Ordering::Less | Ordering::Equal => {
                    ok = mid;
                }
                Ordering::Greater => {
                    ng = mid;
                }
            }
        }
        ok as usize
    }

    fn upper_bound(&self, key: &T) -> usize {
        let mut ng = -1;
        let mut ok = self.len() as i64;
        while (ok - ng).abs() > 1 {
            let mid = (ok + ng) / 2;
            match key.cmp(&self[mid as usize]) {
                Ordering::Less => {
                    ok = mid;
                }
                Ordering::Equal |Ordering::Greater => {
                    ng = mid;
                }
            }
        }
        ok as usize
    }
}
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: i64 = sc.input();
    let mut a: Vec<i64> = sc.vec(n as usize);
    let mut b: Vec<i64> = sc.vec(n as usize);
    let mut c: Vec<i64> = sc.vec(n as usize);

    a.sort();
    b.sort();
    c.sort();

    let mut ans: i64 = 0;
    for x in b.iter() {
        let lower = a.lower_bound(&x) as i64;
        let upper = c.upper_bound(&x) as i64;
        ans += lower * (n - upper);
    }
    println!("{}", ans);
}


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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  int a, b;
  std::cin >> a >> b;

  if(a < b) {
    rep(i, b) {
      std::cout << a;
    } std::cout << "" << '\n';
    return 0;
  } else {
    rep(i, a) {
      std::cout << b;
    } std::cout << "" << '\n';
    return 0;
  }
}


Measured memory_bytes: 256
using System;
using System.Linq;
using static System.Math;
using System.Collections.Generic;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var revA = new int[n];
            for(int i=0;i<n;i++)
            {
                revA[a[i]-1] = i+1;
            }
            foreach(var x in revA)
            {
                Console.Write("{0} ",x);
            }


            
        }
    }
}


Measured memory_bytes: 26328
//config = { input: 'tmp', newline: '\r\n' }; // win
config = { input: '/dev/stdin', newline: '\n' }; // linux

A = require('fs').readFileSync(config.input, 'ascii')
  .trim()
  .split(config.newline);
A.shift();
A = A.map(function (line) {
  var ary = line.split(' ');
  return {'suit': ary[0], 'number': parseInt(ary[1], 10)};
});

B = [].concat(A);
sort(B, 0, B.length);
console.log(is_stable(A, B) ? 'Stable' : 'Not stable');
for (i in B) console.log('%s %d', B[i].suit, B[i].number);

function sort(A, p, r) {
  if (r - p >= 2) {
    q = partition(A, p, r);
    sort(A, p, q);
    sort(A, q+1, r);
  }
}

function partition(A, p, r) {
  var x, i, j, tmp;
  x = A[r - 1].number;
  i = p;
  for (j = p; j < r - 1; j++) {
    if (A[j].number <= x) {
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
      i++;
    }
  }
  tmp = A[i];
  A[i] = A[r - 1];
  A[r - 1] = tmp;
  return i;
}

function get_doubled_numbers(ary) {
  var numbers, res, i, cur, cnt;
  numbers = ary.map(function (x) { return x.number; });
  numbers.sort(function (a, b) { return a - b; });
  res = [];
  cur = 0;
  cnt = 0;
  for (i in numbers) {
    if (numbers[i] !== cur) {
      if (cnt >= 2) res.push(cur);
      cur = numbers[i];
      cnt = 1;
    } else {
      cnt++;
    }
  }
  if (cnt >= 2) res.push(cur);
  return res;
}

function is_this_number(card) {
  return card.number === this.number;
}

function equal(cards1, cards2) {
  for (var i in cards1)
    if (cards1[i].suit !== cards2[i].suit) return false;
  return true;
}

function is_stable(A, B) {
  var doubled, i, filter_object, a, b;
  doubled = get_doubled_numbers(A);
  for (i in doubled) {
    filter_object = {'number': doubled[i]};
    a = A.filter(is_this_number, filter_object);
    b = B.filter(is_this_number, filter_object);
    if (!equal(a, b)) return false;
  }
  return true;
}

Measured memory_bytes: 61408
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{    

    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());

        string input = Console.ReadLine();
        string[] str = input.Split(' ');

        int[] data = new int[n];

        for(int i = 0; i < n; i++)
        {
            data[i] = int.Parse(str[i]);
        }
      
        int count = 0;      

        for(int i = 0; i < n - 1; i++)
        {
            int minj = i;

            for(int j = i; j < n; j++)
            {
                if(data[j] < data[minj])
                {
                    minj = j;                 
                }
               
            }

            int temp = data[i];
            data[i] = data[minj];
            data[minj] = temp;
            if(i != minj)
            {
                count++;
            }
            
        }
        

        Console.WriteLine(String.Join(" ", data));
        Console.WriteLine(count);
       
    }
}


Measured memory_bytes: 18000
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n,a[110];
signed main(){
    cin>>n;
    int ans=INF;
    rep(i,n)cin>>a[i];
    for(int i=0;i<=100;i++){
        int sum=0;
        rep(j,n){
            sum+=(a[j]-i)*(a[j]-i);
        }
        chmin(ans,sum);
    }
    cout<<ans<<endl;
    return 0;
}

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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

int main()
{
	louble n=ty(),d=ty(),x=ty(),ans=0;
	for(int i=n;i>=1;i--)ans+=d+x*(i+i-1)*0.5,d=(d*(i+i+2)+5*x)/(i+i),x=x*(i+2)/i;
	printf("%.13Lf\n",ans);

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
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; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<int> c(n),l(200000,-1);
    for(int i=0;i<n;i++){
        cin >> c[i];
        c[i]--;
    }
    vector<ll> dp(n+1);
    dp[0]=1;
    for(int i=0;i<n;i++){
        (dp[i+1]+=dp[i])%=mod;
        if(l[c[i]]!=-1&&l[c[i]]<i-1){
            (dp[i+1]+=dp[l[c[i]]+1])%=mod;
        }
        l[c[i]]=i;
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 3456
s = input()
n = len(s) + 1
l = [None]*n
s = '>' + s + '<'
for i in range(n):
  if s[i] == '>' and s[i+1] == '<':
    l[i] = 0
  elif s[i] == '<':
      l[i] = l[i-1] + 1
for i in range(n-1,-1,-1):
  if s[i+1] == '>':
    if l[i] is None or l[i] < l[i+1]+1:
      l[i] = l[i+1] + 1

print(sum(l))

Measured memory_bytes: 23220
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;

#define ll long long

ll MAX(ll a, ll b) {

	if (a>b)return a;
	else return b;

}
bool func(ll n) {

	for (int i = 2; i <= sqrt(n); i++)if (n%i == 0)return false;

	return true;

}
int main() {
	
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (abs(a - c) <= d || (abs(a - b) <= d&&abs(b - c) <= d))cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import core.bitop : popcnt;
alias Generator = std.concurrency.Generator;

enum long INF = long.max/5;
enum long MOD = 10L^^9+7;

void main() {
  char[] xs = readln.chomp.to!(char[]);
  long ans = 0;
  foreach(i; 0..xs.length/2) {
    if (xs[i] != xs[$-i-1]) ans++;
  }
  ans.writeln;
}

// ----------------------------------------------


void times(alias fun)(long n) {
  // n.iota.each!(i => fun());
  foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(long n) {
  // return n.iota.map!(i => fun()).array;
  T[] res = new T[n];
  foreach(ref e; res) e = fun();
  return res;
}

T ceil(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  // `(x+y-1)/y` will only work for positive numbers ...
  T t = x / y;
  if (y > 0 && t * y < x) t++;
  if (y < 0 && t * y > x) t++;
  return t;
}

T floor(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  T t = x / y;
  if (y > 0 && t * y > x) t--;
  if (y < 0 && t * y < x) t--;
  return t;
}

ref T ch(alias fun, T, S...)(ref T lhs, S rhs) {
  return lhs = fun(lhs, rhs);
}
unittest {
  long x = 1000;
  x.ch!min(2000);
  assert(x == 1000);
  x.ch!min(3, 2, 1);
  assert(x == 1);
  x.ch!max(100).ch!min(1000); // clamp
  assert(x == 100);
  x.ch!max(0).ch!min(10); // clamp
  assert(x == 10);
}

mixin template Constructor() {
  import std.traits : FieldNameTuple;
  this(Args...)(Args args) {
    // static foreach(i, v; args) {
    foreach(i, v; args) {
      mixin("this." ~ FieldNameTuple!(typeof(this))[i]) = v;
    }
  }
}

void scanln(Args...)(auto ref Args args) {
  enum sep = " ";
  enum n = Args.length;
  enum fmt = n.rep!(()=>"%s").join(sep) ~ "\n";
  static if (__VERSION__ >= 2071) {
    readf!fmt(args);
  } else {
    enum argsTemp = n.iota.map!(
      i => "&args[%d]".format(i)
    ).join(", ");
    mixin(
      "readf(fmt, " ~ argsTemp ~ ");"
    );
  }
}

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
  template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
      static if (S.length < 2) {
        return reduce!fun(seed, r);
      } else {
        return reduce!fun(tuple(seed), r);
      }
    }
  }
}

// popcnt with ulongs was added in D 2.071.0
static if (__VERSION__ < 2071) {
  ulong popcnt(ulong x) {
    x = (x & 0x5555555555555555L) + (x>> 1 & 0x5555555555555555L);
    x = (x & 0x3333333333333333L) + (x>> 2 & 0x3333333333333333L);
    x = (x & 0x0f0f0f0f0f0f0f0fL) + (x>> 4 & 0x0f0f0f0f0f0f0f0fL);
    x = (x & 0x00ff00ff00ff00ffL) + (x>> 8 & 0x00ff00ff00ff00ffL);
    x = (x & 0x0000ffff0000ffffL) + (x>>16 & 0x0000ffff0000ffffL);
    x = (x & 0x00000000ffffffffL) + (x>>32 & 0x00000000ffffffffL);
    return x;
  }
}


Measured memory_bytes: 256
import numpy as np
import math

def coin_prob(dice, score):
    num = math.ceil(np.log2(score/dice))
    return 1/(2 ** num)

N,K = map(int, input().split())
base = 0

if N >= K:
    base = (N - K + 1)/N
    for i in range(1,K):
        base = base + coin_prob(i, K)/N
else:
    for i in range (1,N + 1):
        base = base + coin_prob(i, K)/N
print(base)

Measured memory_bytes: 12500
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
 
int main()
{
	vector<string> ans;
	string E = "-";
	while (1){
		string s;
		int m;
		cin >> s;
		if (s == E) break;
		cin >> m;
		REP(i, m){
			int h;
			cin >> h;
			string tmp = s.substr(0, h);
			s.erase(0, h);
			s += tmp;
		}
		ans.push_back(s);
	}

	for (auto x : ans) cout << x << endl;
}



Measured memory_bytes: 3168
h, w = map(int, input().split())
field = ["." * (w + 2)] + ["." + input() + "." for x in range(h)] + ["." * (w + 2)]

result = [["@" for x in range(w)] for x in range(h)]
#
# for i in field: print(i)
# print()

for i, row in enumerate(field[1:-1]):
    for j, cell in enumerate(row[1:-1]):
        if cell == ".":
            part = "".join(field[i + n][j:j+3] for n in range(3))
            result[i][j] = part.count("#")
        else:
            result[i][j] = "#"

for i in result: print("".join(map(str, i)))


Measured memory_bytes: 3064
a, b = map(int,input().split())
B = []
A = []
for i in range(1, a+1):
    B.append(b+i-1)
    A.append(abs(b+i-1))

if min(A) in B:
    print(sum(B) - min(A))
else:
    print(sum(B) + min(A))

Measured memory_bytes: 38256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  cin >> str;

  int n;
  n = str.length();
  char c = 'a';
  
  for(int i=0; i<26; i++){
    int flg = 0;
    for(int j=0; j<n; j++){
      if(str[j]==c){
        flg = 1;
      }
    }
    if(flg==0){
      cout << c << endl;
      break;
    }
    c = c + 1;
    if(i==25){
      cout << "None" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cmath>
//#include<array>
#include<algorithm>
//#include<deque>
#include<vector>
//#include<utility>
//#include<set>
//#include<map>
//#include<list>

using namespace std;
using LLI = long long int;
vector<int>dir_x = { 0,0,1,1,1,-1,-1,-1 };
vector<int>dir_y = { 1,-1,1,0,-1,1,0,-1 };
vector<int>dir_x2 = { 0,0,1,-1 };
vector<int>dir_y2 = { 1,-1,0,0 };

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//LLI gcd(LLI x, LLI y) {
//	LLI tmp, r;
//	if (x < y) {
//		tmp = x;
//		x = y;
//		y = tmp;
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}
//LLI lcm(LLI x,LLI y) {
//	return x / gcd(x,y) * y;
//}

//long nCr(int n,int r) {
//	long ans = 1;
//	for (int i = n; i > n - r;i--) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1;i++) {
//		ans = ans / i;
//	}
//	return ans;
//}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

int main(void) {
	vector<LLI>A;
	vector<LLI>B;
	vector<LLI>C;
	LLI N,a,cnt = 0;
	cin >> N;
	for (int i = 0; i < N;i++) {
		cin >> a;
		A.push_back(a);
	}
	for (int i = 0; i < N; i++) {
		cin >> a;
		B.push_back(a);
	}
	for (int i = 0; i < N; i++) {
		cin >> a;
		C.push_back(a);
	}

	sort(A.begin(),A.end());
	sort(B.begin(),B.end());
	sort(C.begin(),C.end());
	
	for (int i = 0; i < N;i++) {
		LLI Acnt = lower_bound(A.begin(),A.end(),B[i]) - A.begin();
		LLI Ccnt = C.end() - upper_bound(C.begin(),C.end(),B[i]);
		cnt += Acnt * Ccnt;
	}
	cout << cnt << endl;
}

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

using namespace std;
#define rep(i, n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
typedef long double Double;

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif


int sum[4000][4000];

void solve(ll N, ll K, vector<ll> x, vector<ll> y, vector<string> c) {
    int M = 2 * K;
    for (int i = 0; i < N; i++) {
        if (c[i] == "W") x[i] += K;
        x[i] %= M;
        y[i] %= M;
        sum[x[i] + M][y[i] + M]++;
        sum[x[i]][y[i]]++;
        sum[x[i] + M][y[i]]++;
        sum[x[i]][y[i] + M]++;
    }
    for (int i = 0; i < 2 * M; i++) {
        for (int j = 1; j < 2 * M; j++) {
            sum[i][j] += sum[i][j - 1];
        }
    }


    for (int i = 1; i < 2 * M; i++) {
        for (int j = 0; j < 2 * M; j++) {
            sum[i][j] += sum[i - 1][j];
        }
    }

    auto f = [&](int k, int x, int y, int X, int Y) {
        int ans =
                sum[Y - 1][X - 1] - (y ? sum[y - 1][X - 1] : 0) - (x ? sum[Y - 1][x - 1] : 0) +
                (x && y ? sum[y - 1][x - 1] : 0);
        return ans;
    };
    int ans = 0;
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < M; j++) {
            int topLeft = f(0, i, j, i + K, j + K);
            int bottomRight = f(0, i + K, j + K, i + 2 * K, j + 2 * K);
            int sub = topLeft + bottomRight;
            ans = max(ans, sub);
        }
    }
    cout << ans << endl;
}


void main_(istream &cin) {
    ll K;
    ll N;
    cin >> N;
    vector<string> c(N - 1 + 1);
    vector<ll> y(N - 1 + 1);
    vector<ll> x(N - 1 + 1);
    cin >> K;
    for (int i = 0; i <= N - 1; i++) {
        cin >> x[i];
        cin >> y[i];
        cin >> c[i];
    }
    solve(N, K, x, y, c);
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





Measured memory_bytes: 72192
a, b, c, d = map(int, input().split())
if c-b <= 0 :
    print('Yes')
else :
    for i in range(100):
        C = c-b 
        if C <= 0:
            print('Yes')
            break
        A = a-d 
        if A <= 0:
            print('No')
            break
        c = C;a = A

Measured memory_bytes: 61820
import math

def combi(n ,k):
    return math.factorial(n)//(math.factorial(k)*math.factorial(n-k))

N,K = map(int,input().split())
R = N - K

for i in range(1,K+1):
    if R + 1 >= i:
        tmp = combi(R+1,i) * combi(K-1,i-1)
    else:
        tmp = 0
    print(tmp % (10**9+7))

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) ((a>b)?a:b);
#define min(a,b) ((b>a)?a:b);
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert                                                                      //copy NUL check.cpp
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)                                 //g++ atc.cpp -o atc.exe
#define zeroes(x) memset(x,0,sizeof(x))                                        //all elements to 0
#define all(x) (x).begin(), (x).end()
typedef long long int ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn=100000;







bool sortbysec(const pair<int,int> &a,                         //sorting of elements wrt second
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 




int main()
{
	long int n,b;
	vector< pair <long long int, long long int> > vect;
	cin>>n;

	
	for(int i=1;i<=n;i++)
	{
		cin>>b;

		vect.push_back( make_pair(b,i) ); 
 	}
 	
 	sort(vect.begin(), vect.end()); 
 	for(int i=0;i<n;i++)
	{
		cout<<vect[i].second<<" ";
		} 

	return 0;
}

Measured memory_bytes: 2544
N, x = gets.split.map(&:to_i)
As = gets.split.map(&:to_i)

ss = As.sort.inject([0]){|s, a| s << s.last + a}.drop(1)
if ss.last == x
  puts N
else
  k = ss.take_while{|s| s <= x}.length
  if k == N
    puts N - 1
  else
    puts k
  end
end

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = Integer.parseInt(sc.next());

        for (int i = 0; i < n; i++) {
            Double x1 = Double.parseDouble(sc.next());
            Double y1 = Double.parseDouble(sc.next());
            Double x2 = Double.parseDouble(sc.next());
            Double y2 = Double.parseDouble(sc.next());
            Double x3 = Double.parseDouble(sc.next());
            Double y3 = Double.parseDouble(sc.next());

            double px, py, r;

            px = ((2*(y2-y1))*(Math.pow(x1, 2)-Math.pow(x3,2)+Math.pow(y1,2)-Math.pow(y3,2))-(2*(y3-y1))*(Math.pow(x1,2)-Math.pow(x2,2)+Math.pow(y1,2)-Math.pow(y2,2)))
                    /((2*(x2-x1))*(2*(y3-y1))-(2*(x3-x1))*(2*(y2-y1)));

            py = ((Math.pow(x1,2)-Math.pow(x2,2)+Math.pow(y1,2)-Math.pow(y2,2))*(2*(x3-x1))-(Math.pow(x1,2)-Math.pow(x3,2)+Math.pow(y1,2)-Math.pow(y3,2))*(2*(x2-x1)))
                    /((2*(x2-x1))*(2*(y3-y1))-(2*(x3-x1))*(2*(y2-y1)));
            r = Math.sqrt((Math.pow(px-x1,2))+(Math.pow(py-y1,2)));

            px *= 1000;
            px = Math.round(px);
            px /= 1000;
            
            py *= 1000;
            py = Math.round(py);
            py /= 1000;
            
            r *= 1000;
            r = Math.round(r);
            r /= 1000;

            System.out.printf("%.3f %.3f %.3f\n", px, py, r);
        }
    }
}

Measured memory_bytes: 26444
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; i<n; i++)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define reprs(i, s, e) for(int i=s-1; i>=s; i--)

ll gcd(ll n, ll m){

    if(m > n)  return gcd(m, n);

    ll r = n % m;
    if(r == 0) return m;
    else       return gcd(m, r);
}

ll lcm(ll n, ll m){
    return n / gcd(n, m) * m;
}

int main(){

    ll n; cin >> n;
    ll a[n];
    rep(i, n){
        cin >> a[i];
    }

    ll temp = gcd(a[0], a[1]);
    reps(i, 2, n){
        temp = gcd(temp, a[i]);
    }

    cout << temp;

    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

vector<P> v;

int main(void){
	int n,i;
	ll a,b,t=0ll;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> a >> b;
		v.push_back(P(b,a));
	}
	sort(v.begin(),v.end());
	for(i=0; i<n; ++i){
		t += v[i].second;
		if(t>v[i].first){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


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

const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

int main() {
	
	//vector<int> a(n);  sort(a.begin(),a.end());
	//cout << "test" << "\n";
	cin.tie(0);
	ios::sync_with_stdio(false);
	//string ans="YES";
	
	
	ll ans=0;
	
	int n;
	cin >> n;
	
	vector<int> a(n),b(n);
	rep(i,n) cin >> a[i],b[i]=a[i];
	sort(a.begin(),a.end());
	
	
	int n1,n2;
	
	rep(i,n){
		if(a[n-1]==b[i]) n1=i;
		else if(a[n-2]==b[i]) n2=i;
	}
	
	//cout << n1 << "()" << endl;
	
	rep(i,n){
		if(i!=n1) ans=a[n-1];
		else ans=a[n-2];
		cout << ans << "\n";
	}
	
	
	return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;




int main(){
    ll n,h;

    cin>>n>>h;
    vector<ll> a(n);
    vector<ll> b(n);
    for(int i=0;i<n;i++){
        ll x,y;
        cin>>x>>y;
        a.push_back(x);
        b.push_back(y);
    }
    
    sort(a.rbegin(),a.rend());
    sort(b.rbegin(),b.rend());
    
    ll nage=0;
    ll nokori=0;
    ll ans=0;
    
    
    ll mi=h/a[0];
    
    if(h%a[0]!=0)mi++;
    
    
    for(ll i=0;i<n;i++){
        nage+=b[i];
        nokori=h-nage;
        if(nokori>0){
        ans=nokori/a[0];
        if(nokori%a[0]!=0)ans++;
        ans+=i+1;
        }else{
            ans=i+1;
        }
        mi=min(ans,mi);
    }
    
    cout<<mi<<endl;
    

return 0;
}


Measured memory_bytes: 3424