akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>s
using namespace std;
char s;
int main()
{
    int a,b;
    cin>>a>>b;
    for(int i=1;i<=a+b+1;i++)
    {
        cin>>s;
        if((s<'0'||s>'9')&&i!=a+1)
        {
            cout<<"No"<<endl;
            return 0;
        }
        if(i==a+1&&s!='-')
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
using namespace std;
int A[26];
int main() {
	string str;
	cin >> str;
	for (int i = 0; i < str.size(); ++i) {
		A[str[i] - 'a']++;
	}
	bool X = 1;
	for (int i = 0; i < 26; ++i) {
		if (A[i] % 2 == 1) {
			X = 0;
		}
	}
	if (X) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
function Main(input) {
    var input = input.split(' ').map(n => parseInt(n, 10));
    var count = 0;
    var x = input[0];
    var y = input[1];
    var z = input[2];
    var i = y + 2*z;
    while(x >= i) {
        count++;
        i += y + z;
    }
    console.log(count);
    
    }
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

int main(void)
{
    std::cout << std::fixed << std::setprecision(10);
    ll W, H, x, y;
    cin >> W >> H >> x >> y;

    printf("%lf %d\n", (double)W * (double)H / 2, (x + x == W) && (y + y == H));
    return (0);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int  main()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  while(1)
  {
     c=c-b;
     a=a-d;
    if(c<=0)
    { 
      cout<<"Yes";
      break;
    }
    else if(a<=0)
    {
      cout<<"No";
      break;
    }
  }
}
  


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

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

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;
const ld PI = 4*atan((ld)1);

int N,M;
bool in[MX];
vi adj[MX], cpath;

void dfs(int x) {
    in[x] = 1; cpath.pb(x);
    for (int i: adj[x]) if (!in[i]) {
        dfs(i);
        return;
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N >> M;
    F0R(i,M) {
        int a,b; cin >> a >> b;
        adj[a].pb(b), adj[b].pb(a);
    }
    vi ans;
    vector<vi> path;
    in[1] = 1;
    for (int i: adj[1]) if (!in[i]) {
        cpath.clear();
        dfs(i);
        path.pb(cpath);
    }
    if (sz(path)) {
        reverse(all(path[0]));
        for (int i: path[0]) ans.pb(i);
    }
    ans.pb(1);
    if (sz(path) > 1) {
        for (int i: path[1]) ans.pb(i);
    }
    cout << sz(ans) << "\n";
    for (int i: ans) cout << i << " ";
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

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

#define ll long long
#define int ll
#define pii pair<int, int>
#define pb push_back
#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define FORD(i, a, b) for (int i=a; i>=b; i--)
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

using namespace std;

void solve() {

    string S, ans;
    cin >> S;

    if (S == "Sunny") ans = "Cloudy";
    else if (S == "Cloudy") ans = "Rainy";
    else if (S == "Rainy") ans = "Sunny";

    print(ans);
}

signed main() {
    solve();
}


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

using namespace std;

//typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)

int N, c[4];
double dp[301][301][301];


double solve(int c1, int c2, int c3){

	if (c1 == 0 && c2 == 0 && c3 == 0) return 0.0;
	if (dp[c1][c2][c3] > 0.0) return dp[c1][c2][c3];

	double ans = 0.0;
	if (c1 > 0) ans += (double)c1 / N*solve(c1 - 1, c2, c3);
	if (c2 > 0) ans += (double)c2 / N*solve(c1 + 1, c2 - 1, c3);
	if (c3 > 0) ans += (double)c3 / N*solve(c1, c2 + 1, c3 - 1);

	dp[c1][c2][c3] = (double)N / (c1 + c2 + c3)*(ans +1.0);
	return dp[c1][c2][c3];
}

signed main(){

	cin >> N;
	for (int i = 0; i < N; i++){
		int t;
		cin >> t;
		c[t]++;
	}

	cout << setprecision(15) << solve(c[1], c[2], c[3]) << endl;

	return 0;
}


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

using namespace std;

int main() {

	long h, n;
	cin >> h >> n;

	vector<long> a(n + 1);
	vector<long> b(n + 1);

	for (long i = 1; i <= n; i++) {
		cin >> a[i] >> b[i];
	}

	vector<long> dp(h + 1,1000000000);

	dp[0] = 0;
	for (long i = 1; i <= h; i++) {

		for (long j = 1; j <= n; j++) {
			
			if (i - a[j] >= 0) {
				dp[i] = min(dp[i], dp[i - a[j]] + b[j]);
			}
			else {
				dp[i] = min(dp[i], b[j]);
			}
		}
	}

	cout << dp[h] << endl;
	return 0;
}

Measured memory_bytes: 512
import java.util.*;
public class Main {
	
	Scanner sc = new Scanner(System.in);
	int n,q;
	int nowtime=0;
	Integer process;
	String name;
	
	Queue<String> jobname = new ArrayDeque<String>();
	Queue<Integer> queue = new ArrayDeque<Integer>();
	
	Queue<String> finishjob = new ArrayDeque<String>();
	Queue<Integer> finish = new ArrayDeque<Integer>();
	
	public void input() {
		n = sc.nextInt();
		q = sc.nextInt();
		for(int i=0; i<n; i++) {
			jobname.add( sc.next() );
			queue.add( sc.nextInt() );
		}
	}
	
	public void queue() {
		while(true) {
			process = queue.poll();
			if(process == null) break; //キューがnullなら終了
			if(q >= process) { //プロセスの終了
				nowtime += process;
				name = jobname.poll();
				finish.add(nowtime);
				finishjob.add(name);
			}else { //タイムクオンタムを超えた
				nowtime += q;
				name = jobname.poll();
				queue.add( process-q );
				jobname.add(name);
			}
		}
	}
	
	public void output() {
		while(true) {
			name = finishjob.poll();
			process = finish.poll();
			if(name == null || process == null) break;
			System.out.println(name+" "+process);
		}
	}
	
	public static void main(String[] args) {
		Main obj = new Main();
		obj.input();
		obj.queue();
		obj.output();
	}
}



Measured memory_bytes: 76012
module Main (main) where
import Control.Applicative hiding (read)

type Point = (Integer,Integer)
type Rect = Point
type Circle = (Point,Integer)

main :: IO ()
main = do
  [w,h,x,y,r] <- (map read . words) <$> getLine :: IO [Integer]
  putStrLn $ yesno $ overlap (w,h) ((x,y),r)

overSurface :: Rect -> Circle -> Bool
overSurface (_,h) ((_,y),r) = h < y + r

overBase :: Rect -> Circle -> Bool
overBase _ ((_,y),r) = 0 > y - r

overRight :: Rect -> Circle -> Bool
overRight (w,_) ((x,_),r) = w < x + r

overLeft :: Rect -> Circle -> Bool
overLeft _ ((x,_),r) = 0 > x - r

overlap :: Rect -> Circle -> Bool
overlap rect circle
  | overSurface rect circle || overBase rect circle ||
    overRight rect circle || overLeft rect circle = False
  | otherwise = True

yesno :: Bool -> String
yesno True  = "Yes"
yesno False = "No"

Measured memory_bytes: 3636
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
 
#define lint long long
#define VI vector<int>
#define VL vector<lint>
#define VB vector<bool>
#define VC vector<char>
#define VS vector<string>
#define VVI vector<VI>
#define VVL vector<VL>
#define rep(i, n) for(int i = 0 ; i < n ; i++)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int main(){
    int w, a, b;
    cin >> w >> a >> b;
    if(a < b){
        cout << max(b-(a+w), 0) << endl;
    }else{
        cout << max(a-(b+w), 0) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    if (a > b) {
        if (v <= w) {
            cout << "NO" << endl;
        }
        else if ((abs(b - a) + (v - w - 1)) / (v - w) <= t) {
            cout << "YES" << endl;
        } 
        else {
            cout << "NO" << endl;
        }
    } 
    else {
        if (v <= w) {
            cout << "NO" << endl;
        }
        else if ((b - a + (v - w - 1)) / (v - w) <= t) {
            cout << "YES" << endl;
        }
        else {
            cout << "NO" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
int c(int a,int b){
	return a/b +((a%b)!=0);
}
int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	int n,k; cin>>n>>k;
	for(int i=1; i<=n; i++) {
		int a; cin>>a;
	}

	cout<<c(n-1,k-1)<<endl;


	return 0;
}


Measured memory_bytes: 3636
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
int compare(const void *a,const void *b){
    if(*(int *)a>*(int *)b)return 1;
    return -1;
}
int main()
{   int a,b;
    scanf("%d%d",&a,&b);
    for(int i=1;i<=1250;i++){
        if(i*2/25==a&&i/10==b){
            printf("%d",i);
            return 0;
        }
    }
    printf("-1");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds; 
using namespace std;

#define int           long long
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define ub            upper_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (int)(4e18)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii>
#define ordered_set   tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){ cerr << name << " = " << arg1 << endl;}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args)
{ const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);}

template< typename T1, typename T2 > istream& operator>>(istream& in, pair<T1, T2> &q){ in >> q.F >> q.S; return in;}
template< typename T1, typename T2 > ostream& operator<<(ostream& out, pair<T1, T2> &q){ out << q.F << " " << q.S; return out;}
template< typename T1, typename T2 > pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F+p2.F, p1.S+p2.S};}
template< typename T1, typename T2 > pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F-p2.F, p1.S-p2.S};}
template< typename T1, typename T2 > bool operator<(pair<T1, T2> p1, pair<T1, T2> p2){ return p1 < p2 ;}

template<typename T> void Unique(vector<T> &v) {
    sort(all(v)), v.resize(distance(v.begin(), unique(all(v))));
}

void solve() {
	int k;
	cin >> k;
	while(k--) {
		cout << "ACL";
	}cout << endl;
}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   
    start = clock(); 

   

    int test = 1;
    // cin >> test;
    
    cout << fixed << setprecision(2);
     
    for(int i = 1; i <= test; ++i){
    	solve();
    }

    cerr << time(start);
    return 0;
}


Measured memory_bytes: 3800
import java.util.Scanner;

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

        int n = sc.nextInt();
        String gara = "SHCD";
        int [][] card = new int[4][13];
        
        for(int i = 0; i < n; i++){
        	
            char inputgara = sc.next().charAt(0);
            int  cardnum = sc.nextInt();
            
            card[gara.indexOf(inputgara)][cardnum - 1] = 1;// 1???????????? 0??????????????????
            
        }
        
        for(int i = 0 ; i < 4 ; i++ ){
        	for(int j = 0 ; j < 13 ; j++ ){
        		if(card[i][j] != 1){
        			System.out.println( gara.charAt(i) + " " + (j+1));
        		}
        	}
        		
        }
           
            
    }
}

