akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

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 max = 0;
        int max2 = 0;
        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
            if(a[i] > max){
                max2 = max;
                max = a[i];
            }else if(a[i] > max2){
                max2 = a[i];
            }
        }

        int half = 0, half2 = 0;
        int dif = Integer.MAX_VALUE, dif2 = Integer.MAX_VALUE;
        int mid = max / 2;

        for(int i=0; i<n; i++){
            int mdif = Math.abs(a[i] - mid);
            if(mdif < dif){
                half2 = half;
                half = a[i];
                dif2 = dif;
                dif = mdif;
            }else if(mdif < dif2){
                half2 = a[i];
                dif2 = mdif;
            }
        }

        if(max == half){
            System.out.println(max + " " + half2);
        }else{
            System.out.println(max + " " + half);
        }

    }
}

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

#define ll long long
#define endl "\n"

int main ()
{
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #define int ll
	
	int x, n;
	cin >> x >> n;

	bool taken[202];
	memset(taken, false, sizeof(taken));
	for (int i=1; i<=n; i++){
		int a;
		cin >> a;
		taken[a] = true;
	}
	
	for (int i=0; i<=100; i++){
		if (taken[x - i] == false){
			cout << x-i << endl;
			return 0;
		}
		if (taken[x+i] == false){
			cout << x+i << endl;
			return 0;
		}
	}

	return 0;
}

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

using namespace std;

typedef queue<char> Q;

int main(){
	string alice,bob,charlie;
	cin >> alice >> bob >> charlie;

	//Step 1: safe each deck of cards in a queue

	Q a;
	for(int i=0;i<alice.size();++i){
		a.push(alice[i]);
	}
	Q b;
	for(int i=0;i<bob.size();++i){
		b.push(bob[i]);
	}
	Q c;
	for (int i=0;i<charlie.size();++i){
		c.push(charlie[i]);
	}

	//Step 2: take card from decks until one of them is empty
	char init = 'a';
	string ans = "A";
	while(true){
		if(init=='a' && !a.empty()){
		    //cout << "init a no empty " << endl;
			init = a.front();
			a.pop();
		}
		else if(init=='a' && a.empty()){
		    //cout << "init a empty " << endl;
			ans = "A";
			break;
		}
		else if(init=='b' && !b.empty()){
		    //cout << "init b no empty " << endl;
			init = b.front();
			b.pop();
		}
		else if(init=='b' && b.empty()){
		    //cout << "init b empty " << endl;
			ans = "B";
			break;
		}
		else if(init=='c' && !c.empty()){
		    //cout << "init c no empty " << endl;
			init = c.front();
			c.pop();
		}
		else if(init=='c' && c.empty()){
		    //cout << "init c empty " << endl;
			ans = "C";
			break;
		}
	}

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

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
	
		MyScanner sc = new MyScanner();
		int w =sc.nextInt();
		int h=sc.nextInt();
		int n=sc.nextInt();
		int x[]=new int[n];
		int y[]=new int[n];
		int a[]=new int[n];
		int x_l=w;
		int x_r=0;
		int y_b=h;
		int y_t=0;
		for(int i=0;i<n;i++) {
			x[i]=sc.nextInt();
			y[i]=sc.nextInt();
			a[i]=sc.nextInt();
			switch(a[i]) {
				case(1):
						if(x[i]>x_r) {
							x_r=x[i];
						}			
						break;
			
				case(2):
						if(x[i]<x_l) {
							x_l=x[i];
						}
						break;
			
				case(3):
						if(y[i]>y_t){
							y_t=y[i];
						}
						break;
			
				case(4):
						if(y[i]<y_b) {
							y_b=y[i];
						}
						break;
		
			}
		}
		
		int ans=0;
		if(!(y_t>=y_b||x_l<=x_r)) {
			ans=(x_l-x_r)*(y_b-y_t);
		}
		
		
		System.out.println(ans);
		
		}
	
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	

}





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

int main() {
  vector<char>vec(4);
  cin  >> vec[0] >> vec[1] >> vec[2] >> vec[3];
  sort(vec.begin(),vec.end());
  if(vec[0] == vec[1] && vec[1] != vec[2] && vec[2] == vec[3]){
    cout << "Yes" << endl;
    return 0;
  }
  else{
    cout  << "No" << endl;
  }
}


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

int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  
  int cost1 = A * X + B * Y;
  int cost2 = 2 * C * max(X, Y);
  int cost3;
  if (X > Y) {
    cost3 = 2 * C * Y + A * (X - Y);
  } else {
    cost3 = 2 * C * X + B * (Y - X);
  }
  if (cost1 >= cost2) {
    if (cost2 >= cost3) {
      cout << cost3 << endl;
    } else {
      cout << cost2 << endl;
    }
  } else {
    if (cost1 >= cost3) {
      cout << cost3 << endl;
    } else {
      cout << cost1 << endl;
    }
  } 
}


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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

