akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(2e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

struct UnionFindTree {
    vector<int> par;
    vector<int> rank;
    vector<int> siz;

    void init(int n) {
        par.resize(n);
        rank.resize(n);
        siz.resize(n);
        for (int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
            siz[i] = 1;
        }
    }
    int find(int x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) rank[x]++;
        par[y] = x;
        siz[x] += siz[y];
    }
    bool is_same(int x, int y) {
        return find(x) == find(y);
    }
    int size(int x) {
        x = find(x);
        return siz[x];
    }
};

int main() {
    int n, m = 1e5;
    vector<int> x, y;
    cin >> n;
    x.resize(n);
    y.resize(n);
    UnionFindTree g;
    g.init(2*m);
    REP(i,n){
        cin >> x[i] >> y[i];
        x[i]--; y[i]--;
        g.unite(x[i], y[i]+m);
    }
    map<int,P> cnt;
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    x.erase(unique(x.begin(), x.end()),x.end());
    y.erase(unique(y.begin(), y.end()),y.end());
    for(auto i : x){
        cnt[g.find(i)].first++;
    }
    for(auto i : y){
        cnt[g.find(i+m)].second++;
    }
    ll ans = 0;
    for(auto p : cnt){
        ans += p.second.first * p.second.second;
    }
    ans -= n;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3328
def main():
    n,k,q=map(int,input().split())
    a=[k-q]*n
    for i in range(q):
        a[int(input())-1]+=1
    for i in range(n):
        print('Yes' if a[i]>0 else 'No')




if __name__ == '__main__':
    main()

Measured memory_bytes: 6580
#include <bits/stdc++.h>
#include <string>
#include <stdio.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
using namespace std;

int main(void) {
    int N, M, count_p=0,count_m=0;
    cin>>N;
    string s[N];

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

    vector<string>vec(N+M),tmp(N+M);
    for(int i=0;i<M;i++){
          cin>>t[i];
    }
    for(int i=0;i<N+M;i++){
      if(i<N){
      vec[i]=s[i];tmp[i]=s[i];
      }
      else{
        vec[i]=t[i-N]; tmp[i]=t[i-N];
      }
    }
    std::sort(vec.begin(), vec.end());
    vec.erase(std::unique(vec.begin(), vec.end()), vec.end());

    
    vector<int> cnt((int)vec.size());

    for(int i=0;i<(int)vec.size();i++){
      for(int j=0;j<N+M;j++){
        if(j<N){
          if(vec[i]==s[j])count_p++;

        }
        else{
          if(vec[i]==t[j-N])count_m--;
          }
        }
      cnt[i] = count_p+count_m;
      count_m=0,count_p=0;
    }

    int max = *(max_element(cnt.begin(), cnt.end()));
    if(max<0){
      cout<<0<<endl;
    }else{
      cout<<max<<endl;
    }

    return 0;
}


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

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

  vector<vector<int>> M(n, vector<int>(n));
  for (int i = 0; i < n; i++) {
    int node;
    int d;
    cin >> node >> d;
    node--;

    for (int j = 0; j < d; j++) {
      int tmp;
      cin >> tmp;
      tmp--;
      M[i][tmp] = 1;
    }
  }

  vector<int> res(n, -1);
  vector<int> e(n);
  res[0] = 0;

  queue<int> q;
  q.push(0);

  while (!q.empty()) {
    int num = q.front();
    q.pop();

    int cnt = res[num] + 1;

    for (int i = 0; i < M[num].size(); i++) {
      if (M[num][i] == 0) { continue; }
      if (e[i] == 1) { continue; }
      q.push(i);
      e[i]   = 1;
      res[i] = cnt;
    }
  }
  res[0] = 0;

  for (int i = 0; i < n; i++) {
    cout << i + 1 << " " << res[i] << endl;
  }
}


Measured memory_bytes: 3204
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <random>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int main() {
    int n;
    string s;

    int h, w;
    cin >> h >> w;
    vector<string> t(h), ans(h);
    REP(i,h) cin >> t[i];
    REP(i,h) REP(j,w){
        if (t[i][j] == '#') ans[i] += '#';
        else{
            ans[i] += '0';
            REP(k,8){
                int ii = i + dx[k];
                int jj = j + dy[k];
                if (ii < 0 || jj < 0 || ii >= h || jj >= w) continue;
                if (t[ii][jj] == '#') ans[i][j]++;
            }
        }
    }

    REP(i,h) cout << ans[i] << endl;

    return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

template <typename T> using vec = std::vector<T>;
using vi = vec<int>;
using vvi = vec<vi>;
using pii = std::pair<int, int>;
using ll = long long;
using ld = long double;
// constexpr auto mod = 1000000007;
using namespace std;

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  vi lst{A, B, C};
  sort(ALL(lst));
  vi expected{5, 5, 7};
  cout << (lst == expected ? "YES" : "NO") << endl;

  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }


signed main()
{
	int N;
	cin >> N;
	bool b = false;
	REP(i, N)
	{
		char c;
		cin >> c;
		if (c == 'Y') b = true;
	}
	cout << (b ? "Four" : "Three") << endl;
}



Measured memory_bytes: 3640
n=int(input())
a=[int(i) for i in input().split()]
result=1
if 0 in a:
	print(0)
	exit()
for i in range(n):
	result *= a[i]
	if result > 1000000000000000000 and a[i] != 0:
		print(-1)
		exit()
print(result)


Measured memory_bytes: 21756
#include<algorithm>
#include<functional>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

typedef unsigned long long ull;
typedef long long ll;

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

using namespace std;

typedef pair<int ,int > P;


int main()
{
	int a[5];
	rep(i,5) cin>>a[i];

	sort(a,a+5,greater<int>());

	rep(i,5)
	{
		cout<<a[i];
		if(i!=4)
			cout<<" ";
	}
	cout<<endl;

	return 0;
}

Measured memory_bytes: 1176
s = int(input())
l = [int(n) for n in input().split()]
l = sorted(l)
flag = 0

for i in range(len(l)- 1):
  if l[i] == l[i+1]:
    print("NO")
    flag = 1
    break
    
if flag == 0:
  print("YES")
 

Measured memory_bytes: 25172
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

template <class T>
class binary_indexed_tree {
    vector<T> a;

    int lsb(int i) {
        return i & -i;
    }

public:
    binary_indexed_tree(int n) {
        a = vector<T>(n, 0);
    }

    void add(int i, T v) {
        for (; i < static_cast<int>(a.size()); i += lsb(i + 1)) {
            a[i] += v;
        }
    }

    int sum(int i) {
        T r = 0;
        for (; i >= 0; i -= lsb(i + 1)) {
            r += a[i];
        }
        return r;
    }
};

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

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

    vector<vector<pair<int, int>>> rl(n, vector<pair<int, int>>(0));
    for (int i = 0; i < q; i++) {
        int l, r;
        cin >> l >> r;
        rl[r - 1].push_back(make_pair(l - 1, i));
    }

    vector<int> res(q);

    vector<int> cr(n, -1);
    binary_indexed_tree<int> bit(n + 1);
    for (int i = 0; i < n; i++) {
        if (cr[c[i]] != -1) {
            bit.add(cr[c[i]] + 1, -1);
        }

        cr[c[i]] = i;
        bit.add(i + 1, 1);

        for (int j = 0; j < static_cast<int>(rl[i].size()); j++) {
            res[rl[i][j].second] = bit.sum(i + 1) - bit.sum(rl[i][j].first);
        }
    }

    for (int i = 0; i < q; i++) {
        cout << res[i] << endl;
    }
}


Measured memory_bytes: 33244
/*
最短経路は(h+w)!/h!*w!
ここから(a+b)!/a!b! + (a+(b-1))!/a!(b-1)! +..+1
*/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
static const int mod = 1e9 + 7;
static const int Max = 5e5;

