akhauriyash/Code-Regression huggingface dataset:
#Convolution_998244353

MOD = 998244353
ROOT = 3

sum_e = (911660635, 509520358, 369330050, 332049552, 983190778, 123842337, 238493703, 975955924, 603855026, 856644456, 131300601, 842657263, 730768835, 942482514, 806263778, 151565301, 510815449, 503497456, 743006876, 741047443, 56250497, 0, 0, 0, 0, 0, 0, 0, 0, 0)
sum_ie = (86583718, 372528824, 373294451, 645684063, 112220581, 692852209, 155456985, 797128860, 90816748, 860285882, 927414960, 354738543, 109331171, 293255632, 535113200, 308540755, 121186627, 608385704, 438932459, 359477183, 824071951, 0, 0, 0, 0, 0, 0, 0, 0, 0)

def butterfly(arr):
    n = len(arr)
    h = (n - 1).bit_length()
    for ph in range(1, h + 1):
        w = 1 << (ph - 1)
        p = 1 << (h - ph)
        now = 1
        for s in range(w):
            offset = s << (h - ph + 1)
            for i in range(p):
                l = arr[i + offset]
                r = arr[i + offset + p] * now
                arr[i + offset] = (l + r) % MOD
                arr[i + offset + p] = (l - r) % MOD
            now *= sum_e[(~s & -~s).bit_length() - 1]
            now %= MOD

def butterfly_inv(arr):
    n = len(arr)
    h = (n - 1).bit_length()
    for ph in range(1, h + 1)[::-1]:
        w = 1 << (ph - 1)
        p = 1 << (h - ph)
        inow = 1
        for s in range(w):
            offset = s << (h - ph + 1)
            for i in range(p):
                l = arr[i + offset]
                r = arr[i + offset + p]
                arr[i + offset] = (l + r) % MOD
                arr[i + offset + p] = (MOD + l - r) * inow % MOD
            inow *= sum_ie[(~s & -~s).bit_length() - 1]
            inow %= MOD

def convolution(a, b):
    n = len(a)
    m = len(b)
    if not n or not m: return []
    if min(n, m) <= 50:
        if n < m:
            n, m = m, n
            a, b = b, a
        res = [0] * (n + m - 1)
        for i in range(n):
            for j in range(m):
                res[i + j] += a[i] * b[j]
                res[i + j] %= MOD
        return res
    z = 1 << (n + m - 2).bit_length()
    a += [0] * (z - n)
    b += [0] * (z - m)
    butterfly(a)
    butterfly(b)
    for i in range(z):
        a[i] *= b[i]
        a[i] %= MOD
    butterfly_inv(a)
    a = a[:n + m - 1]
    iz = pow(z, MOD - 2, MOD)
    for i in range(n + m - 1):
        a[i] *= iz
        a[i] %= MOD
    return a

def autocorrelation(a):
    n = len(a)
    if not n: return []
    if n <= 50:
        res = [0] * (2 * n - 1)
        for i in range(n):
            for j in range(n):
                res[i + j] += a[i] * a[j]
                res[i + j] %= MOD
        return res
    z = 1 << (2 * n - 2).bit_length()
    a += [0] * (z - n)
    butterfly(a)
    for i in range(a):
        a[i] *= a[i]
        a[i] %= MOD
    butterfly_inv(a)
    a = a[:2 * n - 1]
    iz = pow(z, MOD - 2, MOD)
    for i in range(2 * n - 1):
        a[i] *= iz
        a[i] %= MOD
    return a

import sys
input = sys.stdin.buffer.readline

N, M = map(int, input().split())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

print(*convolution(A, B))

Measured memory_bytes: 197280
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

//nCrを返す関数.
long long int comb(long long int n, long long int r){
	if(n < r || n < 0)
		return 0;
	long long int x = 1, y = 1;
	if (n-r < r) r = n - r;
	for (long long int i = 0; i < r; i++)
	{
		x = x * (n - i);
		y = y * (i + 1);
	}
	return x / y;
}

