akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<55)+1e9; // ~ 3.6 * 1e16
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
using T = tuple<Int,Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
ostream& operator<<(ostream& o,T t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){Int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){Int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

ll mod_pow(ll x,ll n){
  ll res=1;
  while(n){
    if(n%2) res=res*x%mod;
    x=x*x%mod;
    n/=2;
  }
  return res;
}

Int inv(Int x){return mod_pow(x, mod-2);}

Int Add(_int &a,Int b){return a = (a + b)%mod;}
Int Sub(_int &a,Int b){return a = ((Int)a - b + mod)%mod;}
const Int N = 5010;
//dp[i][j] := i回打って長さがjになっている通り数
_int dp[N+1][N+1];
void DP(){
  dp[0][0] = 1;
  for(Int i=0;i<N;i++)
    for(Int j=0;j<N;j++){
      //type 0;
      Add(dp[i+1][j+1], dp[i][j]);
      
      //type 1;
      Add(dp[i+1][j+1], dp[i][j]);
      
      //type backSpace
      Add(dp[i+1][max(0LL,j-1)], dp[i][j]);
    }
}


Int solve(Int n, string str){
  DP();
  Int m = str.size();
  _int sum = dp[n][m];
  sum = sum * inv(mod_pow(2, m)) % mod;
  return sum;
}

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int n;
  string s;
  cin>>n;
  cin>>s;

  Int ans = solve(n, s);
  cout<<ans<<endl;

  
  return 0;
}


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

int main()
{
	int N, K;
	cin >> N >> K;
	long ans;
	if (K % 2 == 1) {
		long a = N / K;
		ans = a * a * a ;
	}
	else {
		long a = N / K;
          	long b = 2*N / K - a;
		ans = a * a * a+ b * b * b ;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
# ####################################################################
# import io
# import sys

# _INPUT = """\
# 2 3 4
# ..#
# ###

# 2 3 2
# ..#
# ###
# """
# sys.stdin = io.StringIO(_INPUT)
####################################################################
import sys
def _p(*_a):
  #return
  _s=" ".join(map(str,_a))
  #print(_s)
  sys.stderr.write(_s+"\n")
####################################################################
def _pa(_aa):
  #return
  for _a in _aa: _p(_a)
####################################################################


H,W,K = map(int, input().split())

M = list( list(input()) for _ in range(H) )

def fCntM(A):
  cnt = 0
  for h in range(H):
    for w in range(W):
      if A[h][w] == "#": cnt += 1
  return cnt


ans = 0

# if fCntM(M) == K: ans += 1

for h in range(1 << H):
  for w in range(1 << W):

    A = [ ["_"]*W for _ in range(H) ]
    for i in range(H):
      for j in range(W):
        if ( (h >> i) & 1 ) or ( (w >> j) & 1 ):
          A[i][j] = "R"
        else:
          A[i][j] = M[i][j]

    if fCntM(A) == K: ans += 1
    # _p("h,w = ", h,w, "ans=",ans)
    # _pa(A)


print(ans)







Measured memory_bytes: 9160
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	var c = 0
	for i := 0; i < n; i++ {
		var tmp int
		fmt.Scan(&tmp)
		if tmp == c+1 {
			c++
		}
	}
	if c == 0 {
		fmt.Println(-1)
		return
	}
	fmt.Println(n - c)
}


Measured memory_bytes: 7552
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int N = stdIn.nextInt();

        int[] a = new int[100];

        for (int i = 0; i<N; i++){
            a[i] = stdIn.nextInt();
        }
        
        int flag = 0;
        int j;
        for (j=0; j<N; j++){
            if (a[j]%2 == 0) {
                if (a[j]%3 != 0 && a[j]%5 != 0){
                    flag = 1;
                    break;
                }
            }
        }

        if (flag == 1)
            System.out.println("DENIED");
        else
            System.out.println("APPROVED");
        
        //System.out.println("j = "+j);
        

    }
}

Measured memory_bytes: 21844
#include <stdio.h>
int a[50];

int fib(int n){
    if(n==0 || n==1)return a[n]=1;
    if(a[n]!=-1)return a[n];
    return a[n]=fib(n-1)+fib(n-2);
}