Measured memory_bytes: 26132
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int h,w,cnt=0;
    cin>>h>>w;
    string a[100];
    for(int i=0;i<h;++i)
        cin>>a[i];
    for(int i=0;i<h;++i)
    {   
        for(int j=0;j<w;++j)
        {
            if(a[i][j] == '#')
                cnt++;
        }
    }
    if(cnt==h+w-1)
        cout<<"Possible"<<endl;
    else 
        cout<<"Impossible"<<endl;
    return 0;
    
}

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

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)

const int N = 200;
const int V = 2e5;

typedef long long ll;

int n, w;

ll dp[N][V];

ll ww[N], v[V];


int main() {
    cin >> n >> w;
    int s = 0;
    fore(i, 1, n + 1) {
        cin >> ww[i] >> v[i];
        s += v[i];
    }
    fore(i, 0, s + 1) dp[0][i] = 1e17;
    fore(i, 0, n + 1) dp[i][0] = 0;

    fore(i, 1, n + 1) {
        fore(j, 1, s + 1) {
            dp[i][j] = dp[i - 1][j];
            if(v[i] <= j) dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i]] + ww[i]);
        }
    }
    int res = 0;
    fore(j, 0, s + 1) if(dp[n][j] <= w) res = max(res, j); 
    cout << res << endl;
}