int main(){
	int n;
	cin >> n;
	map<string, int> m;
	rep(i, n)
	{
		string s;
		cin >> s;
		sort(all(s));
		m[s]++;
	}
	ll ans = 0;
	for (auto x : m)
	{
		ans += comb(x.second, 2);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 11136
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

ll n, m, k;
// string s;

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

    if (n >= k) {
        printf("%lld %lld\n", n-k, m);
    } else if (n+m >= k) {
        printf("0 %lld\n", m-(k-n));
    } else {
        std::cout << "0 0" << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds; 
using namespace std;
#define int long long
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define mii map<int,int>
#define mp make_pair
#define pb push_back
#define rep(i,b) for(ll (i)=0;i<(b);i++)
#define all(c) (c).begin(), (c).end()
#define F first
#define S second
#define CLR(p) memset(p, 0, sizeof(p))
#define SET(p) memset(p, -1, sizeof(p))
#define DEBUG true
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
//typedef long long int ll;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
tree_order_statistics_node_update> new_data_set; 
const int MAX=200005;
#define MOD 1000000007
/*std::cout << std::fixed;
std::cout << std::setprecision(6);*/
//(a%mod-b%mod+mod)%mod



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


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

vector<vector<ll>>v;
ll T=0;
ll cnt1=0,cnt0=0;
vector<ll>dep;
bool visited[MAX];
vector<ll>par;
vector<ll>tin,tout;
vector<ll>col;
ll f=0,k=1;
map<pll,ll>m;
ll dp1[MAX],dp2[MAX];
ll red,blue;
ll ans;
ll dp[MAX];

ll lca(ll u,ll v){
	while(u!=v){
		ll l1,l2;
		l1 = log2(u);
		l2 = log2(v);
		//cout<<l1<<"$$"<<l2<<endl;
		if(l1<l2)
			swap(u,v);
		u /=2;
	}
	return u;
}





signed main(){
	boost;
	int t=1;
	// cin>>t;
	while(t--){
		int n,k;
		cin>>n>>k;
		if(n>k){
			int d = n-k;
			int q = d/k;
			n = n-(q*k);
			int  i=0;
			while(i++<100000){
				n = min(n,abs(n-k));
			}
		}
		else{
			int i=0;
			while(i++<100000){
				n = min(n,abs(n-k));
			}
		}
		cout<<n<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Queue;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt(), Q = scn.nextInt();
		GraphWay[] GW = new GraphWay[N];
		int[] C = new int[N];

		for(int i = 0;i < N;i++) {
			GW[i] = new GraphWay();
		}
		for(int i = 0;i < N-1;i++) {
			int a = scn.nextInt()-1, b = scn.nextInt()-1;
			GW[a].add(b);
		}
		for(int i = 0;i < Q;i++) {
			int p = scn.nextInt()-1, c = scn.nextInt();
			C[p] +=c;
		}
		int[] ans = new int[N];
		Queue<Pair> DQ = new ArrayDeque<Pair>();
		DQ.add(new Pair(0,0));
		while(!DQ.isEmpty()) {
			Pair p = DQ.poll();
			int n = p.first;
			int v = p.second + C[n];
			ans[n] += v;
			for(int next:GW[n].getItr()) {
				DQ.add(new Pair(next,v));
			}
		}
		Printer.printArrayLine(ans);

	}

}
class Printer{
	static void printArrayLine(int[] a) {
		int N = a.length;
		for(int i = 0;i < N;i++) {
			System.out.print(a[i] + ((i==N-1)?"\n":" "));
		}
	}
}

class GraphWay{//有向パス
	ArrayList<Integer> to;
	public GraphWay() {
		to = new ArrayList<Integer>();
	}

	void add(int t) {
		to.add(t);
	}

	Iterable<Integer> getItr() {
		return to;
	}
}

class Pair {
	int first,second;
	public Pair(int f,int s) {
		this.first = f;
		this.second = s;
	}
}

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

int main(){
    int n, k, t;
    cin >> n;
    ll x = 0, e = pow(2, n);
    cin >> k;
    rep(i, k){
        cin >> t;
        x += (1<<t);
    }
    repc(i, 0LL, e){
        if((i & x) == x){
            bitset<20> xx(i);
            cout << i << ":";
            rep(j, n){
                if (xx.test(j)){
                    cout << " " << j;
                }
            }
        cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3268
N=gets.to_i
fs = N.times.map { gets.split.map(&:to_i)}
ps = N.times.map { gets.split.map(&:to_i)}

max = -10 **9
ignore = [0] * 10
[0,1].repeated_permutation(10) do |a|
    next if a == ignore
    sum = 0
    fs.each.with_index do |f,i|
        x = 0
        f.zip(a).each_with_index do |(m,n),j|
            x += m & n
        end
        sum += ps[i][x]
    end
    max = sum if max < sum
end

p max

Measured memory_bytes: 14344
#include<algorithm>
#include<bits/allocator.h>
#include<bits/basic_ios.h>
#include<bits/basic_string.h>
#include<bits/basic_string.tcc>
#include<bits/c++config.h>
#include<bits/char_traits.h>
#include<bits/cpp_type_traits.h>
#include<bits/cxxabi_forced.h>
#include<bits/ios_base.h>
#include<bits/locale_classes.h>
#include<bits/localefwd.h>
#include<bits/ostream_insert.h>
#include<bits/postypes.h>
#include<bits/range_access.h>
#include<bits/stl_algobase.h>
#include<bits/stl_function.h>
#include<bits/stl_iterator.h>
#include<bits/stl_iterator_base_funcs.h>
#include<bits/stl_iterator_base_types.h>
#include<bits/stringfwd.h>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwchar>
#include<cwctype>
#include<debug/debug.h>
#include<deque>
#include<exception>
#include<ext/atomicity.h>
#include<ext/numeric_traits.h>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<math.h>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<valarray>
#include<vector>
using namespace std;
int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	if ((a-b)%2==0)
		cout<<"Alice";
	else
		cout<<"Borys";
	return 0;
}

Measured memory_bytes: 256
N,P=map(int,input().split())
maxfac = round(P**(1/N))
# print(range(1,maxfac+1))
if N==1:
    print(P)
    exit()
for i in range(1,maxfac+1)[::-1]:
    p = i**N
    # print(P%p)
    if P%p == 0:
        print(i)
        break


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef     long long    ll;
typedef     vector<int> vi;
typedef     vector<long long> vl;
typedef     pair<int,int>pi;
typedef     pair<long long,long long>pl;
#define F   first
#define S   second
#define pb  push_back
#define     all(x)      x.begin() , x.end()
#define mp  make_pair
#define     FOR(i,a,b) for(i=a;i<=b;i++)
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)

int main()
{
   int n,i,j,x,y,c=0;
   cin>>n;
    vi v;
    FOR(i,1,n)
    {
      cin>>j;
      v.push_back(j);
    }
    sort(all(v));
     FOR(i,0,n-3)
     {
      FOR(j,i+1,n-2)
      {
        x=lower_bound(v.begin()+j+1,v.end(),v[i]+v[j])-v.begin();
        c+=(x-j-1);
      }

     }
     cout<<c<<endl;
      
   }

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;

ld sqrt_(ld d) {
	assert(d >= 0.0);
	ld l = 0.0, r = 100000000.0;
	rep(q, 50) {
		ld m = (l + r) / 2.0;
		if (m * m >= d)
			r = m;
		else
			l = m;
	}
	return l;
}

int main() {
	int N, K;
	vd x, y, c;
	cin >> N >> K;
	x.resize(N);
	y.resize(N);
	c.resize(N);
	rep(i, N)
		cin >> x[i] >> y[i] >> c[i];
	ld L = 0.0, R = 1000000.0;
	rep(q, 50) {
		ld t = (L + R) / 2.0;
		//db tt = t;
		//printf("%.12f\n", tt);

		bool can = false;
		rep(i, N) {
			rep(j, N) {
				vector<ld> X(2), Y(2);
				if (i == j) {
					// 円の中心
					X[0] = x[i];
					Y[0] = y[i];
					X[1] = x[i];
					Y[1] = y[i];
				}
				else if (i > j) {
					// 円の交点
					ld A = (t / c[i]) * (t / c[i]);
					ld B = (t / c[j]) * (t / c[j]);
					ld C = (x[i] * x[i] - x[j] * x[j]) + (y[i] * y[i] - y[j] * y[j]) - (A - B);
					ld D = 2.0 * (x[i] - x[j]);
					ld E = 2.0 * (y[i] - y[j]);
					if (D == 0.0) {
						Y[0] = C / E;
						Y[1] = C / E;
						ld AY = A - (Y[0] - y[i]) * (Y[0] - y[i]);
						if (AY < 0.0)
							continue;
						X[0] = sqrt_(AY) + x[i];
						X[1] = -sqrt_(AY) + x[i];
					}
					else {
						ld F = C / D;
						ld G = E / D;
						ld H = F - x[i];
						ld a_ = G * G + 1;
						ld b_ = -1.0 * (G * H + y[i]);
						ld c_ = H * H + y[i] * y[i] - A;
						if (b_ * b_ - a_ * c_ < 0.0)
							continue;
						Y[0] = (-b_ + sqrt_(b_ * b_ - a_ * c_)) / a_;
						Y[1] = (-b_ + -sqrt_(b_ * b_ - a_ * c_)) / a_;
						X[0] = F - G * Y[0];
						X[1] = F - G * Y[1];
						//cout << (F - G * Y[0] - x[i]) * (F - G * Y[0] - x[i]) + (Y[0] - y[i]) * (Y[0] - y[i]) << " - " << A << endl;
						//cout << (X[0] - x[j]) * (X[0] - x[j]) + (Y[0] - y[j]) * (Y[0] - y[j]) << " - " << B << endl;
						//cout << (X[1] - x[j]) * (X[1] - x[j]) + (Y[1] - y[j]) * (Y[1] - y[j]) << " - " << B << endl;
					}
				}
				else continue;

				rep(p, 2) {
					int k = 0;
					rep(n, N) {
						ld dist2 = (X[p] - x[n]) * (X[p] - x[n]) + (Y[p] - y[n]) * (Y[p] - y[n]);
						ld ttmp2 = c[n] * c[n] * dist2;
						if (ttmp2 <= t * t + 0.0000000001)
							k++;
					}
					if (k >= K)
						can = true;
				}
			}
		}
		if (can)
			R = t;
		else
			L = t;
	}
	db ans = L;
	printf("%.12f\n", ans);
	return 0;
}

Measured memory_bytes: 3800
import Foundation

func readString() -> String {
  return readLine()!
}
func readTokens() -> [String] {
  return readString().componentsSeparatedByString(" ")
}
func readIntArray() -> [Int] {
  return readTokens().map { Int($0)! }
}
func readInt() -> Int {
  return Int(readString())!
}
func readInt(n: Int) -> [Int] {
  return (0..<n).flatMap { _ in Int(readString())! }
}

extension String {
  var charArray: [String] {
    return characters.map { String($0) }
  }
  func intArray() -> [Int] {
    return charArray.flatMap { Int($0) }
  }
}

func printWitch<T>(b: Bool, l: T, r: T) {
  print(b ? l : r)
}

print(readString().intArray().filter( { $0 == 1 }).count)


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define VIN(x) for(auto&youso_: (x) )cin>>youso_
#define VOUT(x, delim) for(auto&youso_: (x) )cout<<youso_<<delim;cout<<endl

#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) i64 __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    CIN(x);
    x = (x + 1) % 2;
    COUT(x);

    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define MAXN 200009
#define MAXM 320
#define MOD 1000000007
#define INF 1000000009
#define FOR(x,n) for(int x=0; x<n; x++)
#define FOR1e(x,n) for(int x=1; x<=n; x++)
#define pb push_back
typedef pair<int, int> ii;
typedef long long ll;


int grundy(int a, int k) {
	if (a%k == 0) return a/k;
	if (a < k) return 0;
	int diff = a/k + 1;
	int f = (a%k + diff - 1)/diff;
	return grundy(a - f*diff, k);
}
int main() {
	int n, k, a;
	cin >> n;

	int x = 0;
	FOR(i, n) {
		scanf("%d %d", &a, &k);
		x ^= grundy(a, k);
	}
	if (x) puts("Takahashi");
	else puts("Aoki");
}

Measured memory_bytes: 256
'''
https://atcoder.jp/contests/abc120/tasks/abc120_d
'''
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    def find(x):
        if par[x] < 0:
            return x
        else:
            par[x] = find(par[x])
            return par[x]
    
    def unite(x,y):
        x = find(x)
        y = find(y)
        if x == y:
            return False
        else:
            if par[x] > par[y]:
                x,y = y,x
            par[x] += par[y]
            par[y] = x
            return True
    
    def same(x,y):
        return find(x) == find(y)
    
    def size(x):
        return -par[find(x)]
    
    #xが属するグループの要素全てを返す
    def members(x, n):
        root = find(x)
        return [i for i in range(n) if find(i) == root]
    
    #全ての根の要素を返す
    def roots():
        return [i for i, x in enumerate(par) if x < 0]

    n,m = map(int, input().split())
    edge = [list(map(int, input().split())) for _ in range(m)]
    par = [-1]*n
    res = []
    total = n*(n-1)//2
    for a,b in edge[::-1]:
        a -= 1
        b -= 1
        res.append(total)
        if same(a,b):
            continue
        else:
            total -= size(a)*size(b)
            unite(a,b)

    for i in res[::-1]:
        print(i)

if __name__ == '__main__':
    main()

Measured memory_bytes: 35744
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
#define all(x) x.begin(), x.end()
#define pb push_back
#define endl '\n'
typedef long long ll;


int main()
{
	int n;
	cin >> n;
	map<string, int> mp;
	for (int i = 0; i < n; i++) {
		string temp;
		cin >> temp;
		mp[temp]++;
	}
	cout << "AC x " << mp["AC"] << endl;
	cout << "WA x " << mp["WA"] << endl;
	cout << "TLE x " << mp["TLE"] << endl;
	cout << "RE x " << mp["RE"] << endl;

	
}


Measured memory_bytes: 3584
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

 
public class Main {
	static final long MOD=1000000007;//998244353;
	public static void main(String[] args) {
		PrintWriter out = new PrintWriter(System.out);
		InputReader sc=new InputReader(System.in);
		long[] a=sc.nextLongArray(2);
		long[] c=sc.nextLongArray(2);
		long max=Long.MIN_VALUE;
		for (int i = 0; i < c.length; i++) {
			for (int j = 0; j < c.length; j++) {
				max=Math.max(max, a[i]*c[j]);
			}
		}
		System.out.println(max);
   	}
	
		static class InputReader { 
		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;
		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}
 
		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}
 
		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}
 
		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}
 
		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}
 
		public boolean hasNext() {
			skip();
			return hasNextByte();
		}
 
		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
 
		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public double nextDouble() {
			return Double.parseDouble(next());
		}
 
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}
 
		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}
 
		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
	}

