akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxN = 1e5 + 13;
int x, y, z, a[maxN], b[maxN], c[maxN], arr[maxN], pre[maxN], nxt[maxN], suf[maxN], mp[maxN], ans, tmp[maxN], prf[maxN], mx;
bool cmp (int i, int j) {
    if (a[i] - b[i] != a[j] - b[j])
	return a[i] - b[i] > a[j] - b[j];
    return i < j;
}

bool cmp2 (int i, int j) {
    if (b[i] != b[j])
	return b[i] > b[j];
    return i < j;
}
bool cmp3 (int i, int j) {
    if (a[i] != a[j])
	return a[i] > a[j];
    return i < j;
}

int32_t main () {
    cin >> x >> y >> z;
    int sum = x + y + z;
    for (int i = 0; i < sum; i++) {
	cin >> a[i] >> b[i] >> c[i];
	a[i] -= c[i];
	b[i] -= c[i];
	ans += c[i];
    }
    iota(arr, arr + sum, 0);
    sort(arr, arr + sum, cmp);

    iota(tmp, tmp + sum, 0);
    sort(tmp, tmp + sum, cmp2);
    int r = y - 1;
    for (int i = 0; i < y; i++) {
	suf[0] += b[tmp[i]];
    }
    for (int i = 0; i < sum; i++) {
	pre[i] = i - 1;
	nxt[i] = i + 1;
	mp[tmp[i]] = i;
    }
    for (int i = 1; i <= sum - y; i++) {
	suf[i] = suf[i - 1];
	if (mp[arr[i - 1]] <= r) {
	    r = nxt[r];
	    suf[i] -= b[arr[i - 1]];
	    suf[i] += b[tmp[r]];
	}
	else {
	    int pos = mp[arr[i - 1]];
	    pre[nxt[pos]] = pre[pos];
	    nxt[pre[pos]] = nxt[pos];
	}
	//cout << i << " " << suf[i] << endl;
    }

    iota(tmp, tmp + sum, 0);
    sort(tmp, tmp + sum, cmp3);
    r = x - 1;
    for (int i = 0; i < x; i++) {
	prf[sum - 1] += a[tmp[i]];
    }
    for (int i = 0; i < sum; i++) {
	pre[i] = i - 1;
	nxt[i] = i + 1;
	mp[tmp[i]] = i;
    }
    for (int i = sum - 2; i >= x - 1; i--) {
	prf[i] = prf[i + 1];
	if (mp[arr[i + 1]] <= r) {
	    r = nxt[r];
	    prf[i] -= a[arr[i + 1]];
	    prf[i] += a[tmp[r]];
	}
	else {
	    int pos = mp[arr[i + 1]];
	    pre[nxt[pos]] = pre[pos];
	    nxt[pre[pos]] = nxt[pos];
	}
	//cout << i << " " << prf[i] << endl;
    }
    for (int i = x - 1; i < sum - y; i++)
	mx = max(mx, prf[i] + suf[i + 1] + ans);
    cout << mx << endl;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
string s,t;
int main(){
	cin>>s>>t;
	sort(s.begin(),s.end());
	sort(t.begin(),t.end());
	reverse(t.begin(),t.end());
	if(s<t)
		cout<<"Yes";
	else
		cout<<"No";
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string.h>
#include<map>
#include<string>
#include<math.h>
#include<stdio.h>
#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
const int MAXN=10010;
const ll long_inf=9223372036854775807;
const int int_inf=2147483647;
inline ll read() {
	ll c=getchar(),Nig=1,x=0;
	while(!isdigit(c)&&c!='-')c=getchar();
	if(c=='-')Nig=-1,c=getchar();
	while(isdigit(c))x=((x<<1)+(x<<3))+(c^'0'),c=getchar();
	return Nig*x;
}
char s[500005];
char t[500005];
int ans1[500005];
int ans2[500005];
int main() {
	int ans=0;
	scanf("%s%s",s+1,t+1);
	for(int i=1; s[i]; i++) {
		if(s[i]=='B')
			ans1[i]=ans1[i-1]+2;
		else
			ans1[i]=ans1[i-1]+1;
	}
	for(int i=1; t[i]; i++) {
		if(t[i]=='B')
			ans2[i]=ans2[i-1]+2;
		else
			ans2[i]=ans2[i-1]+1;
	}
	int T=read();
	int a,b,c,d;
	for(int i=0; i<T; i++) {
		a=read(),b=read(),c=read(),d=read();
		int TEMP1=ans1[b]-ans1[a-1];
		int TEMP2=ans2[d]-ans2[c-1];
		if((TEMP1%3)==(TEMP2%3))
			puts("YES");
		else
			puts("NO");
	}
}


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

const ll INF = 1ll << 60;
ll MOD = 998244353;

int main()
{

    int n;
    cin >> n;
    vector<int> a(n);

    REP(i, n)
    cin >> a[i];

    vector<int> s = a;
    sort(s.rbegin(), s.rend());
    REP(i, n)
    {
        int ans = s[0];
        if (s[0] == a[i])
            ans = s[1];
        cout << ans << endl;
    }

    return 0;
}

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

using namespace std;

int main() {
int a[10];
for(int i=0; i<10; i++) cin >> a[i];
sort(a, a+10);
reverse(a, a+10);
cout << a[0] << endl;
cout << a[1] << endl;
cout << a[2] << endl;
return 0;
}

Measured memory_bytes: 1176
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (s : t : _) <- T.words <$> T.getLine :: IO [T.Text]
  (a : b : _) <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  u <- T.getLine :: IO T.Text
  let
    (a', b') | u == s    = (pred a, b)
             | otherwise = (a, pred b)
  putStr (show a')
  putStr " "
  putStrLn (show b')

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 508
#include <iostream>
using namespace std;
 
int a[100];
int main(){
  int n,m;
  cin >> n >> m;
  int sum = 0;
  for (int i = 0; i < n; i++){
    cin >> a[i];
    sum += a[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++){
    if (a[i] * 4 * m >= sum)
      ans++;
  }
   if (ans >= m){
     cout << "Yes" << endl;
   }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;}
using ll = long long;
using P = pair<int,int>;

int n,m,k,a,b;
string s,t;
int deg[100005];
vector<int> block[100005];

struct UnionFind {
  vector<int> par;
  UnionFind(int n=0): par(n,-1) {}
  int root(int x) {
    if (par[x] < 0) return x;
    return par[x] = root(par[x]);
  }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (par[x] > par[y]) swap(x,y);
    par[x] += par[y];
    par[y] = x;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y);}
  int size(int x) { return -par[root(x)];}
};

int main() {
  cin >> n >> m >> k;
  UnionFind uf(n);
  rep(i,m){
    cin >> a >> b, a--,b--;
    deg[a]++,deg[b]++;
    uf.unite(a,b);
  }
  rep(i,k){
    cin >> a >> b, a--,b--;
    block[a].push_back(b);
    block[b].push_back(a);
  } 
  rep(i,n){
    int ans=uf.size(i)-deg[i]-1;
    for(auto b : block[i])if(uf.same(i,b)) ans--;
    cout << ans << endl;
  }
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
ll sqr(ll a)
{
    return ((a % MOD) * (a % MOD)) % MOD;
}
ll msub(ll a, ll b)
{
    return ((a - b) % MOD + MOD) % MOD;
}
ll madd(ll a, ll b)
{
    return (a + b) % MOD;
}
ll mmul(ll a, ll b)
{
    return ((a % MOD) * (b % MOD)) % MOD;
}
int t;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    string s;
    cin >> s;
    if(s == "ABC") cout << "ARC";
    else cout << "ABC";
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
//debug
#define vecprint(v) rep(i,v.size())cout << v[i] << " ";cout << endl;
#define setprint(s) for(auto i=s.begin();i!=s.end();i++)cout << *i << " ";cout << endl;
#define mappairprint(s) for(auto i=s.begin();i!=s.end();i++)cout << i->first << " " << i->second << endl;
//reader
#define r1(a) cin>>(a)
#define r2(a,b) cin>>(a)>>(b)
#define r3(a,b,c) cin>>(a)>>(b)>>(c)
//writer
#define wtr(a) cout<<(a)<<" "
//#define wtr(a,b) cout<<(a)<<" "<<(b)<<" "
//#define wtr(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "
#define wtrl(a) cout<<(a)<<endl
//#define wtrl(a,b) cout<<(a)<<" "<<(b)<<endl
//#define wtrl(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
//variable definition
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
//roop
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(c) c.begin(),c.end()
//term
#define elif else if
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
using namespace std;
using ll = long long;
//const
constexpr double PI = 3.141592653589793238462643383279;
vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};


int main() {
  //input
  int n,k;
  cin >> n >> k;
  
  int a[n] = {0};
  
  rep(i,k) {
    int d;
    cin >> d;
    rep(j,d) {
      int aa;
      cin >> aa;
      a[aa-1] = 1;
    }
  }
  
  int count = 0;
  rep(i,n) {
    //cout << a[i] << endl;
    if(a[i] == 0) count++;
  }
  cout << count << endl;
  
}

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

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

int main(){
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    priority_queue<ll> v[3];
    rep(i,a){
        ll xx;
        cin>>xx;
        v[0].push(xx);
    }
    rep(i,b){
        ll xx;
        cin>>xx;
        v[1].push(xx);
    }
    rep(i,c){
        ll xx;
        cin>>xx;
        v[2].push(xx);
    }

    vector<ll> r;
    vector<ll> g;
    ll sum = 0;
    rep(i,x){
        r.push_back(v[0].top());
        sum+=v[0].top();
        v[0].pop();
    }
    rep(i,y){
        g.push_back(v[1].top());
        sum+=v[1].top();
        v[1].pop();
    }


    reverse(r.begin(),r.end());
    reverse(g.begin(),g.end());

    r.push_back(MOD);
    g.push_back(MOD);
    int ri=0,gi=0;
   // cout<<r[ri]<<g[gi]<<endl;

    while(true){
        if(v[2].empty()||(ri==x&&gi==y))break;
        ll v2=v[2].top();
        v[2].pop();


        if(r[ri]<v2||g[gi]<v2){
            if(ri!=x&&gi!=y){
                if(r[ri]>=g[gi]){
                    sum-=g[gi];
                    gi++;
                    sum+=v2;
                }else{
                    sum-=r[ri];
                    ri++;
                    sum+=v2;
                }

            }else if(r[ri]>=g[gi]&&gi!=y){
                sum-=g[gi];
                gi++;
                sum+=v2;
            }else if(r[ri]<=g[gi]&&ri!=x){
                sum-=r[ri];
                ri++;
                sum+=v2;
            }
        }else{break;

        }

    }cout<<sum<<endl;











return 0;
}


Measured memory_bytes: 4852
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
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; }

//　ローカルでの実行方法は g++ main.cpp -std=c++14 -I .

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

	while(t--){
		ll n, m, a, b;
		cin >> n >> m >> a >> b;
		cout << floor_sum(n, m, a, b) << endl;
	}

}


Measured memory_bytes: 3660
import java.lang.Math.*

private fun readLn() = readLine()!! // string line
private fun readStrings() = readLn().split(" ") // list of strings
private fun readLong() = readLn().toLong()
private fun readLongs() = readStrings().map { it.toLong() } // list of ints
private fun readInt() = readLn().toInt() // single int
private fun readInts() = readStrings().map { it.toInt() } // list of ints


//var n = 0
//var ar = listOf<Int>()

fun main() {
    val d = readInt()
    val C = readInts()
    var S = mutableListOf<List<Int>>()
    S.add(mutableListOf())

    for (i in 0 until d) {
        S.add(readInts())
    }

    val last = Array(26) {0}
    val chosen = mutableListOf<Int>()

    for (day in 1 until d + 1) {
        var max = Integer.MIN_VALUE
        var maxContest = -1

        for (contest in 0 until 26) {
            var cur = S[day][contest]
            val daysSince = day - last[contest]
            cur -= (C[contest] * daysSince * (daysSince + 1) / 2)

            if (cur > max) {
                max = cur
                maxContest = contest
            }
        }

        last[maxContest] = day
        chosen.add(maxContest + 1)
    }

    print(chosen.joinToString("\n"))
}


Measured memory_bytes: 39784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
#define all(a) begin(a),end(a)
#define rall(a) (a).rbegin(),(a).rend()

int main()
{
    int N; cin >>N;
    vector<int> posi, nega;
    rep(i, N) {
        int A; cin >> A;
        if (A >= 0) {
            posi.push_back(A);
        } else {
            nega.push_back(A);
        }
    }
    sort(rall(posi));
    sort(all(nega));
    
    int ans = -1;
    vector<pair<int, int>> op;

    if (posi.size() == 0) {
        op.push_back(make_pair(nega[N-1], nega[N-2]));
        posi.push_back(nega[N-1]-nega[N-2]);
        nega.resize(N-2);
    }

    if (nega.size() == 0) {
        if (N == 2) {
            op.push_back(make_pair(posi[0], posi[1]));
            posi.resize(1);
        } else {
            op.push_back(make_pair(posi[N-1], posi[N-2]));
            nega.push_back(posi[N-1]-posi[N-2]);
            posi.resize(N-2);
        }
    }

    for (int i = 0; i < posi.size() - 1; i++) {
        op.push_back(make_pair(nega.back(), posi[i]));
        nega.back() -= posi[i];
    }
    for (int i = 0; i < nega.size(); i++) {
        op.push_back(make_pair(posi.back(), nega[i]));
        posi.back() -= nega[i];
    }

    ans = posi.back();

    cout << ans << endl;
    for (auto const& p: op) {
        cout << p.first << " " << p.second << endl;
    }
}


Measured memory_bytes: 3444
n = int(input())
a = [[int(i) for i in input().split()] for i in range(n)]

dp = [[-1 for i in range(3)] for j in range(n + 1)]
dp[0] = [0 for i in range(3)]

for i in range(1, n + 1):
    for j in range(3):
        for k in range(3):
            if j == k:
                # if same as previous day
                continue
            dp[i][j] = max(dp[i - 1][k] + a[i - 1][j], dp[i][j])

print(max(dp[-1]))

Measured memory_bytes: 102880
import heapq
import sys
from operator import itemgetter

input = sys.stdin.readline
N, L = map(int, input().split())
LR = []
LR_set = []
for _ in range(N):
  l, r = map(int, input().split())
  LR.append((l, r))
  LR_set.append(l)
  LR_set.append(r)
LR_set = sorted(set(LR_set))
mapping = {}
# zahyou asshuku
for i, lr in enumerate(LR_set):
  mapping[lr] = i


imos = [0] * (len(mapping)+1)

LR.sort(key=itemgetter(0))
q = []
ans_x = 0
right = 0
for i, (l, r) in enumerate(LR, 1):
  # x
  heapq.heappush(q, -r)
  #print(q, right, ans_x)
  if i<N and LR[i][0] > right:
    rr = heapq.heappop(q)
    rr = -rr
    right = rr
    ans_x += 1

  # y
  imos[mapping[l]] += 1
  imos[mapping[r]] -= 1

if L > right:
  ans_x += 1

for i in range(1, len(imos)):
  imos[i] += imos[i-1]

ans_y = N + 1 - min(imos[:mapping[L]])

print(ans_x, ans_y)






Measured memory_bytes: 105964
#include <stdio.h>
#include <float.h>
#include <string.h>
int main(){
	int n,i;
	float x,m=0;
	char u[10];
	scanf("%d",&n);
	for (i = 0; i < n; ++i)
	{
		scanf("%f %s",&x,&u);
		if (strcmp(u,"JPY")==0)
		{
			m=m+x;
		}else if (strcmp(u,"BTC")==0)
		{
			m=m+x*380000;
		}
	}
	printf("%g\n",m);
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int d1, d2,number, maxu = 0,maxn = 0,  kai;
	cin >> kai;
	while (kai != 0){
		for (int i = 0; i < kai; i++){
			cin >> number >> d1 >> d2;
			if (maxu < d1 + d2){
				maxu = d1 + d2;
				maxn = number;
			}
		}
		cout << maxn << " " << maxu << endl;
		maxu = maxn = 0;
		cin >> kai;
	}
	return 0;
}

Measured memory_bytes: 1160
N = input()

# NはK桁
K = len(N)

# 最上位の桁がc
c = int(N[0])

# 最上位の桁以外
d = N[1:]

if "9" * len(d) == d:
    print(c + 9 * (K - 1))
else:
    print(c + 9 * (K - 1) - 1)


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

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            bool ret = true;
            var input = RL();

            var leng = input.Length;
            var fore = input.Substring(0, (leng - 1) / 2);
            var afte = input.Substring((leng +1) / 2);

           

            ret &= comprev(input); 
            ret &= comprev(fore); 
            ret &= comprev(afte);

            Console.WriteLine(bool2ret(ret));
            //Console.ReadLine();
        }
        static bool comprev(string s) {return string.Compare(s, new string(s.Reverse().ToArray())) == 0; }
        static string RL() { return Console.ReadLine().Trim(); }
        static IEnumerable<string> spr(string s) { return s.Split(' '); }
        static int c2i(string c) { return int.Parse(c); }
        static double c2d(string c) { return double.Parse(c); }
        static string bool2ret(bool b) { return b ? "Yes" : "No"; }
    }
}