/*全部llにしておく*/
ll modpow(ll a, ll n){
    ll res = 1;
    while(n > 0){
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll facto[Max];
void factorial(){
    facto[0] = 1;
    for (int i = 1; i < Max; i++){
        facto[i] = facto[i - 1] * i % mod;
    }
}

ll comb(ll n, ll k){
    ll ca = facto[n];
    ll cb = facto[k] * facto[n - k] % mod;
    return ca * modpow(cb, mod - 2) % mod;
}

int main(){
    int h, w, a, b;
    sc(h) sc(w) sc(a) sc(b)
    factorial();
    ll tmp, ans = 0;
    for (int i = b + 1; i <= w; i++){
        tmp = comb(h - a + i - 2, h - a - 1);
        tmp = tmp * comb(w - i + a - 1, w - i) % mod;
        ans = (ans + tmp) % mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4096
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B =sc.nextInt();
        int sum=N*A;
        if(sum<B) System.out.println(sum);
        else System.out.println(B);
    }
}


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

int main() {
	UL N, C; cin >> N >> C; N++;
	UL A = 0; rep(i, C) { UL a; cin >> a; A += a; }
	cout << ((A - 1) / N + 1) << endl;

	return 0;
}



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

using namespace std;

int main(){
    vector <int> vec(5);
    for (int i = 0; i < 5; i++){
        cin >> vec.at(i);
    }
    int ans = 11;
    int n;
    for (int i = 0; i < 5; i++){
        if (vec[i]%10 != 0 && vec[i]%10 < ans){
            ans = vec[i]%10;
            n = i;
        }
    }
    int cnt = 0;
    if (ans != 11){
        for (int i = 0; i < 5; i++){
            if(i != n){
                if (vec[i]%10 != 0){
                    cnt += (vec[i]/10 + 1) * 10;
                }else{
                    cnt += vec[i];
                }
            }else{
                cnt += vec[i];
            }
        }
    }else{
        for (int i = 0; i < 5; i++){
            cnt += vec[i];
        }
    }

    cout << cnt << endl;

}

Measured memory_bytes: 256
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import pdb
import sys
import math
F = sys.stdin

D, G = map(int,F.readline().split())
p = []
c = []
all_score = []
maisu = 0
ans = 0
sum = 0
all_selected = [0]*D
for k in range(D):
    p1, c1 = map(int,F.readline().split())
    p.append(p1)
    c.append(c1)
    all_score.append(100 * (k+1) * p1 + c1)

for bit in range(1<<D):
    for i in range(D):
        if bit & (1<<i):
            all_selected[i] = 1
            sum += all_score[i]
            maisu += p[i]

    nokori = G - sum
    if nokori <= 0:
        if ans == 0:
            ans = maisu
        else:
            ans = min(ans, maisu)
        all_selected = [0]*D
        maisu = 0
        sum = 0
        continue

    for j in range(D)[::-1]:
        if all_selected[j] == 0:
            nokorimaisu = math.ceil(nokori / (100 * (j+1)))
            if nokorimaisu <= p[j]:
                maisu += nokorimaisu
                if ans == 0:
                    ans = maisu
                else:
                    ans = min(ans, maisu)
            break

    all_selected = [0]*D
    maisu = 0
    sum = 0

print(ans)


Measured memory_bytes: 5548
#include <cstdio>
#include <algorithm>
#include <utility>
using namespace std;

typedef pair<int, int> P;

int main(){
    int n, m;
    int count[1001] = {};
    int a[1001];
    scanf("%d%d", &n, &m);
    for(int i = 0; i < n; i++){
        scanf("%d", a+i);
    }
    for(int i = 0; i < m; i++){
        int b;
        scanf("%d", &b);
        for(int j = 0; j < n; j++){
            if(a[j] <= b){
                ++count[1+j];
                break;
            }
        }
    }
    int max_v = 0, ans;
    for(int i = 1; i <= n; i++){
        if(count[i] > max_v){
            max_v = count[i];
            ans = i;
        }
    }
    printf("%d\n", ans);
    return 0;
}

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

int main() {
  string S; cin >> S;
  size_t len{S.length()};

  long total{};
  for (int i{}; i < (1 << len - 1); ++i) {
    long num = S[0] & 0xF;
    for (int j{}; j < len - 1; ++j) {
      if (i & (1 << j)) {
        total += num;
        num = 0;
      }
      num *= 10;
      num += S[j + 1] & 0xF;
    }
    total += num;
  }

  cout << total << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import Counter
from operator import itemgetter

n, k = map(int, input().split())
a = Counter(map(int, input().split()))
sa = sorted(a.items(), key=itemgetter(1), reverse=True)

if len(sa) <= k:
    print(0)
else:
    print(sum(c for m, c in sa[k:]))


Measured memory_bytes: 41492
#include<stdio.h>
int main(void){
	int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int b;
	scanf("%d",&b);
	printf("%d",a[b-1]);
	return 0;
}

Measured memory_bytes: 128
import itertools

N,M,Q = map(int,input().split())
li = []

for i in range(Q):
  li.append(list(map(int,input().split())))
li.sort(key = lambda x:x[3])
num = [i for i in range(1,M+1)] 
l = list(itertools.combinations_with_replacement(num, N))
max_sum=-1
for i in range(len(l)):
  s = 0
  for j in range(Q):
    if l[i][li[j][1]-1] -  l[i][li[j][0]-1] == li[j][2]:
      s+= li[j][3]
      
  max_sum = max(max_sum,s)
print(max_sum)
    

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

#define MAXN 150005

typedef long long lint;

using namespace std;

int n;
int ch[MAXN][2], val[MAXN][2], size[MAXN];

struct node {
	lint p, q;
	node(lint p = 0, lint q = 0):p(p), q(q) {}

	bool operator < (const node b) const {
		return p < b.p || (p == b.p && q < b.q);
	}
};

vector<node> a[MAXN];

int read() {
	char c = getchar();
	int x = 0;
	while (!isdigit(c))
		c = getchar();
	while (isdigit(c)) {
		x = (x << 3) + (x << 1) + c - '0';
		c = getchar();
	}
	return x;
}

void merge(lint limit, vector<node>& u, vector<node>& v, vector<node>& w) {
	if (!v.size() || !u.size())
		return ;
	for (int i = 0, j = 0; i < (int)u.size(); ++i) {
		while (j + 1 < (int)v.size() && u[i].q + v[j + 1].p <= limit)
			++j;
		if (u[i].q + v[j].p <= limit) {
			node temp(u[i].p, v[j].q);
			if (w.size() && temp.p >= w[w.size() - 1].p && temp.q >= w[w.size() - 1].q)
				continue;
			w.push_back(temp);
		}
	}
}

void DFS(int u, lint limit) {
	a[u].clear();
	if (!size[u]) {
		a[u].push_back(node());
		return ;
	}
	for (int i = 0; i < 2; ++i) {
		int v = ch[u][i], w = val[u][i];
		DFS(v, limit);
		for (int j = 0; j < (int)a[v].size(); ++j) {
			a[v][j].p += w;
			a[v][j].q += w;
		}
	}
	int ls = ch[u][0], rs = ch[u][1];
	sort(a[ls].begin(), a[ls].end());
	sort(a[rs].begin(), a[rs].end());
	merge(limit, a[ls], a[rs], a[u]);
	merge(limit, a[rs], a[ls], a[u]);
}

bool check(lint limit) {
	DFS(1, limit);
	return a[1].size();
}

int solve() {
	lint l = 0, r = 1ll << 34, res = -1;
	while (l <= r) {
		lint mid = (l + r) >> 1;
		if (check(mid)) {
			res = mid;
			r = mid - 1;
		}
		else
			l = mid + 1;
	}
	return res;
}

int main() {
	n = read();
	for (int i = 2; i <= n; ++i) {
		int f = read(), v = read();
		ch[f][size[f]] = i;
		val[f][size[f]] = v;
		++size[f];
	}
	lint ans = solve();
	printf("%lld\n", ans);
}

Measured memory_bytes: 29352
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main {
  while (true) {
    int n = in();
    if (n == 0) break;
    vector<int> x(n), y(n), r(n), c(n);
    rep(i, n) cin >> x[i] >> y[i] >> r[i] >> c[i];
    auto intersectCC = [&](int i, int j) {
      int r2 = (r[i] + r[j]) * (r[i] + r[j]);
      int d = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
      return d < r2;
    };
    auto intersect = [&](int t, int used) {
      bool f = false;
      rep(i, t) f |= (~used >> i & 1) && intersectCC(t, i);
      return f;
    };
    vector<char> dp(1 << n, -1);
    function<int(int)> dfs = [&](int used) {
      if (dp[used] != -1) return dp[used];
      cmax(dp[used], 0);
      rep(i, n) loop(j, i + 1, n) {
        if ((used >> i & 1) || (used >> j & 1) || c[i] != c[j]) continue;
        if (intersect(i, used) || intersect(j, used)) continue;
        cmax(dp[used], dfs(used | (1 << i) | (1 << j)) + 2);
      }
      return dp[used];
    };
    cout << dfs(0) << endl;
  }
}



Measured memory_bytes: 19488
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int i=1;
  while(++i<=n){
    int x=i;
    if(x%3==0){
      cout << " " << i;
      continue;
    }
    while(x){
      if(x%10==3){
	cout << " " << i;
	break;
      }
      x/=10;
    }
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 3108
arr = []
ptr = [
    [0, 1, 2],
    [3, 4, 5],
    [6, 7, 8],
    [0, 3, 6],
    [1, 4, 7],
    [2, 5, 8],
    [0, 4, 8],
    [2, 4, 6]]
for i in range(3):
    row = list(map(int, input().split()))
    arr.extend(row)
bingo = [False] * 9
N = int(input())
for i in range(N):
    n = int(input())
    if n in arr:
        idx = arr.index(n)
        bingo[idx] = True
for p in ptr:
    if all([bingo[idx] for idx in p]):
        print("Yes")
        exit(0)
print("No")


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

public class Main {
  private static boolean debug = false;
  private static boolean elapsed = false;

  private static PrintWriter _err = new PrintWriter(System.err);

  private long n;
  private long s;

  private void solve(Scanner sc, PrintWriter out) {
    n = sc.nextLong();
    s = sc.nextLong();

    if (n == s) {
      out.println((n + 1));
      return;
    }

    for (long i = 2; i <= Math.sqrt(n); ++i) {
      if (f(i, n) == s) {
        out.println(i);
        return;
      }
    }

    for (long i = (long)Math.sqrt(n); i > 0; --i) {
      long b = (n - s) / i + 1;
      if (b > 1 && f(b, n) == s) {
        out.println(b);
        return;
      }
    }

    out.println(-1);
  }
  private long f(long b, long n) {
    if (n < b) {
      return n;
    } else {
      return f(b, n / b) + (n % b);
    }
  }
  private long C(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    for (long i = r; i > 1; --i) {
      res /= i;
    }
    return res;
  }
  private long P(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    return res;
  }
  private long ceil2pow(long n) {
    if (n == 0) {
      return 1;
    }
    n--;
    n |= (n >>> 1);
    n |= (n >>> 2);
    n |= (n >>> 4);
    n |= (n >>> 8);
    n |= (n >>> 16);
    n++;
    return n;
  }
  /*
   * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
   * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
   */
  public static void main(String[] args) {
    long S = System.currentTimeMillis();

    Scanner sc = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    new Main().solve(sc, out);
    out.flush();

    long G = System.currentTimeMillis();
    if (elapsed) {
      _err.println((G - S) + "ms");
    }
    _err.flush();
  }
}

Measured memory_bytes: 10304
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		
		for(int i = 0; i < s.length(); i++) {
			 if(i % 2 == 0) {
				 System.out.print(s.charAt(i));
			 }
		}
	}
}


Measured memory_bytes: 30208
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

const int N=300005;

struct ST{
	int l,r,f;
}t[N<<2];
struct node{
	int l,r,d;
	node(){}
	node(int l,int r,int d):l(l),r(r),d(d){}
}a[N];
int n,m,l,r,d,ans;

bool cmp(node a,node b){
	return a.d<b.d;
}

void build(int k,int l,int r){
	t[k].l=l; t[k].r=r;
	if (l==r) return;
	int mid=(l+r)>>1;
	build(k<<1,l,mid);
	build(k<<1|1,mid+1,r);
}

void add(int k,int f){
	t[k].f+=f;
}

void pushdown(int k){
	if (t[k].f){
		add(k<<1,t[k].f);
		add(k<<1|1,t[k].f);
		t[k].f=0;
	}
}

void modify(int k,int L,int R){
	if (L<=t[k].l&&t[k].r<=R){
		add(k,1);
		return;
	}
	pushdown(k);
	int mid=(t[k].l+t[k].r)>>1;
	if (L<=mid) modify(k<<1,L,R);
	if (R>mid) modify(k<<1|1,L,R);
}

int query(int k,int p){
	if (t[k].l==t[k].r) return t[k].f;
	pushdown(k);
	int mid=(t[k].l+t[k].r)>>1;
	if (p<=mid) return query(k<<1,p);
	else return query(k<<1|1,p);
}

int main(){
	int i,p;
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++){
		scanf("%d%d",&l,&r);
		a[i]=node(l,r,r-l+1);
	}
	sort(a+1,a+1+n,cmp);
	build(1,1,m);
	p=1;
	for (d=1;d<=m;d++){
		for (;p<=n&&a[p].d<d;p++) modify(1,a[p].l,a[p].r);
		ans=n-p+1;
		for (i=d;i<=m;i+=d) ans+=query(1,i);
		printf("%d\n",ans);
	}
	return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

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

int T,X;
int main(){
    scanf("%d%d", &T,&X);
    
    printf("%lf", (double)T/X);

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int mod = 1000000007;
int main() {
  int n, m;
  scan(n, m);
  vi broken(n+1, 0);
  rep (i, m) {
    int a;
    scan(a);
    broken[a] = 1;
  }

  vll dp(n+1, 0);
  dp[0] = 1;
  if (!broken[1]) {
    dp[1] = 1;
  }
  FOR (i, 2, n+1) {
    if (broken[i]) {
      dp[i] = 0;
    } else {
      dp[i] = (dp[i-1] + dp[i-2]) % mod;
    }
  }
  print(dp[n]);

  return 0;
}


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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)

int main() {
	int a, b;
	cin >> a >> b;
	pv(a*b)
	return(0);
}

Measured memory_bytes: 3636
k = int(input())
kkk = [0] * k
kkk[0] = 7 % k
ans = -1
for i in range(1, k):
    kkk[i] = (kkk[i - 1] * 10 + 7) % k
for j in range(k):
    if kkk[j] == 0:
        ans = j + 1
        break
print(ans)


Measured memory_bytes: 48400
#include<stdio.h>
int main(){
  int A;
  int B;
  scanf("%d", &A);
  scanf("%d", &B);
  if(A+B > A-B){
    if(A+B > A*B){
      printf("%d\n",A+B);
    }else{
      printf("%d\n",A*B);
    }
  }else if(A-B > A*B){
    printf("%d\n", A-B);
  }else{
    printf("%d\n", A*B);
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#ifdef TEST
#define getchar_unlocked _getchar_nolock
#define putchar_unlocked _putchar_nolock
#endif
#define int long long
#define ins insert
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define pp pop
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define g0(a) get<0>(a)
#define g1(a) get<1>(a)
#define g2(a) get<2>(a)
#define g3(a) get<3>(a)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef double db;
typedef long long ll;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef tree<pair<int, int>, null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<pair<int, int>, null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int N;

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N;
	int S = (N + 999) / 1000;
	S *= 1000;
	cout << S - N << '\n';
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
using namespace std;
map< pair<char,int>,int> Assigned;//for array size
map<char ,int> M;//information of aray declartion
bool flag;
int point = 0;

void dec(string temp){
  int i =0;
  i=2;
  int size=0;
  while(temp[i] != ']'){
    size = size*10+temp[i]-'0';
    i++;
  }
  M[temp[0]]=size;
}

int exper(string temp,int count){
  int ret=0;
  if ( isdigit(temp[point])){
    while(point < temp.size() && isdigit(temp[point])){
      ret = ret* 10 + temp[point]-'0';
      point++;
    }
  }else {
    char arrayname = temp[point];
    point+=2;
    int index =exper(temp,count+1); 
    int sizecheck = M[arrayname];
    point++;
    
    if ( index >= sizecheck){
      flag = false;
      return 0;
    }
    if (  Assigned.find(make_pair(arrayname,index)) == Assigned.end()){
      flag = false;
      return 0;
    }
    ret = Assigned[ make_pair(arrayname,index)];
    //cout << arrayname << "["<< index << "]= " << ret  << endl;
  }
  return ret;
}

main(){
  string temp;
  while(cin >> temp && temp != "."){
    Assigned.clear();M.clear();
    vector<string> data;
    data.push_back(temp);
    while(cin >> temp && temp != ".")data.push_back(temp);
    int ans = 0;
    for(int i=0;i<data.size();i++){
      string now=data[i];
      flag = true;
      string::iterator itr= find(now.begin(),now.end(),'=');
      if ( itr == now.end()){
	dec(now);
      }else {
	//cout << "assignment" << endl;
	string array=now.substr(0,itr-now.begin()),val =now.substr(itr-now.begin()+1);
	point = 0;
	int value = exper(val,1);
	if ( flag == false){ans=i+1;break;}
	point = 0;
	int index  =exper(array.substr(2),0);
	if ( index >= M[array[0]]){ans=i+1;break;}
	Assigned[ make_pair(array[0],index)]=value;
      }
      if ( flag == false){ans = i+1;break;}
    }
    cout << ans << endl;
  }
  return false;
}

Measured memory_bytes: 1024
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let mut v: Vec<i64> = read_vec();
    let (m, n) = (v[0], v[1]);
    if (m - n).abs() <= 1 {
        println!("Brown");
    } else {
        println!("Alice");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <string>
#include <map>
using namespace std;


int main (int argc, char const *argv[])
{
    int n;
    cin>>n;
    vector<double> a(n);
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
    }
    
    double  ans=0.0;

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

    cout.precision(10);
    cout<<1/ans<<endl;
    return 0;
}

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

using namespace std;
using ll = long long;
constexpr int mo = 1000000007;
constexpr int  mod = mo;
constexpr ll inf = 1ll<<62;
int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<int>> dp(n,vector<int>(n,1<<20));
    vector<tuple<int,int,int>> t;
    for(int i=0;i<n;++i)dp[i][i] = 0; 
    for(int i=0;i<m;++i){
        int a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        t.emplace_back(a,b,c);
        dp[a][b] =  dp[b][a] = c;
    }
    for(int i=0;i<n;++i)for(int j=0;j<n;++j)for(int k=0;k<n;++k)dp[j][k] = min(dp[j][k],dp[j][i] + dp[i][k]);
    int count =0;
    for(int i=0;i<m;++i){
        int a,b,c;
        tie(a,b,c) = t[i];
        bool ng = true;
        for(int j=0;j<n;++j){
            for(int k=0;k<n;++k){
                if(dp[j][a] + c + dp[b][k] == dp[j][k] or dp[j][b] + c + dp[a][k] == dp[j][k]){ng = false;}
            }
        }
        if(ng)count++;
    }
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
using namespace std;
int main() {
	int n;
	int ans = 0;
	int count = 0;
	cin >> n;
	vector<int>r(n);
	rep0(i, n - 1) {
		cin >> r[i];
	}
	rep1(j, n - 1) {
		rep0(k, j - 1) {
			if (r[k] <= r[j])
				++count;
		}
		if (j == count)
			++ans;
		count = 0;
	}
	cout << ans + 1<< endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
taskList = []
for x in range(N):
    ABtuple = tuple(map(int, input().split()))
    taskList.append(ABtuple)

taskList.sort(key=lambda x: x[1])

Judge = True
time = 0

for x in taskList:
    time += x[0]
    if time > x[1]:
        Judge = False
        break

if Judge:
    print('Yes')
else:
    print('No')

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

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      int id,left,right;
      String[] words;
      Tree tree = new Tree(n);

      for(int i=0,k=0; i<n; i++,k=0){
        words = br.readLine().split(" ");
        id = Integer.parseInt(words[k++]);
        left  = Integer.parseInt(words[k++]);
        right = Integer.parseInt(words[k++]);

        tree.nodeInit(id,left,right);
      }

      tree.dispRoundPath(tree.getTreeRoot());
    }
    catch(IOException e) {
      System.out.println("IOException!");
    }
  }
}

class Tree {

  static final int NIL = -1;
  BTreeNode[] node;
  StringBuilder buf;

  public Tree(int size) {
    node = new BTreeNode[size];
    for (int i=0; i < size; i++) {
      node[i] = new BTreeNode();
    }
    buf = new StringBuilder(size*3);
  }

  void nodeInit(int id, int left, int right) {
    node[id].id = id;
    node[id].left = left;
    node[id].right = right;
    setParent(id);
  }
  int getTreeRoot() {
    int root=0;

    for (BTreeNode e : node) {
      if(e.parent == Tree.NIL)
        root = e.id;
    }

    return root;
  }
  void setParent(int id) {
    if(node[id].left != Tree.NIL)
      node[ node[id].left ].parent = id;
    if(node[id].right != Tree.NIL)
      node[ node[id].right ].parent = id;
  }

  void preParse(int u) {
    if(u != NIL){
      buf.append(" ").append(u);
      preParse(node[u].left);
      preParse(node[u].right);
    }
  }
  void inParse(int u) {
    if(u != NIL) {
      inParse(node[u].left);
      buf.append(" ").append(u);
      inParse(node[u].right);
    }
  }
  void postParse(int u) {
    if(u != NIL) {
      postParse(node[u].left);
      postParse(node[u].right);
      buf.append(" ").append(u);
    }
  }

  void dispRoundPath(int root) {

    buf.append("Preorder\n");
    preParse(root);
    buf.append("\n")
       .append("Inorder\n");
    inParse(root);
    buf.append("\n")
       .append("Postorder\n");
    postParse(root);
    buf.append("\n");

    System.out.print(buf);
  }
}

class BTreeNode {
  int id,parent,left,right;

  public BTreeNode() {
    this.id =
    this.parent =
    this.left =
    this.right = Tree.NIL;
  }
}


Measured memory_bytes: 24500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    ll ruisekiwa = 0;
    int ary[n+2];
    ary[0] = 0;
    rep(i,n)
    {
        cin >> ary[i+1];
    }
    ary[n+1] = 0;
    rep(i, n+1)
    {
        ruisekiwa += abs(ary[i] - ary[i+1]);
    }
    rep(i,n)
    {
        if (ary[i+1] > ary[i] && ary[i+1] > ary[i+2])
        {
            cout << ruisekiwa - abs(max(ary[i], ary[i+2]) - ary[i+1]) * 2 << endl;
        }
        else if (ary[i+1] < ary[i] && ary[i+1] < ary[i+2])
        {
            cout << ruisekiwa - abs(min(ary[i], ary[i+2]) - ary[i+1]) * 2 << endl;
        }
        else
        {
            cout << ruisekiwa << endl;
        }
        
    }
}


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


int main(){
    int64_t a,b,c;
    cin>>a>>b>>c;
    int64_t x = c-a-b;
    if(x>0 and x*x>4*a*b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}




Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<b){
        printf("a < b\n");
    } else if(a==b){
        printf("a == b\n");
    } else if(a>b){
        printf("a > b\n");
    }
    return 0;
}