Measured memory_bytes: 32476
"use strict"
function main(arg) {
    arg = arg.trim().split("\n")
    var N = Number(arg.shift())
    var data = []
    for (var i = 0; i < arg.length; i++) {
        var row = arg[i].split(" ")
        var n = (100 - Number(row[1]))
        var n_str = ''
        if (n < 10) {
            n_str = '00' + n
        } else if (n < 100) {
            n_str = '0' + n
        } else {
            n_str = n
        }
        data.push(
            row[0] + n_str + "_" + Number(i + 1)
        )
    }
    data.sort()
    for (var i = 0; i < data.length; i++) {
        var id = data[i].split("_")[1]
        console.log(id)
    }
    // console.log(JSON.stringify(data, null, "\t"))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,c,d,x1,x2,y1,y2,h,k;
  cin >> x1 >> x2 >> y1 >> y2 >> a >> b >> c >> d;
  h=x1*a+x1/10*c+x2*b+x2/20*d;
  k=y1*a+y1/10*c+y2*b+y2/20*d;
  if(h>k){
    cout << "hiroshi" << endl;
  }else if(h<k){
    cout << "kenjiro" << endl;
  }else{
    cout << "even" << endl;
  }
  return 0;
}



Measured memory_bytes: 3112
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	vector<int>nums(10);
	cin>>n;
	while(n--)
	{
		int in;
		cin>>in;
		fill(nums.begin(),nums.end(),0);
		while(0<in)
		{
			int num=in%10;
			nums[num]++;
			in/=10;
		}
		int mx=0,mn=0;
		int i=9;
		vector<int> cp=nums;
		while(0<=i)
		{
			if(0<cp[i])
			{
				mx*=10;
				mx+=i;
				cp[i]--;
			}
			else i--;
		}
		i=0;
		while(i<10)
		{
			if(0<nums[i])
			{
				mn*=10;
				mn+=i;
				nums[i]--;
			}
			else i++;
		}

		cout<<mx-mn<<endl;
	}
  return 0;
}

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

