akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAX_STRING_SIZE = 100;

ll base = 4049;

vector<ll> MODS({2147483647, 6700417});

vector<vector<ll>> invs(MODS.size()), pows(MODS.size());

ll powm(ll e, ll x, ll m) {
  ll r = 1;
  while (x) {
    if (x % 2) {
      r = (r * e) % m;
    }
    e = (e * e) % m;
    x >>= 1;
  }
  return r;
}

void RHinit() {
  int i = 0;
  for (auto &p : MODS) {
    invs[i].resize(MAX_STRING_SIZE + 1);
    invs[i][0] = 1;
    ll inv = powm(base, p - 2, p);
    for (int j = 1; j <= MAX_STRING_SIZE; j++) {
      invs[i][j] = (invs[i][j - 1] * inv) % p;
    }
    pows[i].resize(MAX_STRING_SIZE + 1);
    pows[i][0] = 1;
    for (int j = 1; j <= MAX_STRING_SIZE; j++) {
      pows[i][j] = (pows[i][j - 1] * base) % p;
    }
    i++;
  }
}

vector<ll> h(vector<int> &s) {
  vector<ll> ret(MODS.size());
  int n = s.size();
  for (int i = 0; i < MODS.size(); i++) {
    ll r = 0;
    for (int j = 0; j < n; j++) {
      r = (r + pows[i][j] * s[j]) % MODS[i];
    }
    ret[i] = r;
  }
  return ret;
}

struct RH {
  int n;
  vector<int> s;
  vector<vector<ll>> hs;

  RH(vector<int> &s) : s(s) {
    if (pows[0].empty()) {
      RHinit();
    }
    n = s.size();
    hs.resize(MODS.size());
    for (int i = 0; i < MODS.size(); i++) {
      hs[i].resize(n + 1);
      hs[i][0] = 0;
      for (int j = 0; j < n; j++) {
        hs[i][j + 1] = (hs[i][j] + pows[i][j] * s[j]) % MODS[i];
      }
    }
  }

  vector<ll> substr(int l, int r) {
    vector<ll> ret(MODS.size());
    for (int i = 0; i < MODS.size(); i++) {
      ret[i] = (hs[i][r] - hs[i][l] + MODS[i]) % MODS[i];
      ret[i] *= invs[i][l];
      ret[i] %= MODS[i];
    }
    return ret;
  }
};
ll hh(vector<ll> &ha) { return ha[0] * (1LL << 32) + ha[1]; }

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s1, s2;
  cin >> s1 >> s2;
  RHinit();
  int ans = 0;
  int n = s1.size(), m = s2.size();
  for (int k = 1; k <= min(n, m); k++) {
    unordered_set<ll> sz;
    vector<int> v(26);
    for (int i = 0; i < k; i++) {
      v[s1[i] - 'a']++;
    }
    auto hs = h(v);
    sz.insert(hh(hs));
    for (int i = k; i < n; i++) {
      hs[0] += MODS[0] - pows[0][s1[i - k] - 'a'];
      hs[0] %= MODS[0];
      hs[1] += MODS[1] - pows[1][s1[i - k] - 'a'];
      hs[1] %= MODS[1];
      hs[0] += pows[0][s1[i] - 'a'];
      hs[0] %= MODS[0];
      hs[1] += pows[1][s1[i] - 'a'];
      hs[1] %= MODS[1];
      sz.insert(hh(hs));
    }
    v.clear();
    v.resize(26);
    for (int i = 0; i < k; i++) {
      v[s2[i] - 'a']++;
    }
    hs = h(v);
    auto it = sz.find(hh(hs));
    if (it != sz.end()) {
      ans = max(ans, k);
    }
    for (int i = k; i < m; i++) {
      hs[0] += MODS[0] - pows[0][s2[i - k] - 'a'];
      hs[0] %= MODS[0];
      hs[1] += MODS[1] - pows[1][s2[i - k] - 'a'];
      hs[1] %= MODS[1];
      hs[0] += pows[0][s2[i] - 'a'];
      hs[0] %= MODS[0];
      hs[1] += pows[1][s2[i] - 'a'];
      hs[1] %= MODS[1];
      it = sz.find(hh(hs));
      if (it != sz.end()) {
        ans = max(ans, k);
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3352
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define LL_MAX LLONG_MAX
#define ULL_MAX ULLONG_MAX
#define ull unsigned long long
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pb(x) push_back(x)
#define re() pop_back()
#define eb(x) emplace_back(x)
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
#define all(a) a.begin(),a.end()
#define msort(a) sort(a.begin(),a.end())
#define pii pair<int,int>
#define sz(x) int(x.size())
#define mk make_pair
#define endl '\n'

void solve()
{
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
    }
    
    int s=1,e=1e9;
    int ans=-1;
    while(s<=e)
    {
        int mid=(s+e)/2;
        int count=0;
        for (int i = 0; i < n; i++)
        {
            double val=double(a[i])/mid;
            count+=ceil(val)-1;
        }
        if(count<=k){
            ans=mid;
            e=mid-1;
        }
        else{
            s=mid+1;
        }
    }

    cout<<ans<<endl;
}

int main()
{
    IOS;
    ll t=1; //cin>>t;
    while (t--)
    {
        solve();
    }
}

Measured memory_bytes: 3984
import scala.io.StdIn.{readInt, readLine};
import scala.collection.mutable.PriorityQueue;

object Main {
    def main(args: Array[String]): Unit = {
        val n = readInt;
        val ig = new IntGraph(n);
        for (i <- (0 until n)) {
            val line = readLine.split(" ").map(_.toInt);
            val src = line(0);
            val dstNum = line(1);
            for (j <- (0 until dstNum)) {
                val dst = 2 + (2 * j);
                val cost = 2 + (2 * j) + 1;
                ig.add(src, line(dst), line(cost));
            }
        }
        ig.shortestPath(0).zipWithIndex.foreach { e => println("%d %d".format(e._2, e._1))};
    }
}

class IntGraph(size: Int) {
    val m: Array[List[(Int, Int)]] = new Array[List[(Int, Int)]](size).map(e => Nil);
    def add(src: Int, dst: Int, cost: Int): Unit = m(src) = (dst, cost) :: m(src);
    def shortestPath(start: Int): Array[Int] = {
        val stat = new Array[Int](size); // 0: 未追加, 1: 追加済み
        val dist = new Array[Int](size).map( e => Int.MaxValue);
        val pq = new PriorityQueue[(Int, Int)]()(Ordering.by((e: (Int, Int)) => e._2).reverse);
        
        dist(start) = 0;
        pq.enqueue((start, dist(start)));
        while (pq.isEmpty == false) {
            val (src, srcCost) = pq.dequeue;
            if (stat(src) != 1) {
                stat(src) = 1;
                for ((dstIdx, dstCost) <- m(src)) {
                    val newCost = dstCost + srcCost;
                    if (stat(dstIdx) != 1 && newCost < dist(dstIdx)) {
                        dist(dstIdx) = newCost;
                        pq.enqueue((dstIdx, newCost));
                    }
                }
            }
        }
        dist;
    }
}


Measured memory_bytes: 185592
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;++i)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;
const int lim = 51;
char mp[lim][lim];
int main(){
    fol(i,lim)fol(j,lim)mp[i][j]='.';
    int h,w;cin>>h>>w;
    fol(i,h)fol(j,w)cin>>mp[i][j];
    bool ans = true,buf;
    int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
    int x,y;
    fol(i,h)fol(j,w){
        if(mp[i][j]=='#'){
            buf = false;
            fol(k,4){
                x = j + dx[k];
                y = i + dy[k];
                if(x>=0&&y>=0&&x<w&&y<h){
                    if(mp[y][x]=='#') buf = true;
                }
            }
            if(!buf)ans=false;
        }

    }
    cout << (ans?"Yes":"No")<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

import static java.lang.System.in;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(in);
        int n = scanner.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }
        long[][] dp = new long[n][n];
        int parity = n%2;
        long s = sum(arr,0,n-1,dp,parity,parity);

        System.out.println(s);
    }
    private static long sum(int[] arr, int i, int j, long[][] dp, int parity, int currParity){
        if(i>j) return 0;
        if(i==j){
            if(parity!=currParity)
                return -arr[i];
            else
                return arr[i];
        }
        if(dp[i][j]!=0) return  dp[i][j];
        if(currParity==parity)
            return dp[i][j] = Math.max(sum(arr,i+1,j,dp,parity,~currParity )+arr[i],sum(arr,i,j-1,dp,parity,~currParity )+arr[j]);
        return dp[i][j] = Math.min(sum(arr,i+1,j,dp,parity,~currParity )-arr[i],sum(arr,i,j-1,dp,parity,~currParity )-arr[j]);

    }
}


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