Measured memory_bytes: 158464
import numpy as np


def inpl():
    return list(map(int, input().split()))


N, M, X = inpl()

costs = []
aa = []
for _ in range(N):
    ca = inpl()
    costs.append(ca[0])
    aa.append(ca[1:])

aa = np.array(aa)
costs = np.array(costs)

ans = 10**10
for bit in range(1 << N):
    flags = [(bit >> i) & 1 == 1 for i in range(N)]
    rikai = aa[flags].sum(axis=0)
    if (rikai >= X).sum() == M:
        ans = min(ans, costs[flags].sum())


if ans == 10 ** 10:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 27380
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int> a;
	vector<int> b;
	a.resize(n);
	b.resize(n);
	for(int i = 0; i < n; ++i) {
		int A;
		cin >> A;
		while(A--) {
			int x, y;
			cin >> x >> y;
			--x;
			if(y == 0) {
				b[i] |= 1 << x;
			} else {
				a[i] |= 1 << x;
			}
		}
	}
	int ans = 0;
	for(int S = 0; S < 1 << n; ++S) {
		bool f = true;
		for(int i = 0; i < n; ++i) {
			if(S >> i & 1) {
				if(((S & a[i]) != a[i]) || ((S & b[i]) != 0)) {
					f = false;
				}
			}
		}
		if(f == true) {
			ans = max(ans, __builtin_popcount(S));
		}
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll beki(ll a, ll b) {
	ll tmp = 1;
	REP(i, b) tmp *= a;
	return tmp;
}

string N;

int main() {
	cin >> N;
	REP(i, N.length()) {
		if (N[i] == '1') N[i] = '9';
		else N[i] = '1';
	}
	cout << N << endl;
}

Measured memory_bytes: 256
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Code author: Saurabh Singhal
Code copy karne vaale tera muh kaala
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back

using namespace std;
typedef long long int ll;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
int t=1;
vll_t a,b;
int  main(){
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	// #endif
	int n;
	cin>>n;
	if(n==0){
		cout<<"0"<<endl;
		return 0;
	}
	string res="";
	while(n!=0){
		int rem=n%(2);
		//cout<<rem<<" "<<n<<endl;
		if(rem){
			res+="1";
		}
		else{
			res+="0";
		}
		if(n&1){
			n--;
			n/=-2;
		}
		else{
			n/=-2;
		}
	}
	reverse(res.begin(),res.end());
	cout<<res<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	int N;
	cin >> N;
	if(N == 3 || N == 5 || N == 7)
		cout << "YES";
	else
		cout << "NO";
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.StringBuffer;

class Main{
    public static long fact(int n){
        long ret = 1;
        for(int i = n; i >= 1; i--){
            ret *= i; 
        }
        return ret;
    }
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        String s = new String(in.next());
        int[] count = new int[26];
        for(int i = 0; i < s.length(); i++){
            count[s.charAt(i) - 'a'] ++;
        }
        int nOdd = 0;
        long div = 1;
        for(int i = 0; i < 26; i++){
            if(count[i] % 2 == 1){
                nOdd++;
            }
            div *= fact(count[i] / 2);
        }
        if(nOdd != s.length() % 2){
            System.out.println(0);
        }else{
            System.out.println(fact(s.length() / 2) / div);
        }
    }
}

Measured memory_bytes: 17320
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  int a,d[100000]={};
  while(cin>>a){
    d[a-1]++;
    d[a]++;
    d[a+1]++;
  }
  int mx=0;
  for(int x:d){
    mx=max(mx,x);
  }
  cout<<mx;
}
  

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