using namespace std;

const int max_n = 2022, mod = 1000000007;

int n, m, a[max_n], b[max_n], dp[max_n][max_n];

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &a[i]);
        dp[i][0] = 1;
    }
    for (int i = 1; i <= m; ++i) {
        scanf("%d", &b[i]);
        dp[0][i] = 1;
    }
    dp[0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            int x = (dp[i - 1][j] + dp[i][j - 1]) % mod;
            x = (x + mod - dp[i - 1][j - 1]) % mod;
            if (a[i] == b[j]) {
                x = (x + dp[i - 1][j - 1]) % mod;
            }
            dp[i][j] = x;
        }
    }
    printf("%d\n", dp[n][m]);
    return 0;
}


Measured memory_bytes: 16128
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main() {
    IOS; int n; cin >> n;
    if(n%10==3) cout << "bon";
    else if(n%10==0 || n%10==1 || n%10==6 || n%10==8) cout << "pon";
    else cout << "hon";
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>

int main(void)
{
    int i = 1;
    while(true) {
        int x;
        std::cin >> x;
        if(x == 0) {
            break;
	}
        std::cout << "Case " << i << ": " << x << std::endl;
	i++;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589

using namespace std;

int gcd(int a, int b){return (a % b)? gcd(b, a % b) : b;}
int lcm(int a, int b){return a * b / gcd(a, b);}

void solve_A(){
    int n, m;
    cin >> n >> m;

    int ans = n * (n-1) / 2 + m * (m-1) / 2;

    cout << ans;
}


int main(void){
    solve_A();
    
    return 0;
}

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

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<P> key;
    for(int i = 0; i < m; i++){
        int a, b, c;
        cin >> a >> b;
        int d=0;
        for(int j = 0; j < b; j++){
            cin >> c;
            c--;
            d += (1<<c);
        }
        key.push_back(P(a, d));
    }
    int dp[1005][4100];
    for(int i = 0; i < 1005; i++){
        for(int j = 0; j < 4100; j++)dp[i][j] = INF;
    }
    dp[0][0]=0;
    for(int i = 1; i <= m; i++){
        for(int j = 0; j < 4096; j++){
            dp[i][j|key[i-1].second] = min(dp[i][j|key[i-1].second], dp[i-1][j]+key[i-1].first);
            dp[i][j] = min(dp[i][j], dp[i-1][j]);
        }
    }
    if(dp[m][(1<<n)-1] == INF)cout << -1 << endl;
    else cout << dp[m][(1<<n)-1] << endl;
    return 0;
}

Measured memory_bytes: 16384
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    vector< pair< string ,pair<ll,ll > > > ar;
    ll n;
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        string s; ll u;
        cin>>s>>u;
        u*=-1;
        ar.push_back({s,{u,i}});
    }
    sort(ar.begin(),ar.end());
    for(int i=0;i<n;i++)
        cout<<ar[i].second.second+1LL<<"\n";
      return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    string weather[] = {"Sunny", "Cloudy", "Rainy"}, s;
    
    cin >> s;
    int sn;
    if (s == "Sunny") sn = 0;
    else if (s == "Cloudy") sn = 1;
    else sn = 2;
    
    cout << weather[(sn+1)%3] << endl;
}


