akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> A(n);
	vector<long long> f(1e5 + 1, 0);
	long long sum = 0;
	for(int i = 0; i < n; i++)
	{
		cin >> A[i];
		sum += A[i];
		f[A[i]]++;
	}
	int Q;
	cin >> Q;
	while(Q--)
	{
		int b, c;
		cin >> b >> c;
		int diff = c - b;
		sum += diff*f[b];
		f[c] += f[b];
		f[b] = 0;
		cout << sum << "\n";
	}
}


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

bool ok[82][82][160*80*2];
int A[82][82],B[82][82];
const int shift = 160*80;

int abs(int num){return num>0?num:(-num);};
int main(){
	int H,W,maxLen=0,minD=10000000;
	
	cin>>H>>W;
	for(int i=1;i<=H;i++)for(int j=1;j<=W;j++)cin>>A[i][j];
	for(int i=1;i<=H;i++)for(int j=1;j<=W;j++)cin>>B[i][j];
	
	ok[0][1][shift]=true;
	ok[1][0][shift]=true;
	
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			for(int k=0;k<=160*80*2;k++){
				if(ok[i-1][j][k]||ok[i][j-1][k]){
					ok[i][j][k+A[i][j]-B[i][j]]=true;
					ok[i][j][k-A[i][j]+B[i][j]]=true;
				}
			}
		}
	}
	for(int i=shift;i<=160*80*2;i++){
		if(ok[H][W][i]||ok[H][W][2*shift-i]){
			cout<<min(abs(i-shift),abs(maxLen-i-shift));
			return 0;
		}
		
	}
	return 0;
}

Measured memory_bytes: 166144
#include<iostream>
#include<algorithm>
#include<vector>
#include<cassert>
#include<cmath>
#include<cstdio>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define MAX 8
#define inf (1<<29)

using namespace std;

int N,M,cnt;
int ans[MAX];
int input[MAX];
bool amida[MAX][MAX];

int solve(int *array)
{
  rep(i,N)array[i] = i;
  int mex,men;
  mex = -inf;
  men = inf;
  rep(h,8)
    {
      rep(w,N)
	{      
	  if(amida[h][w])
	    {
	      men = min(men,h);
	      mex = max(mex,h);
	      swap(array[w],array[w+1]);
	    }
	}
    }
  return mex - men + 1;
}

bool check(int *array)
{
  rep(i,N)if(array[i] != ans[i])return false;
  return true;
}


void dfs(int cur)
{
  if(cur >= M)
    {
      int array[N];
      int cost = solve(array);
      if(check(array))cnt = min(cnt,cost);
      return;
    }

  rep(h,8)
    {
      int w = input[cur];
      if(amida[h][w])continue;
      if(!amida[h][w-1] && !amida[h][w+1])
	{
	  amida[h][w] = true;
	  dfs(cur+1);
	  amida[h][w] = false;
	}
    }

}

int main()
{
  scanf("%d %d",&N,&M);

  rep(i,MAX)rep(j,MAX)amida[i][j] = false;
  rep(i,M)
    {
      scanf("%d",&input[i]);
      input[i]--;
      amida[i][input[i]] = true;
    } 
  cnt = solve(ans);
  assert(cnt == M);

  rep(h,8)rep(w,N)amida[h][w] = false;

  dfs(0);

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;
const double PI=acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	ll s; cin >> s;
	vector<ll> dp(s + 10,0);
	vector<ll> sum(s + 10,0);
	dp[3] = 1;
	rep(i,3,s + 1){
		dp[i] = (sum[i - 3] + 1) % MOD;
		sum[i] = (sum[i - 1] + dp[i]) % MOD; // sum更新
	}
	ll ans = dp[s] % MOD;
	cout << ans << endl;

}

Measured memory_bytes: 3624
//	ZapZu's code hohoho
//	#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define dfs_black 1
#define dfs_white -1
#define pr pair
#define vt vector
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef double db;
typedef long long li;
typedef long double ld;

typedef pr<int, int> ii;
typedef pr<ld,ld> dd;

typedef vt<int> vi;
typedef vt<li> vli;
typedef vt<ld> vld;
typedef vt<ii> vii;

typedef map<int, int> mii;
typedef map<int, bool> mib;
typedef map<int, char> mic;

typedef set<int> s_i;
typedef set<char> s_c;

const int MOD = 1e9+7;
const li INF = 1e18;
const ld PI = 4*atan((ld)1);
vi v[2];
signed main()
{
//	freopen(".inp", "r", stdin);
//	freopen(".out", "w", stdout);
	int n;
	cin>>n;
	vi v;
	for(int i=1; i<=n; i++)
	{
		int temp;
		cin>>temp;
		v.eb(temp-i);
	}
	sort(begin(v), end(v));
	li ans=0;
	for(auto temp: v)
	{
		ans+=abs(temp-v[(v.size()+1)/2-1]);
	}
	cout<<ans;
}




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

struct Task {
	int n;
	vector<int> a;

	Task(int n): n(n), a(n) {
		for (auto& item : a) {
			cin >> item;
		}
	}