Measured memory_bytes: 13524
#include <bits/stdc++.h>
using namespace std;
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto x : v) cerr << x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int i = 0; i < (n); ++i) cerr << a[i] << ", "; cerr << endl
typedef long long ll;
typedef long double ld;
ll num[155];
int main() {
	ll mx = 1e15;
	int K;
	scanf("%d", &K);
	vector<ll> v;
	for (int x = 1; x <= 135; ++x) {
		ll y = x;
		while (y <= mx) {
			v.push_back(y);
			y = y * 10 + 9;
		}
	}
	sort(v.begin(), v.end());
	v.resize(unique(v.begin(), v.end()) - v.begin());
	for (int i = 0; i < v.size(); ++i) {
		string s = to_string(v[i]);
		int d = 0;
		for (char c : s) d += c - '0';
		ll add = 1;
		while (!s.empty()) {
			if (s.back() == '9') add *= 10;
			else break;
			s.pop_back();
		}
		bool bad = (v[i] + add) * d < v[i] * (d + 1);
		if (K && !bad) {
			printf("%lld\n", v[i]);
			--K;
		}
	}
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
using index_t = std::size_t;

namespace lib
{
	using graph_t = std::vector<std::set<index_t>>;
	template<class T>using weighted_graph_t = std::vector<std::map<index_t, T>>;

	struct max_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::max(lhs, rhs);
		}
	};
	struct min_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::min(lhs, rhs);
		}
	};

	constexpr max_t max;
	constexpr min_t min;

	template<class T>auto order_by(T func)
	{
		return [=](auto&& lhs, auto&& rhs)
		{
			return func(lhs) < func(rhs);
		};
	}

	template<class T>constexpr auto max_v = std::numeric_limits<T>::max();
	template<class T>constexpr auto min_v = std::numeric_limits<T>::min();

	template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;
	
	template<class T>constexpr T pow(T val, std::uint64_t p)
	{
		auto ret = T(1);
		auto s = 1ULL;
		for (auto i = 0; i < 63; ++i, s <<= 1)
		{
			if (p & s)
			{
				ret *= val;
			}
			val *= val;
		}
		return ret;
	}
}