Measured memory_bytes: 256
a = []
flag = False
for i in range(3):
    t,b,c = map(int,input().split())
    a.append([t,b,c])
n = int(input())
for i in range(n):
    buf = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == buf:
                a[j][k] = 0
for i in range(3):
    if(a[0][i] == 0 and a[1][i] == 0 and a[2][i] == 0 ):
        flag = True
for i in range(3):
    if(a[i][0] == 0 and a[i][1] == 0 and a[i][2] == 0):
        flag = True
if(a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0 ):
    flag = True
if(a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0):
    flag = True

if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**10
mod = 10**9 + 7


def f():
    h,w = list(map(int, input().split()))
    a = [input().split() for _ in range(h)]
    for i in range(h):
        if 'snuke' in a[i]:
            return "{0}{1}".format(chr(a[i].index('snuke') + ord('A')), i + 1)



print(f())


Measured memory_bytes: 6696
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <limits>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

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

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



signed main() {
    ll A,B; cin >> A >> B;
    
    A--;

    int Asta, Bsta;
    Asta = A - A % 4;
    Bsta = B - B % 4;

    ll lh = 0, rh = 0;
    int buf = 0;

    for (int i = Asta; i <= A; i++) {
        lh = lh xor i;
    }
    for (int i = Bsta; i <= B; i++) {
        rh = rh xor i;
    }

    cout << (rh xor lh) << endl;
//    for(int i = 0; i < 100; i++){
//        buf = buf xor i;
//        cout << bitset<16>(buf) << endl;
//    }
}


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