int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	for(int i=0;i<200;i++)
	{
		c-=b;
		if(c<=0&&a>0)
		{
			cout<<"Yes";
			return 0;
		}
		a-=d;
		if(a<=0&&c>0)
		{
			cout<<"No";
			return 0;
		}
    }
}

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

/*
提出前に確認!
- setとmultisetを間違えない
*/

int INF = 2e9;

bool grid[1001][1001];
bool is_visited[1001][1001];
int dist[1001][1001];

int	main(void)
{
	int h, w;
	cin >> h >> w;
	int start_h, start_w;
	cin >> start_h >> start_w;
	start_h--; start_w--;
	int end_h, end_w;
	cin >> end_h >> end_w;
	end_h--; end_w--;
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			char c;
			cin >> c;
			grid[i][j] = (c == '.');
			dist[i][j] = INF;
		}
	}
	int depth = 0;
	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
	q.push({0, start_h * 10000 + start_w});
	while (q.size())
	{
		int a, b;
		tie(a, b) = q.top(); q.pop();
		int now_h, now_w;
		now_h = b / 10000;
		now_w = b % 10000;
		if (is_visited[now_h][now_w] == true) continue;
		if (now_h == end_h && now_w == end_w)
		{
			cout << a << endl;
			return (0);
		}
		is_visited[now_h][now_w] = true;
		dist[now_h][now_w] = a;
		vector<int> ddh = {1, -1, 0, 0};
		vector<int> ddw = {0, 0, 1, -1};
		for (int i = 0; i < 4; i++)
		{
			if (now_h + ddh[i] < 0 || now_h + ddh[i] >= h) continue;
			if (now_w + ddw[i] < 0 || now_w + ddw[i] >= w) continue;
			if (grid[now_h + ddh[i]][now_w + ddw[i]] == false) continue;
			if (dist[now_h + ddh[i]][now_w + ddw[i]] <= a) continue;
			q.push({a, (now_h + ddh[i]) * 10000 + (now_w + ddw[i])});
		}
		for (int dh = -2; dh <= 2; dh++)
		{
			for (int dw = -2; dw <= 2; dw++)
			{
				if (now_h + dh < 0 || now_h + dh >= h) continue;
				if (now_w + dw < 0 || now_w + dw >= w) continue;
				if (grid[now_h + dh][now_w + dw] == false) continue;
				if (dist[now_h + dh][now_w + dw] <= a) continue;
				q.push({a + 1, (now_h + dh) * 10000 + (now_w + dw)});
			}
		}
	}
	cout << -1 << endl;
	return (0);
}


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

