akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

template<typename T>
struct BellmanFord{
	struct Edge{
		int  from,to; ll cost;
		Edge(){}
		Edge(int from,int to,ll cost):from(from),to(to),cost(cost){}
	};

	int n;
	vector<vector<int> >G;
	vector<int> used,reach;
	BellmanFord(int n):n(n),G(n),used(n,0),reach(n,0){}

	vector<Edge> es;
	void add_edge(int from,int to,ll cost){
		es.push_back(Edge(from,to,cost));
		G[from].push_back(to);
	}

	void dfs(int v){
		if(used[v])return ;
		used[v]=1;
		for(int u:G[v]){
			dfs(u);
		}
	}
	ll build(int from,int to,int &neg_loop){
		for(int i=0;i<n;i++){
			fill(used.begin(),used.end(),0);
			dfs(i);
			reach[i]=used[to];
		}
		vector<ll> ds(n,1e18);
		ds[from]=0;
		for(int i=0;i<n;i++){
			bool update=0;
			for(auto e:es){
				if(!reach[e.from]||!reach[e.to]||ds[e.from]==1e18) continue;
				if(ds[e.to]>ds[e.from]+e.cost){
					ds[e.to]=ds[e.from]+e.cost;
					update=1;
				}
			}
			if(!update)break;
			if(i==n-1){
				neg_loop=1;
				return 1e18;
			}
		}
		neg_loop=0;
		return ds[to];
	}
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, m;
    cin >> n >> m;
    BellmanFord<ll> bf(n);
    rep(i, m) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        bf.add_edge(a, b, -c);
    }
    int neg;
    ll dist = bf.build(0, n - 1, neg);
    if (neg) cout << "inf" << endl;
    else cout << -dist << endl;
    return 0;
}


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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int K;
  cin >> K;
  queue<ll> que;
  for (int i = 1; i < 10; i++)
    que.push(i);
  for (int i = 0; i < K - 1; i++)
  {
    ll s = que.front();
    que.pop();
    for (int j = -1; j <= 1; j++)
    {
      ll add = (s % 10) + j;
      if (add >= 0 && add <= 9)
        que.push(s * 10 + add);
    }
  }
  cout << que.front() << endl;
  return 0;
}

// K番目に小さいものを求めよという問題でpriority_queueが使える問題は多い．まず，priority_queueに1から9をpushする．以下の操作をK回繰り返す．
// キューの先頭を取り出す．(sとする)
// sの一の位がdであるとき
// d > 0ならキューに10v + (d - 1)をpush
// キューに10v + dをpush
// d < 9ならキューに10v + (d + 1)をpush
// キューにpushされる値は，時系列にそって単調増加であるためpriority_queueではなくqueueでかまわない
// これらの操作はBFSと見なすことが出来る．


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
typedef long long li;
#define f(n) (n*(n-1)/2)
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }


int main(){
  int n,m; cin >>n >>m;
  print(f(n)+f(m));
}


Measured memory_bytes: 256
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>


using namespace std;

typedef long long ll;

#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vld vector<ld>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define vvld vector<vector<ld>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
const ll M = 1000000007;
const ll MM = 998244353;
ll begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//#define trace(...)
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

template<typename T, typename F>
void chmax( T &a, F b) {
  if (b > a)a = b;
}

template<typename T, typename F>
void chmin( T &a, F b) {
  if (b < a)a = b;
}



ll powM(ll a, ll b, ll m)
{
  if (a <= 0)return 0;
  a %= m;
  ll ans = 1LL;
  while (b)
  {
    if (b & 1)ans = ans * a % m;
    a = a * a % m;
    b >>= 1;
  }

  return ans;
}



ll poww(ll a, ll b)
{

  ll ans = 1;
  while (b)
  {
    if (b & 1)ans = ans * a;
    a = a * a;
    b >>= 1;
  }

  return ans;

}


string tostring(ll x) {
  stringstream sss;
  sss << x;
  string ans = sss.str();
  return ans;
}



const ll N = 1e6 + 5;



int main() {

  IOS;

#ifndef ONLINE_JUDGE

  freopen("input1.txt", "r", stdin);
  freopen("output1.txt", "w", stdout);

#endif

  ll x; cin >> x;

  cout << 1 - x << endl;

  return 0;
}

Measured memory_bytes: 3612
#include<stdio.h>

int main()
{
    int x1,y1,y2,x2,x3,y3,y4,x4,x,y;
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    x = x2-x1;
    y = y2-y1;
    x3 = x2-y;
    x4 = x1-y;
    y3 = y2+x;
    y4 = y1+x;
    printf("%d %d %d %d\n", x3,y3,x4,y4);
    return 0;

}


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

long long int acc[100005]={0};