long long n;

int main(){
    ios_base::sync_with_stdio(0);
    //ifstream in ("input.txt");

    cin>>n;

    int largest = 1;
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0){
            largest = i;
        }
    }

    cout << largest + n/largest - 2<< endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int H, W;
	int h, w;

	while (1) {
		scanf("%d%d", &H, &W);
		if (H == 0 && W == 0) break;
		for (h = 0; h < H; h++) {
			for (w = 0; w < W; w++) {
				putchar(((h & 1) ^ (w & 1)) == 0 ? '#' : '.');		}
			putchar('\n');
		}
		putchar('\n');
	}
	return 0;
}



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

int main() {
	int a;
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			a = i * j;
			cout << i << "x" << j << "=" << a << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1116
using System;
namespace pro
{
    class MainClass
    {
        public static void Main()
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            int c = int.Parse(str[2]);
            if (b + c - a > 0)
                Console.WriteLine(b + c - a);
            else
                Console.WriteLine(0);
        }
    }
}

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

using namespace std;

int main()
{
    string s ;
    cin>>s ;
    int ans = 1e9 ;
    for(int i = 0 ; i < s.size() ; ++i)
    {
        if(i+2 == s.size())
            break;
        int x = 0 ;
        for(int j = i ; j <= i+2 ; ++j)
           x = x * 10 + (s[j] - '0') ;
        ans = min(ans , abs(x - 753));
    }
    return cout<<ans , 0 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

double dp[3000][3000];

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

    vector<double> p(N);
    rep(i, N) cin >> p[i];

    dp[0][0] = 1.0 - p[0];
    dp[0][1] = p[0];
    
    for (int i = 1; i < N; ++i) {
        dp[i][0] = dp[i-1][0] * (1.0 - p[i]); 
        for (int j = 1; j <= i; ++j) {
            dp[i][j] = dp[i-1][j-1] * p[i] + dp[i-1][j] *  (1.0 - p[i]);
        }
        dp[i][i+1] = dp[i-1][i] * p[i];
    }

    double ans = 0;
    for (int j = (N+1)/2; j <= N; ++j) {
        ans += dp[N-1][j];
    }

    cout << setprecision(10) << ans << endl;

    return 0;
}


Measured memory_bytes: 68864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD (int) (1e9+7)
#define INF (int) 2e9