	void run() {
		multiset<int> s;
		long long sum = 0;
		for (int i = 0; i < n; ++i) {
			s.insert(a[i]);
			sum += a[i];
		}
		int mx = 0;
		for (int i = 0; i < n; ++i) {
			if (a[i] <= mx) {
				cout << 0 << '\n';
				continue;
			}
			s.erase(s.find(a[i]));
			long long prv = sum;
			sum -= a[i] - mx;
			while (!s.empty() && (*s.begin()) <= a[i]) {
				sum -= (*s.begin()) - mx;
				s.erase(s.begin());
			}
			sum -= 1LL * s.size() * (a[i] - mx);
			mx = a[i];
			cout << prv - sum << '\n';
		}
	}
};

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

	int n;
	cin >> n;

	Task a(n);
	a.run();

	return 0;
}

Measured memory_bytes: 6144
N = int(input())
h = list(map(int, input().split()))

dp = [10**9]*N
dp[0] = 0
dp[1] = abs(h[0]-h[1])
for i in range(2, N):
  dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))

print(dp[N-1])

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

int n,m,buf,num;
bool even = false;
long long ans = 1;

int main(){
    cin >> n >> m;
    if((n + m) % 2 == 0) even = true;
    if(abs(n-m) > 1){
        cout << 0 << endl;
        return 0;
    }
    if(n > m){
        buf = m;
        m = n;
        n = buf;
    }
    num = n;
    for(int i = 0; i < num; i++){
        ans = (ans * m ) % (1000000000 + 7);
        ans = (ans * n ) % (1000000000 + 7);
        m--;
        n--;
    }
    if(even) ans = (ans * 2) % (1000000000 + 7);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace::std;
#define int long long int
 
int ar[200005];
 
main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++)
		cin>>ar[i];
	int t=1;
	for(int i=0;i<n;i++)
		if(2*m/ar[i]>=t/__gcd(ar[i]/2,t))
			t=ar[i]/2/__gcd(ar[i]/2,t)*t;
		else{
			cout<<0<<'\n';
			return 0;
		}
		// cout<<t<<'\n';
	for(int i=0;i<n;i++)
		if(!((2*t/ar[i])&1))
			return cout<<0<<'\n',0;
	cout<<(m-t)/t/2+1<<'\n';//<<t<<' '<<lcm<<'\n';
}

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

const int MAXN = 500000 + 50;

string str;
int answer, N, digit[MAXN];

bool check(int mid)
{
	int len = N, sum = 0;
	for(int i = 0; i < N; i++)
		digit[i] = (str[i] - '0') * 9;
	digit[0] += 9 * mid;

	for(int i = 0 ; i < len; i++)
		if(digit[i] > 9)
		{
			if(i == len - 1)
				digit[len++] = 0;
			digit[i + 1] += digit[i] / 10;
			digit[i] %= 10;
		}
	for(int i = 0; i < len; i++)
		sum += digit[i];

	return sum <= 9 * mid;
}

int main()
{
	cin >> str ;
	N = str.length();
	int L = 0, R = N;
	reverse(str.begin(), str.end());
	while(L + 1 < R)
	{
		int mid = (L + R) >> 1;

		//cerr << mid << " " << L << " " << R << endl ;

		if(check(mid))
			//cerr << "R selected" << endl ,
			R = mid;
		else
			//cerr << "L selected" << endl ,
			L = mid;
	}

	cout << R << endl ;
}


Measured memory_bytes: 2948
import math
import itertools
n = int(input())
x = [0] * n
y = [0] * n
for i in range(n):
    x[i], y[i] = map(int, input().split())
 
l = list(itertools.permutations(range(n)))
length = []
for perm in l:
    length.append(sum([math.sqrt((x[perm[i]]-x[perm[i+1]])**2+(y[perm[i]]-y[perm[i+1]])**2) for i in range(n-1)]))
 
print(sum(length)/math.factorial(n))

Measured memory_bytes: 9332
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll md = 1000000007;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
vl p, fac(2, 1), ifac(2, 1);

ll add(ll a, ll b, ll mod = md) {
    return (a%mod + b%mod + mod) % mod;
}

ll mul(ll a, ll b, ll mod = md) {
    return ( (a%mod) * (b%mod) ) % mod;
}

ll power(ll x, ll n, ll mod = md) {
    ll res = 1;
    x %= mod;
    while (n) {
        if (n & 1)  res = ((res%mod) * (x%mod))%mod;
        n = (n >> 1);
        x = ((x%mod) * (x%mod))%mod;
    }
    return res;
}

void cachefact(ll lim, ll mod = md) {
    for(int i = 2; i <= lim; i++) {
        ifac.push_back((ifac[mod%i] * (mod - mod/i) % mod)%mod);
    }
    for(ll i = 2; i <= lim; i++) {
        fac.push_back((fac[i-1] * i)%mod);
        ifac[i] = (ifac[i-1] * ifac[i])%mod;
    }
}

ll C(ll n, ll r, ll mod = md) {
    if(n < r) return 0;
    return mul(fac[n], mul(ifac[r], ifac[n-r], mod), mod);
}