int main(){
    int n;
    cin >> n;
    vector<long long int> v;
    for(int i=0;i<n;++i){
        long long int a;
        cin >> a;
        v.push_back(a);
    }

    sort(v.begin(), v.end());
    acc[0] = v[0];
    for(int i=1;i<n;++i){
        acc[i] = acc[i-1] + v[i];
    }

    int ans = 1;
    for(int i=n-2;i>=0;--i){
        if(acc[i] * 2 >= v[i+1])ans++;
        else break;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2036
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long 
#define ull unsigned long long
#define db double
#define vi vector<ll>
#define vvi vector<vector<int> >
#define vvii vector<vector<pii> >
#define rep(i,a,b) for(int i=a;i<b;i++)
#define endl "\n"
#define pii pair<ll,ll>
#define piii pair<ll,pair<ll,ll> >
#define mem(a,b) memset(a , b , sizeof a ) ; 
#define pb push_back
#define pf push_front
#define F first 
#define S second 
#define mp make_pair
#define all(v) v.begin(),v.end()

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}



#define deb1(a) cout<<#a<<"=*"<<a<<endl;
#define deb2(a) cout<<#a<<"=@"<<a<<endl;
#define deb3(a) cout<<#a<<"=#"<<a<<endl;
#define deb4(a,b) cout<<#a<<"="<<a<<" and "<<#b<<"="<<b<<endl;
#define deb5(a,b) cout<<#a<<"="<<a<<" and "<<#b<<"="<<b<<endl;


typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


ll mod=1000000007;
ll vis[212345]={0};
vvi v(212345);
ll d[212345]={0};


ll pow(ll a, ll b, ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}





int main()
{
speed
ll n,k;
cin>>n>>k;
ll p[n+1];
rep(i,1,n+1) cin>>p[i];
ll c[n+1];
rep(i,1,n+1) cin>>c[i];

ll f[n+1];
ll mx=-1e18;
rep(i,1,n+1)
{
	mem(f,0);
	ll t=1;
	ll cr=i;
	//f[cr]=t++;
	
	ll cy=0;
	ll cs=0;
	vi pr;
	pr.pb(cs);
	while(1)
	{
		cr=p[cr];
		if(f[cr])
		{
			cy=t-f[cr];
			break;
		}
		f[cr]=t++;
		cs+=c[cr];
		pr.pb(cs);	
	}
	//deb4(i,cy);
	//deb4(cr,t);
	if(k<pr.size())
	{
	//	deb4(mx,pr[k]);
		rep(j,1,k+1) mx=max(mx,pr[j]);
		mx=max(mx,pr[k]);
	}
	else
	{
		ll l=pr.size()-1-cy;
//		ll cs=(pr[pr.size()-1]-pr[l]);
		rep(j,1,pr.size()) mx=max(mx,pr[j]);
		ll zz=(k-l)/cy-1;
		ll q=(k-l)/cy*(pr[pr.size()-1]-pr[l])+(pr[(k-l)%cy+l]);

		mx=max(mx,q);
		ll dd=0;
		rep(j,l+1,(k-l)%cy+l+1) dd=max(dd,pr[j]);
		q=(zz+1)*(pr[pr.size()-1]-pr[l])+dd;
		mx=max(mx,q);
		dd=0;
//		ll z1=(pr[pr.size()-1]-pr[l]);
		rep(j,l+1,pr.size()) dd=max(dd,pr[j]-pr[l]);
//		rep(j,l+1,(k-l)%cy+l+1) dd=max(dd,pr[j]+z1);
	//	deb1(zz);
		q=(zz)*(pr[pr.size()-1]-pr[l])+dd;
		mx=max(mx,q);
		

		
	}

}
	cout<<mx<<endl;
}


Measured memory_bytes: 8584
h,w=map(int,input().split())
from collections import *
l=[(0,1),(0,-1),(1,0),(-1,0)]
dp=[[float("inf")]*w for i in range(h)]
f=[[False]*w for i in range (h)]
ch,cw=map(int,input().split())
sx,sy=ch-1,cw-1
dh,dw=map(int,input().split())
gx,gy=dh-1,dw-1
for i in range(h):
    s=input()
    for j in range(w):
        if s[j]==".":
            f[i][j]=True
q=deque()
q.append((sx,sy))
dp[sx][sy]=0
while q:
    x,y=q.popleft()
    for a,b in l:
        nx,ny=x+a,y+b
        if 0<=nx<h and 0<=ny<w:
            if f[nx][ny]==True and dp[nx][ny]>dp[x][y]:
                dp[nx][ny]=dp[x][y]
                q.appendleft((nx,ny))
    for nx in range(x-2,x+3):
        for ny in range(y-2,y+3):
            if 0<=nx<h and 0<=ny<w:
                if f[nx][ny]==True and dp[nx][ny]>dp[x][y]+1:
                    dp[nx][ny]=dp[x][y]+1
                    q.append((nx,ny))
if dp[gx][gy]==float("inf"):
    print(-1)
else:
    print(dp[gx][gy])

Measured memory_bytes: 106184
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

void ProblemA();
void ProblemB();
void ProblemC();
void ProblemD();

int main() {
  // ProblemA();
  ProblemB();
  return 0;
}

void ProblemB() {
  uint32_t N;
  cin >> N;
  vector<double> A(N);
  for (uint32_t i = 0; i < N; ++i) {
    cin >> A[i];
  }
  double Sum = 0;
  for (uint32_t i = 0; i < N; ++i) {
    Sum += 1 / A[i];
  }
  cout << setprecision(14) << 1 / Sum << endl;
}

void ProblemA() {
  uint32_t a;
  string s;

  cin >> a >> s;

  if (a < 3200) {
    cout << "red" << endl;
  } else {
    cout << s << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string>
#include <set>
#include <tuple>
#include <algorithm>
#include <unordered_map>
#include <vector>

using namespace std;

int main()
{
	int A;
	int B;
	int h = 100;
	int w = 100;
	char s[100][100];
	cin >> A >> B;

	bool moreA = A > B;
	char fillin = moreA ? '.' : '#';
	char bgr = moreA ? '#' : '.';
	int higher = max(A, B);
	int lower = min(A, B);

	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < 100; j++)
		{
			s[i][j] = bgr;
		}
	}

	bool first = true;

	int starti = 1, startj = 1;
	for (int i = 0; i < lower; i++) {
		s[starti][startj] = fillin;
		s[starti+1][startj] = fillin;
		s[starti+2][startj] = fillin;
		s[starti][startj+1] = fillin;
		s[starti][startj+2] = fillin;
		s[starti+1][startj+2] = fillin;
		s[starti+2][startj+1] = fillin;
		s[starti+2][startj+2] = fillin;
		if (first) {
			s[starti + 1][startj + 1] = fillin;
			first = false;
		}

		starti += 4;
		if (starti > 96) {
			starti = 1;
			startj += 4;
		}
	}

	for (int i = 0; i < higher - lower; i++) {
		s[starti][startj] = fillin;
		starti += 4;
		if (starti > 98) {
			starti = 1;
			startj += 4;
		}
	}


	
	ofstream file("C:\\Users\\Jeroen\\Desktop\\test.txt");
	cout << 100 << " " << 100 << endl;
	file << 100 << " " << 100 << endl;
	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < 100; j++)
		{
			cout << s[i][j];
			file << s[i][j];
		}
		cout << endl;
		file << endl;
	}
	return 0;
}