int main(){
  long long n,ans = 0;
  cin >> n;
  for(int i = 1;i <= n;i++){
    if((i%3 == 0)||(i%5 == 0)){
      ans += 0;
    }
    else{
      ans += i;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 100000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
int a,b,t;
cin>>a>>b>>t;
int ans=0;
int tmp=a;
while(tmp<=t+0.5){
    ans+=b;
    tmp+=a;
}
cout<<ans<<endl;
   return 0;
}

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

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

  vector<int> d(N);

  for (int i = 0; i < N; i++) {
    cin >> d[i];
  }

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

  int k = d.size();

  if (k % 2 == 1) {
    cout << "0";
    return 0;
  }

  k /= 2;

  cout << d[k] - d[k - 1] << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define upd(x,y) x=(x+y>=mu?x+y-mu:x+y)
int n,m,mu,dp[305][305][305];
int main(){
	scanf("%d%d%d",&n,&m,&mu);
	dp[0][1][0]=1;
	for (int i=0;i<=n;i++)
		for (int j=1;j<=m;j++)
			for (int k=i;k>=0;k--){
				if (k) upd(dp[i][j][k-1],dp[i][j][k]);
				else upd(dp[i][j+1][i],dp[i][j][k]);
				upd(dp[i+1][j][k],1ll*dp[i][j][k]*(k+1)%mu);
			} 
	printf("%d",dp[n][m][0]);
}

Measured memory_bytes: 113040
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

main()
{
  unsigned short *A, *B;
  int C[VMAX+1]; //カウント用
  int i, j, n;

  scanf("%d", &n);
  A = malloc(sizeof(short)*n + 1);
  B = malloc(sizeof(short)*n + 1);

  for(i=0; i<=VMAX; i++) C[i]=0;

  /* Aの読込み & Cにそれぞれの数の出現数をカウント */
  for(i=0; i<n; i++)
    {
      scanf("%hu", &A[i+1]);
      C[A[i+1]]++;
    }

  /* C[i]にi以下の数の出現数を記録(handout 6th lecture p17) */
  for(i=1; i<=VMAX; i++) C[i] = C[i] + C[i-1];

  /* Counting Sort */
  for(j=1; j<=n; j++)
    {
      B[C[A[j]]] = A[j];
      C[A[j]]--;
    }

  /* print */
  for(i=1; i<=n; i++)
    {
      printf("%d", B[i]);
      if(i != n)
	{
	  printf(" ");
	}
    }
  printf("\n");

  return 0;
}

Measured memory_bytes: 8460
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vs = vector<string>;
template <typename T>
using ost = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
#define forn(i,n) for(int i=0; i<int(n); ++i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define ff first
#define ss second

int main() {
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vvi adj(n);
    while (m--) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    vi path{0};
    vi used(n);
    used[0]=1;
    forn(_, 2) {
        for (;;) {
            int v = path.back();
            int next = -1;
            for (int u:adj[v])
                if (!used[u])
                    next = u;
            if (next == -1) break;
            path.push_back(next);
            used[next] = true;
        }
        reverse(all(path));
    }
    int p=path.size();
    cout << p << '\n';
    forn(i, p) cout << (path[i]+1) << " \n"[i+1==p];
}


Measured memory_bytes: 7160
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int N = 3;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		char[] a = sc.next().toCharArray();
		char[] s = sc.next().toCharArray();
		char[] c = sc.next().toCharArray();
		sc.close();
		out.print(a[0]);
		out.print(s[0]);
		out.println(c[0]);
	}
}


Measured memory_bytes: 23124
a=int(input())
b=[int(input()) for i in range(a)]

def isPrime(x):
    if x==2:
        return True
    if x<2 or x%2==0:
        return False
    i=3
    while i<=x**0.5:
        if x%i==0:
            return False
        i+=2
    return True
ans=0
for i in b:
    if isPrime(i):
        ans+=1
print(ans)


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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int r, D, x;
  cin >> r >> D >> x;
  vector<ll> vc(11);
  vc[0] = x;
  REP1(i, 10)
  vc[i] = 1ll * r * vc[i - 1] - D;
  REP1(i, 10)
  cout << vc[i] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yes(){
    cout << "Yes" << endl;
}

void no (){
    cout << "No" << endl;
}

ll cel (ll a, ll b){
    if (a % b == 0) return a / b;
    else return a / b + 1;
}