void sieve(ll n) {
	vector<bool> prime(n+1, true);
    for(int i = 2; i*i <= n; i++) {
        if(prime[i]) {
            for(int j = i*i; j <= n; j += i) {
                prime[j] = false;
            }
        }
    }
    p.push_back(2);
    for(int i = 3; i <= n; i += 2) {
        if(prime[i]) {
            p.push_back(i);
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cachefact(1000005);
   	ll n, m, ans = 1;
   	cin >> n >> m;
   	sieve(100000);
   	int pn = p.size();
   	for(int i = 0; i < pn && p[i]*p[i] <= m; i++) {
   		int cnt = 0;
   		while(m%p[i] == 0) {
   			cnt++;
   			m /= p[i];
   		}
	   	if(cnt) {
	   		ans = mul(ans, C(cnt + n - 1, cnt));
	   	}
   	}
   	if(m > 1) {
   		ans = mul(ans, C(n,1));
   	}
   	cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 23336
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <cstring>
#include <fstream>
#include <numeric>
#include <algorithm>

using namespace std;

int main(int argc, char **argv) {
  int bank[50][3];
  int n, y;

  while (cin >> n, n) {
    cin >> y;
    for (int i = 0; i < n; i++)
      cin >> bank[i][0] >> bank[i][1] >> bank[i][2];

    double max_get = 0.0;
    int bank_num;
    for (int i = 0; i < n; i++) {
      double get;
      if (bank[i][2] == 1) {
        get = 100 * (1 + y * bank[i][1] / 100.0);
      } else {
        get = 100 * pow((1 + bank[i][1] / 100.0), y);
      }
      if (get > max_get) {
        max_get = get;
        bank_num = bank[i][0];
      }
    }
    cout << bank_num << endl;
  }
  return 0;
}

Measured memory_bytes: 1164
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	stack<int>s1; stack<pair<int, int>>s2;
	int sum(0);
	string in; cin >> in;
	rep(i, 0, in.size()) {
		if (in[i] == '\\') {
			s1.push(i);
		}
		else if (!s1.empty() && in[i] == '/') {
			int b = s1.top(); s1.pop();
			int x = i - b;
			sum += x;
			while (!s2.empty() && b < s2.top().first) {
				x += s2.top().second;
				s2.pop();
			}
			s2.push(make_pair(b, x));
		}
	}
	cout << sum << endl;
	vector<int>ans;
	while (!s2.empty()) {
		ans.push_back(s2.top().second);
		s2.pop();
	}
	reverse(all(ans));
	cout << ans.size();
	rep(i, 0, ans.size())cout << ' ' << ans[i];
	cout << endl;
	return 0;
}

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

inline int num (const std::string& S, int idx){
	return S.at(idx) - '0';
}

inline unsigned int bitMask(int i){
	return (1 << i);
}

inline bool isTrue(unsigned int bit, int i){
	return bit & bitMask(i);
}

int main(){
	string S;
	cin >> S;
	int numbers[4];
	numbers[0] = num(S, 0);
	numbers[1] = num(S, 1);
	numbers[2] = num(S, 2);
	numbers[3] = num(S, 3);
	for(unsigned short bit=0; bit<(1<<4); ++bit){
		int sums = numbers[0];
		for(int i=1; i<4; ++i){
			if(bit&bitMask(i)) sums -= numbers[i];
			else               sums += numbers[i];
		}
		if(sums == 7){
			cout << numbers[0] << (bit&bitMask(1)? "-" : "+")
					 << numbers[1] << (bit&bitMask(2)? "-" : "+")
					 << numbers[2] << (bit&bitMask(3)? "-" : "+")
					 << numbers[3]
					 << "=7" << endl;
			return 0;
		}
	}
	return 0;
}


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

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def solve():
    s = input()
    if s == "ABC":
        print("ARC")
    else:
        print("ABC")

    return 0

if __name__ == "__main__":# {{{
    solve()

# vim: set foldmethod=marker: }}}


Measured memory_bytes: 79620
#include<stdio.h>
#include<stdlib.h>

int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}

int main(){
	int n,i,c=0;
	long a[100000];
	long long ab[2]={0};
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%ld",&a[i]);
	qsort(a,n,sizeof(long),compare_int);
	for(i=1;i<n;i++){
		if(c>=2)break;
		if(a[i]==a[i-1]){
			ab[c++]=a[i];
			a[i]=0;
		}
	}
	printf("%lld\n",ab[0]*ab[1]);
	return 0;
}

Measured memory_bytes: 1788
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int ISjiwei(int b);
int main()
{
	int a,b,i,c,num,sum,t = 1;
	scanf("%d %d",&a,&b);
	num = ISjiwei(b);
	for(i = 0;i < num; i++)
		t *= 10;
		a *= t;
	sum = a + b;
	if(sqrt(sum) == (int)sqrt(sum))
		printf("Yes\n");
		else
			printf("No\n");
			return 0;
}
int ISjiwei(int b)
{
	if(b / 10 == 0)
		return 1;
		else if(b / 100 == 0)
			return 2;
			else
				return 3;
}

Measured memory_bytes: 128
a=map(int, raw_input().split())
#print a

a_start=a[0]
a_end=a[1]
b_start=a[2]
b_end=a[3]

if a_start<=b_start:
	c_start=b_start
else:
	c_start=a_start

#print c_start

if a_end<b_end:
	c_end=a_end
else:
	c_end=b_end

#print c_end

if c_end-c_start<0:
	print 0
else:
	print c_end-c_start

Measured memory_bytes: 2696
//BISMILLAHIR RAHMANIR RAHIM


#include<bits/stdc++.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>

#define ls ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define quit return 0

using namespace std;
int main()
{
    ls
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int n,a;
    cin >> n ;
    a=n+pow(n,2)+pow(n,3);
    cout << a ;
    quit;

}


Measured memory_bytes: 4112
#include <cstdio>
#define min(a,b) ((a)<=(b)?(a):(b))
int main() {
    int Q;
    scanf("%d",&Q);
    for(int i=0;i<Q;i++) {
        int c,a,n;
        scanf("%d %d %d",&c,&a,&n);
        int CAN,CCA,CCC;
        CAN=min(c,min(a,n));
        c-=CAN,a-=CAN;
        CCA=min(c/2,a);
        c-=CCA*2;
        CCC=c/3;
        printf("%d\n",CAN+CCA+CCC);
    }
}

Measured memory_bytes: 1028
/**
class cfmaster {
 public:
  struct code {
  	see the details down there !
  };
};
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long k;
  cin >> k;
  long long ans = 1;
  long long cnt = 1;
  while (k > 1) {
  	k /= 2;
  	cnt *= 2;
  	ans += cnt;
	}
	cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

class Graph01 {
	private int totalVertex;
	//adjMatrix[u][v] = 1 if there is an edge from u to v, otherwise 0
	private int[][] adjMatrix;
	//adjWeight[u][v] -- the weight of the edge from u to v if there is one
	private int[][] adjWeight;
	//if a node is settled (e.g., processed in the Dijkstra's algorithm)
	private Boolean[] ifSettled;
	public Graph01() { totalVertex = 0; }
	public int getTotalVertex() { return totalVertex; }
	//load graph from standard input
	public void loadAdjMatrix() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjMatrix = new int[totalVertex][totalVertex];
		adjWeight = new int[totalVertex][totalVertex];
		ifSettled = new Boolean[totalVertex];
		int i, j;
		for(i = 0; i < totalVertex; i ++) {
			ifSettled[i] = false;
			for(j = 0; j < totalVertex; j ++) {
				adjMatrix[i][j] = adjWeight[i][j] = 0;
			}
		}
		int u, v;
		for(i = 0; i < totalVertex; i ++) {
			for(j = 0; j < totalVertex; j ++) {
				int d = in.nextInt();
				if(d >= 0) {
					adjMatrix[i][j] = 1;
					adjWeight[i][j] = d;
				}
			}	
		}
		in.close();
	}
	//return weight of the edge from u to v if there is one
	public int getWeight(int u, int v) {
		return adjWeight[u][v];
	}
	//return neighbors of u as a LinkedList
	public LinkedList<Integer> getNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if(adjMatrix[u][v] == 1) tmp.add(v);
		}
		return tmp;
	}
	//return unsettled neighbors of u as a LinkedList
	public LinkedList<Integer> getUnsettledNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if((adjMatrix[u][v] == 1) && (ifSettled[v] == false)) tmp.add(v);
		}
		return tmp;
	}
	//return the unsettled node that has the smallest dist
	public int getUnsettledNearest(int[] dist) {
		int md = Integer.MAX_VALUE;
		int mv = -1;
		int v;
		for(v = 0; v < totalVertex; v ++) {
			if((ifSettled[v] == false) && (dist[v] < md)) {
				md = dist[v];
				mv = v;
			}
		}
		return mv;
	}
	//implement the following	
	public int Dijkstra(int s) {
		int answer = 0;
		int[] Ans = new int[totalVertex];
		for(int i = 1; i < totalVertex; i++) {
			Ans[i] = Integer.MAX_VALUE;
		}
		
		int curr = getUnsettledNearest(Ans);
		
		while (curr != -1) {
			ifSettled[curr] = true;
			LinkedList<Integer> r = getUnsettledNeighbors(curr);
			for(Integer neighbor:r) {
				int e = getWeight(curr, neighbor);
				if(e < Ans[neighbor]) {
					Ans[neighbor] = e;
				}
			}
			
			curr = getUnsettledNearest(Ans);
			
		}
		for(int i = 0; i < Ans.length; i++) {
			answer += Ans[i];
		}
		
		return answer;
		

	}
}

public class Main {
	public static void main(String[] argv) {
		Graph01 g = new Graph01();
		g.loadAdjMatrix();
		int dist = g.Dijkstra(0);
		System.out.println(dist);
	}
}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());


void c_p_c()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
//  c_p_c();

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

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

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


   return 0;
}



Measured memory_bytes: 6636
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace atcoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var buffer = Console.ReadLine().Split();
            var buffer2 = Console.ReadLine().Split();
            var dic = new Dictionary<string, int>();
            dic[buffer[0]] = int.Parse(buffer2[0]);
            dic[buffer[1]] = int.Parse(buffer2[1]);

            var tmp = Console.ReadLine();
            dic[tmp] -= 1;

            Console.WriteLine($"{dic[buffer[0]]} {dic[buffer[1]]}");
        }
    }
}


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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

int main(){
    ll Q;
    cin >> Q;

    set<ll> se;

    while(Q--){
        ll a, x;
        cin >> a >> x;

        if(a==0){
            // insert
            se.insert(x);
            p(se.size());
        }
        else if(a==1){
            // find
            p(se.count(x));
        }
        else if(a==2){
            // delete
            se.erase(x);
        }
        else{
            // dump
            ll L = x;
            ll R; cin >> R;

            auto it = se.lower_bound(L);
            auto it2 = se.upper_bound(R);
            for(; it!=it2; it++){
                p(*it);
            }
        }
    }

    return 0;
}


Measured memory_bytes: 12360
<?php

function fget_array($dlmt = null) {
    $input = trim(fgets(STDIN));
    return $dlmt ? explode($dlmt, $input) : str_split($input);
}

list($n) = fget_array(' ');
$s = fget_array();

$sum = 0;
$prev = '';
foreach ($s as $v) {
    if ($prev !== $v) $sum++;
    $prev = $v;
}

echo $sum;
?>


Measured memory_bytes: 11000
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

const long long INF = 1LL << 60;

int main() {
  int N, K; cin >> N >> K;
  vector<long long> H(N);
  for (int i = 0; i < N; i++) cin >> H[i];

  vector<long long> DP(N, INF);
  DP[0] = 0;
  DP[1] = abs(H[1] - H[0]);
  for (int i = 2; i < N; i++) {
    for (int k = 1; k <= K; k++) {
      if (i - k >= 0) DP[i] = min(DP[i - k] + abs(H[i] - H[i - k]), DP[i]);
    }
  }
  cout << DP[N - 1] << endl;
}


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

using namespace std;

#define vit vector<int>::iterator
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fr first
#define sc second
#define skip continue
#define PI 3.14159265

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int ui;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const ll MAXN = 3e5 + 3;
const int  M   =   1e9+7;

void faster(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

bool cmp(const string& a, const string& b) {
    return (a + b) < (b + a);
}

void solve(){

    ll n, m, i, j, k, x;

    cin >> n;
    map<ll, ll> a;
    for(k = 2; k <= n; ++k)
    {
        ll cnt = 0;
        ll num = k;
        while(num % 2 == 0) {
            ++cnt;
            num /= 2;
        }
        if(cnt) a[2] += cnt;
        for(i = 3; sqrt(i) <= num; i += 2) {
            if(num % i == 0) {
                cnt = 0;
                while(num % i == 0) {
                    ++cnt;
                    num /= i;
                }
                a[i] += cnt;
            }
        }
        if(num > 1) a[num]++;
    }

    ll tot = 1;
    for(auto t : a)
    {
        tot *= (t.second + 1);
        tot %= M;
    }
    cout << tot << endl;
}


int main(){
    
    int n = 1;
   
    while(n--){
        solve();
        cout << endl;
    }
  
}


Measured memory_bytes: 3696
#include <iostream>
using namespace std;
 
int main()
{
    while(true){
        int h, w;
        cin >> h >> w;
        if(h==0 && w==0){
            break;
 		}
        int d = h*h+w*w;
        int H = 150;
        int W = 150;
        int D = 150*150+150*150;
 
        for(int y=1; y<=150; y++){
            for(int x=y+1; x<=150; x++){
                int z = y*y+x*x;
                if(z<=d){
                    continue;
                }
                else{
                    if(z<D){
                        H = y;
                        W = x;
                        D = z;
                    }
                    break;
                }
            }
        }
 
        for(int y=h+1; y<150; y++){
            bool flg = false;
            for(int x=y+1; x<=150; x++){
                int z = y*y+x*x;
 
                if(z==d){
                    H = y;
                    W = x;
                    D = z;
                    flg = true;
                }
                if(z>=d)
                    break;
            }
            if(flg)
                break;
        }
        cout << H << ' ' << W << endl;
    }
 
    return 0;
}



Measured memory_bytes: 2996
A,B,C = (int(x) for x in input().split())

if A == B == C:
    print("No")
elif A == B and A != C:
    print("Yes")
elif A == C and A != B:
    print("Yes")
elif B == C and A != C:
    print("Yes")
elif B == C and A != B:
    print("Yes")
elif A != B != C:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  long long int a,b,c,d=0,f,g,h;
  cin>>a;
  b=a/2;
  c=a-b;
  cout<<b*c;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int N, K;
int main() {
  cin >> N >> K;
  vector<int> a, b;
  bool ok = true;
  for(int i = 0; i < (N+1)/2; ++i) {
    ok &= K+i*2 + K+N+(N+1)/2-1-i <= K+N*2+i;
    a.push_back(K+i*2);
    b.push_back(K+N+(N+1)/2-1-i);
  }
  for(int i = 0; i < N/2; ++i) {
    ok &= K+i*2+1 + K+N*2-1-i <= K+N*2+(N+1)/2+i;
    a.push_back(K+i*2+1);
    b.push_back(K+N*2-1-i);
  }
  if(ok)
  for(int i = 0; i < N; ++i)
    cout << a[i] << " " << b[i] << " " << i+K+N*2 << '\n';
  else cout << -1;
  return 0;
}

Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

#define fo(i,j,l) for(int i=j;i<=l;++i)
#define fd(i,j,l) for(int i=j;i>=l;--i)

using namespace std;
typedef long long ll;
const ll N=12e4;

int a[4],n;

char s[N];

inline int min(int a,int b)
{return a<b?a:b;}

int main()
{
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	scanf("%d",&n);
	int ans=0;
	fo(i,1,n){
		scanf("%s",s+1);
		int len=strlen(s+1);
		fo(l,1,len-1)if(s[l]=='A'&&s[l+1]=='B')++ans;
		int zt=0;
		if(s[1]=='B')zt=2;
		if(s[len]=='A')zt^=1;
		++a[zt];		
	}
	int k=min(a[2],a[1]);
	a[2]-=k; a[1]-=k;
	ans=ans+k;
	if(a[3]>0){
		if(k)ans=ans+a[3];
		else ans=ans+a[3]-(a[1]==0&&a[2]==0);
	}
	cout<<ans;
}

Measured memory_bytes: 256
//#define TEST

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Linq;

class Program
{
    private static int N;
    private static int M;
    private static int[] a;
    private static int[] b;
    private static int[] c;
    private static int[,] Edge; //辺の長さ
    private static int[,] MinDis; //頂点間の最短距離を格納する

    public static void Main()
    {
        /*入力の受け取り、各変数の初期化*/
        int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        N = input[0];
        M = input[1];
        a = new int[M];
        b = new int[M];
        c = new int[M];
        Edge = new int[N, N];
        for (int i = 0; i < N; i++)
            for (int j = 0; j < N; j++)
                Edge[i, j] = (int)1e9; //辺の長さを∞に初期化
        MinDis = new int[N, N];
        for (int i = 0; i < N; i++)
            for (int j = 0; j < N; j++)
                MinDis[i, j] = (int)1e9; //頂点間の最短距離を∞に初期化
        for (int i = 0; i < N; i++)
            MinDis[i, i] = 0; //同一頂点の距離は0に
        for (int i = 0; i < M; i++)
        {
            input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int ai = input[0] - 1;
            int bi = input[1] - 1;
            int ci = input[2];
            Edge[ai, bi] = ci;
            Edge[bi, ai] = ci;
            MinDis[ai, bi] = ci;
            MinDis[bi, ai] = ci;
            a[i] = ai;
            b[i] = bi;
            c[i] = ci;
        }

        /*各頂点間の距離を求める*/
        WarshallFloyd();
        ShowMinDis();

        /*各辺(a,b;c)について、次を満たすか判定する
            i = 0,1,2,...,N - 1 , j = i + 1,i + 2,i + 3,...,N について
            MinDis[i,j] != MinDis[i,a] + c + MinDis[b,j]
            MinDis[j,i] != MinDis[j,a] + c + MinDis[b,i]
        */
        int ans = 0;
        for (int e = 0; e < M; e++)
        {
            bool f = true;
            for (int i = 0; i < N - 1; i++)
            {
                for (int j = i + 1; j < N; j++)
                {
                    f = f && MinDis[i, j] != MinDis[i, a[e]] + c[e] + MinDis[b[e], j];
                    f = f && MinDis[j, i] != MinDis[j, a[e]] + c[e] + MinDis[b[e], i];
                    if (!f) goto Fin;
                }
            }
            Fin:;
            if (f) ans++;
        }

        /*答えを出力*/
#if TEST
        Console.WriteLine("ANS");
#endif
        Console.WriteLine(ans);
    }

    /*ワ―シャルフロイド法により、各頂点間の最短距離を計算する*/
    private static void WarshallFloyd()
    {
        for (int k = 0; k < N; k++)
            for (int i = 0; i < N; i++)
                for (int j = 0; j < N; j++)
                    if (MinDis[i, j] > MinDis[i, k] + MinDis[k, j])
                        MinDis[i, j] = MinDis[i, k] + MinDis[k, j];
    }

    /*MinDisを表示する*/
    [Conditional("TEST")]
    private static void ShowMinDis()
    {
        Console.WriteLine("MinDis");
        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j < N; j++)
                Console.Write("{0} ", MinDis[i, j]);
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 13396
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n;
char str[1005];
bool check(int l,int r){
	while(l<=r){
		if(str[l]!=str[r]) return 0;
		l++,r--;
	}
	return 1;
}
signed main(){
	scanf("%s",str);
	n=strlen(str);
	if(check(0,(n-1)/2-1)&&check((n+3)/2-1,n-1)&&check(0,n-1)) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	ll n, k;cin >> n >> k;
	vector<ll> a(n);
	vector<ll> b(n);
	vector<ll> c(n);

	REP(i, n)c[i] = k + 2 * n + i;
	ll ida = 0;
	ll idb = (n > 1);
	REP(i, n){
		a[ida] = k + i;
		b[idb] = k + n + i;
		ida += 2;if(ida >= n)ida = 1;
		idb += 2;if(idb >= n)idb = 0;
	}

	// SHOW1d(a, n);
	// SHOW1d(b, n);
	// SHOW1d(c, n);

	REP(i, n){
		if(a[i] + b[i] > c[i]){
			cout << -1 << endl;
			return 0;
		}
	}

	REP(i, n)cout << a[i] << " " << b[i] << " " << c[i] << "\n";

	return 0;
}