int main()
{
	string w;
	string t;
	int count=0;
	int i=0;
	
	cin >> w;
	while(w[i]!='\0'){
		if(islower(w[i]))
			w[i]=toupper(w[i]);
		i++;
	}
	
	while(1){
		cin >> t;
		if(t=="END_OF_TEXT")
			break;
		
		i=0;
		while(t[i]!='\0'){
			if(islower(t[i]))
				t[i]=toupper(t[i]);
			i++;
		}
		
		if(t==w)
			count++;
	}
	
	cout << count << endl;
	
	return 0;
}

Measured memory_bytes: 1192
#include <stdio.h>

int main()
{
    int A1, A2, A3;
    scanf("%d %d %d", &A1, &A2, &A3);

    if(A1 + A2 +A3 >= 22){
            printf("bust\n");
    }
    else{
        printf("win\n");
    }

    return 0;
}

Measured memory_bytes: 1644
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define all(v) (v).begin(),(v).end()
#define trav(x,v) for(auto &x : v)
#define sz(v) int(v.size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;

const ll md = 1e9+7;

vector<ll> calc(int n, int k){
	vector<ll> todo(n);
	todo[0] = -1;
	if(n > 1) todo[1] = 1;
	rep(i,0,n){
		if(i+1 < n) todo[i+1] = (todo[i+1] + 2*todo[i]) % md;
		if(i + k+1 < n) todo[i+k+1] = (todo[i+k+1] - todo[i]) % md;
		todo[i] *= -1;
	}
	return todo;
}

vector<ll> calc1(int n){
	vector<ll> todo(n);
	todo[0] = -1;
	if(n > 1) todo[1] = 1;
	vector<ll> ans(n);
	rep(i,0,n){
		if(i+1 < n) todo[i+1] = (todo[i+1] + todo[i]) % md;
		if(i+2 < n) todo[i+2] = (todo[i+2] + todo[i]) % md;
		todo[i] *= -1;
	}
	return todo;
}

ll solve(){
	int n, m;
	string s;
	cin >> n >> m >> s;
	if(s[0]=='B') trav(c, s) c = 'B'+'R'-c;
	if(count(all(s), 'R') == m){
		ll ans = 1;
		auto dp = calc1(n-1);
		for(int l = 1; l < n; ++l)
			ans += (l+1) * dp[n-l-1] % md;
		return ans;
	} else {
		if(n%2) return 0;
		int mx = n-1;
		rep(i,0,m) if(s[i]=='B' && s[i-1]=='R'){
			int j = i;
			while(j && s[j-1] =='R') --j;
			if(j == 0) mx = min(mx, i + (i%2==0));
			else if((i-j)%2) mx = min(mx, i-j);
		}
		auto dp = calc(n/2, (mx+1)/2);
		ll ans = 0;
		for(int l = 1; l <= mx; l += 2)
			ans += (l+1) * dp[(n-l-1)/2] % md;
		return ans;
	}
}

int main(){
	cin.sync_with_stdio(0);
	cin.tie(0);

	ll res = solve();
	res %= md;
	if(res < 0) res += md;
	cout << res << endl;
}

Measured memory_bytes: 3732
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    vvi ma(3, vi(3));
    int num = 3*c;
    ma[0][0] = a;
    ma[0][1] = b;
    ma[1][1] = c;
    ma[0][2] = num-a-b;
    ma[2][2] = num-a-c;
    ma[2][1] = num-b-c;
    ma[1][2] = num-ma[0][2] - ma[2][2];
    ma[1][0] = num-c-ma[1][2];
    ma[2][0] = num-a-ma[1][0];
    rep(i, 3) {
        rep(j, 3) {
            cout << ma[i][j] << (j == 2?'\n':' ');
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string::size_type npos=string::npos;
int main()
{
  string s;
  cin>>s;
  bool can=true;
  if(s.find('W')!=npos){
    if(s.find('E')==npos) can=false;
  }
  if(s.find('E')!=npos){
    if(s.find('W')==npos) can=false;
  }
  if(s.find('N')!=npos){
    if(s.find('S')==npos) can=false;
  }
  if(s.find('S')!=npos){
    if(s.find('N')==npos) can=false;
  }
  cout<<(can?"Yes":"No");
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int taiseki = sc.nextInt();
        double taiseki2 = (double)taiseki;
        double ans = taiseki2/3;
        double ans2 = ans * ans * ans;
        System.out.println(ans2);
    }
}


Measured memory_bytes: 21332
N,*as=$<.read.split.map(&:to_i)
as << 0

i = 0
ret = 0
while i < N
    ret += as[i]/2
    if as[i].odd? && 0 < as[i+1]
        ret += 1
        as[i+1] -= 1
    end
    i += 1
end

puts ret

Measured memory_bytes: 21528
import sys

input = sys.stdin.readline

# input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


def main():
    N = int(input())
    v = list(map(int, input().split()))
    v = sorted(v)
    # print(v)

    s = (v[0] + v[1]) / 2
    for i in range(2, N):
        s += v[i]
        s /= 2

    print(s)




if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
  ll N;
  scanf("%lld",&N);
  vector<ll> A(N+1);
  for(int i=0; i<N+1; i++){
    scanf("%lld",&A[i]);
  }
  vector<ll> B(N);
  for(int i=0; i<N; i++){
    scanf("%lld",&B[i]);
  }

  ll ans = 0;
  for (int i=0; i<N; i++) {
    ans += min(B[i],A[i]);
    ll t = max(0LL, B[i]-A[i]);
    ans += min(A[i+1], t);
    A[i+1] = max(0LL, A[i+1]-t);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse = True)
q.sort(reverse = True)
r.sort(reverse = True)

ans = []
ans.extend(p[:x])
ans.extend(q[:y])
from heapq import *
heapify(ans)

r = [-i for i in r]
heapify(r)


while True:
    a = heappop(ans)
    b = -heappop(r)
    if a < b:
        heappush(ans, b)
        heappush(r, -a)
    else:
        heappush(ans, a)
        break

print(sum(ans))


Measured memory_bytes: 118736
// ------------------------------------
// Date:2018/ 3/13
// Problem:ABC 068 ABCxxx a.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

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

typedef long long ll;

static const int MOD = 1000000007;

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

  int N;
  cin >> N;
  cout << "ABC" << N << endl;
  return 0;
}



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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k, ans =0;
    cin >> n >> k;
    while(n){
        ans++;
        n/=k;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=20+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("F.in","r",stdin);
	freopen("F.out","w",stdout);
#endif
}
int n,m,k;
int limit[N][N];
void input()
{
	int x,y,z;
	n=read<int>()-1,m=read<int>(),k=read<int>();
	memset(limit,-1,sizeof limit);
	For(i,1,k)
	{
		x=read<int>(),y=read<int>(),z=read<int>();
		limit[x][y]=z;
	}
}
const int mo=1e9+7;
int dp[2][20][1<<19];
void add(int &x,int y)
{
	x+=y;x-=(x>=mo?mo:0);
}
void work()
{
	int now=1,pre=0;
	dp[0][n][0]=1;
	int Max=(1<<n)-1;
	For(i,1,m)
	{
		memset(dp[now],0,sizeof dp[now]);
		For(s,0,Max)dp[now][0][s]=dp[pre][n][s];
		For(j,1,n)For(s,0,Max)if(dp[now][j-1][s])
		{
			int o=(s>>(j-1))&1;
			if(limit[i][j]==0&&o==1)continue;
			if(limit[i][j]==-1||(limit[i][j]==o))add(dp[now][j][s],dp[now][j-1][s]);
			if(o==0&&limit[i][j]!=0)
			{
				int nex=s|(1<<(j-1));
				For(l,j+1,n)if(((nex>>(l-1)))&1){nex^=(1<<(l-1));break;}
				add(dp[now][j][nex],dp[now][j-1][s]);
			}
		}
		swap(now,pre);
	}
	int ans=0;
	For(i,0,Max)add(ans,dp[pre][n][i]);//,cerr<<i<<' '<<dp[pre][n][i]<<endl;
	write(ans,'\n');
}
int main()
{
	//file();
	input();
	work();
	//cerr<<1.0*clock()/CLOCKS_PER_SEC<<endl;
	return 0;
}