Measured memory_bytes: 2056
# https://atcoder.jp/contests/abc077/tasks/arc084_a

from bisect import bisect_left, bisect_right

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
# print(A)
# print(B)
# print(C)

total = 0
for b in B:
    c1 = bisect_right(A, b - 1)
    c2 = N - bisect_left(C, b + 1)
    # print(b, c1, c2, c1 * c2)
    total += c1 * c2

print(total)

Measured memory_bytes: 105488
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=sys.stdin.readline
def resolve():
    n=int(input())
    A=list(map(int,input().split()))
    xor=0
    max_digit=0
    for a in A:
        xor^=a
        max_digit=max(max_digit,a.bit_length())
    # xorのうち、bitが立っていない部分だけでスクリーニング
    for i in range(n): A[i]&=(~xor)
    # このAに対してsweeping
    r=0 # Aのrank
    for d in reversed(range(max_digit)): # digit
        for i in range(r,n):
            if A[i]&(1<<d): # 候補のiをfixする
                for j in range(i+1,n): # sweep(確定してる奴は掃き出さなくてよい)
                    if A[j]&(1<<d): A[j]^=A[i]
                A[i],A[r]=A[r],A[i] # swap
                r+=1
                break
    # sweepしたAに対し、最上位bitから確定させていく
    x=0
    for i in range(r):
        d=A[i].bit_length()
        if not x&(1<<(d-1)):
            x^=A[i]
    print(xor+2*x)