Measured memory_bytes: 4608
#include <stdio.h>

int main(void){
    int n ,a ,b;
    int taxi;
    int train;
    do{
    scanf("%d", &n);
    scanf("%d", &a);
    scanf("%d", &b);
    }while(n < 1 || n > 20 || a < 1 || a > 50 || b < 1 || b > 50);
    taxi = b;
    train = a*n;
    if(taxi <= train){
        printf("%d\n",taxi);
    }else if(train < taxi){
        printf("%d\n",train);
    }
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
main(){
  int n,m,i,j,a[101][2],b,tmp[2];
  while(1){
  scanf("%d %d",&n,&m);
  if(n==0&&m==0)break;
  for(i=0;i<102;i++)a[i][0]=0,a[i][1]=i+1;
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      scanf(" %d",&b);
      if(b==1)a[j][0]++;
    }
  }
 
  for(i=0;i<=m-1;i++){
    for(j=m-1;j>i;j--){
      if(a[j][0]>a[j-1][0]){
	tmp[0]=a[j][0],tmp[1]=a[j][1];
	a[j][0]=a[j-1][0],a[j][1]=a[j-1][1];
	a[j-1][0]=tmp[0],a[j-1][1]=tmp[1];
      }
    }
  }

  for(i=0;i<m;i++){
    printf("%d",a[i][1]);
    if(i!=m-1)printf(" ");
  }
  printf("\n");
  }
  return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n,m; cin >> n >> m;
  vector<int> v(m); cin >> v;
  int sum = 0;
  for(int e:v)sum += e;
  cout << (n >= sum ? n - sum : -1) << endl;
  return 0;
}


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