Measured memory_bytes: 82176
N = int(input())
A = list(map(int, input().split()))
#A = [int(x) for x in input().split()]
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
A = [-float('inf')] + A + [float('inf')]
B.sort()
C.sort()
C = [-float('inf')] + C + [float('inf')]

total = 0

for i in range(N):
    low = 0
    high = N + 1
    while low + 1 < high:
        mid1 = (low + high) // 2
        if A[mid1] < B[i]:
            low = mid1
        else:
            high = mid1
    mid1 = low
    low = 0
    high = N + 1
    while low + 1 < high:
        mid2 = (low + high) // 2
        if C[mid2] <= B[i]:
            low = mid2
        else:
            high = mid2
    mid2 = high
    total = total + mid1 * (N + 1 - mid2)

print(total)

Measured memory_bytes: 23200
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <functional>

template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct frep {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr frep(int l_, int r_): l(std::min(l_, r_)), r(r_) {}
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct brep {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr brep(int r_, int l_): r(std::max(l_, r_) - 1), l(l_ - 1) {}
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

template <class T>
inline T scan() {
  T res;
  std::cin >> res;
  return res;
}

int main() {
  const int N = scan<int>();
  std::vector<std::vector<int>> graph(N), lca(N, std::vector<int>(N));
  std::vector<int> parent(N), depth(N);
  for (int i: frep(0, N - 1)) {
    int a = scan<int>() - 1;
    int b = scan<int>() - 1;
    graph[a].emplace_back(b);
    graph[b].emplace_back(a);
  }
  std::function<void(int, int)> dfs = [&](int v, int p) {
    parent[v] = p;
    if (p != -1) {
      depth[v] = depth[p] + 1;
    }
    for (int x: graph[v]) {
      if (x != p) {
        dfs(x, v);
      }
    }
  };
  dfs(0, -1);
  for (int i: frep(0, N)) {
    for (int j: frep(0, N)) {
      int x = i, y = j;
      while (depth[x] > depth[y]) {
        x = parent[x];
      }
      while (depth[y] > depth[x]) {
        y = parent[y];
      }
      while (x != y) {
        x = parent[x];
        y = parent[y];
      }
      lca[i][j] = x;
    }
  }
  const int M = scan<int>();
  std::vector<int> A(M), B(M), sum(N);
  for (int i: frep(0, M)) {
    A[i] = scan<int>() - 1;
    B[i] = scan<int>() - 1;
  }
  std::function<void(int, int)> propagate = [&](int v, int p) {
    for (int x: graph[v]) {
      if (x != p) {
        propagate(x, v);
        sum[v] += sum[x];
      }
    }
  };
  long long ans = (1ll << (N - 1));
  for (int S: frep(1, 1 << M)) {
    std::fill(sum.begin(), sum.end(), 0);
    for (int i: frep(0, M)) {
      if ((1 << i) & S) {
        ++sum[A[i]];
        ++sum[B[i]];
        sum[lca[A[i]][B[i]]] -= 2;
      }
    }
    propagate(0, -1);
    int count = 0;
    for (int i: frep(0, N)) {
      if (sum[i] > 0) {
        ++count;
      }
    }
    if (__builtin_popcount(S) & 1) {
      ans -= (1ll << (N - 1 - count));
    } else {
      ans += (1ll << (N - 1 - count));
    }
  }
  std::cout << ans << '\n';
  return 0;
}


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

using namespace std;

int main() {
  int n, a, b, c, x;
  while(cin>>n>>a>>b>>c>>x && (n||a||b||c||x)) {
    vector<int> y;
    int flames = -1;
    for(int i=0; i<n; i++) {
      int tmp;
      cin>>tmp;
      y.push_back(tmp);
    }
    for(int i=0; i<n && flames<10001; i++) {
      bool flag = false;
      while(flag == false && flames<10001) {
	if(x == y[i]) {
	  flag = true;
	}
        x = (a*x+b)%c;
	flames++;
      }
    }
    //cout<<n<<endl;
    if(flames > 10000) {
    cout<<"-1"<<endl;
    }
    else {
      cout<<flames<<endl;
    }
  }
}

Measured memory_bytes: 1220
#include <stdio.h>

int main(void){
        int A,B,C;
        scanf("%d %d %d",&A,&B,&C);
        if (A == B && A != C){
                printf("Yes\n");
        }
        else if ( A == C && A != B){
                printf("Yes\n");
        }
        else if ( B == C && C != A){
                printf("Yes\n");
        }
        else{
                printf("No\n");
        }

        return 0;
}

Measured memory_bytes: 1644
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n;
	while(cin>>n){
		if(n==0)break;
		int dt[n];
		rep(i,n){
			cin>>dt[i];
		}
		int cnt=0;
		while(1){
			if(n==1)break;
			rep(i,n-1){
				if(dt[i]>dt[i+1]){
					int alt=dt[i];
					dt[i]=dt[i+1];
					dt[i+1]=alt;
					cnt++;
				}
			}
			n--;
		}
		cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
array = list(map(int, input().split()))
miniDis = [0]*(array[0] -1)
for i in range(1,array[0]):
  for j in range(i+1,array[0]+1):
    miniDis[min(j-i,abs(array[1]-i)+1+abs(array[2]-j))-1] += 1
    
                   
                   
                   
                   
for i in range(array[0] -1):
  print(miniDis[i])


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


int main(){
	    int N, M; cin >> N >> M;
        vector<bool> ac(N, false);
        vector<int> wa(N, 0);
        vector<int> P(M);
        vector<string> S(M);

        rep(i, M){
            int p; string s;
            cin >> p >> s;
            p--;
            P[i] = p;
            S[i] = s;
        }

        int ans = 0, plt = 0;
        rep(i, M){
            if(ac[P[i]]) continue;
            else{
                if(S[i] == "AC"){
                    ans++;
                    ac[P[i]] = true;
                    plt += wa[P[i]];
                }
                else
                {
                    wa[P[i]]++;
                }
                
            }
        }

        cout << ans << " " << plt << endl;
}


Measured memory_bytes: 8064
#include <iostream>
#include <cstdlib>

using namespace std;

int main() {
    int n;
    int a[100000];

    cin >> n;

    int c = 0;
    int p = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        c += abs(p - a[i]);
        p = a[i];
    }
    c += abs(p);

    for (int i = 0; i < n; i++) {
        int m = c;
        if (i == 0) {
            m -= abs(a[0]);
            m -= abs(a[0] - a[1]);
            m += abs(a[1]);
        } else if (i == n - 1) {
            m -= abs(a[n-1]);
            m -= abs(a[n-1] - a[n-2]);
            m += abs(a[n-2]);
        } else {
            m -= abs(a[i-1] - a[i]);
            m -= abs(a[i] - a[i+1]);
            m += abs(a[i-1] - a[i+1]);
        }
        cout << m << endl;
    }

    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 1000000000000000;
#define MOD 1000000007LL;
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

int N, K; cin>> N >> K;
VI D(K); rep(i, 0, K) cin >> D[i];

rep(i, N, 10*N+1){
    string is = to_string(i);
    if(none_of(ALL(is), [D](char c){return binary_search(ALL(D), c - '0');})){
        cout << i << endl;
        return 0;
    }
}



}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



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

using namespace std;

int a,b,c,k;
int main() {
 cin >> a >> b >> c;
 cin >> k;
 if (a >= b and a >= c) a = a * pow(2, k);
else if ( b >= a and b >= c) b = b * pow(2,k);
else c = c * pow (2,k);
cout << a + b + c;

}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#define mod 1000000007
#define MN 201000

struct xxx {
	int x, v;
} d[MN], e[MN];

bool cmp(xxx a, xxx b) {return a.x == b.x ? a.v > b.v : a.x < b.x;}

int Max[MN], Min[MN], f[MN], s[MN];

int main()
{
	int n; scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d%d", &d[i].x, &d[i].v); 
	std::sort(d + 1, d + n + 1, cmp);
	
	Max[1] = d[1].v;
	for(int i = 2; i <= n; i++) Max[i] = std::max(Max[i - 1], d[i].v);
	
	Min[n] = d[n].v;
	for(int i = n - 1; i >= 1; i--) Min[i] = std::min(Min[i + 1], d[i].v);
	
	for(int i = 1; i <= n; i++)
	{
		int l = std::lower_bound(Max + 1, Max + n + 1, d[i].v) - Max;
		int r = std::upper_bound(Min + 1, Min + n + 1, d[i].v) - Min - 1;
		d[i].x = l, d[i].v = r;
	}
	
	std::sort(d + 1, d + n + 1, cmp);
	int m = 0;
	for(int i = 1; i <= n; i++)
	{
		while(m > 0 && e[m].v >= d[i].v) m--;
		e[++m] = d[i];
	}
	
	int j = 0;
	f[0] = s[0] = 1;
	for(int i = 1; i <= n; i++)
	{
		if(j <= m && i > e[j].v) j++; 
		f[i] = (s[i - 1] - (e[j - 1].x == 0 ? 0 : s[e[j - 1].x - 1]) + mod) % mod;
		s[i] = (s[i - 1] + f[i]) % mod;
	}
	printf("%d\n", (s[n] - s[e[m].x - 1] + mod) % mod);
	return 0;
}

Measured memory_bytes: 6528
def atc_060a(input_value: str) -> str:
    A, B, C = map(str, input_value.split(" "))
    if A[-1] == B[0] and B[-1] == C[0]:
        return "YES"
    else:
        return "NO"

input_value = input()
print(atc_060a(input_value))


Measured memory_bytes: 8896
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,n) for(int i = (a); i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define debug_v(v,N) for(int i=0;i<N;i++) { cout << v[i] << " "; } cout << endl;
#define debug_vv(v,H,W) for(int i=0;i<H;i++) { for(int j=0;j<W;j++) { cout << v[i][j] << " "; } cout << endl; }

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
    // 配るDP
    int INF = 2000000000;
    int N; cin >> N;
    vi H(N);
    rep(i, N) cin >> H[i];
    vi dp(N + 5, INF);
    dp[0] = 0;
    rep(i, N) {
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(H[i + 2] - H[i]));
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(H[i + 1] - H[i]));
    }
    cout << dp[N - 1] << endl;
}

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