template<class T>void println(T const& v)
{
	std::cout << v << std::endl;
}

void Main()
{
	std::size_t N;
	std::cin >> N;
	std::vector<int> vec(N);
	for (auto& v : vec)
	{
		std::cin >> v;
	}
	std::sort(vec.begin(), vec.end());
	int count = 0;
	for (auto i : boost::irange(N))
	{
		for (auto j : boost::irange(i + 1, N))
		{
			for (auto k : boost::irange(j + 1, N))
			{
				if (vec[i] != vec[j] && vec[j] != vec[k] && vec[k] < vec[i] + vec[j])
				{
					++count;
				}
			}
		}
	}
	println(count);
}

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

Measured memory_bytes: 3648
#include<stdio.h>
#include<stdlib.h>
int main(void)
{	
	int s[5];
	int k;
	int p=0;
	
	for(int i=0;i<5;i++)
		scanf("%d",&s[i]);
	scanf("%d",&k);
	
	for(int i=0;i<4;i++)
	{
		for(int n=1;n+i<5;n++)
		{	
			if(abs(s[i]-s[n+i])<=k){
				
				p++;
		}
		
	}
	
	}
	
	if(p==10)
	printf("Yay!");
	
	else
	printf(":(");
	

	return 0;
}
	
	

Measured memory_bytes: 1728
#include<stdio.h>