int main()
{
	long long n, p, ans{1};
	scanf("%lld%lld", &n, &p);
	for (long long i = 2; i * i <= p; i++)
	{
		if (p % i) continue;
		int tmp{};
		while (!(p % i))
		{
			p /= i;
			tmp++;
		}
		tmp /= n;
		for (int j = 0; j < tmp; j++)
			ans *= i;
	}
	if (n == 1) ans *= p;
	printf("%lld\n", ans);

	return 0;
}

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

keta = len(str(N))

if keta % 2 == 0:
     ans = 0
else:
     ans = N - 10 ** (keta-1) + 1

i = 1
while i < keta:
     ans += 10**i - 10**(i-1)
     i += 2


print(ans)

Measured memory_bytes: 9168
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>

////多倍長整数, cpp_intで宣言
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

#pragma gcc target ("avx2")
#pragma gcc optimization ("Ofast")
#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	string s, t;
	scans(s);
	scans(t);
	int ans = 0;
	rep(i, s.length())ans += (s[i] != t[i]);
	printf("%d\n", ans);

	Please AC;
}

Measured memory_bytes: 3980
from collections import deque

def calc(b,a,s):
    if s == '+':
        return a + b
    if s == '-':
        return a - b
    if s == '*':
        return a * b

L = input().split()
S = deque()
for c in L:
    if c in ['+','-','*']:
        S.append(calc(int(S.pop()), int(S.pop()), c))
    else:
        S.append(c)