Measured memory_bytes: 256
n = int(input())
P = list(map(int, input().split()))

if n == 1:
    print(1)
    exit()

count = 0
base = P[0]
for i in range(n - 1):

    if base >= P[i + 1]:
        count += 1
        base = P[i + 1]

print(count+1)


Measured memory_bytes: 24744
function *main() {
  
  const [a, b] = (yield).split` `;
  const s = a.repeat(+b);
  const t = b.repeat(+a);
  console.log((s < t) ? s : t);
  
}
const iter = main();
iter.next();
require("readline").createInterface({input: process.stdin, output: process.stdout}).on("line", line => iter.next(line));


Measured memory_bytes: 29932
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define MOD 1000000007
#define endl "\n"
#define sz(a) (int)((a).size())
#define all(x) (x).begin(), (x).end()
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define OTP(s) cout<<s<<endl;
#define FOR(i,j,k,l) for(int i=j;i<k;i+=l)
#define REP(i,j) FOR(i,0,j,1)
inline ll add(ll a, ll b){a += b; if(a >= MOD)a -= MOD; return a;}
inline ll sub(ll a, ll b){a -= b; if(a < 0)a += MOD; return a;}
inline ll mul(ll a, ll b){return (ll)((ll) a * b %MOD);}
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

ll min(ll a,ll b)
{
    return a>b?b:a;
}
ll max(ll a,ll b)
{
    return a>b?a:b;
}
ll n,a[200000],b[200000],c[200000];
ll dp[200000][3];
int main()
{
    IOS
    cin>>n;
    REP(i,n)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    for(int i=1;i<n;i++)
    {
        dp[i][0] = a[i]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = b[i]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = c[i]+max(dp[i-1][1],dp[i-1][0]);
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
}

Measured memory_bytes: 8832
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[8];
		int r = 0, c = 0;
		for(int i = 0 ; i < n ; i++) a[i] = sc.nextInt();
		for(int i = 0 ; i < n ; i++) {
			int index = a[i] / 400;
			if(index == 0) b[index]++;
			else if(index == 1) b[index]++;
			else if(index == 2) b[index]++;
			else if(index == 3) b[index]++;
			else if(index == 4) b[index]++;
			else if(index == 5) b[index]++;
			else if(index == 6) b[index]++;
			else if(index == 7) b[index]++;
			else c++;
		}
		for(int i = 0 ; i < 8 ; i++) {
			if(b[i] != 0) r++;
		}
		int min = Math.max(1, r);
		int max = 0;
		if(min == r) max = c + r;
		else max = c;
		System.out.println(min + " " + max);
	}
}


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

#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define MAXX 200005


#define PI 3.14159265358979323846264338327950

#define ll  long long int
vector<ll> v;
multiset<ll> ms;
multiset<ll>::iterator it;
ll a[MAXX], b[MAXX];
ll mod = 1000000007;
char c[MAXX];

int main()
{
	FAST;
	ll  ans = 0, a1 = 0, a2 = 0, n , mx = 0, m;
	cin >> a1 >> a2 >> n;
	mx = min(a1, min(a2, n));
	m = max(a1, max(a2, n));
	m = a1+ a2 + n - mx - m;
	cout << mx*m / 2;
	
}

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

int main() {
  string S;
  cin >> S;
  int price = 700;
  for(int i = 0; i < 3; i++){
  	if(S[i] == 'o') price += 100;
  }
  cout << price << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> c(n - 1), s(n - 1), f(n - 1);
    rep(i, 0, n - 1){
        cin >> c[i] >> s[i] >> f[i];
    }
    rep(i, 0, n){
        int ans = 0;
        rep(j, i, n - 1){
            if(ans < s[j]) ans = s[j];
            else ans = (ans + f[j] - 1) / f[j] * f[j];
            ans += c[j];
        }
        cout << ans << endl;
    }
}

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

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