long ans[ 100000000 ] ;


long max( long a ,long b )
{
	if( a < b )
	{
		return max( b ,a ) ;
	}

	return a ;
}


int main()
{
	long n ,k ;

	while( scanf( "%ld %ld" ,&n ,&k ) ,n || k )
	{

		long i ;
		for( i = 1 ; i <= n ; i++ )
		{
			scanf( "%ld" ,&ans[ i ] ) ;

			ans[ i ] += ans[ i - 1 ] ;

			if( i >= k )
			{
				ans[ 0 ] = max( ans[ i ] - ans[ i - k ] ,ans[ 0 ] ) ;
			}
		}

		printf( "%ld\n" ,ans[ 0 ] ) ;
	}

	return 0 ;
}

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

int main(){
  ll n;
  cin >> n;
  n--;
  ll a = 26;
  int b = 1;
  while(true) {
    if(n - a < 0) break;
    n -= a;
    a *= 26;
    b++;
  }
  string s;
  rep(i,b) {
    a /= 26;
    ll d = n / a;
    n -= (d*a);
    s += (char)('a'+d); 
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 3608
#include <iostream>
int main() {
    int a, b, k;
    std::cin >> a >> b >> k;
    int n = 0;
    for (int i = std::min(a, b); i >= 1; i--) {
        if (a % i == 0 && b % i == 0) {
            n++;
            if (n == k) {
                std::cout << i;
                break;
            }
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MP make_pair
#define ull unsigned long long int
#define F first
#define S second
#define put insert
#define pb push_back
#define rsort(arr) sort(arr.begin(),arr.end(),greater<int>())
#define srt(arr) sort(arr.begin(),arr.end())
ll MOD = 1e9+7;
bool check(int a, int b, int c) {
    if(b > a && c > b)
        return true;
    return false;
}
int main() {
    int t = 1;
    // cin>>t;
    while(t--) {
        int a,b,c,k;
        cin>>a>>b>>c>>k;
        bool answerable = false;
        if(check(a,b,c)) {
            answerable = true;
        } else {
            while(k--) {
                if(b <= a)
                    b = b*2;
                else if(c <= b)
                    c = c*2;
                if(check(a,b,c)) {
                    answerable = true;
                    break;
                }
            }
        }
        if(answerable)
            cout<<"Yes";
        else
            cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 3620
ans = {}
n = int(input())
for _ in range(n):
    s = input()
    ans.setdefault(s, 0)
    ans[s] += 1

m = int(input())
for _ in range(m):
    t = input()
    ans.setdefault(t, 0)
    ans[t] -= 1

ans = sorted(ans.items(), key=lambda x: x[1], reverse=True)
print(max(0, ans[0][1]))


Measured memory_bytes: 3060
# A = [list(map(int, input().split())) for _ in range(3)]
# n = int(input())
# B = [int(input()) for _ in range(n)]
# X = list(map(int, input().split()))
a, b = map(int, input().split())
for i in range(10000):
    za = (8*i)//100
    zb = (10*i)//100
    if za == a and zb == b:
        print(i)
        exit()
print(-1)


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

using namespace std;

int main(int argc, char *argv[])
{
	long long a, b;
	cin >> a >> b;

	long long ans = max(a + b, a - b);
	ans = max(ans, a * b);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long int
#define phi 1.6180339
#define rep(i,n) for(auto i=0;i<(n);i++)
#define endl "\n"
#define For(i,a,b) for(auto i=(a);i<(b);i++)
#define op1 cin.tie(NULL)
#define op2 cout.tie(NULL)
#define op3 std::ios_base::sync_with_stdio(false)
#define MAXX 1000001
using namespace std;
vector<int> arr(MAXX);
void trozen()
{
    string a,b;
    int n;
    cin>>n;
    cin>>a>>b;
    for(int i=0;i<n;i++)
    {
        cout<<a[i]<<b[i];
    }
}
int32_t main()
{
    op1;op2;op3;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    trozen();
    return 0;
}


Measured memory_bytes: 10860
// import chie template :) {{{
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
    std.range, std.container, std.bigint, std.ascii, std.typecons;

// }}}
// nep.scanner {{{
class Scanner
{
    import std.stdio : File, stdin;
    import std.conv : to;
    import std.array : split;
    import std.string : chomp;

    private File file;
    private char[][] str;
    private size_t idx;

    this(File file = stdin)
    {
        this.file = file;
        this.idx = 0;
    }

    private char[] next()
    {
        if (idx < str.length)
        {
            return str[idx++];
        }

        char[] s;
        while (s.length == 0)
        {
            s = file.readln.chomp.to!(char[]);
        }

        str = s.split;
        idx = 0;

        return str[idx++];
    }

    T next(T)()
    {
        return next.to!(T);
    }

    T[] nextArray(T)(size_t len)
    {
        T[] ret = new T[len];

        foreach (ref c; ret)
        {
            c = next!(T);
        }

        return ret;
    }

    void scan()()
    {
    }

    void scan(T, S...)(ref T x, ref S args)
    {
        x = next!(T);
        scan(args);
    }
}
// }}}

struct P
{
    int id, num;
    this(int id, int num)
    {
        this.id = id;
        this.num = num;
    }
}

void main()
{
    auto cin = new Scanner;
    int n = cin.next!int;
    P[] ar;
    foreach (i; 0 .. n)
    {
        int b;
        cin.scan(b);
        ar ~= P(i, b);
    }
    ar.sort!("a.num < b.num");
    int[] res = new int[n];
    foreach (i; 0 .. n)
    {
        if (i < n / 2)
        {
            res[ar[i].id] = ar[n / 2].num;
        }
        else
        {
            res[ar[i].id] = ar[n / 2 - 1].num;
        }
    }
    foreach (e; res)
    {
        writeln(e);
    }
}


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

using namespace std;

typedef long long ll;
typedef pair< ll, ll > pll;
typedef pair< int, int > pii;

const double pi = 3.14159265358979323846;

// #define fio() cin.tie(0); ios::sync_with_stdio(false);
// template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
// template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos
// 1e18

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

  ll A, B, M;
  cin >> A >> B >> M;

  ll a[A], as[A];
  for (ll i = 0; i < A; i++) {
    cin >> a[i];
    as[i] = a[i];
  }

  ll b[B], bs[B];
  for (ll i = 0; i < B; i++) {
    cin >> b[i];
    bs[i] = b[i];
  }

  sort(as, as + A);
  sort(bs, bs + B);

  ll res = as[0] + bs[0];

  ll x, y, c;
  for (ll i = 0; i < M; i++) {
    cin >> x >> y >> c;

    ll total = a[x - 1] + b[y - 1] - c;
    res = min(total, res);
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<stdio.h>
using namespace std;

int main()
{
	char ch;

	while (1) {
		scanf("%c", &ch);

		if ('a' <= ch && ch <= 'z') {
			ch -= 32;
			cout << ch;
		}
		else if('A'<=ch && ch<='Z'){
			ch += 32;
			cout << ch;
		}
		else {
			cout << ch;
		}

		if (ch == '\n')break;
	}
    return 0;
}




Measured memory_bytes: 3148
a = 1
b = 1

n = STDIN.readline.to_i
n.times do
    ratio = STDIN.readline.split
    x = ratio[0].to_r
    y = ratio[1].to_r
    n1 = a / x
    n2 = b / y
    n = [n1, n2].max.ceil
    a = n * x;
    b = n * y;
end

puts (a+b).to_i


Measured memory_bytes: 1788
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;

int main() {
    int n,k;
    cin >> n >> k;
    int max = 0;
    vector<int> a(100005, 0);
    vector<int> s(100005,0);
    while (n != 0 || k != 0) {
        int b;
        s[0] = 0;
        for(int i = 0; i < n; i++) {
            cin >> b;
            s[i+1] = s[i] + b;
        }
        for (int i = 0; i < n-k; i++) {
            if(max < s[i+k] - s[i]) {
                max = s[i+k] - s[i];
            }
        }
        cout << max << endl;
        cin >> n >> k;
    }
}
// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/



Measured memory_bytes: 3548
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Integer n = Integer.valueOf(br.readLine());
		String[] temp = br.readLine().split(" ");
		Integer[] a = new Integer[n];
		int i, alice=0, bob=0;
		for(i=0;i<n;i++) a[i]= Integer.parseInt(temp[i]);
		Arrays.sort(a);
		for(i=0;i<n;i++) if(i % 2 != 0) alice += a[i]; else bob += a[i];
		System.out.println(Math.abs(alice - bob));
	}
}


Measured memory_bytes: 22996
#include<stdio.h>
#define N 100

int p[N],m[N][N],n;

 
  void MatrixChainOrder(){
 
  int i,j,l,k,q;
 
 
  for(i=1;i<=n;i++){
    m[i][i]=0;
  }

  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
     
      j=i+l-1;
      m[i][j]=100000;
      
      for(k=i;k<=j-1;k++){
	q = m[i][k] + m[k+1][j] + p[i] * p[k+1]*p[j+1];
    
	if( q < m[i][j] ){
	  m[i][j] = q;
	}
      }
    }
  }

  printf("%d\n", m[1][n]);

}
 
main(){
   
  int i,a,count;
  
  scanf("%d",&n);
   
  for(i=0;i<n;i++){
    scanf("%d %d",&p[i+1],&a);
     
  }

  p[i+1] = a;
   
  MatrixChainOrder();
   
  return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////




#define N 200005
ll n;
ll a[N];

ll ret[N][2];
void cal(){
    set<l_l>s,s2;
    memset(ret,-1,sizeof(ret));
    rep(i,0,n-1){
        while(!s2.empty()){
            l_l t=*s2.begin();
            if(t.first<a[i]){
                ret[t.second][1]=i;
                s2.erase(t);
            }else{
                break;
            }
        }
        while(!s.empty()){
            l_l t=*s.begin();
            if(t.first<a[i]){
                ret[t.second][0]=i;
                s2.insert(t);
                s.erase(t);
            }else{
                break;
            }
        }
        s.insert(l_l(a[i],i));
    }
}

int main(){fastio
    cin>>n;
    rep(i,0,n-1)cin>>a[i];
    ll dp[n][4];
    cal();
    rep(i,0,n-1)rep(j,0,1){
        dp[i][j]=ret[i][j];
    }
    reverse(a,a+n);
    cal();
    rep(i,0,n-1)rep(j,0,1){
        if(ret[i][j]==-1)dp[n-1-i][j+2]=ret[i][j];
        else dp[n-1-i][j+2]=n-1-ret[i][j];
    }
    reverse(a,a+n);
    rep(i,0,n-1){
        rep(j,0,1){
            if(dp[i][j]==-1)dp[i][j]=n;
        }
        rep(j,2,3){
            if(dp[i][j]==-1)dp[i][j]=-1;
        }
    }
    /*
    rep(j,0,3){
        rep(i,0,n-1){
            cout<<dp[i][j]<<" ";
        }cout<<endl;
    }*/
    ll ans=0;
    rep(i,0,n-1){
        ll c=0;
        c+=(dp[i][0]-i)*(dp[i][2]-dp[i][3]);
        c+=(dp[i][1]-dp[i][0])*(i-dp[i][2]);
        ans+=c*a[i];
    }
    cout<<ans<<endl;
    
    return 0;
}













Measured memory_bytes: 13568
char r[99],g[99],*G,d[99];main(c,i,k){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=k=0,G=g,c=*G++;*(G-1);)c=(c==d[k]?k++,r[i++]:(putchar(c),*G++));exit(0);}

Measured memory_bytes: 524
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc=new Scanner(System.in);
        int apple=sc.nextInt();
        int apple_piece=sc.nextInt();
        apple_piece+=apple*3;
        System.out.println(apple_piece/2);
    }    
}


Measured memory_bytes: 21844
V,E,Start = map(int,input().split())
INF = 10**20
Edge = []
D = [INF]*V
for _ in range(E):
    Edge.append(list(map(int,input().split())))

D[Start] = 0
loop = 0
while True:
    update = False
    for i in range(E):
        fr   = Edge[i][0]
        to   = Edge[i][1]
        cost = Edge[i][2]

        if D[fr] != INF and D[to] > D[fr] + cost:
            D[to] = D[fr] + cost
            update = True
    if update == False:
        break

    loop += 1
    if loop > V:
        break

if loop > V:
    print('NEGATIVE CYCLE')
else:
    for d in D:
        if d == INF:
            print('INF')
        else:
            print(d)


Measured memory_bytes: 6116
import java.util.Scanner;

public class Main {

	static int n, m;
	static int[] a, b;
	static boolean[][] graph;
	static boolean[] vis;

	public static void main(String[] args) {
		//入力受付
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		m = sc.nextInt();
		//枝の端点の配列
		a = new int[m];
		b = new int[m];
		graph = new boolean[n][n]; 					//ノードペア（枝）のデータ
		vis = new boolean[n]; 							//あるノードから別のノードへ行けるかどうか
		for (int i = 0; i < m; i++) {
			a[i] = sc.nextInt() - 1; 					//4-5を結ぶ枝はgraphの(3.4),(4,3)成分のtrueに対応
			b[i] = sc.nextInt() - 1;
			graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;	//隣接アークの端点に対応するところはtrueにする
		}

		long ans = 0;
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < n; j++) {
				vis[j] = false;							//vis初期化
			}
			graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;	//枝を一か所切ってみる
			dfs(0);											//ノード1から到達可能か深さ優先探索

			boolean bridge = false;
			//枝を切って到達不能になったノードがあるならbridgeをtrueに
			for (int j = 0; j < n; j++) {
				if (!vis[j]) {
					bridge = true;
				}
			}
			//bridgeがtrueならansを1増やす
			if (bridge)
				ans++;
			graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;//切った枝を元に戻す
		}
		System.out.println(ans);
		sc.close();
	}


	public static void dfs(int x) {
		//すでに別の経路で到達可能と分かっていたら何もしない
		if (vis[x])
			return;
		//初めて到達可能と分かった場所はtrueに書き換え
		vis[x] = true;
		//xに隣接しているノードiについて深さ優先探索
		for (int i = 0; i < n; i++) {
			if (graph[x][i] == false)
				continue;
			dfs(i);
		}
	}
}


Measured memory_bytes: 24020
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let n: usize = read!();
    let t: isize = read!();
    let a: isize = read!();

    let mut places = Vec::with_capacity(n);
    for _ in 0..n {
        let hi: isize = read!();
        places.push(hi);
    }

    let t = t * 1000;
    let a = a * 1000;

    let mut places = places
        .iter()
        .map(|high| t - high * 6)
        .map(|temp| (temp - a).abs())
        .enumerate()
        .sorted_by(|(_index, diff), (_index2, diff2)| diff.cmp(diff2));

    println!("{}", places.next().unwrap().0 + 1);
}