Measured memory_bytes: 1024
#include<iostream>
#include<queue>

using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define pb         push_back

enum RES{DRAW=-1,WIN,LOSE};

class state{
public:
  bool who;//0 queen 1 army
  short q,a;
};


enum RES win[2][900][900];
char need[2][900][900];
vector<state> edge[2][900][900];

int dx[]={0,0,1,-1,0};
int dy[]={1,-1,0,0,0};
char m[30][30];

bool out(int y,int x,int r,int c){
  return y<0||x<0||y>=r||x>=c;
}

int md(int y,int x,int yy,int xx){
  return max(y,yy)-min(y,yy)+max(x,xx)-min(x,xx);
}

void solve(int q,int a,int r,int c){
  rep(i,2){
    rep(j,r*c){
      rep(k,r*c){
	win[i][j][k]=DRAW;
	edge[i][j][k].clear();
	need[i][j][k]=0;
      }
    }
  }
  
  rep(qi,r){
    rep(qj,c){
      if (m[qi][qj] == '#')continue;
      rep(ai,r){
	rep(aj,c){
	  if (m[ai][aj] == '#')continue;
	  rep(k,5){
	    int nex=qj+dx[k],ney=qi+dy[k];
	    if (out(ney,nex,r,c)||m[ney][nex] == '#')continue;

	    need[0][qi*c+qj][ai*c+aj]++;
	    edge[1][ney*c+nex][ai*c+aj].pb((state){0,qi*c+qj,ai*c+aj});
	  }
	  rep(k,5){
	    int nex=aj+dx[k],ney=ai+dy[k];
	    if (out(ney,nex,r,c)||m[ney][nex] == '#')continue;
	    need[1][qi*c+qj][ai*c+aj]++;
	    edge[0][qi*c+qj][ney*c+nex].pb((state){1,qi*c+qj,ai*c+aj});
	  }
	}
      }
    }
  }

  queue<state> Q;
  //win q
  rep(i,r){
    rep(j,c){
      if (m[i][j] == '#')continue;
      rep(ii,r){
	rep(jj,c){
	  if (m[ii][jj] == '#'||(ii==i&&jj==j))continue;
	  if (m[i][j] == 'E'){
	    win[0][i*c+j][ii*c+jj]=WIN;
	    Q.push((state){0,i*c+j,ii*c+jj});
	  }
	}
      }
    }
  }
  

  //win a
  rep(i,r){
    rep(j,c){
      if (m[i][j] == '#')continue;
      rep(k,4){
	int nex=j+dx[k],ney=i+dy[k];
	if (out(ney,nex,r,c)||m[ney][nex]=='#'){
	  continue;
	}
	if (win[1][i*c+j][ney*c+nex] == DRAW){
	  win[1][i*c+j][ney*c+nex]=WIN;
	  Q.push((state){1,i*c+j,ney*c+nex});
	}
      }
    }
  }
  

  
  rep(i,r){
    rep(j,c){
      if (m[i][j] == '#')continue;
      if (win[1][i*c+j][i*c+j] == DRAW){
	win[1][i*c+j][i*c+j]=WIN;
	Q.push((state){1,i*c+j,i*c+j});
      }
    }
  }
  

  while(!Q.empty()){
    state now = Q.front();Q.pop();
    
    rep(i,edge[now.who][now.q][now.a].size()){
      state next=edge[now.who][now.q][now.a][i];
      need[next.who][next.q][next.a]--;

      if (win[next.who][next.q][next.a] != DRAW)continue;
      if (win[now.who][now.q][now.a] == LOSE){
	win[next.who][next.q][next.a]=WIN;
	Q.push(next);
      }else if (need[next.who][next.q][next.a] == 0 && 
		win[next.who][next.q][next.a]  == DRAW){
	win[next.who][next.q][next.a]=LOSE;
	Q.push(next);
      }
    }
  }

  if (win[0][q][a] == LOSE)cout << "Army can catch Queen." << endl;
  else if (win[0][q][a] == WIN)cout << "Queen can escape." << endl;
  else cout << "Queen can not escape and Army can not catch Queen."<<endl;
  return;
}