resolve()

Measured memory_bytes: 69408
import java.util.Scanner;

public class Main {
	
	static int[][] field;
	// l <= ..... <  r , u <= ..... < d
	static int min;
	
	static boolean ok(int l, int r, int u, int d) {
		boolean flag = true;
		int max = 0;
		for(int i = u; i < d; i++) {
			for(int j = l; j < r; j++) {
				max = Math.max(field[i][j], max);
			}
		}
		for(int j = l-1; j <= r; j++) {
			min = Math.min(Math.min(field[u-1][j], field[d][j]), min);
			if(min <= max)	flag = false;
		}
		for(int i = u; i < d; i++) {
			min = Math.min(Math.min(field[i][l-1], field[i][r]), min);
			if(min <= max)	flag = false;
		}
		return flag;
	}
	
	static int water(int l, int r, int u, int d) {
		int ans = 0;
		for(int i = u; i < d; i++) {
			for(int j = l; j < r; j++) {
				ans += min - field[i][j];
			}
		}
		return ans;
	}
	
    public static void main(String[] args) throws Exception {
    	try(Scanner sc = new Scanner(System.in)) {
    		while(true) {
    			int d = sc.nextInt();
    			int w = sc.nextInt();
    			if(d+w==0) break;
    			field = new int[d][w];
    			for(int i = 0; i < d; i++) {
    				for(int j = 0; j < w; j++) {
    					field[i][j] = sc.nextInt();
    				}
    			}
    			int ans = 0;
    			for(int l = 1; l < w-1; l++) {
    				for(int r = 2; r < w; r++) {
    					for(int u = 1; u < d-1; u++) {
    						for(int b = 2; b < d; b++) {
    							min = 10;
    							if(ok(l, r, u, b)) {
    								ans = Math.max(ans, water(l, r, u, b));
    							}
    						}
    					}
    				}
    			}
    			System.out.println(ans);
    		}
    		
    	}
    }
}