#define ST 10000000000000000
int	main() {
	long K;
	cin >>K;
	if (0==K) {
		cout <<2 <<endl;
		cout <<"1 1" <<endl;
		return 0;
	}
	long N, D, SS;
	SS=ST;
	N=K/SS;
	D=K%SS;
	if (0!=D)
		N++;
	if (N==1)
		N++;
	SS=K/N;
	if (K%N>0)
		SS++;
	D=N*SS-K;
	vector<long> a(N, SS+N-1);
	for (int i=0; i<N; i++) {
		if (D>i) {
			a.at(i) -=N+1;
		}
		a.at(i)+=D;
	}
	cout <<N <<endl;
	for (int i=0; i<N; i++)
		cout <<a.at(i) << ' ';
	cout <<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1100000000

struct point{
	long long x,y;
	pair<long long,long long> d;
	char c;
	point(){
	}
	point(long long X,long long Y,char C){
		x=X,y=Y,c=C;
		if(c=='R')d = {1,0};
		if(c=='L')d = {-1,0};
		if(c=='U')d = {0,1};
		if(c=='D')d = {0,-1};
	}
	
	long long get_cross_time(point P){
		if(d==P.d)return -1;
		if(d.first*P.d.first==-1){
			return abs(x-P.x)/2;
		}
		if(d.second*P.d.second==-1){
			return abs(y-P.y)/2;
		}
		if(P.d.first!=0){
			return (x-P.x)/P.d.first;
		}
		else{
			return (y-P.y)/P.d.second;
		}
	}
	
	pair<long long,long long> get(long long t){
		return {x+d.first*t,y+d.second*t};
	}
	
};

void Assign(map<char,long long> &mp,char c,long long v,bool f){
	if(mp.count(c)){
		if(f){
			mp[c] = max(mp[c],v);
		}
		else{
			mp[c] = min(mp[c],v);
		}
	}
	else{
		mp[c] = v;
	}
}

bool check(map<char,long long> &mp,char c,long long v){
	if(!mp.count(c))return false;
	if(mp[c]==v){
		mp.erase(c);
		return true;
	}
	else{
		return false;
	}
}

int main(){
	
	vector<point> P;
	int N;
	cin>>N;
	
	for(int i=0;i<N;i++){
		long long x,y;
		cin>>x>>y;
		x*=2,y*=2;
		char d;
		cin>>d;
		P.push_back(point(x,y,d));
	}
	
	map<char,long long> min_x,min_y,max_x,max_y;
	
	for(int i=0;i<P.size();i++){
		Assign(min_x,P[i].c,P[i].x,false);
		Assign(max_x,P[i].c,P[i].x,true);
		Assign(min_y,P[i].c,P[i].y,false);
		Assign(max_y,P[i].c,P[i].y,true);
	}
	
	{
		vector<point> Q;
		for(int i=0;i<P.size();i++){
			if(check(min_x,P[i].c,P[i].x)){
				Q.push_back(P[i]);
				continue;
			}
			if(check(max_x,P[i].c,P[i].x)){
				Q.push_back(P[i]);
				continue;
			}
			if(check(min_y,P[i].c,P[i].y)){
				Q.push_back(P[i]);
				continue;
			}
			if(check(max_y,P[i].c,P[i].y)){
				Q.push_back(P[i]);
				continue;
			}
		}
		
		P = Q;
	}

	vector<long long> T(1,0LL);
	
	for(int i=0;i<P.size();i++){
		for(int j=0;j<P.size();j++){
			long long t = P[i].get_cross_time(P[j]);
			if(t<=-1)continue;
			T.push_back(t);
		}
	}
	
	long long ans = (long long)Inf*Inf;
	
	for(int i=0;i<T.size();i++){
		long long mx=Inf,my=Inf,Mx=-Inf,My=-Inf;
		for(int j=0;j<P.size();j++){
			pair<long long,long long> ret = P[j].get(T[i]);
			mx = min(mx,ret.first);
			Mx = max(Mx,ret.first);
			my = min(my,ret.second);
			My = max(My,ret.second);
		}
		ans = min(ans,(Mx-mx)*(My-my));
	}
	
	cout<<fixed<<setprecision(10)<<(double)ans/4.0<<endl;
	
	return 0;
}

Measured memory_bytes: 7536
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mpr make_pair
#define fi first
#define se second
using ll=long long int;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main(){
	int a;
	cin>>a;
	cout<<3*a*a<<endl;
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << __LINE__ << ' ' << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
template<class T> using pque = priority_queue<T, vector<T>, greater<T>>;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr int mod1e9 = 1000000007;
constexpr int mod998 = 998244353;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
constexpr ll ten(int n) { return n ? 10 * ten(n - 1) : 1; };
int dx[] = { 1,0,-1,0,1,1,-1,-1 }; int dy[] = { 0,1,0,-1,1,-1,1,-1 };
void fail() { cout << "-1\n"; exit(0); }
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }
template<class T> istream &operator >> (istream &s, vector<T> &v) { for (auto &e : v) s >> e; return s; }
template<class T> ostream &operator << (ostream &s, const vector<T> &v) { for (auto &e : v) s << e << ' '; return s; }

struct fastio {
	fastio() {
		cin.tie(0); cout.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(20);
		cerr << fixed << setprecision(20);
	}
}fastio_;

constexpr ll mod = mod1e9;

ll modpow(ll a, ll b, ll m = mod) {
	ll ans = 1;
	a %= m;
	while (b) {
		if (b & 1) ans = ans * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return ans;
}

int main() {
	ll n;
	cin >> n;
	cout << ((modpow(10, n) - modpow(9, n) * 2 + modpow(8, n)) % mod + mod) % mod << '\n';
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
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; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int n,m;
vector<string> s,t;

void input(){
    cin >> n;
    s.resize(n);
    for(int i=0;i<n;i++) cin >> s[i];
    cin >> m;
    t.resize(m);
    for(int i=0;i<m;i++) cin >> t[i];
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    map<string, int> cnt;
    for(int i=0;i<s.size();i++) cnt[s[i]]++;
    for(int i=0;i<t.size();i++) cnt[t[i]]--;
    int ans = 0;
    for(auto p : cnt){
        ans = max(ans, p.second);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
using namespace std;
int main()
{
    long long l,r;
    cin>>l>>r;
    long long ans = INT_MAX;
    for(long long i=l;i<=min(l+2019,r);++i)
    {
        for(long long j=i+1;j<=min(l+2019,r);++j)
        {
            ans = min(ans,i%2019*j%2019%2019);
        }
    }
    cout<<ans;
}

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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
template <class T>
T GCD(T a, T b)
{
  T r;
  while (a)
    r = b, b = a, a = r % a;
  return b;
}
template <class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repd(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
}

int ans = 0;
bool check = 0;
string s, t;
int N = 3;
vector<int> v(N);
int a, b, c, d, n;
int x, y;
char ch;

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  char a, b;
  cin >> a >> b;
  if (a == 'H' && b == 'H')
    cout << 'H';
  if (a == 'H' && b == 'D')
    cout << 'D';
  if (a == 'D' && b == 'H')
    cout << 'D';
  if (a == 'D' && b == 'D')
    cout << 'H';
  return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
int main(){
  string s;
  cin >> s;
  string t;
  cin >> t;
  int ans = 0;
  for(int i = 0;i < 3;i++){
    if(t[i] == s[i])ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    vector<int> S1(N, -INF);
    vector<int> S2(N, -INF);
    S1[0] = A[0];
    S2[N-1] = A[N-1];

    for (int i = 1; i < N; i++) S1[i] = max(S1[i-1], A[i]);
    for (int i = N - 2; i >= 0; i--) S2[i] = max(S2[i+1], A[i]);

    for (int i = 0; i < N; i++) {
        int ret = -INF;
        if (i > 0) ret = max(ret, S1[i-1]);
        if (i < N - 1) ret = max(ret, S2[i+1]);
        cout << ret << endl;
    }

    return 0;
}

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

vector<int> edges[210000];

int main(){
    string str;
    cin >> str;
    int cur = 0;

    map<int,int> dist;

    dist[0] = 0;
    for(int i = 0; i < str.size(); i++){
        int a = str[i] - 'a';
        cur ^= (1 << a);

        if(dist.find(cur) == dist.end()){
            dist[cur] = 1e7;
        }
        for(int j = 0; j < 26; j++){
            int c = cur ^ (1<<j);
            if(dist.find(c) == dist.end()) continue;
            dist[cur] = min(dist[cur], dist[c] + 1);
        }
    }
    cout << max(dist[cur], 1) << endl;

    /*int c = 0;
    for(map<int,int>::iterator it = z.begin(); it != z.end(); it++){
        f[it->first] = c;
        c++;
    }
    for(map<int,int>::iterator it = z.begin(); it != z.end(); it++){
        int num = it->first;
        for(int j = 0; j < 26; j++){
            int num2 = num ^ (1<<j);
            if(z.find(num2) == z.end()) continue;
            //cout << num << " " << num2 << endl;
            edges[f[num]].push_back(f[num2]);
            edges[f[num2]].push_back(f[num]);
        }
    }
    int dist[c];
    int vis[c];
    for(LL i = 0; i < c; i++){
        dist[i] = 1e7;
        vis[i] = 0;
    }
    dist[f[0]] = 0;
    set<pair<LL,LL> > curset;
    for(LL i = 0; i < c; i++){
        curset.insert(make_pair(dist[i], i));
    }

    while(!curset.empty()){
        pair<LL,LL> v = *curset.begin();
        curset.erase(curset.begin());
        LL a = v.second;
        vis[a] = 1;
        for(int i = 0; i < edges[a].size(); i++){
            LL b = edges[a][i];
            if(vis[b]) continue;
            if(1 + dist[a] < dist[b]){
                curset.erase(make_pair(dist[b], b));
                dist[b] = dist[a] + 1;
                curset.insert(make_pair(dist[b], b));
            }
        }
    }

    cout << max(1, dist[f[cur]]) << endl;*/
}


Measured memory_bytes: 14724
#include<bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
typedef pair<int, int>P;
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 5000100;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll dp[101010];

//union-find木について
ll par[101010];
ll rank2[101010];

void init(ll n) {
	rep(i, n) {
		par[i] = i;
		rank2[i] = 0;
	}
}

ll find(ll x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

void unite(ll x, ll y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rank2[x] < rank2[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rank2[x] == rank2[y]) {
			rank2[x]++;
		}
	}
}

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

//long longしか使わない
//素数は1より大きい
int main() {
	ll n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	ll res = 0;
	rep(i, n - 1) {
		if (s[i] == s[i + 1])res++;
	}
	ll ans = min(res + 2 * k, n - 1);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input():
    return sys.stdin.readline().rstrip()

def main():
    K,X=map(int,input().split())
    if K*500>=X:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
from collections import defaultdict
from itertools import permutations

n, c = map(int, input().split())
d = [list(map(int, input().split())) for _ in range(c)]
cmat = [list(map(int, input().split())) for _ in range(n)]

dcnt = [defaultdict(int) for _ in range(3)]
for i, ci in enumerate(cmat, 1):
    for j, cij in enumerate(ci, 1):
        mod = (i + j) % 3
        dcnt[mod][cij - 1] += 1

ans = 1000 * n ** 2
for color in permutations(range(c), 3):
    tmp = 0
    for i, cnt in enumerate(dcnt):
        tmp += sum(d[k][color[i]] * cnt[k] for k in cnt)
    ans = min(ans, tmp)
print(ans)


Measured memory_bytes: 77348
#include<iostream>

using namespace std;

int main(void) {

	char a[52], ans[52] = {};
	int num[52], n, i, j, k = 0;

	cin >> n;

	for (int i = 0; i < n; i++) {

		cin >> a[i] >> num[i];

		if (a[i] == 'S') {
			//4n-4
			ans[4 * num[i] - 4] = 1;
		}

		else if (a[i] == 'H') {
			//4n-3
			ans[4 * num[i] - 3] = 1;

		}

		else if (a[i] == 'C') {
			//4n-2
			ans[4 * num[i] - 2] = 1;

		}

		else if (a[i] == 'D') {
			//4n-1
			ans[4 * num[i] - 1] = 1;

		}
	}



	for (int i = 1; i <= 13; i++) {

		if (ans[4 * i - 4] == 0)
			cout << 'S' << " " << i << endl;
	}

	for (int i = 1; i <= 13; i++) {

		if (ans[4 * i - 3] == 0)
			cout << 'H' << " " << i << endl;
	}

	for (int i = 1; i <= 13; i++) {

		if (ans[4 * i - 2] == 0)
			cout << 'C' << " " << i << endl;

	}

	for (int i = 1; i <= 13; i++) {

		if (ans[4 * i - 1] == 0)
			cout << 'D' << " " << i << endl;

	}

}

Measured memory_bytes: 3096
import math
import itertools
import statistics
#import collections
n, a, b = list(map(int, input().split()))
x = list(map(int, input().split()))

total = 0
for i in range(n-1):
    if (x[i+1]-x[i])*a < b:
        total += (x[i+1]-x[i])*a
    else:
        total += b

print(total)



Measured memory_bytes: 16340
#include <iostream>
#include <string>

using namespace std;

int main() {
    string weather;
    cin >> weather;

    if (weather == "Sunny")
        cout << "Cloudy" << endl;
    else if (weather == "Cloudy")
        cout << "Rainy" << endl;
    else
        cout << "Sunny" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
    int64_t a, b, c;
    cin >> a >> b >> c;

    if (c <= a + b) {
        cout << b + c << endl;
    } else {
        cout << b + (a + b + 1) << endl;
    }
}

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

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  int k;
  cin >> k;

  int g[300][300];
  for (int i = 1; i < 300; ++i)
    for (int j = 1; j < 300; ++j)
      g[i][j] = __gcd(i, j); 

  long long ans = 0;
  for (int i = 1; i <= k; ++i)
    for (int j = 1; j <= k; ++j)
      for (int l = 1; l <= k; ++l)
        ans += g[i][g[j][l]];


  cout << ans << '\n';
}

Measured memory_bytes: 4004
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

#define REP(i,x) for(int i=0 ; i<(int)(x) ; i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int N;
int Z, W;
vector<int> A;

int memo[2][2005];

int rec(int turn, int idx){
  if(memo[turn][idx]!=-1)return memo[turn][idx];
  int opp = idx==0 ? W : A[idx-1];
  int res = abs(opp-A[N-1]);
  vector<int> hoge;
  for(int i=idx; i<N-1; i++){
    int tmp = rec(1-turn, i+1);
    hoge.push_back(tmp);
    if(turn==0){
      res = max(res, tmp);
    } else {
      res = min(res, tmp);
    }
  }
  return memo[turn][idx] = res;
}

int main(){
  memset(memo, -1, sizeof(memo));
  cin >> N >> Z >> W;
  A.resize(N);
  REP(i, N)cin >> A[i];
  cout << rec(0, 0) << endl;
}


Measured memory_bytes: 512
n,*ab = map(int,open(0).read().split())
a = sorted(ab[::2])
b = sorted(ab[1::2])
m = (n-1)//2
if n % 2 == 0:
  print(b[m]-a[m]+b[m+1]-a[m+1]+1)
else:
  print(b[m]-a[m]+1)

Measured memory_bytes: 55240
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include <math.h> 

using namespace std;

int main(void)
{
	int N;

	cin >> N;
	bool flag = false;
	int temp = N;


	int ones = temp % 10;
	temp = temp / 10;
	int tens = temp % 10;
	temp = temp / 10;
	int hundreds = temp % 10;

	if (hundreds >= ones && hundreds >= tens)
	{
		for (int i = 0; i < 3; i++)
		{
			cout << hundreds;

		}
	}

	else if (tens >= ones)
	{
		for (int i = 0; i < 3; i++)
		{
			cout << hundreds+1;
		}
	}

	else 	{
		for (int i = 0; i < 3; i++)
		{
			cout << hundreds+1;
		}
	}



}

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

#define rep(i,n) for(int i=0;i<(n);i++)

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second　//pairの二つ目の要素

int n;
int c[]={0,0,0,0};
vector<vector<vector<double>>> dp;
vector<vector<vector<int>>> flag;
double f(int c1, int c2, int c3){
    if(flag[c1][c2][c3]) return dp[c1][c2][c3];
    flag[c1][c2][c3]=1;
    if(c1==0 && c2==0 && c3==0) return 0.;
    double ret=1./(1.-(double)(n-c1-c2-c3)/n);
    if(c1>0) ret+=f(c1-1,c2,c3)  *(double)c1/n/(1.-(double)(n-c1-c2-c3)/n);
    if(c2>0) ret+=f(c1+1,c2-1,c3)*(double)c2/n/(1.-(double)(n-c1-c2-c3)/n);
    if(c3>0) ret+=f(c1,c2+1,c3-1)*(double)c3/n/(1.-(double)(n-c1-c2-c3)/n);
    dp[c1][c2][c3]=ret;
    return ret;
}

int main(){
    cin>>n;
    rep(i,n){
        int a;
        cin>>a;
        c[a]++;
    }
    dp.resize(n+1);
    flag.resize(n+1);
    rep(i,n+1){
        dp[i].resize(n+1);
        flag[i].resize(n+1);
        rep(j,n+1){
            dp[i][j].resize(n+1);
            flag[i][j].resize(n+1);
        }
    }
    cout<<fixed<<setprecision(9)<<f(c[1],c[2],c[3])<<endl;
}

Measured memory_bytes: 327936
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
bool isPrime(int n) 
{ 
    // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    // This is checked so that we can skip 
    // middle five numbers in below loop 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
} 
const ll MOD= 2019;
int main() {
     ios::sync_with_stdio(false);
  cin.tie(0);
string s;
cin>>s;
int n=s.length();
ll suf=0;
ll j=1;
map<ll,ll>m;
m[0]++;
ll cnt=0;
for(int i=n-1;i>=0;i--){
    ll x=s[i]-'0';
    suf=(suf+x*j)%MOD;
    j=j*10;
    j%=MOD;
    cnt+=m[suf];
    m[suf]++;
    
}
cout<<cnt<<endl;
  
  
	// your code goes here
	return 0;
}


Measured memory_bytes: 3712
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pii pair<int,int>
#include <bits/stdc++.h>
#define pll pair<ll,ll>
#define vi vector<int>
#define ld long double
#define ll long long
#define sh short int
#define pb push_back
#define mid (l+r)/2
#define S second
#define F first
using namespace std;
const ll inf = 1e18;
const ll mod = 1e9+7;
int main(){
    ll n,m,sum = 0;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        ll x; cin>>x;
        sum += x;
    }
    if(sum >= n) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
// CONTEST

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

// Utility
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, X, Y) for (int I = (X); I < (Y); I++)
using ll = int64_t;
using ull = uint64_t;
template<typename T> struct is_container {
template<typename C> static char test(typename C::const_iterator*); template<typename> static int test(...);
static bool const value = sizeof(test<T>(nullptr)) == sizeof(char) && !std::is_same<std::string, T>::value;
};
namespace std {
template<class ...Ts>        istream& operator>>(istream& i, tuple<Ts...>& x) { apply([&](auto&&... ys){ ((i >> ys), ...); }, x); return i; }
template<class T1, class T2> istream& operator>>(istream& i, pair<T1, T2>& x) { i >> x.first >> x.second; return i; }
template<class T, enable_if_t<is_container<T>::value, int> = 0>
istream& operator>>(istream& i, T& x) { for (auto& y : x) { i >> y; } return i; }
}

// Debugging
#define DD(X) std::cout << #X ": " << (X) << std::endl << std::flush
#define DD2(X) std::cout << #X ":" << std::endl; for (auto x : (X)) { std::cout << x << std::endl << std::flush; }
namespace std {
template<class ...Ts>        ostream& operator<<(ostream& o, const tuple<Ts...>& x) { o << "("; apply([&](auto&& y, auto&&... ys){ o << y; ((o << ", " << ys), ...); }, x); o << ")"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const pair<T1, T2>& x) { o << tie(x.first, x.second); return o; }
template<class T, enable_if_t<is_container<T>::value, int> = 0>
ostream& operator<<(ostream& o, const T& x) { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
}

// Main
void mainCase() {
  int n, m, k; // <= 10^6
  cin >> n >> m >> k;
  vector<tuple<int, int>> ls(k, {0, 0});
  cin >> ls;
  for (auto& [x, y] : ls) { x--; y--; }
  // DD(ls);

  vector<int> hs(n, 0);
  vector<int> ws(m, 0);
  for (auto [i, j] : ls) {
    hs[i]++; ws[j]++;
  }
  // DD(tie(hs, ws));

  int h_max = *max_element(ALL(hs));
  int w_max = *max_element(ALL(ws));
  set<int> I;
  set<int> J;
  FOR(i, 0, n) {
    if (hs[i] == h_max) { I.insert(i); }
  }
  FOR(j, 0, m) {
    if (ws[j] == w_max) { J.insert(j); }
  }
  // DD(tie(h_max, I));
  // DD(tie(w_max, J));

  ull hit = 0;
  for (auto [i, j] : ls) {
    if (I.count(i) && J.count(j)) { hit++; }
  }
  bool ok = (I.size() * J.size()) > hit;
  int res = h_max + w_max - !ok;
  cout << res << endl;
}

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  // [ Single case ]
  mainCase();
  return 0;
  // [ Multiple cases ]
  // int t;
  // cin >> t;
  // FOR(i, 0, t) { mainCase(); }
  // return 0;
}


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

int main() {
	int N,D,count = 0;
	cin >> N >> D;
    while (N > 0){
        N = N - (2*D+1);
        count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define mod 998244353

typedef long long ll;

using namespace std;

void Fastio(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

ll fact[1000006], inv[1000006];

ll fp(ll base, ll exp)
{
    if (exp == 0)
        return 1;
    ll ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}

void calcFacAndInv(ll n)
{
    fact[0] = inv[0] = 1;
    for (ll i = 1; i <= n; i++)
    {
        fact[i] = (i * fact[i - 1]) ;
        inv[i] = fp(fact[i], mod - 2);
    }
}

ll ncr(ll n, ll r)
{
    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}

ll npr(ll n, ll r)
{
    return (fact[n] * inv[n - r]) % mod;
}

long double  NCR(int n, int m){
    long double res = 1;
    m = min(m, n - m);
    for(int i = 0; i < m; i++){
        res = res * ( n - i) / (i + 1);
 }
    return res;
}
ll tol(string a){
    ll res=0;
    while(a[0]=='0'){
        a.erase(a.begin());
    }
    if(a=="")a="0";
    for(int i=0; i<a.size(); i++){
        res*=10; res+=a[i]-'0';
    }
    return res;
}

int primeFactors(int n)
{
    ll c=0;
    while (n % 2 == 0)
    {
        c++;
        n = n/2;
    }
    for (int i = 3; i*i <= n; i = i + 2)
    {
        while (n % i == 0)
        {
            c++;
            n = n/i;
        }
    }
    if (n > 2)
        c++;
    return c;
}
class data{
    public:
    ll l, r, d, w;
    bool operator <(data& d){
        return w>d.w || (w==d.w && this->d>d.d);
    }
};
/*ll n, arr[200005], dp[200005][2][2];
ll solve(int i, int l, int ch){
    if(i==n)return 0;
    if(dp[i][l][ch]!=-1)return dp[i][l][ch];
    ll res1=-1e18,res2=-1e18;
    if(ch){
        if(!l)res1=solve(i+1,1,1)+arr[i];
        else res1=solve(i+1,0,1);
    }
    else {
        if(!l)res1=solve(i+1,1,0)+arr[i];
        if(l)res2=solve(i+1,0,0);
        else res2=solve(i+2,0,1);
    }
    return dp[i][l][ch]=max(res1,res2);
}*/

int main()
{
    Fastio();
    int n; cin>>n;
    vector<ll> arr, sum(n+10);
    for (int i=1; i<=n; i++) {
        ll x; cin>>x;
        arr.push_back(x);
        if (i%2==1) {
            if (i==1)sum[i]=x;
            else
                sum[i]=sum[i-2]+x;
        }
    }

    /*memset(dp,-1,sizeof(dp));
    cout<<solve(0,0,0)<<'\n';
    */
    ll dp[n+10]={0};
    dp[1]=0;
    for(int i=2; i<=n; i++){
        if(i%2==1)dp[i]=max(dp[i-2]+arr[i-1], dp[i-1]);
        else dp[i]=max(dp[i-2]+arr[i-1], sum[i-1]);
    }
    cout<<dp[n]<<'\n';

    return 0;
}



Measured memory_bytes: 7936
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int n;
signed main() {
	cin >> n;
	int ans = n;
	if (n % 2 == 0) { ans /= 2; while (n % 2 == 0)n /= 2; }
	for (int i = 3; i <= sqrt(n); i += 2) {
		if (n % i == 0) {
			ans *= i - 1; ans /= i;
			while (n % i == 0)n /= i;
		}
	}
	if (n > 1) { ans *= n - 1; ans /= n; }
	cout << ans << endl;
}


Measured memory_bytes: 3116
#include<stdio.h>
int main(void)
{
	int N,i;
	scanf("%d",&N);
	if(N<10)
	printf("%d",N);
	if(10<=N && N<100)
	printf("9");
	if(100<=N && N<1000)
	{
		printf("%d",N-99+9);
	}
	if(1000<=N && N<10000)
	printf("909");
	if(10000<=N && N<100000)
	{
		printf("%d",N-9999+909);
	}
	if(N==100000)
	printf("90909");
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,j,n) for(int (i)=(j);(i)<(n);(i)++)
#define eFOR(i,j,n) for(int (i)=(j);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
const int INF = 1000000000;
const ll LLINF = 1LL << 62;
const int mod = 1000000007;
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(){
    cin.tie(false);
    ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    int u, v;
    vector<VI> edge(n * 3 + 1);
    FOR(i, 0, m){
        cin >> u >> v;
        edge[u].push_back(v + n);
        edge[u + n].push_back(v + n * 2);
        edge[u + n * 2].push_back(v);
    }
    int s, t;
    cin >> s >> t;

    vector<bool> ever(n * 3 + 1, false);
    queue<pair<int, int>> bfs;
    ever[s] = true;
    bfs.push({ s, 0 });
    while (!bfs.empty()){
        int now = bfs.front().first;
        int dis = bfs.front().second + 1;
        bfs.pop();
        for (int i : edge[now]){
            if (ever[i])continue;
            ever[i] = true;
            bfs.push({ i, dis });
            if (i == t){
                cout << dis / 3 << "\n";
                return 0;
            }
        }
    }
    cout << -1 << "\n";
}


Measured memory_bytes: 16768
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    string s;cin>>s;
    int sum=0;
    for(char c:s){
        sum+=(c-'0');
    }
    if(sum%9==0){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3752
fun main() {
    println(next().split("S").map { it.length }.max())
}

// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)

// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }
inline fun <reified T> sized2DArray(row: Int, column: Int, default: T) = Array(row) { Array(column) { default } }

// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}

Measured memory_bytes: 36528
N = gets.to_i
D = gets.split.map(&:to_i)
L = Array.new(D.max + 1,0)
D.each{|d| L[d] += 1}
if D.each_with_index.any?{|d,i| i > 0 && d == 0 }
  puts 0
else
  puts (1 ... L.size).inject(1){|sum, i| (sum * L[i-1] ** L[i]) % 998244353 }
end


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

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, x; cin >> n >> x;
    vector<int> v;
    for (int i = 0; i < n; ++i) {
        int y; cin >> y;
        v.push_back(y);
    }
    sort(v.begin(), v.end());
    int i;
    for (i = 0; i < n; ++i) {
        if(0>=x){break;}
        x-=v[i];
    }
    if(x>0) cout << n-1 << endl;
    else if(x<0) cout << i-1 << endl;
    else cout << i << endl;

    return 0;
}

Measured memory_bytes: 256
import bisect
n=int(input())
A=sorted(list(map(int,input().split())))
B=sorted(list(map(int,input().split())))
C=sorted(list(map(int,input().split())))
BB=[0]*(n+1)
for i in A:
  BB[bisect.bisect_right(B,i)]+=1
BB=BB[:-1]
for j in range(n-1):
  BB[j+1]+=BB[j]
ans=0
for k,l in zip(B,BB):
  ans+=l*(n-bisect.bisect_right(C,k))
print(ans)

Measured memory_bytes: 23092
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// input scanner
var sc = bufio.NewScanner(os.Stdin)

const (
	initialBufSize = 10e4
	maxBufSize     = 10e6
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// util
func max(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n > ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

func min(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n < ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

func run(b []bool, n int) [][]bool {
	if n == len(b) {
		return [][]bool{append(b, true)}
	}
	b1 := make([]bool, len(b))
	b2 := make([]bool, len(b))
	copy(b1, b)
	copy(b2, b)
	bt := run(append(b1, true), n)
	bf := run(append(b2, false), n)
	ans := append(bt, bf...)
	return ans
}

func count(choco [][]int, b []bool, w int, k int) int {
	d := make([]int, len(choco))
	var ans int
	for i := 0; i < len(b)-1; i++ {
		if b[i] {
			ans++
		}
	}
	for j := 0; j < w; j++ {
		var cut bool
		var c int
		var newc int
		for i := 0; i < len(choco); i++ {
			d[i] = d[i] + choco[i][j]
			c += d[i]
			newc += choco[i][j]
			if newc > k {
				return INF
			}
			if c > k {
				cut = true
			}
			if b[i] {
				c = 0
				newc = 0
			}
		}
		if cut {
			ans++
			for i := 0; i < len(choco); i++ {
				d[i] = choco[i][j]
			}
		}
	}
	return ans
}

var INF = 1001001001

// main
func main() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	h := nextInt()
	w := nextInt()
	k := nextInt()
	choco := make([][]int, h)
	for i := 0; i < h; i++ {
		s := next()
		ci := make([]int, w)
		for j := 0; j < w; j++ {
			x, _ := strconv.Atoi(s[j : j+1])
			ci[j] = x
		}
		choco[i] = ci
	}
	yoko := run([]bool{}, h-1)
	ans := INF
	for _, y := range yoko {
		c := count(choco, y, w, k)
		if c < ans {
			ans = c
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 896
import Data.List
mark = ["R", "G", "B"]

f [] = True
f a@(h:t) = (r1 && (f (a \\ [h,h,h]))) || (r2 && (f (a \\ [h,h+1,h+2])))
  where
    nh = length $ filter (== h) a
    r1 = nh >= 3
    r2 = (elem (h+1) a) && (elem (h+2) a)

tst c =
  let n = sort $ map snd c
  in
    f n

ans' c =
  let cc = map (\m -> filter (\cc -> m == (fst cc)) c) mark
      r  = and $ map tst cc
  in
    if r then 1 else 0

ans [] = []
ans (n:m:r) =
  let n' = map read n :: [Int]
      z  = zip m n'
  in
    (ans' z):(ans r)

main = do
  _ <- getLine
  c <- getContents
  let i = map words $ lines c
      o = ans i
  mapM_ print o
  



Measured memory_bytes: 4192
f=->(x){x.even?? x/2:3*x+1}
s=gets.to_i
a,x,j=0,[],0
(1..1e6).map{|i|
  a=(i==1?s:f[a])
  j=i and break if x.include?(a)
  x.push(a)
}
p j

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}
#define int LL
signed main()
{
	int n,k;
	cin>>n>>k;
	int ans=0;
//	For(a,1,n)
	{
		For(b,k+1,n)
		{
		//	if(a%b>=k)ans++;
			ans+=(n/b)*(b-k)+((n-(n/b*b)+1-k)<0?0:(n-(n/b*b)+1-k));
		}
	}
	if(k==0)ans-=n;
	cout<<ans<<endl;
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main(void) {
    ll N;
    vector<ll> a;
    vector<ll> good;
    vector<ll> balls;
    cin >> N;
    a.resize(N);
    balls.resize(N, 0);
    for(ll i = 0;i < N;i++) cin >> a[i];
    for(ll i = N;i >= 1;i--) {
        ll count = 0;
        for(ll j = 1;j <= N / i;j++) {
            count += balls[i * j - 1];
        }
        if(count % 2 != a[i - 1]) {
            balls[i - 1] = 1;
            good.push_back(i);
        }
    }
    cout << good.size() << endl;
    for(auto &i: good) cout << i << ' ';
    return 0;
}


Measured memory_bytes: 4980
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
        cin >> A.at(i);

    sort(A.begin(), A.end());
    auto p = A.begin();
    int a, b;
    while (p != A.end()) {
        a = *p;
        ++p;
        if (p == A.end()) {
            cout << "YES" << endl;
            break;
        }
        b = *p;
        if (a == b) {
            cout << "NO" << endl;
            break;
        }
    }
}



Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <map>
#include <vector>
#include <string>
#include <sstream>
using namespace std;

int main()
{
    int n;
    while(cin >> n, n){
      vector<int> j(n-1);
      long long int len = 0, ans = -1;
      for(int i = 0; i < n; ++i){
          int temp;
          cin >> temp;
          len += temp;
      }
      for(int i = 0; i < n - 1; ++i) cin >> j[i];
      sort(j.begin(), j.end(), greater<int>());
      
      ans = len * n;
      
      for(int i = 1; i < n; ++i){
          len += j[i-1];
          ans = max(ans, len * (n - i));
      }
      
      cout << ans << endl;
    }
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

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

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

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int n = read();
  int mi = LONG_MAX, ma = 0;
  REP(i, n) {
    int a = read();
    chmax(ma, a);
    chmin(mi, a);
  }
  print(ma - mi);
}


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

int n;
int d[int(1e5) + 1];

int main () {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> d[i];
	sort(d, d + n);
	cout << d[n/2] - d[(n/2) - 1] << "\n";
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin >>a>>b;
  if(a>=b&&(a-1)>=b) cout <<2*a-1<<endl;
  else if(a==b)cout << 2*a <<endl;
  else cout << 2*b-1 <<endl;
}

Measured memory_bytes: 256