main(){
  int r,c;
  while(cin>>c>>r && c){
    rep(i,r){
      rep(j,c)cin>>m[i][j];
    }
    int q,a;
    rep(i,r){
      rep(j,c){
	if (m[i][j] == 'Q')q=i*c+j;
	if (m[i][j] == 'A')a=i*c+j;
      }
    }
    solve(q,a,r,c);
  }
}

Measured memory_bytes: 31000
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

long solve (long [] a)
{
	long a0 = min (a[0], 2);
	a[0] -= a0;

	long a3 = min (a[3], 2);
	a[3] -= a3;

	long a4 = min (a[4], 2);
	a[4] -= a4;

	long res = 0;

	res += a[1];
	a[1] = 0;

	res += (a[0] / 2) * 2;
	a[0] %= 2;

	res += (a[3] / 2) * 2;
	a[3] %= 2;

	res += (a[4] / 2) * 2;
	a[4] %= 2;

	long add = 0;

	add = max (add, ((a0 + a[0]) / 2) * 2 +
	    ((a3 + a[3]) / 2) * 2 + ((a4 + a[4]) / 2) * 2);

	if (a0 > 0 && a3 > 0 && a4 > 0)
	{
		add = max (add, 3 + ((a0 + a[0] - 1) / 2) * 2 +
	    ((a3 + a[3] - 1) / 2) * 2 + ((a4 + a[4] - 1) / 2) * 2);
	}

	if (a0 > 1 && a3 > 1 && a4 > 1)
	{
		add = max (add, 6 + ((a0 + a[0] - 2) / 2) * 2 +
	    ((a3 + a[3] - 2) / 2) * 2 + ((a4 + a[4] - 2) / 2) * 2);
	}

	return res + add;
}