Measured memory_bytes: 2152
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
using intl = int64_t;
using graph = vector<vector<int> >;
int main(){
    intl h;
    cin >> h;
    intl twos=1;
    while(h>=twos){
        twos*=2;
    }

    cout << twos-1 << endl;
}

Measured memory_bytes: 3632
//入力マクロここから
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
//入力マクロここまで

fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn lcm(a: u64, b: u64) -> u64 {
    a / gcd(a, b) * b
}

fn main() {
    input! {
        n: usize,
        t: [u64;n],
    }

    let ans = t.iter().fold(1, |state, &x| lcm(state, x));

    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.Int();
            int[] A = in.Int(N);
            int[] B = in.Int(N);
            int[] C = in.Int(N);
            Arrays.sort(A);
            Arrays.sort(B);
            Arrays.sort(C);

            int[] bi = new int[N];
            long[] cntB = new long[N + 1];
            int j = 0;
            for (int i = 0; i < N; i++) {
                while (j < N && A[i] >= B[j]) j++;
                bi[i] = j;
            }
            j = 0;
            for (int i = 0; i < N; i++) {
                while (j < N && B[i] >= C[j]) j++;
                cntB[i + 1] = (N - j) + cntB[i];
            }
            long ans = 0;
            for (int i = 0; i < N; i++) {
                ans += (cntB[N] - cntB[bi[i]]);
            }
            out.println(ans);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

        public int[] Int(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = Int();
            }
            return a;
        }

    }
}