int main(){
    string s,t;
    while(cin>>s>>t){
        rep(i,s.size()-t.size()+1){
            bool ok = true;
            rep(j,t.size()){
                if(!(t[j]=='_' || s[i+j]==t[j])){
                    ok = false;
                }
            }
            if(ok){
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
    }
}


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

namespace _1_4D
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] array = new int[n];
            string[] str = Console.ReadLine().Split();
            long Sum = 0;
            int Max = -1000000;
            int Min = 1000000;
            for (int i = 0; i < array.Length; i++)
            {
                array[i] = int.Parse(str[i]);
                Sum += array[i];
                if (Min > array[i])
                {
                    Min = array[i];
                }
                if(Max < array[i])
                {
                    Max = array[i];
                }
            }
            Console.WriteLine("{0} {1} {2}",Min,Max,Sum);
        }
    }
}



Measured memory_bytes: 18136
from heapq import heappush, heappop
import re
from collections import deque
import sys
import math
input = sys.stdin.readline


def int_raw():
    return int(input())


def ss_raw():
    return input().split()


def ints_raw():
    return tuple(map(int, ss_raw()))


DIV = 10**9+7


def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def ncr(n, r, mod=DIV):
	r = min(r, n-r)
	ret = 1
	for i in range(1, r+1):
		ret = ret * (n-i+1) % mod
		ret = ret * mod_inv(i, mod) % mod
	return ret


def main():
    A,B = ints_raw()
    if abs(A-B)%2==1:
        return "IMPOSSIBLE"
    else:
        return (A+B)//2

print(main())


Measured memory_bytes: 38384
#include <stdio.h>

#define MAX 100000

int readSeq(char *S, int idx, int max, int *num) {
        int i;
        *num = 0;
        for (i = idx; i < max; i++) {
                if (S[i] == S[idx]) (*num)++;
                else break;
        }

        if (S[idx] == '0') *num *= -1;

        return i;
}

int main() {
        int N, K;
        char S[MAX] = { '\0' };
        int Tidx[MAX] = { 0 };
        int i, j, idx, tidx;
        int max, tmp;

        scanf("%d %d", &N, &K);
        scanf("%s", S);

        i = 0;
        while (i < N) {
                Tidx[tidx++] = i;
                i = readSeq(S, i, N, &tmp);
                //tidx++;
        }

        max = -1;
        for (i = 0; i < tidx; i++) {
                int idx = Tidx[i];
                int tmp;
                if (S[idx] == '0') {
                        if (i + 2 * K < tidx) {
                                tmp = Tidx[i+2*K] - idx;
                        } else {
                                tmp = N - idx;
                        }
                } else if (S[idx] == '1') {
                        if (i + 2 * K + 1 < tidx) {
                                tmp = Tidx[i+2*K+1] - idx;
                        } else {
                                tmp = N - idx;
                        }
                }

                if (tmp > max) max = tmp;
        }

        printf("%d\n", max);

        return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define N 200005
#define mod 1000000007
using namespace std;
template<typename T>
inline void in(T &x)
{
	x=0;
	char c=getchar();
	bool fu=0;
	while(c<'0'||c>'9'){if(c=='-')fu=1;c=getchar();}
	while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();
}
int fa[N],n,m;
int Find(int x){return fa[x]<0?x:fa[x]=Find(fa[x]);}
void uni(int x,int y)
{
	x=Find(x),y=Find(y);
	if(x==y)return;
	if(fa[x]>fa[y])fa[y]+=fa[x],fa[x]=y;
	else fa[x]+=fa[y],fa[y]=x;
}
int main()
{
	in(n);in(m);
	memset(fa,-1,sizeof(fa));
	while(m--)
	{
		int x,y;
		in(x);in(y);
		uni(x,y);
	}
	int mn=0;
	for(int i=1;i<=n;++i)
	if(fa[i]<mn)mn=fa[i];
	printf("%d\n",-mn);
	return 0;
}

Measured memory_bytes: 4560
s=input()
t=input()
f=0
e=len(t)
flg=0
while e<=len(s):
  tmp=s[f:e]
  for i in range(len(t)):
    if tmp[i]!=t[i] and tmp[i]!='?':
      break
    if i==len(t)-1:
      ans=s[:f]+t+s[e:]
      flg=1
  f+=1
  e+=1
if flg==0:
  print('UNRESTORABLE')
else:
  print(ans.replace('?','a'))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

int main(int argc, char *argv[]) {

  i64 N, i;
  cin >> N;
  vector<pi> P(N);
  i64 ans = 0;
  REP(0, N, i) {
    cin >> P[i].first >> P[i].second;
    P[i].second += 1;

    //ans = max(ans, P[i].second - P[i].first);
  }
  sort(all(P));

  i64 L1, R1, L2, R2;
  L1 = P[0].first, R1 = P[0].second;
  L2 = P[1].first, R2 = P[1].second;
  REP(2, N, i) {
    i64 L1_1 = max(L1, L2), R1_1 = min(R1, R2);
    i64 L2_1 = P[i].first, R2_1 = P[i].second;
    i64 V1 = max(0LL, R1_1 - L1_1) + max(0LL, R2_1 - L2_1);
    
    i64 L1_2 = max(L1, P[i].first), R1_2 = min(R1, P[i].second);
    i64 L2_2 = L2, R2_2 = R2;
    i64 V2 = max(0LL, R1_2 - L1_2) + max(0LL, R2_2 - L2_2);

    i64 L1_3 = max(L2, P[i].first), R1_3 = min(R2, P[i].second);
    i64 L2_3 = L1, R2_3 = R1;
    i64 V3 = max(0LL, R1_3 - L1_3) + max(0LL, R2_3 - L2_3);

    if(V1 > V2 && V1 > V3) {
      L1 = L1_1, R1 = R1_1;
      L2 = L2_1, R2 = R2_1;
    }
    else if(V2 > V1 && V2 > V3) {
      L1 = L1_2, R1 = R1_2;
      L2 = L2_2, R2 = R2_2;
    }
    else {
      L1 = L1_3, R1 = R1_3;
      L2 = L2_3, R2 = R2_3;
    }
  }

  cout << max(0LL, R1 - L1) + max(0LL, R2 - L2) << endl;
  
  return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;

    ll one = (N - M) * 1 + M * 19;
    ll need = 1 << M;
    cout << one * need * 100 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;

using namespace std;

int main()
{
    ll n, b, f, r, v;

    cin >> n;

    ll record[4][3][10] = {0};

    // calculation
    while (cin >> b >> f >> r >> v)
    {
        record[b-1][f-1][r-1] += v;
    }

    // output
    for (ll k=0; k<4; k++)
    {
        for (ll j=0; j<3; j++)
        {
            for (ll i=0; i<10; i++)
            {
                printf(" %lld", record[k][j][i]);
            }
            cout << endl;
        }
        if (k != 3)
            cout << "####################" << endl;
    }

    return 0;
}



Measured memory_bytes: 3224
N, C, K = map(int, input().split())
T = []
for _ in range(N):
    T.append(int(input()))
T = sorted(T)

ans = 0
c = 0
s = 0

for t in T:
    if (s != 0) and (s + K < t):
        s = 0
        c = 0
        ans += 1

    if s == 0:
        s = t
    c += 1

    if c == C:
        s = 0
        c = 0
        ans += 1
    #print(t, s, c, ans)

if s != 0:
    ans += 1

print(ans)

Measured memory_bytes: 8280
N,M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()

d = []
tmp = X[0]
for i in range(M):
    d.append((i,X[i]-tmp))
    tmp = X[i]

d.sort(key=lambda x: x[1],reverse = True)
sumd = 0
for i in range(N-1,M):
    sumd = d[i][1] + sumd
print(sumd)




Measured memory_bytes: 59176
using System;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            int cost = 0;
            string[] 　tmp = Console.ReadLine().Split(' ');
            int[] a_list = tmp.Select(s => int.Parse(s)).ToArray();
            Array.Sort(a_list);

            int before = a_list[0];

            for (int i=1; i<a_list.Length; i++)
            {
                cost += (a_list[i] - before);
                before = a_list[i];
            }

            Console.WriteLine(cost);
        }



    }
}