print(S[0])


Measured memory_bytes: 6004
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m,q,num[20],a[60],b[60],c[60];
ll ans=-1,d[60];
void search(int pos) {
//	printf("%d %d\n",pos,num[pos-1]);
	if(pos>n) {
		ll val=0;
		for(int i=1;i<=q;++i)
			if(num[b[i]]-num[a[i]]==c[i])
				val+=d[i];
//		for(int i=1;i<=n;++i) printf("%d ",num[i]);
//		printf("%d\n",val);
		ans=max(ans,val);
		return;
	}
//	cout<<1<<endl;
	for(int i=num[pos-1];i<=m;++i) {
//		printf("%d %d\n",pos,i);
		num[pos]=i;
		search(pos+1);
		num[pos]=0;
	}
	return;
}
int main()
{
	memset(num,0,sizeof(num));
	num[0]=1;
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=q;++i) scanf("%d%d%d%lld",&a[i],&b[i],&c[i],&d[i]);
	search(1);
	printf("%lld",ans);
	return 0;
}

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

void solve() {
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        auto up = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        auto low = c.end() - upper_bound(c.begin(), c.end(), b[i]);
        ans += up * low;
    }
    cout << ans;
}


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


Measured memory_bytes: 4520
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

unsigned GetDigit(unsigned num){
    if(num == 0)return 1;
    return log10(num)+1;
}