int main(){
    int a, b;
    cin >> a >> b;

    int ans = (b-1)/(a-1);
    if((b-1)%(a-1)>0) ans++;

    cout << ans << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int abs(int n)
{
	if (n < 0)
		n *= -1;
	return n;
}
int x, y;
int f(int i, int j)
{
	int res = abs(i - j);
	if (res > abs(x - i) + 1 + abs(j - y))
		res = abs(x - i) + 1 + abs(j - y);
	if (res > abs(i - y) + 1 + abs(j - x))
		res = abs(i - y) + 1 + abs(j - x);
	return res;
}
int main()
{
	int n;
	scanf("%d %d %d", &n, &x, &y);
	x--;
	y--;
	int k[2003];
	int i, j;
	for (i = 0; i < n; i++)
		k[i] = 0;
	for (i = 0; i < n; i++)
		for (j = i + 1; j < n; j++)
			k[f(i, j)]++;
	for (i = 1; i < n; i++)
		printf("%d\n", k[i]);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000007
int u[1100000];
vector<int> y;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=0,e=0,f=0,g=0;
  cin >>a>>b;
  if(a>8||b>8) cout <<":(\n";
  else cout <<"Yay!\n";
  return (0);
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define SZ(x) ((int)x.size()-1)
#define ms(a,b) memset(a,b,sizeof a)
#define F(i,a,b) for (int i=(a);i<=(b);++i)
#define DF(i,a,b) for (int i=(a);i>=(b);--i)
using namespace std;
inline int read(){
	char ch=getchar(); int w=1,c=0;
	for(;!isdigit(ch);ch=getchar()) if (ch=='-') w=-1;
	for(;isdigit(ch);ch=getchar()) c=(c<<1)+(c<<3)+(ch^48);
	return w*c;
}
const int M=2e5+10;
int fa[M],sz[M],n,m;
int Fd(int x){
	if (fa[x]==x) return x;
	return fa[x]=Fd(fa[x]);
}
int main(){
	n=read(); m=read();
	F(i,1,n) fa[i]=i,sz[i]=1;
	int ans=1;
	F(i,1,m){
		int x=read(),y=read(); 
		x=Fd(x); y=Fd(y);
		if (x==y) continue;
		fa[x]=y; sz[y]+=sz[x];
		ans=max(ans,sz[y]);
	}
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 5200
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef vector<ll> vll;
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        ll n;
        in >> n;
        vll a(n);
        ll ans = 1;
        for (int i = 0; i < n; i++) {
            in >> a[i];
            ans *= a[i] % 2 ? 1 : 2;
        }
        out << pow(3LL, n) - ans << '\n';
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


Measured memory_bytes: 512
/*Coded by::
    **Avinash Tiwary**
    **BE/10298/2015**
    **Production Engineer**
    **Producing <code>**
*/
#include<bits/stdc++.h>
#define bf ios_base::sync_with_stdio (0), cin.tie (0)
typedef long long ll;
typedef double d;
#define MAX 1000009
#define MIN -1
#define M 1000000007
#define INF 5e17
using namespace std;
typedef vector<ll> Vector;
typedef queue<ll > Queue;
typedef stack<ll> Stack;
typedef pair<ll,ll> Pair;
#define mp make_pair
#define pb push_back
bool desc(ll i, ll j) { return i > j; }
ll power(ll x,ll n)
{   if(n==0) return 1;
    else if(n%2 == 0) return power((x*x)%M,n/2);
    else return (x*power((x*x)%M,(n-1)/2))%M;
}
ll ar[MAX],diff[MAX],dif1[MAX],dif2[MAX];
ll not_prime[MAX]; 
void sieve(){
    not_prime[1]=1; not_prime[0]=1;
    for(ll p=2;p*p<=MAX;p++){
        if(!not_prime[p]){
            for(ll i=p*2;i<=MAX;i+=p) not_prime[i]=1;
        }
    }
}
int main(){
    bf; 
    //sieve();
    ll n,i,j,r,flag,t=1,t2,ans=0,m,x=0; 
    cin>>n;
    for(i=0;i<3*n;i++) cin>>ar[i];
    sort(ar,ar+3*n,desc);
    for(i=1;t<=n;i+=2) {t++;ans+=ar[i];}
    cout<<ans;
    return 0;
}  

Measured memory_bytes: 4480
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    println!("{}", get!(String).chars().map(|c| c.to_digit(10).unwrap()).sum::<u32>());
}

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

const int Maxn = 22;

int n;
int h[Maxn], a[Maxn];
int res;

int main()
{
    scanf("%d", &n);
    a[0] = 0;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &h[i]);
        a[i] = max(a[i - 1], h[i]);
        if (a[i] <= h[i]) res++;
    }
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  int n,m;
  cin >>n>>m;
  vector<ll> h(n);
  rep(i,n) cin >>h[i];
  int ans=0;
   
  // グラフ入力受取
  vector<vector<int>> G(n);
  rep(i,m){
        int a, b;
        cin >> a >> b;
    if(h[a-1]<=h[b-1]) G[a-1].push_back(b-1);
    if(h[b-1]<=h[a-1]) G[b-1].push_back(a-1);
  }
  rep(i,n){
    if(G[i].size()==0)ans++;
  }
  cout  <<ans<<endl;
}

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