int main(){
    int i,j;
    for(i=0;i<50;i++)a[i]=-1;
    scanf("%d",&j);
    printf("%d\n",fib(j));
    return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
#define ld long double
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

void print(Vl vec){
    rep(i, 0, sz(vec)){
        if(i) cout << " ";
        cout << vec[i];
    }
    coel;
}

////////////////////////////////////////////////////////

// greedy

int main() {
    ll n; cin >> n;
    Vp p(n);
    rep(i, 0, n){
        ll x, l; cin >> x >> l;
        p[i].fi = x+l, p[i].se = x-l;
    }
    sort(ALL(p));
    rep(i, 0, n) swap(p[i].fi, p[i].se);
    ll bl = p[0].fi, br = p[0].se;
    ll cnt = 0;
    rep(i, 1, n){
        if(p[i].fi < br) cnt++;
        else br = p[i].se;
    }
    co(n-cnt);

    return 0;
}


Measured memory_bytes: 1792
/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<ll>;

#define nextline() (std::cerr << "\n")
#define debug(x) (#x " : " + (x))
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<=i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b);
constexpr int INF = 2000000100;
constexpr ll DIV = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
#define diup(a, b) (a % b == 0 ? a / b : a / b + 1)
#define exist_in(list, value) (list.end() != std::find(all(list),value))
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
//template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
//template<class T> T math_C(T m, T n) { T ret = mathP(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
//template<class T> bool compare_by_b(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
//template<class T> T math_gcd(T a, T b) { a = abs(a); b = abs(b); if (a < b) { std::swap(a, b); } T tmp; while (b != 0) { tmp = b; b = a % b; a = tmp; } return a; }
//template<class T> T math_lcm(T a, T b) { a = abs(a); b = abs(b); if (a > b) { std::swap(a, b); } if (a == 1) { return b; } T i = a; while (i % b != 0) { i += a; } return i; }
//template<class T1, class T2> bool exist_in(const T1& list, const T2& v) { return (list.end() != std::find(list.begin(), list.end(), v)); }
//template<class T> bool exist_in(const T& c, const typename T::value_type& v) {	return (c.end() != std::find(c.begin(), c.end(), v));}

/*****/

void Main()
{
	int x, t;
	cin >> x >> t;
	cout << (x - t > 0 ? x - t : 0);
}

/*****/

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

	std::cout << std::fixed << std::setprecision(10);


	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/


	Main();

	return 0;
}


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vi v(n);
	REP(i, n)cin >> v[i];
	sort(ALL(v));
	vector<pii> p(m);
	REP(i, m) {
		int a, b; cin >> a >> b;
		p[i] = { b,a };
	}
	sort(ALL(p),greater<>());
	int j = 0;
	REP(i, m) {
		int cnt = p[i].second;
		while (j < n && cnt>0 && v[j] < p[i].first) {
			v[j] = p[i].first;
			j++;
			cnt--;
		}
	}
	ll ans = 0;
	REP(i, n)ans += v[i];
	cout << ans << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define frep(i, m, n) for(int i = m;i < n;i++)
#define frepr(i, m, n) for(int i = m;i >= n;i--)
#define vsort(v) sort(v.begin(),v.end())
#define ll long long
#define inf 999999999
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vst;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
typedef pair<int,P> PP;
typedef pair<ll,LP> LPP;

int change(char color){
    switch(color){
        case 'R':return 0;break;
        case 'G':return 10;break;
        case 'B':return 20;break;
        default:return 30;break;
    }
}

int main(){
    int t;
    while(cin >> t && t!=0){
        rep(i,t){
            vi card(9,0);
            int cl=0;
            rep(j,9){
                cin >> card[j];
            }
            rep(j,9){
                char color;
                cin >> color;
                card[j]+=change(color);
            }
            vsort(card);
            do {
                // cout << "card:";
                // rep(j,9){
                //     cout << card[j] << ",";
                // }
                int f=0;
                rep(j,3){
                    if(card[j*3]/10==card[j*3+1]/10 && card[j*3+2]/10==card[j*3+1]/10){
                        if((card[j*3]==card[j*3+1] && card[j*3+2]==card[j*3+1])||(card[j*3]+1==card[j*3+1] && card[j*3+2]==card[j*3+1]+1)){
                            f++;
                        }
                    }
                }
                if(f==3){
                    cl=1;
                    break;
                }
                // cout << "    f:" << f << endl;
            } while (next_permutation(card.begin(),card.end()));
            cout << cl << endl;
        }
    }

    return 0;
}


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