ll gcds(ll a, ll b){
    ll c = a % b;
    while (c != 0){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

int main() {
    int n, k; cin >> n >> k;
    vector<ll> ans(n,0LL);
    vector<ll> rui(n+1,0LL);
    vector<P> ar(k);
    rep(i,k) cin >> ar[i].first >> ar[i].second;
    ans[0] = 1LL;
    rui[1] = 1LL;
    repp(i,n,1){
        ll kuwa = 0LL;
        rep(j,k){
            int ri = max(-1,i-ar[j].first);
            int le = max(0,i-ar[j].second);
            kuwa += (rui[ri+1] - rui[le] + MOD) % MOD;
            kuwa %= MOD;
            //cout << i << " " << j << " " << le << " " << ri << endl;
        }
        ans[i] = kuwa;
        rui[i+1] = ans[i] + rui[i];
        rui[i+1] %= MOD;
    }
    cout << ans[n-1] << endl;
    //printvec(ans);
    //printvec(rui);
}

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

using namespace std;

const int MAX = 3005;
int64_t dp[MAX][MAX];
vector<int> vals(MAX, 0);

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

    for (int i = 0; i < n; i++) cin >> vals[i];

    for (int L = n - 1; L >= 0; L--) {
        for (int R = L; R < n; R++) {
            if (L != R) {
                dp[L][R] = max(vals[L] - dp[L + 1][R], vals[R] - dp[L][R - 1]);
            }
            else {
                dp[L][R] = vals[L];
            }
        }
    }

    cout << dp[0][n - 1];
    return 0;
}



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


typedef long long ll;
#define reg register
#define rep(i,a,b) for(int i=a,i##end=b;i<=i##end;++i)
#define drep(i,a,b) for(int i=a,i##end=b;i>=i##end;--i)


char IO;
inline ll rd(){
	ll s=0,f=0;
	while(!isdigit(IO=getchar())) if(IO=='-') f=1;
	do s=(s<<1)+(s<<3)+(IO^'0');
	while(isdigit(IO=getchar()));
	return f?-s:s;
}


const int N=2e5+10,P=998244353;

int n;
struct node{
	int x,y;
	bool operator < (const node __) const{
		return x<__.x;
	}
}a[N];
int hx[N],cx,hy[N],cy;

struct BIT{
	int s[N];
	void Add(int p,int x){
		while(p<=cy) s[p]+=x,p+=p&-p;
	}
	int Que(int p){
		int res=0;
		while(p) res+=s[p],p-=p&-p;
		return res;
	}
}B[2];

int po[N]={1};

int main(){
	rep(i,1,n=rd()) a[i].x=hx[i]=rd(),a[i].y=hy[i]=rd();
	rep(i,1,N-1) po[i]=po[i-1]*2%P;
	sort(hx+1,hx+n+1),cx=unique(hx+1,hx+n+1)-hx-1;
	sort(hy+1,hy+n+1),cy=unique(hy+1,hy+n+1)-hy-1;
	rep(i,1,n) {
		a[i].x=lower_bound(hx+1,hx+cx+1,a[i].x)-hx;
		a[i].y=lower_bound(hy+1,hy+cy+1,a[i].y)-hy;
		B[1].Add(a[i].y,1);
	}
	sort(a+1,a+n+1);
	//int A=(1<<4)-1;
	ll ans=0;
	rep(i,1,n){
		B[0].Add(a[i].y,1);
		ll a1=B[0].Que(a[i].y-1),b=i-1-a1,c=B[1].Que(a[i].y-1),d=n-i-c;
		a1=po[a1],b=po[b],c=po[c],d=po[d];
		ll t=a1*b%P*c%P*d%P;
		t-=a1*b%P;
		t-=a1*c%P;
		t-=c*d%P;
		t-=b*d%P;
		t+=(a1+b+c+d+1+1)%P;
		t-=4;
		t+=1;
		t%=P;
		//cout<<t<<endl;
		(ans+=t)%=P;
		(ans+=po[n-1])%=P;
		//cout<<a1<<' '<<b<<' '<<c<<' '<<d<<endl;
		/*rep(S,0,A) {
			if(!(S&1)&&!(S&2)) continue;
			if(!(S&1)&&!(S&4)) continue;
			if(!(S&4)&&!(S&8)) continue;
			if(!(S&2)&&!(S&8)) continue;
			ll t=1;
			int cnt=0;
			if(S&1) a1--,cnt^=1;
			if(S&2) b--,cnt^=1;
			if(S&4) c--,cnt^=1;
			if(S&8) d--,cnt^=1;
			t=a1*b%P*c%P*d%P;
			if(cnt) (ans-=t)%=P;
			else (ans+=t)%=P;
			if(S&1) a1++,cnt^=1;
			if(S&2) b++,cnt^=1;
			if(S&4) c++,cnt^=1;
			if(S&8) d++,cnt^=1;
		}
		*/
		B[1].Add(a[i].y,-1);
	}
	printf("%lld\n",(ans%P+P)%P);
}






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

using namespace std;

int main(int argc, char const *argv[]) {
  int n, l;
  cin >> n >> l;
  vector<string> s;
  for (int i = 0; i < n; i++) {
    string s_in;
    cin >> s_in;
    s.push_back(s_in);
  }
  sort(s.begin(), s.end());
  for (int i = 0; i < n; i++) {
    cout << s[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int l = sc.nextInt();
		
		int []a = new int [100*n+m];
		for(int b=0;b<n;b++){
			for(int c=0;c<m;c++){
				a[100*b+c] = sc.nextInt();
			}
		}
		
		int []b = new int[100*m+l];
		for(int c=0;c<m;c++){
			for(int d=0;d<l;d++)
			b[100*c+d] = sc.nextInt();
		}
		
		long x;
		for(int s=0;s<n;s++){
			for(int t=0;t<l;t++){
				x=0;
				for(int u=0;u<m;u++){
					x=x+a[100*s+u]*b[100*u+t];
				}
				if(t!=l-1){
					System.out.print(x+" ");
				}else{
					System.out.println(x);
				}
			}
		}

	}

}

Measured memory_bytes: 53588
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();
		char[] s = sc.next().toCharArray();

		int red = 0;
		for (char c : s) {
			if (c == 'R') {
				red++;
			}
		}
		if (red > n - red) {
			pr.println("Yes");
		} else {
			pr.println("No");
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

void solve(){
    int N;
    cin >> N;
    vector<set<int>> graph(N);
    vector<int> deg(N);
    rep(i,0,N-1){
        int a,b;
        cin >> a >> b;
        --a;
        --b;
        graph[a].insert(b);
        graph[b].insert(a);
    }
    queue<int> que;
    rep(i,0,N) if(graph[i].size()==1) que.push(i);
    vector<bool> done(N);
    while(!que.empty()){
        int u=que.front();
        que.pop();
        if(done[u]) continue;
        done[u]=true;
        if(graph[u].empty()){
            cout << "First" << endl;
            return;
        }
        int v=*graph[u].begin();
        done[v]=true;
        graph[u].clear();
        for(int w:graph[v]){
            graph[w].erase(v);
            if(graph[w].size()==1) que.push(w);
        }
        graph[v].clear();
    }
    cout << "Second" << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


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

int main() {
  vector<int> s(3);
  rep(i, 3) cin>>s[i];
  sort(s.begin(), s.end());
  cout<<s[2]*10+s[1]+s[0]<<endl;
}

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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void OUTS(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}

template <class T>
void OUTN(vector<T> &vec) { for (auto &e : vec) cout << e; }

// DEGUG
template <class T>
void dump_(const char *s, T&& x) {
  clog << '{';
  while(*s != '\0') clog << *(s++);
  clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void dump_(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  dump_(s, forward<Tail>(tail)...);
}
// }}} End

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

  VAR(int, t, x);
  OUTN(fixed, setprecision(15));
  OUTL((double)t / x);
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 int INF=1001001001;
vector<pair<int64_t,int64_t>>pppp(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}
 
int main() {
 int N;
 cin>>N;
 vector<int>A(N);
 map<int,int>t;
 vector<int>s;
 for(int i=0;i<N;i++){
   cin>>A[i];
   t[A[i]]++;
   if(t[A[i]]==2){s.push_back(A[i]);t[A[i]]=0;}
 }
 sort(s.begin(),s.end());
 reverse(s.begin(),s.end());
 if(s.size()>=2){
 cout<<(int64_t)s[0]*s[1]<<endl;
 }
 else{cout<<0<<endl;}
 return 0;
}

Measured memory_bytes: 8164
#include<iostream>
#include<string>
using namespace std;
int main(){
  string a;
  int b=0;
  cin>>a;
  for(int i=0;i<3;i++){
    if(a[i]==a[i+1])
      b++;
  }
  if(b!=0)
    cout<<"Bad"<<endl;
  else
    cout<<"Good"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int m,d;
    std::cin >> m >>d;
    int ans=0;
    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= d; j++) {
            if(j/10>=2 && j%10>=2 && (j/10)*(j%10)==i){
                ans++;
            }
        }
    }
    std::cout << ans << std::endl;
    
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
#include <stack>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef map<int, int> Mii;
typedef vector<int> Vi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;

int x[51];
ll dp[51][51][2501];
 
int main()
{
	int n, a;
	cin >> n >> a;
	rep(i,0,n) cin >> x[i];
 
	dp[0][0][0] = 1;
	// dp[i][j][k] := i枚目まで見て、j枚選んだ時、合計がkである組合せ
 
	rep(i,0,n) rep(j,0,n) rep(k,0,n*a+1) {
			dp[i+1][j][k] += dp[i][j][k];
		if (k+x[i] <= n*a+1)
			dp[i+1][j+1][k+x[i]] += dp[i][j][k];
	}
 
	ll ans = 0;
	rep(i,1,n+1) {
		ans += dp[n][i][i*a];
	}
 
	cout << ans << endl;
 
	return 0;
}

Measured memory_bytes: 50048
#include<bits/stdc++.h>
using namespace std;
int ctn(int i,int n,int a[],int hash[])
{   if(hash[i]!=-1)
    return hash[i];
    if(i==0){hash[0]=0;
    return 0;}
    else if(i==1){
        
    hash[i]=abs(a[1]-a[0]);

    return abs(a[1]-a[0]);
        
    }
    else {
        hash[i]=min(ctn(i-1,n,a,hash)+abs(a[i]-a[i-1]),ctn(i-2,n,a,hash)+abs(a[i]-a[i-2]));
        return min(ctn(i-1,n,a,hash)+abs(a[i]-a[i-1]),ctn(i-2,n,a,hash)+abs(a[i]-a[i-2]));
    }
    
}
int main()
{
    int n;
    cin>>n;
    int a[n],hash[n];
  
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        hash[i]=-1;
    }

cout<<ctn(n-1,n,a,hash);
    
}

Measured memory_bytes: 5760
object Main extends App{
  import scala.io.StdIn.readLine
  
  val s = readLine.split("").toList
  val delvaried = s.foldLeft(List(""))((a,b) => if(a.contains(b)){a}else a :+ b)
  
  if(s.length + 1 == delvaried.length)println("yes");
  else println("no")

}


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

int main(int argc, char const *argv[])
{
	int n,k;
	cin>>n>>k;
	long long h[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>h[i];
	}
	sort(h,h+n);
	long long ans=0LL;
	for (int i = 0; i < n-k; ++i)
	{
		ans+=h[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1920
import sys
S = input()[::-1]
ls = ["maerd", "remaerd", "esare", "resare"]
n = 0
while n != len(S):
    flag = False
    for i in ls:
        tmp_n = len(i)
        if S[n:n+tmp_n] == i:
            n += len(i)
            flag = True
            break
    if not flag:
        print("NO")
        sys.exit()
print("YES")


Measured memory_bytes: 3188
#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
#define rep(x,a,b) for(int x=a;x<=b;x++)
#define drep(x,a,b) for(int x=a;x>=b;x--)
#define rush() int T;scanf("%d",&T);while(T--)
#define wash(x,y) memset(x,y,sizeof(x));

typedef long long LL;

const int maxn=1e5+5;
LL a[3][maxn];
int n;

int main(){
	scanf("%d",&n);
	rep(i,0,2){
		rep(j,0,n-1)
			scanf("%d",&a[i][j]);
		sort(a[i],a[i]+n);
	}
	
	LL t0=0,t2=0,sum=0;
	rep(i,0,n-1){
		while(a[0][t0]<a[1][i]&&t0<n){
			++t0;
		}
		while(a[2][t2]<=a[1][i]&&t2<n){
			++t2;
		}
		sum+=t0*(n-t2);
	}
	
	cout<<sum;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

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

    ll X; cin >> X;
    ll a = -1000, b = -1000;
    ll cnt = 0, cnt2 = 0;
    while (cnt < 2000) {
      cnt2 = 0;
      b = -1000;
      while (cnt2 < 2000) {
        if (X == pow(a, 5) - pow(b, 5)) {
          cout << a << ' ' << b << endl;
          return 0;
        }
        cnt2++;
        b++;
      }
      cnt++;
      a++;
    }
    return 0;
}

Measured memory_bytes: 4136
/**
 から n までの数の中から、重複無しで３つの数を選びそれらの合計が x となる組み合わせの数を求めるプログラムを作成して下さい。

例えば、1 から 5 までの数から３つを選んでそれらの合計が 9 となる組み合わせは、
?1 + 3 + 5 = 9
?2 + 3 + 4 = 9

の２通りがあります。

 */

/*sucannerクラス使うためにインポート*/
import java.util.Scanner;

class Main {
	// プログラムのエントリポイント
	public static void main(String[] args) {
		// 入力ストリームの生成
		Scanner sc = new Scanner(System.in);
		// 点数を受け取る変数を宣言
		int intN = 0;
		int intX = 0;
		int intKekka = 0;

		// breakされるまで処理をくりかえす
		while (true) {

			intN = sc.nextInt();
			intX = sc.nextInt();
			intKekka = 0;
			if (intN == 0 && intX == 0) {
				break;
			}
			
			for (int i = 1; i <= intN; i++) {
				for (int j = 1; j <= intN; j++) {
					for (int k = 1; k <= intN; k++) {
						if(i == j || j == k || i == k){

						}else if ( i + j + k == intX){
							intKekka ++;
							}
						}
					}
				}
			System.out.println(intKekka/6);
			}

		}
	}

Measured memory_bytes: 19676
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main(){
 int H,W,D; cin >> H >> W >> D;
  vector<pair<int,int>> to(H*W+1);
for(int i = 1; i <= H; i++){
  for(int j = 1; j  <= W; j++){
    int a ; cin >> a; to[a] = make_pair(i,j);}}
  //座標配列toを作成
  vector<int> A(H*W + 1,0);
  int Q; cin >> Q;
  
  for(int i = 0; i < D; i++){
    int b = H*W - i;
    while( b - D > 0){
      A[b - D] = A[b] + abs(to[b-D].first - to[b].first) + abs(to[b-D].second - to[b].second);
      b--;} }
  
  for(int i = 0; i < Q; i++){
    int l,r; cin >> l >> r;
    cout << A[l] - A[r] << endl;}
  
  return 0;}
                            
    
    

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

#define ll long long
#define mod 1000000007
#define pii pair<ll,ll>

#define debug(a) { cout << #a << " = " << a << endl;}

const int maxn = 1e5+1;
ll arr[maxn], n, m, t, k;
unordered_map<ll,ll> u;

ll __min(ll a, ll b) {
    return a < b ? a : b;
}

ll __max(ll a, ll b) {
    return a > b ? a : b;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
	cin>>n;
	ll ans=0;
	for (int i=0;i<n;i++){
		t=m;
		cin>>m;
		if (i !=0) {
			if (m<t) {
				ans += t-m;
				m=t;
			}
		}
	}
	cout << ans << "\n";
}


Measured memory_bytes: 3648
#include <cstdio>
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define REP(i,a,b) for(int i=a;i<b;++i)
#define SIZE 1000002
#define MOD 1000000007

using namespace std;

ll powMod(ll a, ll b){
	ll res=1LL;

	while(b){
		if(b&1) res=(res*a)%MOD;
		b>>=1;
		a=(a*a)%MOD;
	}
	return res;
}


ll ncr(ll n, ll r){
	r = min(r,n-r);
	if(r==0) return 1LL;
	ll res=1;
	REP(i,1,r+1){
		res = (res*(n-i+1))%MOD;
		res = (res* powMod(i,MOD-2)%MOD)%MOD;
	}
	return res;
}

int main(){
	
	int n;
	cin>>n;
	int val=n/3;

	ll ans=0;
	REP(i,1,val+1){
		int sub=i*3;
		ans = (ans + ncr(n-sub+i-1,i-1) )%MOD;
	//	cout<<n-sub+i-1<<"C"<<i-1<<":: "<<i<<" : "<<ans<<"\n";
	}
	cout<<ans%MOD;
} 

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<cmath>;
using namespace std;
string s;
int main(){
    cin>>s;
    int k=s.size();
    if(k%2!=0){
        cout<<"No";
        return 0;
    }
    for(int i=0;i<k/2;i++){
        int u=abs(s[i]-s[k-i-1]);
        if(u!=1&&u!=2){
            cout<<"No"; 
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}

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

using namespace std;

unsigned long long a, b, c;

int main()
{
  	std::ios_base::sync_with_stdio(false);
	std::cin.tie(NULL);

	cin >> a >> b >> c;

	if (a < c && b < c && c * c + b * b + a * a > 2 * (b * c + a * b + a * c))
      cout << "Yes";
  	else
      cout << "No";

	return 0;
}

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

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    // int t; cin>>t;
    // while(t--){
        int n; cin>>n;
        vector<double>p(n);
        for(int i=0;i<n;i++){
            cin>>p[i];
        }
        vector<double>dp(n+1, 0);
        dp[0] = 1;
        for(int i=1;i<n+1;i++){
            for(int j=i;j>=0;j--){
                if(j == 0){
                    dp[j] = (1-p[i-1])*dp[j];
                }else{
                    dp[j] = (1-p[i-1])*dp[j] + p[i-1]*dp[j-1];
                }
            }
        }
        double ans = 0;
        for(int i=0;i<n+1;i++){
            if(2*i>n){
                ans += dp[i];
            }
        }
        // for(int i=0;i<n+1;i++){
        //     for(int j=0;j<n+1;j++){
        //         cout<<dp[i][j]<<" ";
        //     }
        //     cout<<"\n";
        // }
        cout << fixed;
        cout << setprecision(10);
        cout << ans << "\n";
    // }
}


Measured memory_bytes: 3876
//https://atcoder.jp/contests/dp/tasks/dp_j
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

int cnt[4];
int N;

using V=vector<double>;
using VV=vector<V>;
using VVV=vector<VV>;
using Vb=vector<int>;
using VVb=vector<V>;
using VVVb=vector<VV>;
double solve(int i,int j,int k,VVV&dp,VVVb&vis){
    if(vis[i][j][k])return dp[i][j][k];
    vis[i][j][k]=true;
                    double d=0;
                //E=(a*A+b*B+c*C)/(1-d)
                if(i>0){
                    double a=i/(N+0.0);
                    dp[i][j][k]+=a*solve(i-1,j+1,k,dp,vis);
                    d+=a;
                }
                if(j>0){
                    double a=j/(N+0.0);
                    dp[i][j][k]+=a*solve(i,j-1,k+1,dp,vis);
                    d+=a;
                }
                if(k>0){
                    double a=k/(N+0.0);
                    dp[i][j][k]+=a*solve(i,j,k-1,dp,vis);
                    d+=a;
                }
                //cout<<i<<j<<k<<d<<" "<<dp[i][j][k]<<endl;
                if(i+j+k>0){
                    dp[i][j][k]++;
                    dp[i][j][k]/=d;
                }

    return dp[i][j][k];
}
int main(){
    cin>>N;
    for(int i:range(N)){
        int a;
        cin>>a;
        cnt[a]++;
    }

    VVV dp(N+1,VV(N+1,V(N+1)));
    VVVb vis(N+1,VV(N+1,V(N+1)));

    cout<<fixed;
    cout<<setprecision(10);
    cout<<solve(cnt[3],cnt[2],cnt[1],dp,vis)<<endl;
    return 0;
}

Measured memory_bytes: 432896