Measured memory_bytes: 50608
#include <bits/stdc++.h>
using namespace std;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define all(a) (a).begin(), (a).end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF  = 1<<30;


struct item {
  int v, w;
  bool operator<(const item &r) const { return w < r.w; }
  void operator+=(const item &r) { w += r.w, v += r.v; }
};


vector<item> enum_powerset(const vector<item> &is) {
  vector<item> a = {{0, 0}};
  vector<item> c;
  a.reserve(1<<sz(is));
  c.reserve(1<<sz(is));
  for (auto &i : is) {
    auto b = a;
    for (auto &e : b) e += i;
    vector<item> c;
    merge(all(a), all(b), back_inserter(c));
    swap(a, c);
  }
  return a;
}


int solve(const vector<item> &is, int W) {
  int n = sz(is);
  auto a = enum_powerset({is.begin(), is.begin() + n/2});
  auto b = enum_powerset({is.begin() + n/2, is.end()});
  reverse(all(a));
 
  int ans = 0;
  int vbmax = -INF;
  auto itr = b.begin();
  for (auto &[va, wa] : a) {
    while (itr != b.end() && wa + itr->w <= W) {
      chmax(vbmax, itr->v);
      ++itr;
    }
    chmax(ans, va + vbmax);
  }
  return ans;
}