int main(){
	string command,ans;
	cin >> command;

	for (int i = 0; i < command.length(); ++i){
		if (command[i] == '0') ans.push_back('0') ;
		else if (command[i] == '1') ans.push_back('1') ;
		else if (command[i] == 'B')
			if (ans.length() > 0) ans.erase( ans.length() - 1 );
	}	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
//const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================


	ll N, W;
	cin >> N >> W;

	vll weight(N);
	vll value(N);
	for (int i = 0; i < N; i++) {
		cin >> weight[i] >> value[i];
	}


	vvll dp(W+1); // 価値wまででi番目までの品物での価値の最大値
	for (int w = 0; w <= W; w++) {
		for (int i = 0; i < N; i++) {
			dp[w].emplace_back(0);
		}
	}

	for (int w = weight[0]; w <= W; w++) {
		dp[w][0] = value[0];
	}

	for (int w = 0; w <= W; w++) {
		for (int i = 1; i < N; i++) {
			if (w - weight[i] < 0) {
				dp[w][i] = dp[w][i - 1];
				continue;
			}
			dp[w][i] = max(dp[w][i - 1], dp[w - weight[i]][i - 1] + value[i]);
		}
	}

	cout << dp[W][N - 1];


}



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

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i = 0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n);
  double d = (double)(a[0]+a[1])/2;
  for(int i = 2;i<n;i++){
    d = (d+a[i])/2;
  }
  cout << d << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
struct Istream {
	Istream() {
#ifdef DEBUG
		freopen("input","r",stdin);
#endif
	}
	template <class T> 
	Istream &operator >>(T &x) {
		static char ch;static bool neg;
		for(ch=neg=0;ch<'0' || '9'<ch;neg|=ch=='-',ch=getchar());
		for(x=0;'0'<=ch && ch<='9';(x*=10)+=ch-'0',ch=getchar());
		x=neg?-x:x;
		return *this;
	}
}is;
struct Ostream {
	template <class T>
	Ostream &operator <<(T x) {
		x<0 && (putchar('-'),x=-x);
		static char stack[233];static int top;
		for(top=0;x;stack[++top]=x%10+'0',x/=10);
		for(top==0 && (stack[top=1]='0');top;putchar(stack[top--]));
		return *this;
	}
	Ostream &operator <<(char ch) {
		putchar(ch);
		return *this;
	}
}os;
#define int64 long long
const int MAXN=1e5+11,P=1e9+7;
int64 Fact(int x) {
	int64 res=1;
	for(int i=1;i<=x;++i) {
		(res*=i)%=P;
	}
	return res;
}
int main() {
	int64 res=0;
	int n,m;is>>n>>m;
	if(n==m) {
		res=2*Fact(n)*Fact(m)%P;
	} else if(abs(n-m)==1) {
		res=Fact(n)*Fact(m)%P;
	}
	os<<res<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main(){
	int h, w, n, a; int out[100][100];
	cin >> h >> w >> n;
	int i, j; int nowx, nowy; nowx = 0; nowy = 0;
	for (i = 1; i <= n; i++) {
		cin >> a;
		for (j = 0; j < a; j++) {
			out[nowx][nowy] = i;
			if (nowy % 2 == 0) {
				nowx++;
				if (nowx == h) {
					nowx--; nowy++;
				}
			}
			else if (nowy % 2 == 1) {
				nowx--;
				if (nowx == -1) {
					nowx++; nowy++;
				}
			}
		}
	}
	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			cout << out[i][j] << " ";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int iinf = 1 << 29;
const int imax = ~(1 << 31);
const long long linf = 1ll << 61;
const long long lmax = ~(1ll << 63);

#define dump(x) cerr << #x << " : " << x << '\n'
#define MOD(x, y) (((y) + (x) % (y)) % (y))

int main(int argc, char* argv[])
{
	int N, K;
	scanf("%d%d", &N, &K);
	ll ans = 0;
	for (int b = K + 1; b <= N; b++) {
		ll n = N / b;
		ll i = (ll)n * ll(b - K);
		if (N % b >= K) {
			i += N - n * (ll)b - K + 1;
		}
		if (K == 0) {
			i--;
		}
		ans += i;
	}
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 256