void main ()
{
	long [] a;
	while ((a = readln.split.map !(to !(long)).array).length > 0)
	{
		writeln (solve (a));
	}
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int n,m,l;
  scanf("%d %d %d\n",&n,&m,&l);
  int A[n][m];
  int b[m][l];
  long int c[n][l];

  for(int i=0; i<n; i++){
    for(int j=0; j<m; j++){
      scanf("%d ",&A[i][j]);
    }
  }
  for(int j=0; j<m; j++){
    for(int k=0; k<l; k++){
      scanf("%d ",&b[j][k]);
    }
  }

  for(int i=0; i<n; i++){
    for(int k=0; k<l; k++){
      c[i][k] = 0;
      for(int j=0; j<m; j++){
        c[i][k] += A[i][j] * b[j][k];
    }
  }
}

for(int i=0; i<n; i++){
  for(int k=0; k<l; k++){
      printf("%ld",c[i][k]);
      if(k<l-1){
        printf(" ");
      }
  }
  printf("\n");
}

return 0;
}


Measured memory_bytes: 2088
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
macro_rules! chmin {
    ($ base : expr , $ cmp : expr ) => {
        if $base > $cmp {
            $base = $cmp;
        }
    };
}
macro_rules! chmax {
    ($ base : expr , $ cmp : expr ) => {
        if $base < $cmp {
            $base = $cmp;
        }
    };
}
fn main() {
    input! {//
        h:i64,w:i64,
    }
    let mut ans = INF;
    ans = min(ans, calc(h, w));
    ans = min(ans, calc(w, h));
    println!("{}", ans);
}
fn calc(h: i64, w: i64) -> i64 {
    let mut mn = INF;
    for i in 1..h {
        let ss = i * w;
        let s2 = (h - i) * (w / 2);
        let s3 = (h - i) * (w - w / 2);
        let mut ve = vec![ss, s2, s3];
        ve.sort();
        mn = min(mn, ve[2] - ve[0]);

        let lh = h - i;
        let mut vv = vec![i * w, lh / 2 * w, (lh - lh / 2) * w];
        vv.sort();
        mn = min(mn, vv[2] - vv[0]);
    }
    mn
}

const INF: i64 = 1 << 60;