int main()
{
  int a, b;
  cin >> a >> b;
  if (a <= b)
  {
    for (int i = 0; i < b; i++)
    {
      cout << a;
    }
  }
  else
  {
    for (int i = 0; i < a; i++)
    {
      cout << b;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int N = 50 + 5;

int main(){
	ll a,b,n;
	cin >> a >> b >> n;
	if(n >= b){
		ll z = floor((a*(b-1))/b);
		cout << z << endl;
	}
	else{
		ll z = floor((a*n)/b);
		cout << z << endl;
	}
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    int length = s.length();
    for(int i = length - 1; i >= 0; i--){
        char match = s[i];
        s.pop_back();
        int index = s.find(match, 0);
        if( index != -1){
            cout << "no" << endl;
            return 0;
        }
    }

    cout << "yes" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(void){
    int K,X,start,end;
    cin >> K >> X;
    start = X-K+1;
    if (start < -1000000){
        start = -1000000;
    }
    end = K+X-1;
    if (end > 1000000){
        end = 1000000;
    }
    while (start<=end){
        cout << start <<endl;
        start++;
    }
    //K-1
}



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

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define PI          3.14159265358979323846
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ld          long double
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    int sum = 0;
    vector<int> v;
    for(int i = 1; i <= n; i++){
        if(sum + i <= n){
            sum += i;
            v.PB(i);
        }else{
            break;
        }
    }
    int delta = n - sum;
    if(delta > 0){
        int len = SZ(v);
        int ad = delta / len;
        if(ad == 0){
            for(int i = len - 1; i >= 0; i--){
                if(delta > 0){
                    v[i] += 1;
                    delta -= 1;
                }
            }
        }else{
            for(int i = len - 1; i >= 0; i--){
                v[i] += ad;
            }
            int yo = delta - ad * len;
            for(int i = len - 1; i >= 0; i--){
                if(yo > 0){
                    v[i] += 1;
                    yo -= 1;
                }
            }
        }
        for(auto &x : v){
            cout << x << nl;
        }
    }else{
        for(auto x : v){
            cout << x << nl;
        }
    }
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split("\\s+");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);

		int qty = N / 100;
		int amount = N % 100;
		for (int unit = 5; unit >= 1; unit--) {
			for (; qty > 0 && amount >= unit;) {
				amount -= unit;
				qty--;
			}
		}
		if (amount == 0)
			System.out.println("1");
		else
			System.out.println("0");
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 23380
#include <iostream>
 
using namespace std;
 
int main()
{
  char b; cin >> b;
  
  if      (b == 'T') cout << 'A' << endl;
  else if (b == 'A') cout << 'T' << endl;
  else if (b == 'C') cout << 'G' << endl;
  else if (b == 'G') cout << 'C' << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<28;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-10;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

class Graph{
	private:
	int V;
	vvi List;
	vb used;
	void bfs(int v,int I){
		queue<int> q;
		q.push(v);
		used[v]=1;
		res[v]=I;
		while(!q.empty()){
			int p=q.front();
			q.pop();
			for(int i=0;i<List[p].size();i++){
				int u=List[p][i];
				if(!used[u]){
					used[u]=1;
					res[u]=I;
					q.push(u);
				}
			}
		}
	}
	public:
	vi res;
	Graph(int v){
		V=v;
		List=vvi(v);
	}
	void add_edge(int s,int t){
		List[s].push_back(t);
		List[t].push_back(s);
	}
	void BFS(){
		used=vb(V);
		res=vi(V);
		int I=0;
		for(int i=0;i<V;i++) if(!used[i]){
			bfs(i,I);
			I++;
		}
	}
};

int n,k,l;

int main(){
	cin>>n>>k>>l;
	Graph a(n),b(n);
	for(int i=0;i<k;i++){
		int s,t;
		cin>>s>>t;
		a.add_edge(s-1,t-1);
	}
	for(int i=0;i<l;i++){
		int s,t;
		cin>>s>>t;
		b.add_edge(s-1,t-1);
	}
	a.BFS();
	b.BFS();
	map<P,int> m;
	for(int i=0;i<n;i++) m[P(a.res[i],b.res[i])]++;
	for(int i=0;i<n;i++){
		if(i) cout<<' ';
		cout<<m[P(a.res[i],b.res[i])];
	}
	cout<<endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

typedef vector<ll> Row;
typedef vector<Row> Matrix;

const ll mod = 1e9+9;

ll add(ll a, ll b) {
    return (a + b) % mod;
}
ll mul(ll a, ll b) {
    return a * b % mod;
}
Matrix mul(Matrix A, Matrix B) {
    Matrix res(A.size(), Row(B[0].size(), 0));
    REP(i, res.size()) REP(j, res[i].size()) REP(k, B.size()) {
        res[i][j] = add(res[i][j], mul(A[i][k], B[k][j]));
    }
    return res;
}
Row mul(Matrix A, Row B) {
    Row res(B.size(), 0);
    REP(i, res.size()) REP(j, A[i].size()) {
        res[i] = add(res[i], mul(A[i][j], B[j]));
    }
    return res;
}
Matrix power(Matrix A, ll n) {
    Matrix res(A.size(), Row(A.size(), 0));
    REP(i, res.size()) res[i][i] = 1;
    for (ll i = 1; i <= n; i <<= 1) {
        if (i & n) res = mul(res, A);
        A = mul(A, A);
    }
    return res;
}

Row dp(const Row& prev, const Row& m) {
    int W = prev.size();
    Row res(W, 0);
    REP(i, W) {
        if (m[i] == 0) {
            if (i > 0) res[i] = add(res[i], prev[i-1]);
            res[i] = add(res[i], prev[i]);
            if (i < W-1) res[i] = add(res[i], prev[i+1]);
        }
    }
    return res;
}
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    ll W, H, N;
    int id = 1;
    while (cin >> W >> H >> N, W || H || N) {
        map<ll, Row> m;
        REP(i, N) {
            ll x, y; cin >> x >> y; --y, --x;
            if (y == 0) continue;
            if (m.count(y) == 0) m[y].assign(W, 0);
            m[y][x] = 1;
        }
        Matrix A(W, Row(W, 0));
        REP(i, W) {
            REP(j, W) {
                if ( abs(i - j) <= 1 ) A[i][j] = 1;
            }
        }
        ll pos = 0;
        Row v(W, 0); v[0] = 1;
        EACH(p, m) {
            ll ny = p.first;
            if (pos < ny-1) {
                v = mul(power(A, ny-1-pos), v);
            }
            v = dp(v, p.second);
            pos = ny;
        }
        v = mul(power(A, H-1-pos), v);
        cout << "Case " << id++ << ": " << v[W-1] << endl;
    }
}

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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int n = cin.Int();
			int[] p = new int[n];
			for (int i = 0; i < n; i++) {
				p[i] = cin.Int();
			}

			List<int> count = new List<int>();
			for (int i = 1; i < n; i++) {
				if (p[i] < p[i - 1]) {
					count.Add(i - 1);
				}
			}

			if (count.Count() == 0) {
				Console.WriteLine("YES");
			} else if (count.Count() == 2) {
				int temp = p[count[0]];
				p[count[0]] = p[count[1] + 1];
				p[count[1] + 1] = temp;
				List<int> count2 = new List<int>();
				for (int i = 1; i < n; i++) {
					if (p[i] < p[i - 1]) {
						count2.Add(i - 1);
					}
				}

				if (count2.Count() == 0) {
					Console.WriteLine("YES");
				} else {
					Console.WriteLine("NO");
				}
			} else {
				Console.WriteLine("NO");
			}
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;
		
		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}


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

using namespace std;

void Main() {
    long long K, N;
    cin >> N >> K;
    map<long long, vector<long long> > t2vecd;
    for (long long i = 0; i < N; ++i) {
        long long ttemp, dtemp;
        cin >> ttemp >> dtemp;
        if (t2vecd.count(ttemp) == 0) {
            t2vecd.insert(make_pair(ttemp, vector<long long>()));
        }
        t2vecd[ttemp].push_back(dtemp);
    }

    vector<long long> maxDeliForEachType;
    vector<long long> otherDeli;
    for (auto e : t2vecd) {
        sort(e.second.begin(), e.second.end(), greater<long long>());
        for (long long i = 0; i < e.second.size(); ++i) {
            if (i == 0LL) {
                maxDeliForEachType.push_back(e.second[0]);
            }
            else {
                otherDeli.push_back(e.second[i]);
            }
        }
    }
    sort(maxDeliForEachType.begin(), maxDeliForEachType.end(), greater<long long>());
    sort(otherDeli.begin(), otherDeli.end(), greater<long long>());

    long long ans = 0LL;
    for (long long ntopping = 1; ntopping <= maxDeliForEachType.size(); ++ntopping) {
        if (ntopping <= K) {
            if (K - ntopping <= otherDeli.size()) {
                long long temp = accumulate(maxDeliForEachType.begin(), maxDeliForEachType.begin() + ntopping, 0LL);
                temp += accumulate(otherDeli.begin(), otherDeli.begin() + (K - ntopping), 0LL);
                temp += ntopping * ntopping;
                ans = max(temp, ans);
            }
            else {
                continue;
            }
        }
        else {
            break;
        }
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 12280
s = input()
if s == "SUN":
    print("7")
elif s == "MON":
    print("6")
elif s == "TUE":
    print("5")
elif s == "WED":
    print("4")
elif s == "THU":
    print("3")
elif s == "FRI":
    print("2")
elif s == "SAT":
    print("1")


Measured memory_bytes: 2940
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#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 loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
const int INF = 1e9;
const int MOD = 1e9 + 7;
int main() {
    int W, a, b;
    int ans;
    cin >> W >> a >> b;
    if (a < b) {
        if (a + W < b) {
            ans = b - (a + W);
        } else {
            ans = 0;
        }
    } else {
        if (a < b + W) {
            ans = 0;
        } else {
            ans = a - (b + W);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
using namespace std;
typedef long long ll;
const int maxn = 105;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
#endif
  string s;
  cin>>s;
  int a0 = 0, a1 = 0;
  for(int i=0;i<s.size();i++){
    int na0 = a1+(s[i]!='0');
    int na1 = a0+(s[i]!='1');
    a0 = na0,a1 = na1;
  }
  cout<<min(a0,a1)<<endl;
  return 0;
}

Measured memory_bytes: 512
// Author : MohamedSameh
#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
ll a , b ;
vector <ll>com ;
int main ()
{
    cin >> a >> b;
    a = __gcd (a , b );
    for (int i =1 ; i <= a / i ; i++)
    {
        if (a % i == 0)
        {
            com.push_back(i);
            if (a/i != i )com.push_back(a/i);
        }
    }
    sort(com.begin() , com.end() );
    int ans =0 ;
    for (int i =0 ; i < com.size() ; i++)
    {
        if (com[i] == -1 )continue ;
        ans++;
        if (com[i] == 1 )continue ;
        for (int j = i+1 ; j < com.size() ;j++)
        {
            if (com[j] % com[i] == 0 )com[j] = -1 ;
        }
    }
    printf ("%d\n" ,ans );

  return 0 ;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>

int main()
{
	char buf[256];

	while (fgets(buf, sizeof(buf), stdin) != NULL) {
		int i;
		for (i = 0; i < strlen(buf); i++) {
			if ( islower(buf[i]) ) {
				buf[i] = toupper(buf[i]);
			}
		}
		printf("%s", buf);
	}
	return 0;
}



Measured memory_bytes: 2004
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ll n, m;
  cin >> n >> m;
  m += n*3;
  cout << m/2 << endl;
}

Measured memory_bytes: 256
n = int(input())
li = [int(input()) for _ in range(n)]

num_max = max(li)
cnt = li.count(num_max)

if cnt >= 2:
    for i in range(n):
        print(num_max)
else:
    s = li.index(num_max)
    for i in range(n):
        if i != s:
            print(num_max)
        else:
            li[i] = 0
            print(max(li))

Measured memory_bytes: 12532
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

const int MAX_N = 100050;

int N;
long long A[MAX_N];

int main(int argc, char **argv) {
    std::cin >> N;

    for (int i = 1; i <= N; i++) {
        std::cin >> A[i];
    }

    A[N+1] = 0;
    long long ret = 0;

    for (int i = 1; i <= N; i++) {
        ret += A[i] / 2;
        A[i] = A[i] % 2;

        if (A[i] == 1 && 1 <= A[i+1]) {
            A[i]--;
            A[i+1]--;
            ret++;
        }
    }

    std::cout << ret << std::endl;

    
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define MAX_N 1001
#define rank dfasfds
using namespace std;
int par[MAX_N],rank[MAX_N];

void init(int n){for(int i=0;i<n;i++)par[i]=i,rank[i]=0;}

int find(int x){
  if(par[x]==x)return x;
  return par[x]=find(par[x]);
}

void unite(int x,int y){
  x=find(x),y=find(y);
  if(x==y)return;
  if(rank[x]<rank[y])par[x]=y;
  else{
    par[y]=x;
    if(rank[x]==rank[y])rank[x]++;
  }
}
bool same(int x,int y){return find(x)==find(y);}

struct edge{
  int a,b,c;
  bool operator < (edge t) const{return c<t.c;}
};

int n,m;
edge e[10001];
int solve(){
  init(n+1);
  for(int i=0,cnt=0;i<m;i++){
    if(same(e[i].a,e[i].b)) continue;
    unite(e[i].a,e[i].b);
    if(cnt++==(n-1)/2) return e[i].c;
  }
  return 0;
}

int main(){
  while(1){
  cin>>n>>m;
  if(!n&&!m)return 0;
  for(int i=0;i<m;i++)cin>>e[i].a>>e[i].b>>e[i].c;
  sort(e,e+m);
  cout<<solve()<<endl;
  }
  return 0;
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 922337203685477;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
int main()
{
    fastio;
    ll n=0;
    cin>>n;
    stack<char>st;
    string s;
    cin>>s;
    for(ll i=0;i<n;++i){
        if(st.empty()) st.push(s[i]);
        else{
            if(s[i]!=st.top()) st.push(s[i]);
        }
    }
    cout<<st.size();
    return 0;
}


Measured memory_bytes: 512
// ABC 155-C
// 2020.2.16 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)

int in() {   // 非負整数の入力
	int n = 0; int c;
	c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

int ins(char *s) { // 文字列の入力　スペース以下の文字で入力終了
	char *p = s--;
	do *++s = gc();
	while (*s > ' ');
	*s = 0;
	return s - p;
}

void outs(char *s) { while (*s) pc(*s++); pc('\n'); }

// 文字列のハッシュ関数
#define HASHSIZ 2000081
typedef struct { char *s; int id; } HASH;
HASH hash[HASHSIZ+2], *hashend = hash + HASHSIZ;

int insert(char *s, int id) {
	unsigned long long i;
	int j;
	char *p;
	HASH *tp;

	i = 0, p = s;
	for (j = 0; *p; j++) i = (i << 5) + (*p++ +1-'a');
	tp = hash + (int)(i % HASHSIZ);
	while (tp->s != NULL) {
		if (!strcmp(tp->s, s)) return tp->id;
		if (++tp == hashend) tp = hash;
	}
	tp->s = s, tp->id = id;
	return -1;
}

#define MAX 200005
typedef struct { char *p; int n; } T;
T tbl[MAX];
char S[MAX][12];

void Qsort(int l, int r) {
	int i, j;
	char *m;

	i = l, j = r, m = tbl[(l+r) >> 1].p;
	while (1) {
		while (strcmp(tbl[i].p, m) < 0) i++;
		while (strcmp(m, tbl[j].p) < 0) j--;
		if (i >= j)	break;
		char *t = tbl[i].p; tbl[i].p = tbl[j].p, tbl[j].p = t;
		i++, j--;
	}
	if (l+1 < i) Qsort(l, i-1);
	if (j+1 < r) Qsort(j+1, r);
}

int main()
{
	int i, j, N, K, ma;

	N = in();
	ma = 0;
	while (N--) {
		ins(tbl[K].p = S[K]);
		if ((i = insert(S[K], K)) < 0) i = K++;
		if (++tbl[i].n > ma) ma = tbl[i].n;
	}
	i = 0;
	for (j = 0; j < K; ++j) if (tbl[j].n == ma) {
		tbl[i++].p = tbl[j].p;
	}
	N = i;
	Qsort(0, N-1);
	for (i = 0; i < N; ++i) outs(tbl[i].p);
	return 0;
}


Measured memory_bytes: 38656
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
//#[allow(unused_imports)]
//use proconio::marker::{Isize1, Usize1, Bytes, Chars};

//#[proconio::fastout]

fn main() {
    input!{
        x: i32,
    }
    if ((x % 100) + 4) / 5 > x / 100 {
        println!("0");
    } else { println!("1"); }
}



Measured memory_bytes: 4352
#include <stdio.h>
#include <string.h>

int H, N;
char init_board[128][2][4];
char board[128][2][4];

char katamari[3][2][2][4];
int atarihantei[3][2][2];

int main(void) {
	while (scanf("%d%d", &H, &N) == 2 && (H > 0 || N > 0)) {
		int i, j, k;
		int search, search_max = 1;
		int answer = 0;
		memset(init_board, 0, sizeof(init_board));
		for (i = 0; i < H; i++) {
			if (scanf("%s%s", init_board[i][0], init_board[i][1]) != 2) return 1;
		}
		for (i = 0; i < N; i++) {
			search_max *= 9;
			for (j = 0; j < 2; j++) {
				if (scanf("%s%s", katamari[i][j][0], katamari[i][j][1]) != 2) return 1;
			}
			for (j = 0; j < 2; j++) {
				for (k = 0; k < 2; k++) {
					if (katamari[i][0][j][k] == '#') atarihantei[i][j][k] = 0;
					else if (katamari[i][1][j][k] == '#') atarihantei[i][j][k] = 1;
					else atarihantei[i][j][k] = -1;
				}
			}
		}

		for (search = 0; search < search_max; search++) {
			int dx[3], dy[3], search_decode = search;
			int valid = 1;
			int score = 0;
			for (i = 0; i < N; i++) {
				dx[i] = search_decode % 3 - 1;
				search_decode /= 3;
				dy[i] = search_decode % 3 - 1;
				search_decode /= 3;
				for (j = 0; j < 2; j++) {
					for (k = 0; k < 2; k++) {
						if (atarihantei[i][j][k] >= 0) {
							/* burokku ga sonzai suru */
							if (j + dy[i] < 0 || 2 <= j + dy[i] || k + dx[i] < 0 || 2 <= k + dx[i]) {
								/* burokku ga hamidasu */
								valid = 0;
							}
						}
					}
				}
			}
			if (!valid) continue;
			memcpy(board, init_board, sizeof(board));

			for (i = 0; i < N; i++) {
				/* burokku wo otosu */
				int y = 50;
				int kietenai = 0;
				for (;;) {
					int stop = 0;
					for (j = 0; j < 2; j++) {
						for (k = 0; k < 2; k++) {
							int jj = j - dy[i], kk = k - dx[i];
							if (0 <= jj && jj < 2 && 0 <= kk && kk < 2 && atarihantei[i][jj][kk] >= 0) {
								int judgey = y - 1 + atarihantei[i][jj][kk];
								if (judgey < 0 || board[judgey][j][k] == '#') {
									stop = 1;
								}
							}
						}
					}
					if (stop) break;
					y--;
				}
				for (j = 0; j < 2; j++) {
					for (k = 0; k < 2; k++) {
						int jj = j - dy[i], kk = k - dx[i];
						if (0 <= jj && jj < 2 && 0 <= kk && kk < 2) {
							if (katamari[i][0][jj][kk] == '#') board[y][j][k] = '#';
							if (katamari[i][1][jj][kk] == '#') board[y + 1][j][k] = '#';
						}
					}
				}

				/* kesu */
				for (j = 0; j < 100; j++) {
					if (board[j][0][0] == '#' && board[j][0][1] == '#' &&
					board[j][1][0] == '#' && board[j][1][1] == '#') {
						/* kieru */
						score++;
					} else {
						board[kietenai][0][0] = board[j][0][0];
						board[kietenai][0][1] = board[j][0][1];
						board[kietenai][1][0] = board[j][1][0];
						board[kietenai][1][1] = board[j][1][1];
						kietenai++;
					}
				}
				for (j = kietenai; j < 100; j++) {
					board[j][0][0] = '.';
					board[j][0][1] = '.';
					board[j][1][0] = '.';
					board[j][1][1] = '.';
				}
			}

			if (score > answer) answer = score;
		}
		printf("%d\n", answer);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,M;cin>>N>>M;
    vector<int> A(N),ok(N,1);
    for(int i=0;i<N;i++) cin>>A[i];
    for(int i=0;i<M;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        if(A[a]<=A[b]) ok[a]=0;
        if(A[b]<=A[a]) ok[b]=0;
    }
    
    int ans=0;
    
    for(int i=0;i<N;i++){
        if(ok[i]) ans++;
    }
    
    cout<<ans<<endl;
}



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


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        var n = int.Parse(Console.ReadLine());
        long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long[] b = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long[] c = Console.ReadLine().Split().Select(long.Parse).ToArray();

        Array.Sort(a);
        Array.Sort(b);
        Array.Sort(c);

        //bを固定して調べる
        long ans = 0;
        for (int i = 0; i < n; i++)
        {
            var tmp1 = LowerBound(a, b[i]);
            var tmp2 = UpperBound(c, b[i]);
            ans += tmp1 * (n-tmp2);
        }

        // 出力
        Console.WriteLine(ans);
    }

    public static long LowerBound<T>(T[] a, T v)
    {
        return LowerBound(a, v, Comparer<T>.Default);
    }

    public static long LowerBound<T>(T[] a, T v, Comparer<T> cmp)
    {
        long l = 0;
        long r = a.Length - 1;
        while (l <= r)
        {
            var mid = l + (r - l) / 2;
            var res = cmp.Compare(a[mid], v);
            if (res == -1) l = mid + 1;
            else r = mid - 1;
        }
        return l;
    }
    public static long UpperBound<T>(T[] a, T v)
    {
        return UpperBound(a, v, Comparer<T>.Default);
    }

    public static long UpperBound<T>(T[] a, T v, Comparer<T> cmp)
    {
        long l = 0;
        long r = a.Length - 1;
        while (l <= r)
        {
            var mid = l + (r - l) / 2;
            var res = cmp.Compare(a[mid], v);
            if (res <= 0) l = mid + 1;
            else r = mid - 1;
        }
        return l;
    }
}

Measured memory_bytes: 43760
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmin(T &a, T b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}
int id = 0;
void dfs(int l,int r,vector<ll>&a,vector<int>&res){
    if(l==id){
        for(int i=r;i>=l;i--){
            res.push_back(i);
        }
        return;
    }else if(r==id-1){
        for(int i=l;i<=r;i++){
            res.push_back(i);
        }
        return;
    }
    if(a[l]>=a[r]){
        a[l] += a[r];
        res.push_back(r);
        dfs(l,r-1,a,res);
    }else{
        a[r] += a[l];
        res.push_back(l);
        dfs(l+1,r,a,res);
    }
    return;
}   

int main(){
    ll n,s;
    cin >> n >> s;
    vector<ll>a(n),b(n);
    rep(i,n){
        cin >> a[i] >> b[i];
    }
    id = lower_bound(a.begin(),a.end(),s)-a.begin();
    if(id==0){
        cout << a[n-1]-s << endl;
        return 0;
    }else if(id==n){
        cout << s-a[0] << endl;
        return 0;
    }
    vector<int>res;
    dfs(0,n-1,b,res);
    reverse(res.begin(),res.end());
    ll ans = 0;
    rep(i,n){
        ans += abs(s-a[res[i]]);
        s = a[res[i]];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2428
#include <iostream>
#include <vector>
#include <set>
#include <utility>
#include <algorithm>
using namespace std;

typedef pair<int, int> pi;
typedef pair<pi, char> pic;

int N;
vector<pic> P;
set<int> Ry;

void input_data(void) {
	cin >> N;
	P.resize(2 * N);
	for (int i = 0; i < N; ++i) {
		cin >> P[i].first.first >> P[i].first.second;
		P[i].second = 'R';
	}
	for (int i = N; i < 2 * N; ++i) {
		cin >> P[i].first.first >> P[i].first.second;
		P[i].second = 'B';
	}
}

int solve(void) {
	int cnt = 0;
	for (int i = 0; i < 2 * N; ++i) {
		if (P[i].second == 'R')
			Ry.insert(P[i].first.second);
		else {
			set<int>::reverse_iterator itr;
			for (itr = Ry.rbegin(); itr != Ry.rend(); ++itr) {
				if (*itr < P[i].first.second) {
					Ry.erase(*itr);
					++cnt;
					break;
				}
			}
		}
	}
	return cnt;
}

int main(void) {
	input_data();

	sort(P.begin(), P.end());
	int ans = solve();

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
//i hate penalty
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;

pair<int, int> a[100001];

int main(){
	int n;
	cin >> n;
	for (int i=0; i<n; i++){
		int x;
		cin >> x;
		a[i]=make_pair(x, i);
	}
	sort(a, a+n);
	int ans=0;
	for (int i=0; i<n; i++){
		if (a[i].s%2!=i%2){
			if (a[i].s%2) ans+=2;
			else ans--;
		}
	}
	cout << ans << "\n";
}

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

int n, q;
int v[111111];

int solve(int key) {
   int l = -1, r = n - 1;
   while (r - l > 1) {
      int m = (l + r) / 2;
      if (v[m] >= key) { // 右閉区間
         // 右側を切り捨てる -> (l, m]
         r = m;
      } else {
         // 左側を切り捨てる -> (m, r]
         l = m;
      }
   }
   return v[r] == key;
}

int main() {
   cin >> n;
   for (int i = 0; i < n; i++) cin >> v[i];
   cin >> q;
   int cnt = 0;
   while (q--) {
      int x;
      cin >> x;
      if (solve(x)) cnt++;
   }
   cout << cnt << endl;

   return 0;
}


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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define Sort(x) sort(x.begin(), x.end())
#define Sort_rev(x) sort(x.begin(), x.end(), greater<int>())
#define ALL(v) (v).begin(), (v).end()

//π M_PI
//deg = rad*180/M_PI

int main() {
    ll n;
    cin >> n;
    ll p[n];
    rep(i, n) {
        cin >> p[i];
    }

    ll min = p[0];
    ll ans = 1;
    rep(i, n) {
        if ( i > 0 ) {
            if ( min > p[i] ) {
                ans++;
                min = p[i];
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
#define INF (1e9)

int main() {
  string S;
  cin >> S;
  for (int i = 0; i < 3; i++) {
    cout << S[i];
  }

  cout << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	int a,b;

	scanf("%d %d",&a,&b);

	if((a*b)%2 == 0){

		printf("Even\n");

	}else{

		printf("Odd\n");
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;

int main(){
	int n, m;
	char tmp;
	string ans = "";
	
	while (true){
		cin >> n;
		if (n == 0)
			break;
		vector<char> before(n);
		vector<char> after(n);
		for (int i = 0; i < n; ++i){
			cin >> before[i];
			cin >> after[i];
		}

		cin >> m;
		for (int i = 0; i < m; ++i){
			cin >> tmp;
			for (int j = 0; j < n; ++j){
				if (tmp == before[j]){
					tmp = after[j];
					break;
				}
			}
			ans += tmp;
		}

		cout << ans << endl;

		ans = "";
		before.clear();
		after.clear();
	}
	return 0;
}

Measured memory_bytes: 1340