Measured memory_bytes: 37516
#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>
using namespace std;

int main(){
    int t=0;
    vector<int> V(5);
    for(auto &v:V) cin>>v;
    sort(V.begin(), V.end(),[](int a,int b){return (a%10?a%10:10)<(b%10?b%10:10);});
    for(int i=4;i>=0;i--){
        if(t%10) t+=10-t%10;
        t+=V[i];
    }
    cout<<t<<endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    K=int(input())
    A=list(map(int,input().split()))
    A.reverse()
    minres = 2
    maxres = 2
    for a in A:
        minres = ((minres+a-1)//a)*a
        if minres>maxres:return -1
        maxres = (maxres//a)*a+a-1
    return str(minres)+" "+str(maxres)

print(main())

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e5 + 5;

int n,m,q;
set<ll> A, B;

void nearest(ll x, set<ll>& s, vector<ll>& coords) {
  auto iter = s.lower_bound(x);
  if (iter != s.end()) {
    coords.push_back(*iter);
    ++iter;
    if (iter != s.end()) {
      coords.push_back(*iter);
    }
    --iter;
  }
  if (iter != s.begin()) {
    --iter;
    coords.push_back(*iter);
  }
}

ll walk(ll cur, ll x, ll y) {
  // cur->x->y
  return abs(cur-x) + abs(x-y);
}

void solve() {
  ll ans = 1e18;
  ll loc; cin>>loc;
  vector<ll> v1, v2;
  // go to A, then B
  nearest(loc, A, v1);
  for (auto x: v1) {
    nearest(x, B, v2);
    for (auto y: v2) {
      ans = min(ans, walk(loc, x, y));
      ans = min(ans, walk(loc, y, x));
    }
    v2.clear();
  }
  
  v1.clear(); v2.clear();
  
  // go to B, then A
  nearest(loc, B, v1);
  for (auto x: v1) {
    nearest(x, A, v2);
    for (auto y: v2) {
      ans = min(ans, walk(loc, x, y));
      ans = min(ans, walk(loc, y, x));
    }
    v2.clear();
  }
  
  cout<<ans<<endl;
}



int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  //cout << fixed << setprecision(6);
  cin>>n>>m>>q;
  for (int i=0; i<n; i++) {
    ll x; cin>>x; A.insert(x);
  }
  for (int i=0; i<m; i++) {
    ll x; cin>>x; B.insert(x);
  }
  
  while(q--) solve();
  
  return 0;
}

Measured memory_bytes: 10752
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

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

        int[] food = new int[m];
        for (int i=0; i<m; i++) food[i] = n;

        for (int i=0; i<n; i++) {
            int k = in.nextInt();
            for (int j=0; j<k; j++) {
                int a = in.nextInt();
                food[a-1]--;
            }
        }

        int count = 0;
        for (int i=0; i<m; i++) {
            if (food[i] == 0) count++;
        }

        System.out.println(count);

        in.close();
    }
}