Measured memory_bytes: 2148
#include<bits/stdc++.h>
using namespace std;
const int N = 30000 + 5;
char s[N];
vector<int> v[10];
int main() {
  int n;
  scanf("%d%s", &n, s);
  for(int i = 0; s[i]; i++) {
    v[s[i] - '0'].push_back(i);
  }
  int cnt = 0;
  for(int i = 0; i <= 9; ++i) {
    if(!v[i].size()) continue;
    int st = v[i][0];
    for(int j = 0; j <= 9; ++j) {
      auto el = upper_bound(v[j].begin(), v[j].end(), st);
      if(el == v[j].end()) continue;
      int El = *el;
      for(int k = 0; k <= 9; ++k) {
        auto ed = upper_bound(v[k].begin(), v[k].end(), El);
        if(ed != v[k].end()) cnt++;
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	FORR(c,S) if(c=='7') return _P("Yes\n");
	_P("No\n");
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = tuple<int, int>;
using iarr = valarray<int>;

int main()
{
    int N;
    cin >> N;
    priority_queue<double, vector<double>, greater<double>> pq;
    for(int i = 0; i < N; ++i){
		double tmp;
        cin >> tmp;
		pq.push(tmp);
    }
    double ans = 0;
    while(pq.size() != 1){
        double tmp = pq.top();pq.pop();
        double tmp2 = pq.top();pq.pop();
        ans = (tmp + tmp2) / 2;
        pq.push(ans);
	}
    cout << pq.top() << endl;
	return 0;
}


Measured memory_bytes: 256
import itertools

N = int(input())

li = []

for n in range(1, 10):
    for num in itertools.product("357", repeat=n):
        if(num.count("3") and num.count("5") and num.count("7")):
            li.append(int("".join(num)))

print(len([i for i in li if i <= N]))


Measured memory_bytes: 4340
S = str(input())
N = len(S)
A = set(["A","C","T","G"])
Flag = True
ans = 0
ret = 0
for i in range(N):
  if S[i] in A:
    if Flag:
      ans += 1
    else:
      ans = 0
  else:
    ans = 0
  ret = max(ret,ans)
print(ret)    

Measured memory_bytes: 9092
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

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

  int n;
  cin >> n;

  vector<int> a(n,0);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }

  long long cumsum = 0;

  map<long long, long long> cumsumCounts;
  cumsumCounts[0] += 1;

  for (int i = 0; i < n; ++i) {
    cumsum += a[i];
    cumsumCounts[cumsum] += 1;
  }

  long long ans = 0;
  for(auto& cumsumItem : cumsumCounts) {
    long long counts = cumsumItem.second;
    ans += counts*(counts-1) / 2;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 13568
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int a,b;
  cin>>a>>b;
  int diff=abs(a-b);
  if(diff&1) cout<<"IMPOSSIBLE"<<endl;
  else cout<<max(a,b)-diff/2<<endl;
  return 0 ;
}


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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl

using namespace std;
using i64 = long long;

int main()
{
    int H, N;
    cin >> H >> N;
    vector<int> a(N);
    for (auto &&item : a)
    {
        cin >> item;
    }
    i64 sum = accumulate(a.begin(), a.end(), 0);

    if (sum >= H)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using p = pair<int, int>;

int main()
{
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    int N, a[212345], o[212345];

    cin >> N;
    REP(i, N)
    {
        cin >> a[i];
        o[a[i]] = i;
    }
    set<int> s;
    s.insert(-1);
    s.insert(N);

    ll ans = 0;
    for (int i = 1; i <= N; i++)
    {
        set<int>::iterator itr = s.lower_bound(o[i]);
        ll r = (*itr) - o[i];
        itr--;
        ll l = o[i] - (*itr);
        ans += i * l * r;
        s.insert(o[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11264
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        string S = cin.next();
        int ans = 0;
        foreach (var c in S)
        {
            ans += c - '0';
        }
        Console.WriteLine(ans);
    }




}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        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] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        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] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        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] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 13140
#include <stdio.h>
#include <math.h>
 
struct Point { double x, y; };
 
void koch(int n, Point a, Point b) {
    if (n == 0) return;
 
    Point s, t, u;
    double th = M_PI * 60.0 / 180.0;
    s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
    s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
    t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
    t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;
 
    koch(n - 1, a, s);
    printf("%.8f %.8f\n", s.x, s.y);
    koch(n - 1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    koch(n - 1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);
    koch(n - 1, t, b);
}
 
int main() {
    Point a, b;
    int n;
 
    scanf("%d", &n);
 
    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;
 
    printf("%.8f %.8f\n", a.x, a.y);
    koch(n, a, b);
    printf("%.8f %.8f\n", b.x, b.y);
 
    return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
int main(){
	int fg=0;
	int k,a,b;
	cin >> k >> a >> b;
	for(int i=a;i<=b;i++){
		if(i%k==0)
		fg=1;
	}
	if(fg) cout << "OK" << endl;
	else cout << "NG" << endl;
	return 0;
} 

Measured memory_bytes: 3624
N = int(input())

P = [[0, 0, 0]]

ans = 'Yes'

for i in range(N):
    l = list(map(int, input().split()))
    P.append(l)

for i in range(N):
    c = P[i+1][0] - P[i][0]
    d = abs(P[i+1][1] - P[i][1]) + abs(P[i+1][2] - P[i][2])

    if c % d != 0:
        ans = 'No'
        break

print(ans)



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

int main() {
  int N; cin >> N;
  int myMin = N;
  for (int i = 1; i < N / 2 + 1; i++) {
    int A = i; int B = N-i;
    int dsum = 0;
    while (A != 0) {
      dsum += A % 10;
      A /= 10;
    }
    while (B != 0) {
      dsum += B % 10;
      B /= 10;
    }
    if (dsum < myMin)
      myMin = dsum;
  }
  cout << myMin << endl;
}


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

int main(){
  int N, M; cin >> N >> M;
  rep(i, M) {
    int A; cin >> A;
    N -= A;
  }
  if (N < 0) N = -1;
  cout << N << endl;
}


Measured memory_bytes: 3636
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		boolean flag=false;
		for(int i=0;i<s.length();i++) {
			if(s.charAt(i)=='7')flag=true;
		}
		if(flag)System.out.println("Yes");
		else System.out.println("No");
	}
}

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

int main(void){
	char roma[101];
	int ara;
	int len;
	int temp;
	int cb, c;
	int i;

	while(scanf("%s", roma) != EOF){
		ara = 0;
		len = strlen(roma);

		if(roma[0] == 'I') cb = 1;
		if(roma[0] == 'V') cb = 5;
		if(roma[0] == 'X') cb = 10;
		if(roma[0] == 'L') cb = 50;
		if(roma[0] == 'C') cb = 100;
		if(roma[0] == 'D') cb = 500;
		if(roma[0] == 'M') cb = 1000;

		temp = cb;		
		for(i=1; i < len; i++){
			if(roma[i] == 'I') c = 1;
			if(roma[i] == 'V') c = 5;
			if(roma[i] == 'X') c = 10;
			if(roma[i] == 'L') c = 50;
			if(roma[i] == 'C') c = 100;
			if(roma[i] == 'D') c = 500;
			if(roma[i] == 'M') c = 1000;

			if(cb < c){
				ara -= cb;
			}else{
				ara += cb;
			}
			cb = c;
		}
		ara += cb;

		printf("%d\n", ara);
	}

	return 0;
}

Measured memory_bytes: 0