Measured memory_bytes: 13396
class UnionFind:
    def __init__(self, N):
        self._size = [1] * N
        self._rank = [0] * N
        self._parent = [i for i in xrange(N)]

    def root(self, x):
        if self._parent[x] == x:
            return x
        else:
            self._parent[x] = self.root(self._parent[x])
            return self._parent[x]

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y: return 
        if self._rank[x] < self._rank[y]:
            self._parent[x] = y
            self._size[y] += self._size[x]
        else:
            self._parent[y] = x
            self._size[x] += self._size[y]
            if self._rank[x] == self._rank[y]: self._rank[x] += 1


N, M = map(int, raw_input().split())
A = list()
B = list()
for i in xrange(M):
    a, b = map(int, raw_input().split())
    A.append(a-1)
    B.append(b-1)

result = [0]*M
result[-1] = N*(N-1) // 2

unf = UnionFind(N)

for i in xrange(M-1):
    idx = -i-1
    if unf.same(A[idx], B[idx]):
        result[idx-1] = result[idx]
    else:
        snsn = unf._size[unf.root(A[idx])] * unf._size[unf.root(B[idx])]
        result[idx-1] = result[idx] - snsn
        unf.unite(A[idx], B[idx])

for i in xrange(M):
    print result[i]




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

const int INF = 1<<28;

int main() {
  string s;
  cin >> s;
  int N = s.size();

  vector<int> h(N+1, 20000);
  for(int i = 0; i < N; ++i) {
    if(s[i] == '/') h[i+1] = h[i] + 1;
    else if(s[i] == '\\') h[i+1] = h[i] - 1;
    else h[i+1] = h[i];
  }

  vector<vector<int> > f(40002);
  for(int i = 0; i < h.size(); ++i) f[h[i]].push_back(i);

  vector<int> used(N+1, 0);
  vector<int> v(N+1, 0);
  for(int y = (int)f.size()-1; y >= 0; --y) {
    for(int i = 0; i+1 < f[y].size(); ++i) {
      int x = f[y][i];
      int nx = f[y][i+1];
      if(!used[x] && s[x] == '\\') {
	int tmp = 0;
	for(int j = x, k = 0; j < nx; ++j) {
	  used[j] = true;
	  int add = k * 2;
	  if(s[j] == '\\') {
	    ++k;
	    ++add;
	  } else if(s[j] == '/') {
	    --k;
	    --add;
	  }
	  tmp += add;
	}
	tmp /= 2;
	v[x] = tmp;
      }
    }
  }

  int sum = 0;
  vector<int> ans;
  for(int i = 0; i < v.size(); ++i) {
    if(v[i]) {
      sum += v[i];
      ans.push_back(v[i]);
    }
  }
  cout << sum << endl;
  cout << ans.size();
  for(int i = 0; i < ans.size(); ++i) cout << " " << ans[i];
  cout << endl;

  return 0;
}