int main() {
  int n; cin >> n;
  vector<item> is(n);
  for (auto &[v, w] : is) cin >> v >> w;
  is.insert(is.begin(), {0, 0});

  int q; cin >> q;
  rep(_, q) {
    int v, l; cin >> v >> l;
    vector<item> qi;
    while (v) {
      qi.push_back(is[v]);
      v /= 2;
    }
    cout << solve(qi, l) << '\n';
  }
}


Measured memory_bytes: 7400
import itertools
h, w = map(int, input().split())
field = [list(input()) for _ in range(h)]

#%%
mine = [['#' for _ in range(w)] for __ in range(h)]

def counter(i, j):
    if (0 <= i <= h-1) and (0 <= j <=w-1):
        if field[i][j] == '#':
            return 1
        else:
            return 0
    else:
        return 0

for i in range(h):
    for j in range(w):
        cnt = 0
        if field[i][j] == '#':
            mine[i][j] = '#'
        else:
            for k, l in itertools.product([i-1, i, i+1], [j-1, j, j+1]):
                cnt += counter(k, l)
            mine[i][j] = cnt

#%%
for m in mine:
    print(''.join(map(str, m)))


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

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    
        String[] s = br.readLine().split(" ");
    
        out.println(s[2] +" "+ s[0] +" "+ s[1]);
        out.close();
        
    }
}