int main(){
    string N;cin >> N;
    int lim = N.size();
    vector<int> num(lim);
    rep(i,lim){
        num[i] = N[i] - '0';
    }
    int ans = 0;

    for(int i = lim-1;i > 0;--i){
        if(num[i] < 9){
            num[i] = 9;
            num[i-1]--;
        }
    }
    rep(i,lim)ans += num[i];
    cout << ans <<  endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;
const int mod = 1e9+7;

int main() {
    string w; cin >> w;
    map<char,int> mp;
    rep(i,w.size()) mp[w[i]]++;
    bool ok = true;
    for (P p : mp) {
        if (p.second % 2 != 0) ok = false;
    }
    printf(ok?"Yes\n":"No\n");
}

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

int main(){
    int N;
    cin >> N;
    unordered_map<string,int> mp;
    long long ans = 0LL;
    for(int i = 0; i < N; i++){
        string s;
        cin >> s;
        sort(s.begin(),s.end());
        auto itr = mp.find(s);
        if(itr != mp.end()){
            ans += mp[s];
            mp[s] += 1;
        }else{
            mp[s] = 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10660
#include <iostream>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

const int N = 100;
const int INF = 100000000;
typedef pair<int, int> P;

class S{
public:
   int pos, cost, s;
   S(){}
   S(int pos, int cost, int s) : pos(pos), cost(cost), s(s) {}
   bool operator < (const S& t) const {
      if(cost == t.cost){
         return s > t.s;
      }
      return cost > t.cost;
   }
};

int n, m;
vector<P> G[N];
int dist[N][3];

void dijkstra(){
   priority_queue<S> que;
   fill(dist[0], dist[N], INF);
   dist[0][0] = 0;
   que.push(S(0, 0, 0));
   while(!que.empty()){
      S p = que.top(); que.pop();
      //cout << p.pos << ' ' << p.cost << ' ' << p.s << endl;
      int v = p.pos;
      int v2 = p.s;
      if(dist[v][v2] < p.cost) continue;
      for(int i=0;i<G[v].size();i++){
         P e = G[v][i];
         if(v2 == 0){
            if(dist[e.first][1] > dist[v][v2]){
               dist[e.first][1] = dist[v][v2];
               que.push(S(e.first, dist[v][v2], 1));
            }
            if(dist[e.first][0] > dist[v][v2] + e.second){
               dist[e.first][0] = dist[v][v2] + e.second;
               que.push(S(e.first, dist[v][v2] + e.second, 0));
            }
         }
         if(v2 == 1){
            if(dist[e.first][2] > dist[v][v2]){
               dist[e.first][2] = dist[v][v2];
               que.push(S(e.first, dist[v][v2], 2));
            }
         }
         if(v2 == 2){
            if(dist[e.first][2] > dist[v][v2] + e.second){
               dist[e.first][2] = dist[v][v2] + e.second;
               que.push(S(e.first, dist[v][v2] + e.second, 2));
            }
         }
      }
   }
}

main(){
   while(cin >> n >> m && (n|m)){
      for(int i=0;i<n;i++) G[i].clear();
      for(int i=0;i<m;i++){
         int a, b, c;
         cin >> a >> b >> c;
         a--;
         b--;
         G[a].push_back(P(b, c));
         G[b].push_back(P(a, c));
      }
      dijkstra();
      //cout << dist[n-1][0] << ' ' << dist[n-1][1] << ' ' << dist[n-1][2] << endl;
      cout << min(dist[n-1][0], dist[n-1][2]) << endl;
   }
}

Measured memory_bytes: 0
#include<stdio.h>
#include<string.h>
int main()
{
    int i;
    char s[7];
    scanf("%s",s);
    if(strcmp(s,"Sunny")==0)
        printf("Cloudy");
    else if(strcmp(s,"Cloudy")==0)
        printf("Rainy");
    else if(strcmp(s,"Rainy")==0)
        printf("Sunny");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(0);

int main()
{
  Hello;
  
  set<int> a;
  long long int b,c;
  cin>>b;
  
  for(int i=0; i<b; i++)
  {
    cin>>c;
    a.insert(c);
  }
  
  long long int d=a.size();
  
  if(d==b)  cout<<"YES";
  else  cout<<"NO";
  
  return 0;
}

Measured memory_bytes: 9600
//Created by Kira

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    

void add_self(int &a, int &b){
    a += b;
    if(a >= mod)
        a-=mod;
}

void sub_self(int& a, int &b){
    a -= b;
    if(a < 0)
        a += mod;
}

int n, k;

//dp[i] = Number of ways to share candies if i candies are distributed 
// so far.

int main(){
   IOS

   cin>>n>>k;

   vi dp(k+1);

    dp[0] = 1;
   for(int i = 0; i < n; i++){
       int up_to; cin>>up_to;

        vi helper(k+1);
        //O(k)
       for(int used = k; used >= 0; --used){
           int L = used + 1;
           int R = used + min(up_to , k - used);
           if(L <= R){
                add_self(helper[L], dp[used]);
                if(R+1 <= k)
                    sub_self(helper[R+1], dp[used]);
           }
       }
    //O(k)
       int prefix_sum = 0;
        for(int j = 0; j <= k; j++){
           add_self(prefix_sum,helper[j]);
           add_self(dp[j], prefix_sum);
       }
    }

    cout<<dp[k]<<"\n";
      
    //Time Complexity : O(nk)




}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



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

using namespace std;

typedef long long ll;
typedef double db;
db ans;
ll ansi;
int n,m,d;

inline int readin(){
    int x=0,s=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')s=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*s;
}

int main(){
    n=readin();m=readin();d=readin();
    if(n<2*d||d==0)ansi=n;
    else ansi=2ll*d+(n-(2ll*d))*2;
    ansi=ansi*(m-1);
    ans=1.0*ansi/(1ll*n*n);
    printf("%.12lf\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
int main() {
	int n, c, k;
	cin >> n >> c >> k;
	V a(n);
	rep(i, n) {
		cin >> a[i];
	}
	sort(all(a));
	int ans = 1;
	int L = a[0] + k;
	int now = 0;
	rep(i, n) {
		if (L >= a[i] && now < c) now++;
		else {
			now = 1;
			ans++;
			L = a[i] + k;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640