Measured memory_bytes: 2988
/**
 *	@file: C.cpp
 *	@author: Huy Le
 *	@created: 08-03-2020 08:24:59
**/


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

//***---***---***---***---***---***---BEGIN USELESS CODE---***---***---***---***---***---***//

#define ll long long
#define ld long double
const char newl = '\n';

template<class T> void read(vector<T>& vt);
template<class T>
void read(T& args) { cin >> args; }
template<class A, class... B >
void read(A& argc, B&... argv) {
	read(argc);
	read(argv...);
}
template<class T>
void read(vector<T>& vt) {
	for(auto &a : vt)
		read(a);
}

string to_string(bool bo) { return (bo ? "true" : "false"); }
string to_string(char c) { return string(1, c); }
string to_string(const char* str) { return string(str);}
string to_string(string str) { return str; }
template<class T>
string to_string(T vt) {
	bool ft = 1;
	string res;
	for(auto &a : vt) {
		if(!ft)
			res += ' ';
		ft = 0;
		res += to_string(a);
	}
	return res;
}
string to_string(vector<bool> vt) {
	string res;
	bool ft = 1;
	for(int i = 0; i < (int)vt.size(); ++i) {
		if(!ft)
			res += ' ';
		ft = 0;
		res += char('0' + vt[i]);
	}
	return res;
}

template<class T>
void write(T args) { cout << to_string(args); }
template<class A, class... B>
void write(const A argc, const B... argv) {
	write(argc);
	write(argv...);
}

void print() { write(newl); }
template<class A, class... B>
void print(const A argc, const B... argv) {
	write(argc);
	if(sizeof...(argv))
		write(' ');
	print(argv...);
}

void DEBUGLOCAL() { cerr << ")" << newl; }
template<class A, class... B> 
void DEBUGLOCAL(A argc, B... argv) {
	cerr << to_string(argc);
	if(sizeof...(argv))
		cerr << ", ";
	DEBUGLOCAL(argv...);
}
#ifdef _DEBUG
#define dbg(...) cerr << "LINE(" << __LINE__ << ") [" << __FUNCTION__ << "] -> (" << #__VA_ARGS__ << "): (",DEBUGLOCAL(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

//***---***---***---***---***---***---END USELESS CODE---***---***---***---***---***---***//

int ts;
int n,m;
vector<int> c;
vector<vector<pair<int,int>>> q;
vector<int> ans, cnt;
vector<int> BIT;

void update(int ind, int value) {
	++ind;
	for(; ind <= n; ind += ind&-ind)
		BIT[ind] += value;
}

int query(int ind) {
	++ind;
	int sum  = 0;
	for(; ind > 0; ind -= ind&-ind)
		sum += BIT[ind];
	return sum;
}

void solve() {
	read(n,m);
	c = vector<int>(n);
	q = vector<vector<pair<int,int>>>(n);
	BIT = vector<int>(n + 1);
	read(c);
	for(int i = 0; i < m; ++i) {
		int x,y;
		read(x,y);
		--x;
		--y;
		q[y].push_back({x, i});
	}
	ans = vector<int>(m);
	cnt = vector<int>(n, -1);
	map<int,int> mp;
	for(int i = 0; i < n; ++i) {
		if(mp.find(c[i]) != mp.end())
			update(mp[c[i]], -1);
		update(i, 1);
		for(auto a : q[i]) {
			ans[a.second] = query(i) - query(a.first - 1);
		}
		mp[c[i]] = i;
	}
	print(ans);
}

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

	//read(ts);
	//while(ts--)
		solve();
}


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

signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n; cin >> n;
  if (n == 3) {
    cout << "2 5 63" << "\n";
    return 0;
  }
  vector<int> r;
  for (int i = 1; i < 15; i++) {
    if (i % 2 == 0 or i % 3 == 0 or i % 5 ==0) {
      r.push_back(i);
      r.push_back(30 - i);
    }
  }
  int res[n];
  int i = 0;
  while (i < n - n % 2) {
    res[i] = 30 * (i / 20) + r[i % 20];
    i++;
  }
  if (n % 2) res[n - 1] = 30;
  for (int i = 0; i < n; i++) cout << res[i] << " ";
  cout << "\n";
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

int n,C;
int d[50][50],c[510][510];