Measured memory_bytes: 38124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};


int main(){
    ll n, m; cin >> n >> m;
    vector<string> a(n), b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];
    rep(i, n-m+1){
        rep(j, n-m+1){
            bool ok = true;
            rep(hi, m){
                rep(wi, m){
                    if(a[i+hi][j+wi] != b[hi][wi]){
                        ok = false;
                        break;
                    }
                }
                if(!ok) break;
            }
            if(ok){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
N = int(input())
T = list(map(int, input().split(' ')))
A = list(map(int, input().split(' ')))


prev = -1
candidates_t = [-1 for _ in range(N)]
for i in range(N):
    if T[i] != prev:
        candidates_t[i] = T[i]

    prev = T[i]


prev = -1
candidates_a = [-1 for _ in range(N)]
for i in range(N-1, -1, -1):
    if A[i] != prev:
        candidates_a[i] = A[i]

    prev = A[i]

ret = 1
for i in range(N):
    if candidates_t[i] == -1 and candidates_a[i] == -1:
        ret *= min(T[i], A[i])
        ret %= 10**9 + 7

    elif candidates_t[i] == -1:
        if T[i] < candidates_a[i]:
            ret *= 0

    elif candidates_a[i] == -1:
        if A[i] < candidates_t[i]:
            ret *= 0

    elif candidates_t[i] != candidates_a[i]:
        ret *= 0


print(ret)




Measured memory_bytes: 90844