Measured memory_bytes: 25132
//swing

//Unhappy Hacking (ABC Edit)

//atcoder_beginner_043_b


#include <iostream>
#include <string>
using namespace std;

int main(){
	string inp;
	string outp;
	cin>>inp;
	int i=0;

	while(i<inp.length()){
		if(inp[i]!='B'){
			outp.push_back(inp[i]);
		}
		else{
			if(outp.length()!=0){
				outp.pop_back();
			}
		}
		i++;
	}
	cout<<outp;


}

Measured memory_bytes: 256
#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 ll = int64_t;
using Graph = vector<vector<int> >;
const ll M = 1000000007;
int main(){
    int n;
    cin >> n;
    int p[n];
    for(int i=0;i<n;i++) cin >> p[i];
    
    int mi[n];
    mi[0]=p[0];
    for(int i=1;i<n;i++){
        if(mi[i-1]>=p[i]){
            mi[i]=p[i];
        }else{
            mi[i]=mi[i-1];
        }
    }

    /*for(int i=0;i<n;i++){
        cout << mi[i] << " "; 
    }
    cout << endl;*/

    int counter=0;
    for(int i=0;i<n;i++){
        if(p[i]<=mi[i]) counter++;
    }

    cout << counter << endl;
}

Measured memory_bytes: 5160