int solve(int x,int y){//(i+j)==xをcで塗る
    int res=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if((i+j)%3==x){
                res+=d[c[i][j]][y];
            }
        }
    }
    return res;
}

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

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

    int cost[3][50];
    for(int i=0;i<3;i++){
        for(int j=0;j<C;j++){
            cost[i][j]=solve(i,j);
        }
    }
    int ans=INF;
    for(int i=0;i<C;i++){
        for(int j=0;j<C;j++){
            for(int k=0;k<C;k++){
                if(i==j || j==k || k==i)continue;
                ans=min(ans,cost[0][i]+cost[1][j]+cost[2][k]);
            }
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 1280
#include<cstdio>
#include<cctype>
#include<vector>
inline int getint() {
	register char ch;
	while(!isdigit(ch=getchar()));
	register int x=ch^'0';
	while(isdigit(ch=getchar())) x=(((x<<2)+x)<<1)+(ch^'0');
	return x;
}
const int N=1e5+1;
std::vector<int> e[N];
inline void add_edge(const int &u,const int &v) {
	e[u].push_back(v);
	e[v].push_back(u);
}
int dfs(const int &x,const int &par) {
	int sg=0;
	for(auto &y:e[x]) {
		if(y==par) continue;
		sg^=dfs(y,x)+1;
	}
	return sg;
}
int main() {
	const int n=getint();
	for(register int i=1;i<n;i++) {
		add_edge(getint(),getint());
	}
	puts(dfs(1,0)?"Alice":"Bob");
	return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  if (n%2)
    n *= 2;
  cout << n << endl;
  return 0;
}

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

int main() {
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << x2 - (y2 - y1) << " " << y2 + (x2 - x1) << " " << x1 - (y2 - y1) << " " << y1 + (x2 - x1) << endl;
    return 0;
}


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

int n,k,arr[1000010];

int main()
{
    scanf("%d%d",&n,&k);

    for(int i=0;i<n;i++) scanf("%d",&arr[i]);
    if(n==2 && k==1)
    {
        printf("1\n");
        return 0;
    }
    int cnt = 0;
    int N = n;
    while(N>0)
    {
        N = N-k;
        cnt++;
        if(!N) break;
        N++;
        //

        //cout << N << " " << cnt << endl;
    }
    //if(n%k==0) cnt--;
    printf("%d\n",cnt);

    return 0;
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

int main() {
  bool can = true;
  int a, b, c, x, y;
  cin >> a >> b >> c;
  x = a - b;
  y = b - c;
  for (int i = 0; i < 2; i++) {
    cin >> a >> b >> c;
    if (x != a - b || y != b - c) can = false;
  }
  cout << ((can) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	string s;
	cin >> s;
	cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int r=nxt();
    cout<<3*r*r<<endl;
    
    
    return 0;   
}


 
 


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define yes "Yes\n"
#define no "No\n"
//int m,n;
//int i,j,k,l;
//int a,b,c,d,e,f,g;
//int sum,total;
//long long int ;
//float ;
//double ;
//char a[101],b[101],s[101],t[101],u[101];
int m,i,j,k,n;
char s[101];
int main(void){
    scanf("%d %s",&n,s);
    if (n%2==1)
        {
            printf(no);
            return 0;
    }
    for (size_t i = 0; i < n/2; i++)
    {
        if (s[i]==s[i+n/2])
        {
            k++;
        }    
    }
    if (k==n/2)
    {
        printf(yes);
        return 0;
    }
    printf (no);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector> 
#include <cmath>
#include <sstream>
#include <string>
#include <algorithm>

int main(){
  long long N;
  std::cin >> N;
  std::vector<long long> A(N);
  std::vector<long long> B(N);
  std::vector<long long> C(N);
  for(int i = 0 ; i < N ; i++){
    std::cin >> A[i];
  }
  for(int i = 0 ; i < N ; i++){
    std::cin >> B[i];
  }
  for(int i = 0 ; i < N ; i++){
    std::cin >> C[i];
  }

  std::sort(A.begin(), A.end());
  std::sort(B.begin(), B.end());
  std::sort(C.begin(), C.end());
  
  long long Count = 0;
  for(int i = 0 ; i < N ; i++){
    long long P = std::lower_bound(A.begin(), A.end(), B[i]) - A.begin();
    long long Q = C.end() - std::upper_bound(C.begin(), C.end(), B[i]) ;
    Count += P * Q;
  }

  std::cout << Count << std::endl;
  return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>

int main(){
	int x,a,b;
	scanf("%d %d %d",&x,&a,&b);
	int dis_a=x-a;
	int dis_b=x-b;
	if(dis_a<0){
		dis_a*=-1;
	}
	if(dis_b<0){
		dis_b*=-1;
	}
	if(dis_a>dis_b){
		printf("B");
	}
	else if (dis_a<dis_b){
		printf("A");
	}
	return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>
#include <ctype.h>

int main()
{
 int i,dem[26]={};
  char array[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
 char c;
while(scanf("%c",&c)!=EOF){
  c = tolower(c);
 for(i=0;i<26;i++)
 {if (c==array[i]) dem[i]++;}
}
for (i = 0; i < 26; i++)
    printf("%c : %d\n", 'a' + i, dem[i]);
 return 0;
}

Measured memory_bytes: 544
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))


a=ns()
print('A' if a.isupper() else 'a')



Measured memory_bytes: 72728
#include <bits/stdc++.h>
using namespace std;
long myPow(long x, long n, long m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}
int main(){
   long long n, i, ans=1, max=-1;
   map<long long, long long> cnt;
   cin >> n;
   for(i=0;i<n;i++){
       long long tmp;
       cin >> tmp;
       if(i==0 && tmp!=0) ans=0;
       if(tmp>max) max=tmp;
       cnt[tmp]++;
   }
   if(ans==0){
       cout << ans <<endl;
       return 0;
   }
   else if(cnt[0]>=2) ans=0;
   else{
       for(i=2;i<=max;i++){
        ans=ans*myPow(cnt[i-1], cnt[i], 998244353);
        ans=ans%998244353;
       }
   }
   cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
int min(int a, int b){
    if(a>b)
	return b;
    return a;
}



int main(){
    int n;
    cin>>n;
	
    int tot=0,ab=0,a=0,b=0;
    while(n--){
	string s;
	cin>>s;
	for(int i=0;i+1<s.size();i++){
	    if(s[i]=='A' && s[i+1]=='B')
		++tot;
	}
	if(s[0]=='B' && s[s.size()-1]=='A')
	    ++ab;
	if(s[0]=='B' && s[s.size()-1]!='A')
	    ++b;
	if(s[0]!='B' && s[s.size()-1]=='A')
	    ++a;
    }
//    cout<<a<<" "<<b<<" "<<ab<<" "<<tot<<endl;
    int r=0;
    if(ab==0){
	r = min(a,b);
	//	cout<<"roo";
    }else{
	if(a+b==0){
	    r=ab-1;
	//    cout<<"2ooo";
	}else{
	    r= ab + min(a,b);
//	    cout<<ab<<" "<<min(a,b)<<endl;	 
	}
    }
    r+=tot;
    cout<<r<<endl;
}

	


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc084/tasks/abc084_a

"""
import sys
from sys import stdin
input = stdin.readline


def solve(M):
    return (24 - M) + 24


def main(args):
    M = int(input())
    ans = solve(M)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
    


Measured memory_bytes: 2940
N = int(input())
n, p, score = N, 2, 0
while p ** 2 <= N:
  e = 1
  while n >= (p ** e) and n % (p ** e) == 0:
    n //= (p ** e)
    score += 1
    e += 1
  else:
    while n >= p and n % p == 0:
      n //= p
    p = p + 1 if p == 2 else p + 2
else:
  if n != 1:
    score += 1
print(score)

Measured memory_bytes: 9140
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
#define _(_1,_2,_3,N,...)N
#define pr(...) _(__VA_ARGS__,pr3,pr2,pr1)(__VA_ARGS__)
template<C T>void pr1(T a){cout<<a;ln;}
template<C T,C T2>void pr2(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr3(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

string S(ll n) {
  stringstream ss;string s;
  ss << n;ss >> s;
  return s;
}
ll N(string s) {
  stringstream ss;ll n;
  ss << s;ss >> n;
  return n;
}
string CZ(string s) {
  int i;
  for(i=0; i<s.size()-1; i++)if(s[i]!='0')break;
  return s.substr(i);
}
string ADD(string s, string t) {
  if(s.size()<t.size()) swap(s,t);
  s='0'+s;
  while(s.size()>t.size()) t='0'+t;
  int c=0;
  rrep(i,s.size()) {
    if(c) {
      if(s[i]=='9') {
        s[i]='0';
        c=1;
      } else {
        s[i]=(char)(s[i]+1);
        c=0;
      }
    }
    int sum=(int)s[i]+(int)t[i]-'0'*2;
    if(sum>=10) {
      s[i]=(char)(sum-10+'0');
      c=1;
    } else s[i]=(char)(sum+'0');
  }
  return CZ(s);
}
void Main() {
  int n;
  R n;
  while(n--) {
    string s,t;
    cin >> s >> t;
    s=ADD(s,t);
    if(s.size()>80) pr("overflow");
    else pr(s);
  }
}

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


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

//?????????(1,1),?????????(i,j)??¨????????????????????????JOI?????°
int dp[1001][1001][3]={0};

int main()
{
    string joi="JOI";
    int m,n,q;
    cin >>m >>n >>q;

    vector<string> f(m);
    rep(i,m) cin >>f[i];

    for(int i=1; i<=m; ++i)rep(j,3)
    {
        dp[i][1][j]=dp[i-1][1][j];
        if(f[i-1][0]==joi[j]) ++dp[i][1][j];
    }
    for(int i=1; i<=n; ++i)rep(j,3)
    {
        dp[1][i][j]=dp[1][i-1][j];
        if(f[0][i-1]==joi[j]) ++dp[1][i][j];
    }

    for(int i=2; i<=m; ++i)for(int j=2; j<=n; ++j)rep(k,3)
    {
        dp[i][j][k]=dp[i-1][j][k]+dp[i][j-1][k]-dp[i-1][j-1][k];
        if(f[i-1][j-1]==joi[k]) ++dp[i][j][k];
    }

    rep(Q,q)
    {
        int a,b,c,d;
        scanf(" %d %d %d %d", &a, &b, &c, &d);
        rep(i,3)
        {
            if(i)printf(" ");
            printf("%d", dp[c][d][i]-dp[a-1][d][i]-dp[c][b-1][i]+dp[a-1][b-1][i]);
        }
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 15616
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var X = long.Parse(Console.ReadLine());
            var result = 0;
            var amount = 100L;
            while (amount < X)
            {
                amount += amount / 100;
                result++;
            }
            Console.WriteLine(result);
        }
    }
}


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


void solve()
{
 int l,r,d;
    cin>>l>>r>>d;
  //  cout<<l<<" "<<r<<" "<<d<<" ";
    if(l>r)
        swap(l,r);
    int ans=(r/d)-(l/d);
    if(l%d==0)ans++;
    
    cout<<ans;
}


int main()
{
 ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int t=1;
   // cin>>t;
    while(t--)
        solve();
}

Measured memory_bytes: 3652