akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359

int N,K;
int h[100000];
LL dp[100000][100];

LL solve(int now, int nokori){
	if(nokori < 0) return MAX;
	if(now == N-1) return abs(h[now]-h[now-(K-nokori)]);
	if(dp[now][nokori] != LL_MAX) return dp[now][nokori];
	return dp[now][nokori] = min(solve(now+1, nokori-1), abs(h[now]-h[now-(K-nokori)]) + solve(now+1, K-1));
}

int main(){
	cin >> N >> K;
	for(int i=0; i<N; i++){
		cin >> h[i];
		for(int j=0; j<K; j++) dp[i][j] = LL_MAX;
	}

	cout << solve(1,K-1) << endl;

	return 0;
}

Measured memory_bytes: 84992
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.close();
        solve(N);
      }
     
      static void solve(int N) {
        long ans = Long.MAX_VALUE;
        for (int i=0; i<=N; i++) {
          int tmpI = i;
          int tmpJ = N-i;
          int tmpAns = 0;
          while (tmpI > 0) {
            tmpAns += tmpI % 9;
            tmpI /= 9;
          }
          while (tmpJ > 0) {
            tmpAns += tmpJ % 6;
            tmpJ /= 6;
          }
          ans = Math.min(tmpAns, ans);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	int cnt=0;
	while(n){
		n/=k;
		cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


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

int main() {
    long N;
    cin >> N;
    if(N % 2 == 1)
    {
        cout << 0 << endl;
        return 0;
    }
    vector <long> d(N, 0);
    for(int i = 0;i < N; i++)
    {
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    cout << d[N / 2] - d[N / 2 - 1] << endl;
 }



Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    int N;
    cin >> N;
    vector<int> a(N), b(N), c(N);
    rep(i, N) cin >> a[i];
    rep(i, N) cin >> b[i];
    rep(i, N) cin >> c[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    //b[i]を固定して、a[j] < b[i]となるjの値の数と、c[k] > b[i]となるkの値の数を求め
    //その積が、b[i]を中段に使う時の作り方の数となる。
    ll ans = 0;
    rep(i, N){
        //a[j] < b[i]を満たすjの個数
        ll r = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        //b[i] < c[k]を満たすkの個数
        ll l = c.end() - upper_bound(c.begin(), c.end(), b[i]);
        ans += r * l;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4584
open System
open System.Numerics

// prelude
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let inc n = n + 1
let dec n = n - 1

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue
  
module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]
  let scan (arr: _ []) fold state =
    let mutable acc = state
    let dest = Array.zeroCreate arr.Length
    for i in 0..(arr.Length-1) do
      acc <- fold acc arr.[i]
      dest.[i] <- acc
    dest

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]

// start

let rec popCnt = function
| 0 -> 0
| n -> (if (n &&& 1) <> 0 then 1 else 0) + popCnt (n>>>1)

let main () =
  let (H, W, K) = readInts() |> triple

  let grid =
    let g = Array2D.create H W 0
    for y in 0..(H-1) do
      let s = readStr().ToCharArray()
      for x in 0..(W-1) do
        g.[y, x] <- if s.[x] = '1' then 1 else 0
    g

  seq {
    for split in 0..((1<<<H-1)-1) do
      let sum =
        let s = Array2D.create 10 W 0
        let mutable i = 0
        for y in 0..(H-1) do
          for x in 0..(W-1) do
            Array2D.modify s i x ((+) grid.[y, x])
          if (split &&& (1<<<y)) <> 0 then do i <- i + 1
        for y in 0..(10-1) do
          for x in 1..(W-1) do
            Array2D.modify s y x ((+) s.[y, x-1])
        s
      
      let pred x1 x2 =
        [0..9]
        |> List.forall (fun i ->
          let c = sum.[i, x2] - if x1=0 then 0 else sum.[i, x1-1]
          c <= K
        )
      
      let rec loop x1 x2 =
        if pred x1 x2 then Some 0
        else
          let rec f x = if pred x1 x then f (x+1) else x
          let x' = f x1
          if x'=x1 then None
          else loop x' x2 |> Option.map inc


      let cnt = (loop 0 (W-1) |> Option.getOr (10 * 1000)) + popCnt split
      yield cnt
  }
  |> Seq.min
  |> printfn "%A"

main()

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

vector<int> distX = {-1, -1, 0, 1, 1, 1, 0, -1};
vector<int> distY = {0, 1, 1, 1, 0, -1, -1, -1};

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    rep(i, H) {
        cin >> S.at(i);
    }

    rep(i, H) {
        rep(j, W) {
            if (S.at(i).at(j) == '#') continue;
            // 周りに何個「#」があるか調べる
            int count = 0;
            rep(k, 8) {
                int aroundY = i + distY.at(k);
                int aroundX = j + distX.at(k);
                if (aroundX < 0 || W - 1 < aroundX) continue;
                if (aroundY < 0 || H - 1 < aroundY) continue;
                if (S.at(aroundY).at(aroundX) == '#') count++;
            }
            S.at(i).at(j) = (char)('0' + count);
        }
    }

    rep(i, H) {
        cout << S.at(i) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
using std::swap;

int main()
{
	string S;
	cin >> S;
	for (int i = 0; i < 3; ++i) {
		if (S.substr(i, 1) == S.substr(i + 1, 1)) {
			cout << "Bad" << "\n";
			return 0;
		}
		
	}
	cout << "Good" << "\n";
	return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <map>
#include <functional>
#include <cstring>
#include <queue>
#include <cmath>
#include <deque>
#include <list>
#include <iomanip>
#include <fstream>
#include <string>
#include <iterator>
#include <set>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
#define mp make_pair
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, N) FOR(i, 0, N)
#define SZ(x) ((int)(x).size())
 
const int MAXN = 57, INF = 100000007;
 
int main()
{	
	int N, p;
	ll a[MAXN], K = 0;
	cin >> N;
	REP(i, N) scanf("%lld", a + i);
	while (true){
		p = 0;
		REP(i, N) if (a[i] > a[p]) p = i;
		if (a[p] < N) break;
		K += a[p]/N;
		REP(j, N) if (j != p) a[j] += a[p]/N;
		a[p] -= N*(a[p]/N);		
	}
	printf("%lld", K);
	//cout << endl; system("pause");//please
	return 0;
}//don't forget about const, please

Measured memory_bytes: 256
/* 
	بسم الله الرحمن الرحیم
	
	(; طلا یک جهانی
*/

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

#define F first
#define S second
typedef pair<int, int> pii;

const int MAX_N = 200 * 1000 + 5;
int n, q, s[MAX_N], t[MAX_N], x[MAX_N], id[MAX_N], d[MAX_N], ans[MAX_N];

void read_input() {
	cin >> n >> q;
	for (int i = 0; i < n; i++) {
		cin >> s[i] >> t[i] >> x[i];
		s[i] -= x[i];
		t[i] -= x[i];
		id[i] = i;
	}
	for (int i = 0; i < q; i++)
		cin >> d[i];
}

inline bool cmp(int &i, int &j) {
	return x[i] < x[j];
}

void solve() {
	memset(ans, -1, sizeof ans);
	sort(id, id + n, cmp);
	set<pii> st;
	for (int i = 0; i < q; i++)
		st.insert({d[i], i});
	for (int tmp = 0; tmp < n; tmp++) {
		int i = id[tmp];
		if (!st.empty()) {
			vector<pii> del;
			for (auto it = st.lower_bound({s[i], 0}); it != st.end() && it->F < t[i]; it++) {
				ans[it->S] = x[i];
				del.push_back(*it);
			}
			for (auto j: del)
				st.erase(j);
		}
	}
}

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

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	read_input();
	solve();
	print_output();
}


Measured memory_bytes: 17280
package main

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

var in = newIo(bufio.NewScanner(os.Stdin))

func main() {
	var s = in.next()
	var k = in.nextLong()
	print(solve(s, k))
}

func print(result string) {
	fmt.Println(result)
}

func solve(s string, k int64) string {
	var result string
	for i := 0; i < len(s) && int64(i) < k; i++ {
		result = string(s[i])
		if string(s[i]) != "1" {
			break
		}
	}
	return result
}

func count(n int, c int) bool {
	var count = 1
	for i := 2; i <= n; i++ {
		var e = 1
		for {
			if n%i != 0 {
				break
			}
			n = n / i
			e++
		}
		count = count * e
	}
	return count == c
}

type io struct {
	sc *bufio.Scanner
}

func newIo(sc *bufio.Scanner) *io {
	i := new(io)
	i.sc = sc
	i.sc.Split(bufio.ScanWords)
	return i
}
func (i *io) next() string {
	i.sc.Scan()
	return i.sc.Text()
}
func (i *io) nextInt() int {
	in, _ := strconv.Atoi(i.next())
	return in
}

func (i *io) nextLong() int64 {
	in, _ := strconv.ParseInt(i.next(), 10, 64)
	return in
}


Measured memory_bytes: 640
import java.io._
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.reflect.ClassTag

object Main {
  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val N = sc.nextInt()

    val ans = if (N % 2 == 0) {
      N
    } else N * 2

    out.println(ans)
  }

  def main(args: Array[String]): Unit = {
    solve()
    out.flush()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  def rep(n: Int)(f: Int => Unit): Unit = {
    var i = 0
    while(i < n) { f(i); i += 1 }
  }
  def rep_r(n: Int)(f: Int => Unit): Unit = {
    var i = n - 1
    while(i >= 0) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i))
    res
  }

  implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {
    // todo Orderingだとboxing発生するので自作Orderを用意したい
    def maxByOpt[B: Ordering](f: A => B): Option[A] = {
      if (as.nonEmpty) Some(as.maxBy(f)) else None
    }

    def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
      val map = mutable.Map.empty[K, ArrayBuffer[A]]
      rep(as.length)(i => map.getOrElseUpdate(f(as(i)), ArrayBuffer()) += as(i))
      map
    }

    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      var sum = num.zero
      rep(as.length)(i => sum = num.plus(sum, f(as(i))))
      sum
    }

    def minByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {
      limit(f, ixRange)(cmp.lt)
    }

    def maxByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {
      limit(f, ixRange)(cmp.gt)
    }

    private def limit[B](f: A => B, ixRange: Range)(cmp: (B, B) => Boolean): (A, B) = {
      var limA = as(ixRange.head)
      var limB = f(limA)

      for (i <- ixRange.tail) {
        val a = as(i)
        val b = f(a)
        if (cmp(b, limB)) {
          limA = a
          limB = b
        }
      }
      (limA, limB)
    }
  }

  implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {
    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))
    }
  }
}


Measured memory_bytes: 26560
#include<stdio.h>
int main(void){
	int a,b,c,d,e,f;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	e=a+b+c+d;
	f=e/60;
	e=e-(f*60);
	printf("%d\n%d\n",f,e);
	
	
	
	return 0;
}


Measured memory_bytes: 2140
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <stdlib.h>
/******memore********/
#define maxn
#define inf

int main()
{
	int c = 0;
	int w, a, b;
	scanf("%d%d%d",&w, &a, &b);
	if (b > a + w)
		c = b - (a + w);
	else if (b < a - w)
		c = a - w - b;
	printf("%d", c);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
using namespace std;
 main()
{   int n;
    cin>>n;
    int sum = 0;
    for(int i =1; i<=n; i++){
        sum+=(!(i % 3 == 0) && !(i % 5 == 0) ? i:0);
    }
    cout<<sum<<endl;
 
    return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  if(a>=b){
    for(int i=0;i<a;i++){
      cout << b;
    }
  }else{
    for(int i=0;i<b;i++){
      cout << a;
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#define int long long
#define double long double
#define oku7 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
using namespace std;
std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

double velocity[200000];
int accel[200000];


signed main() {
	int a, b,maxval,left;
	cin >> a >> b;
	int sa = b - a;
	int l=0, r=0;
	for (int i = 0; i < sa; i++) {
		l += i;
	}
	r = l + sa;
	cout << l - a << "\n";

	return 0;
}

Measured memory_bytes: 256
from collections import deque

S = input()
D = deque(S)
Q = int(input())

conr = 0

for i in range(Q):
  q = list(input().split())
  if q[0] == "1":
    conr += 1
  else:
    s = q[-1]
    f = int(q[1])
    if conr % 2 == 0:
      if f == 1:
        D.appendleft(s)
      else:
        D.append(s)
    else:
      if f == 1:
        D.append(s)
      else:
        D.appendleft(s)

D = list(D)
if conr % 2 == 1:
  D = D[::-1]
ans = "".join(D)
print(ans)

Measured memory_bytes: 10100
import std.stdio, std.algorithm, std.conv, std.array, std.string;

void main()
{
    auto stxy = readln.split.to!(int[]);
    auto xd = stxy[2] - stxy[0];
    auto yd = stxy[3] - stxy[1];

    string ret;
    foreach (_; 0..yd) ret ~= "U";
    foreach (_; 0..xd) ret ~= "R";
    foreach (_; 0..yd) ret ~= "D";
    foreach (_; 0..xd+1) ret ~= "L";
    foreach (_; 0..yd+1) ret ~= "U";
    foreach (_; 0..xd+1) ret ~= "R";
    ret ~= "DR";
    foreach (_; 0..yd+1) ret ~= "D";
    foreach (_; 0..xd+1) ret ~= "L";
    ret ~= "U";

    writeln(ret);
}

Measured memory_bytes: 332
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

void read();
template<typename First, typename... Rest> void read(First& first, Rest&... rest);
void write();
template<typename First, typename... Rest> void write(First first, Rest... rest);
template<typename T> void write_vec(vector<T>& v, char divider);

int main(){
    int N;
    read(N);
    vector<ll> A(N + 1);
    for(int i = 1; i <= N; i++){
        read(A[i]);
    }
    map<ll, int> mp1;
    map<ll, int> mp2;
    for(int i = 1; i <= N; i++){
        mp1[i - A[i]]++;
        mp2[i + A[i]]++;
    }
    ll ans = 0;
    for(int i = 1; i <= N; i++){
        ans += mp1[i + A[i]];
        ans += mp2[i - A[i]];
    }
    write(ans / 2);
    return 0;
}

//配列以外の入力を受け取る
void read(){

}
template<typename First, typename... Rest>
void read(First& first, Rest&... rest){
    cin >> first;
    read(rest...);
}
//
//配列以外を出力する
void write(){

}
template<typename First, typename... Rest>
void write(First first, Rest... rest){
    cout << first << " ";
    write(rest...);
}
//
//配列を区切って出力する
template<typename T>
void write_vec(vector<T>& v, char divider){
    for(size_t i = 0; i < v.size(); i++){
        cout << v[i] << divider;
    }
}
//

Measured memory_bytes: 50124
N, M = map(int, input().split())
LRD = [list(map(int, input().split())) for _ in range(M)]

INF = 10 ** 10
dist = [INF] * (N + 1)

graph = [[] for _ in range(N + 1)]
for i in range(M):
  L, R, D = LRD[i]
  graph[L].append((R, D))
  graph[R].append((L, -D))
#print("graph:", graph)

for i in range(1, N + 1):
  if dist[i] == INF:
    stack = [i]
    dist[i] = 0
    max_d = 0
    min_d = 0
    
    while stack:
      l = stack.pop()
      for r, d in graph[l]:
        if dist[r] != INF:
          if dist[r] != dist[l] + d:
            print("No")
            exit()
          else:
            continue
        else:
          stack.append(r)
          dist[r] = dist[l] + d
#print("dist:", dist)
print("Yes")       

Measured memory_bytes: 111960
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>

using namespace std;

long long a[2*100000+5];
long long sum[2*100000+5];
long long xo[2*100000+5];
int n;

int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];

  long long tmpsum = 0LL;
  sum[0] = 0;
  for(int i=0;i<n;i++){
    tmpsum += a[i];
    sum[i+1] = tmpsum;
  }


  long long tmpxor = 0LL;
  xo[0] = 0;
  for(int i=0;i<n;i++){
    tmpxor = tmpxor ^ a[i];
    xo[i+1] = tmpxor;
  }

  long long ans = 0;
  for(int i=0;i<n;i++){
    int st = i+1;
    int ed = n+1;
    while(1){
      if(st+1 == ed) break;
      int mid = (st+ed)/2;
      if( (sum[mid]-sum[i]) == (xo[mid]^xo[i]) ) st = mid;
      else ed = mid;
    }
    //cout<<i<<" st:"<<st<<" ed:"<<ed<<" "<<endl;
    ans += (st-(i+1) +1 );
  }

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

Measured memory_bytes: 4992
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
struct Node{
	int key;
	Node *parent, *left, *right;
	Node():parent(NULL),left(NULL),right(NULL),key(0){ }
};
Node *root=NULL;int m,cnt=0;
Node * insert(int k,Node *r){
	if(!r){
		r=new Node;
		r->key=k;
	}else if(k>r->key) {
		r->right=insert(k,r->right);
	}else {
		r->left=insert(k,r->left);
	}
	return r;
}
void inorder(Node * r){
	if(!r)return;
	inorder(r->left);
	cout<<" "<<r->key;
	inorder(r->right);
}
void preorder(Node *r){
	if(!r)return ;
	cout<<" "<<r->key;
	preorder(r->left);
	preorder(r->right);
}
void print(){
	cnt=0;
	inorder(root);
	putchar('\n');
	cnt=0;
	preorder(root);
	putchar('\n');
}
int main(){
	int key;
	string s;
	cin>>m;
	for(int i=0;i<m;i++){
		cin>>s;
		if(s=="insert"){
			cin>>key;
			root=insert(key,root);
		}else {
			print();
		}
	}
	return 0;
}


Measured memory_bytes: 26592
#![allow(non_snake_case,unused_imports,dead_code)]
use std::str::FromStr;
use std::collections::{HashMap,HashSet,VecDeque,BinaryHeap};
use std::cmp::{max,min,Reverse,Ordering};

use proconio::input;
use proconio::marker::{Chars,Usize1,Isize1};

fn comp_f64(a: &f64, b: &f64) -> Ordering {
    if a < b {
        return Ordering::Less;
    } else if a > b {
        return Ordering::Greater;
    }
    Ordering::Equal
}

fn main() {
    input!{
        H:usize,
        W:usize,
        S:[Chars;H],
    }

    let Map = ConvertGrid(H,W,&S,'.');
    let d = bfs_dist_grid(H, W, &Map, (0,0));
    if d[H-1][W-1]==-1{
        println!("-1");
    } else {
        let ans = Map.iter().map(|row| row.iter().filter(|&&b| b).count()).sum::<usize>() - d[H-1][W-1] as usize - 1;
        println!("{}",ans);
    }
}

fn ConvertGrid(H:usize,W:usize,Map:&Vec<Vec<char>>,C:char)->Vec<Vec<bool>>{
    let mut ret = vec![vec![false;W];H];
    for i in 0..H{
        for j in 0..W{
            ret[i][j] = Map[i][j] == C;
        }
    }
    ret
}

fn bfs_dist_grid(H:usize,W:usize,Map:&Vec<Vec<bool>>,start:(usize,usize)) -> Vec<Vec<i32>>{
    let mut d = vec![vec![-1;W];H];
    d[start.0][start.1] = 0;
    let mut q = VecDeque::new();
    q.push_back(start);
    while let Some((i,j)) = q.pop_front(){
        let dCur = d[i][j];
        for (di,dj) in vec![(!0,0),(1,0),(0,!0),(0,1)]{
            let i = i.wrapping_add(di);
            let j = j.wrapping_add(dj);
            if i>=H || j>=W {continue;}
            if !Map[i][j] {continue;}
            if d[i][j] != -1 {continue;}
            d[i][j] = dCur +1;
            q.push_back((i,j));
        }
    }
    d
}


Measured memory_bytes: 2208
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair
#include <cmath>

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

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

template <class InputIterator, class T>
bool contains_itr(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class T>
bool contains_set(set<T> st, const T &value)
{
    if (st.find(value) == st.end())
    {
        return false;
    }
    else
    {
        return true;
    }
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// endは排他的(exclusive)なので注意
vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}

// =========ここまでテンプレ============

int pow2(int n)
{
    int result = 1;
    rep(i, n)
    {
        result *= 2;
    }
    return result;
}

int main()
{
    ll h, w, k;
    cin >> h >> w >> k;
    vector<vector<char>> c(h, vector<char>(w));
    rep(i, h)
    {
        rep(j, w) cin >> c[i][j];
    }
    ll result = 0;
    rep(chooseH, pow2(h))
    {
        rep(chooseW, pow2(w))
        {
            vector<vector<char>> tempC = c;
            rep(i, h)
            {
                if (chooseH & (1 << i))
                {
                    rep(j, w)
                    {
                        tempC[i][j] = 'b';
                    }
                }
            }
            rep(j, w)
            {
                if (chooseW & (1 << j))
                {
                    rep(i, h)
                    {
                        tempC[i][j] = 'b';
                    }
                }
            }
            int count = 0;
            rep(i, h)
            {
                rep(j, w)
                {
                    if (tempC[i][j] == '#')
                        ++count;
                }
            }
            if (count == k)
                ++result;
        }
    }
    cout << result << endl;
}

Measured memory_bytes: 3204
#include <iostream>

#define NIL -1

using namespace std;

struct node{
    int id, parent, left, right;
};

struct node tree[50];

void preParse(int u){
    if(u == NIL) return;
    cout << " " << tree[u].id;
    preParse(tree[u].left);
    preParse(tree[u].right);
}

void inParse(int u){
    if(u == NIL) return;
    inParse(tree[u].left);
    cout << " " << tree[u].id;
    inParse(tree[u].right);
}

void postParse(int u){
    if(u == NIL) return;
    postParse(tree[u].left);
    postParse(tree[u].right);
    cout << " " << tree[u].id;
}

int main(){
    int n, tmpId, rootNode;
    cin >> n;
    for(int i = 0; i < n; i++) tree[i].id = tree[i].parent = tree[i].left = tree[i].right = NIL;
    for(int i = 0; i < n; i++){
        cin >> tmpId;
        tree[tmpId].id = tmpId;
        cin >> tree[tmpId].left >> tree[tmpId].right;
        if(tree[tmpId].left != NIL) tree[tree[tmpId].left].parent = tmpId;
        if(tree[tmpId].right != NIL) tree[tree[tmpId].right].parent = tmpId;
    }
    for(int i = 0; i < n; i++) if(tree[i].parent == NIL) rootNode = i;
    cout << "Preorder" << endl;
    preParse(rootNode);
    cout << endl << "Inorder" << endl;
    inParse(rootNode);
    cout << endl << "Postorder" << endl;
    postParse(rootNode);
    cout << endl;
    return 0;        
}

Measured memory_bytes: 3092
// inputに入力データ全体が入る
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    tmp0 = input[0].split(" ");
    N = Number(tmp0[0])
    D = Number(tmp0[1])
    
    num = []
    for(var i=1; i <= N; i++)
    {
        tmp = input[i].split(" ")
        x = []
        for(var j=1; j <= D; j++)
        {
            x.push(Number(tmp[j-1]))
        }
        num.push(x)
    }

    ans=0
    for(var i=1; i< N; i++)
    {
        for(var j=i+1; j <= N; j++)
        {
            var tmp = 0
            for(var k =0; k<D;k++)
            {
                tmp += Math.pow(Math.abs(num[i-1][k] - num[j-1][k]),2)
            }
            if(Math.round(Math.sqrt(tmp)) === Math.sqrt(tmp))
            {
                ans++
            }
        }
    }
    console.log(ans)
}
  //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main("3 2\n1 2\n5 5\n-2 8\n");

Measured memory_bytes: 7500
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <deque>
#include <set>
#include <numeric>
using namespace std;
using ll = long long;
using ld = long double;

const ll MOD = 998244353;
const ll INF = 1e+9;
const ld PI = acos((long double)(-1));

#define no "no"
#define No "No"
#define NO "NO"
#define yes "yes"
#define Yes "Yes"
#define YES "YES"
#define next '\n'
#define sp " "
#define print(x) cout << (x) << endl;
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(elem, _list) for(auto& (elem) : (_list))
#define view(_list) foreach(e, _list){ cout << e << sp; } cout << next
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define ALL(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e)
#define EPS 0.00000001

int main() {
    FAST;

    ll n, q, sum = 0;
    cin >> n;
    vector<ll> a(100010, 0);
    rep(i, n){
        ll e;
        cin >> e;
        a[e]++;
        sum += e;
    }

    cin >> q;
    rep(i, q){
        ll b, c;
        cin >> b >> c;

        sum -= a[b] * b;
        sum += a[b] * c;
        a[c] += a[b];
        a[b] = 0;

        print(sum);
    }
}


Measured memory_bytes: 3952
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);

        long n = sc.nextLong();

        final Map<Long, Integer> pfs = new HashMap<>();
        for (long i = 2; i*i <= n; i++) {
            int x = 0;
            while (n % i == 0) {
                n /= i;
                x++;
            }
            pfs.put(i, x);
        }

        if (n != 1) {
            pfs.put(n, 1);
        }

        int ans = 0;

        for (Map.Entry<Long, Integer> entry : pfs.entrySet()) {
            int x = entry.getValue();
            int b = 1;
            while (b <= x) {
                x -= b;
                b++;
                ans++;
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 106180
def main():
    *CMDs, = map(len, input().split('T'))
    X, Y = map(int, input().split())

    X -= CMDs[0]  # この操作だけは対称性がない

    def is_reachable(cmds, goal):
        SFT = 8000
        # [-SFT,SFT] -> [0,SFT*2]
        dp = 1 << SFT
        for d in cmds:
            dp = (dp >> d) | (dp << d)
        return SFT + goal >= 0 and (dp >> (SFT + goal)) & 1  # negative_shiftでRE

    cond = is_reachable(CMDs[2::2], X) and is_reachable(CMDs[1::2], Y)
    print('Yes' if cond else 'No')


if __name__ == '__main__':
    main()

# RE
# CMDs = [8000, 0]
# X, Y = -8000, 0


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int max = 0;
        for (int i = 1; i <= x; i++) {
            for (int j = 2; j <= 10; j++) {
                int num = (int) Math.pow(i, j);
                if (num > x) {
                    break;
                }
                if (num > max) {
                    max = num;
                }
            }
        }
        System.out.println(max);
    }

}


Measured memory_bytes: 23764
import java.io.*;
import java.util.*;
 
public class Main {
	static int binsearch(int arr[], int f, int l, int val)
    {
        if(f<=l)
        {
            int mid = (f+l)/2;
            if(arr[mid]==val)
                return binsearch(arr,f,mid-1,val);
            if(arr[mid]<val)
                return Math.max(mid,binsearch(arr,mid+1,l,val)); 
            if(arr[mid]>val)
                return binsearch(arr,f,mid-1,val);
        }
        return -1;
    }
    public static int lengthOfLIS(int[] nums) {
        if(nums.length==0)
            return 0;
        int ending[] = new int[nums.length];
        ending[0] = nums[0];
        int last = 0;
        int less;
        for(int i=1;i<nums.length;i++)
        {
            less = binsearch(ending,0,last,nums[i]);
            last = Math.max(last,less+1);
            ending[less+1] = nums[i];
        }
        return last+1;
    }
	public static void main(String[] args)throws IOException {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        
		int n = in.nextInt();
		int arr[] = new int[n];
		for(int i=0;i<n;i++)
		{
			arr[i]=in.nextInt();
		}
		int val = 1;
		int kitne = 0;
		for(int i=0;i<n;i++)
		{
			if(arr[i]==val)
			{
				kitne++;
				val++;
			}
		}
		if(kitne==0)
			out.println(-1);
		else
			out.println(n-kitne);
		out.close();
	}
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

    }

}

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

int n,a,b;

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

int main(){
	n=read(),a=read(),b=read();
	puts(((abs(a-b))&1)?"Borys":"Alice");
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

int main(void) {
	
	int n,k;
	cin >>n >>k;
	
	int h[n],i;
	for (i=0 ; i<n ; i++) {
		cin >>h[i];
	}
	
	sort(h,h+n);
	
	int d,dmin=h[n-1]-h[0];
	for (i=0 ; i<=n-k ; i++) {
		d=h[i+k-1]-h[i];
		if (d<dmin) dmin=d;
	}
	
	cout <<dmin <<endl;
	
	return 0;
}


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

int main() {
	int a, b, c, d;
	bool can;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	if (abs(a - c) <= d) {
		printf("Yes");
	}
	else {
		if (abs(a - b) <= d && abs(b-c) <= d) {
			printf("Yes");
		}
		else {
			printf("No");
		}
	}

	
	
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define ll long long
using namespace std;
const int MOD = 1000000007;
const long long INF = 1LL << 60;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, x, y;
  cin >> n >> x >> y;
  map<ll, ll> m;
  for (ll i = 1; i < n; i++) {
    for (ll j = i + 1; j < n + 1; j++) {
      ll stock = min(abs(x - i) + 1 + abs(j - y), abs(y - i) + 1 + abs(j - x));
      ll len = min(abs(j - i), stock);
      m[len]++;
    }
  }
  for (ll i = 1; i < n; i++) {
    cout << m[i] << endl;
  }
}

Measured memory_bytes: 3744
import math
n = int(input())
x = []
for i in range(n-1):
    x1,y1,z1=[int(i) for i in input().split()]
    x.append([x1,y1,z1])
dp = [0 for i in range(n)]
for i in range(0,n):
  ans = 0
  j = i+0
  while j < n-1:
    a = x[j]
    b = math.ceil(ans/x[j][2]) * x[j][2]
    if b < x[j][1]:
      b = x[j][1]
    ans = b + x[j][0]
    j += 1
  dp[i] = ans
for i in dp:
  print(i)

Measured memory_bytes: 3188
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N, K, X, Y; cin >> N >> K >> X >> Y;
  int result = min(N, K)*X + max(0, N-K)*Y;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
import Control.Monad

solve :: [Int] -> [[(String, Int -> Int -> Int)]] -> [String]
solve _ [] = []
solve params@[a, b, c, d] ([(c1, p1), (c2, p2), (c3, p3)]:ops)
  | a `p1` b `p2` c `p3` d == 7 = formula:solve params ops
  | otherwise = solve params ops
    where formula = concat [show a, c1, show b, c2, show c, c3, show d, "=7"]

main :: IO ()
main = do
  s <- map (read . (:[])) <$> getLine
  putStrLn . head . solve s $ replicateM 3 [("+", (+)), ("-", (-))]

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

int n;
map<int, int> memo;
bool flag = true;

int main(){
    cin >> n;
    int a;
    for(int i=0; i<n; i++){
        cin >> a;
        if(!memo.count(a)){
            memo[a] = 1;
        }
        else{
            flag = false;
            break;
        }
    }
    if(flag == true) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

using namespace std;

#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORD(i, m, n) for (int i = m; i >= n; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REP1(i, n) for (int i = 0; i <= n; ++i)
#define REPR(i, n) for (int i = n; i >= 0; --i)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using ll = long long;
using ull = unsigned long long;
using ld = long double;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin>>n;
	vector<int> a(n);
	vector<int> b(n);
	vector<int> c(n-1);
	REP(i,n){
		cin>>a[i];
		--a[i];
	}
	REP(i,n){
		cin>>b[i];
	}
	REP(i,n){
		cin>>c[i];
	}
	int sum=0;
	REP(i,n){
		sum+=b[a[i]];
		if(i>0&&a[i]==a[i-1]+1)sum+=c[a[i-1]];
	}
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
/* Solution by divyanshu0x16*/
#define int           long long 
#define setbits(x)    __builtin_popcountll(x)
#define zerobits(x)   __builtin_ctzll(x)
#define mod           1000000007 
#define modulo(a, b)  (a%b<0 ? a%b+b : a%b)
#define intpow(a,b)   (int)(pow(a,b) + 0.5)
#define gcd(a,b)      __gcd(a, b)
#define all(x)        (x).begin(), (x).end()
#define ps(x, y)      fixed<<setprecision(y)<<x
#define testcase(x)   int x; cin >> x; while(x--)
#define fastIO        ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set   tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef stack<int> si;
typedef queue<int> qi;
typedef priority_queue<int> pqi;


int32_t main() {
    fastIO;
    int t = 1;
    while(t--){
        int a, b, c, d; cin >> a >> b >> c >> d;
        vi products;
        products.push_back(a*c);
        products.push_back(a*d);
        products.push_back(b*c);
        products.push_back(b*d);
        cout << *max_element(products.begin(), products.end()) << "\n";
    }
    return 0;
}
 

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <cstdlib>

using namespace std;
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; }

const long long INF = 1LL << 60;

#define MOD 1000000007



int N;

long long h[100010];

long long dp[100010];

int main(){

    int N, K;

    cin >> N >> K;

    int h[N];

    for(int i = 0; i < N; ++i) cin >> h[i];

    for(int i = 0; i < 100010; ++i) dp[i] = INF;

    dp[0] = 0;

    for(int i = 0; i < N; ++i){
        for(int k = 1; k <= K; ++k){
            chmin(dp[i+k], dp[i] + abs(h[i+k] - h[i]));
        }
    }

    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1408
#include <iostream>
using namespace std;
int lengthS, lengthT = 0;                         //integer
static const int maxLengthS = 10000;
static const int maxLengthT = 500;
int ArrayS[maxLengthS], ArrayT[maxLengthT];      //Array

void NG(void)
{
    cout << "Invalid value!!" << endl;
    return;
}

void inputData(int *Array, int length, int maxLength)
{
    if(length > maxLength)
    {
        NG();
        return;
    }
     
    for(int i = 0; i < lengthS; i++)
    {
        cin >> Array[i];
    }
    return;
}
 
bool linearSearch(int *Array, int target, int key)
{
    bool result = false;
    for(int targetS = 0; targetS < target; targetS++)
    {
        if(Array[targetS] == key)
        {
            result = true;      //target found
        }
    }
    return result;
}
 
int main(void)
{
    //Input Data
    cin >> lengthS;       //Number of enter into ArrayS
    inputData(ArrayS,lengthS,maxLengthS);
     
    cin >> lengthT;       //Number of enter into ArrayT
    inputData(ArrayT,lengthT,maxLengthT);
     
    //Search
    int count = 0;
    for(int targetT = 0; targetT < lengthT; targetT++)
    {
        bool result = linearSearch(ArrayS, lengthS, ArrayT[targetT]);
        if(result == true)
        {
            count++;
        }
    }
     
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3096
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
using namespace std;
const int INF=INT_MAX/3;
const int V_MAX=15;

int G[V_MAX][V_MAX];
int DP[1<<V_MAX];

void WarshallFloyd(int V){
	for(int k=0;k<V;k++){
		for(int i=0;i<V;i++){
			for(int j=0;j<V;j++){
				G[i][j]=min(G[i][j],G[i][k]+G[k][j]);
			}
		}
	}
}

int MinimumCostMatching(int S,vector< vector<int> > &F){
	int P=F.size();
	if(DP[S]>=0){
		return DP[S];
	}
	if(S==0){
		return DP[0]=0;
	}
	int r=INF;
	for(int i=0;i<P;i++){
		for(int j=0;j<P;j++){
			if((S >> i)%2==1 && (S >> j)%2==1 && i!=j && F[i][j]<INF){
				int T= (S ^ 1<< i)^1<<j ;
				r = min(r, MinimumCostMatching(T,F)+F[i][j]);
			}
		}
	}
	return DP[S]=r;

}

int main(){
	int V,E,s,t,w,W;
	cin >> V >> E ;
	for(int i=0;i<V;i++){
		for(int j=0;j<V;j++){
			if(i==j){G[i][j]=0;}else{G[i][j]=INF;}
		}
	}

	vector<int> count(V,0);
	vector<int> evenodd;
	W=0;

	for(int i=0;i<E;i++){
		cin >> s >> t >> w ;
		G[s][t]=min(w,G[s][t]);
		G[t][s]=G[s][t];
		count[s]++;
		count[t]++;
		W+=w;
	}

	for(int i=0;i<V;i++){
		if(count[i] %2==1){
			evenodd.push_back(i);
		}
	}


	WarshallFloyd(V);
	int P = evenodd.size();

	vector< vector<int> > F(P,vector<int>(P));

	for(int i=0;i<P;i++){
		for(int j=0;j<P;j++){
			F[i][j]=G[evenodd[i]][evenodd[j]];
		}
	}

	memset(DP,-1,sizeof(DP));
	cout << W+MinimumCostMatching((1<<P)-1,F) << endl;

	return 0;
}

Measured memory_bytes: 1348
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const ll mod = 1e9+7;
const int N = 2e5+5;
void solve(){
	int x,xx,y,yy;
	cin>>x>>y>>xx>>yy;
	int dx = xx-x;
	int dy = yy-y;
	cout<<xx-dy<<" "<<yy+dx<<" "<<x-dy<<" "<<y+dx<<endl;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <functional>
#define inf 10000000
using namespace std;
typedef long long ll;
const int MAXN=1e9+10;
const int MAX=1e6+10;
const double eps=1e-6;

int n,m;
string s[110];
map<string,int>p;


int main(){


    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>s[i];
        p[s[i]]++;
    }
    string t;
    cin>>m;
    for(int i=1;i<=m;i++){
        cin>>t;
        p[t]--;
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        ans=max(ans,p[s[i]]);
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
from fractions import gcd
N, X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
x.sort()
diff = []
for i in range(N):
  diff.append(x[i+1]-x[i])

ans = diff[0]
for i in range(N):
  ans = gcd(ans, diff[i])
print(ans)

Measured memory_bytes: 16300
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    string s, t;
    cin >> s >> t;

    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<>());

    if (s < t) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

using namespace std;

int search (vector <int> num, int n, int key)
{
    int i = 0;
    
    num.push_back(key);
    while (num[i] != key)
    {
        i++;
    }
    
    return i != n;
}

int main(int argc, const char * argv[]) {
    int num1;
    int num2;
    int tmp;
    int sum = 0;
    vector<int> num;
    
    cin >> num1;
    for (int i = 0; i < num1; i++)
    {
        cin >> tmp;
        num.push_back(tmp);
    }
    
    cin >> num2;
    for (int i = 0; i < num2; i++)
    {
        cin >> tmp;
        if (search(num, num1, tmp))
        {
            sum++;
        }
    }
    
    cout << sum << endl;
    
    return 0;
}



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

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)
ll MOD = 1e9 + 7;

int n;

int main(void){
	cin>>n;

	string str = "";
	while (n != 0) {
		int r = n % 2;
		if (r < 0) r += 2;

		n = (n - r) / (-2);

		str += (char)('0' + r);
	}

	reverse(str.begin(), str.end());
	if (str == "") str = "0";

	cout<< str <<endl;
	
	return 0;
}

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

using namespace std;

#define rep(i, a, b) for(auto (i)=a;i<b;i++)
#define list(i, N) for(auto (i)=0;i<N;i++)

typedef long long ll;
typedef vector <ll> vi;
typedef pair <ll, ll> pi;
#define mp make_pair
#define pb push_back
#define eb emplace_back

#define int ll
#define INF 1e18+5
#define mod 1000000007

template<class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int32_t main() {

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

    int arr[3][3];
    list(i,3){
        list(j,3) cin >> arr[i][j];
    }

    bool marked[3][3];
    list(i,3){
        list(j,3) marked[i][j] = false;
    }

    int n; cin >> n;
    list(i,n){
        int a; cin >> a;
        //Now mark off the position as marked, if exists
        //Go through the whole bingo board and mark the position if exists
        list(l,3){
            list(m,3){
                if(arr[l][m]==a){
                    marked[l][m] = true;
                    break;
                }
            }
        }
    }

    string ANS = "No";
    for(int i = 0; i < 3; i++) {
     if(marked[i][0] and marked[i][1] and marked[i][2]) ANS = "Yes";
    }
    for(int i = 0; i < 3; i++) {
     if(marked[0][i] and marked[1][i] and marked[2][i]) ANS = "Yes";
    }
    if(marked[0][0] and marked[1][1] and marked[2][2]) ANS = "Yes";
    if(marked[0][2] and marked[1][1] and marked[2][0]) ANS = "Yes";
    cout << ANS << endl;

    return 0;
}

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

int main(){
  int n,k;
  cin>>n>>k;
  vector<int> d(n);
  for(int i=0;i<k;i++){
    int s;
    cin>>s;
    for(int j=0;j<s;j++){
      int a;
      cin>>a;
      d[a-1]=1;
    }
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(d[i]==0){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3596
object Main {

  case class Edge(v: Int)

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val V, E = sc.nextInt()
    val G = Array.fill(V+1)(List[Edge]())
    val Dim = Array.fill(V+1)(0)
    (0 until E) foreach { _ =>
      val u, v = sc.nextInt()
      G(u+1) ::= Edge(v+1)
      Dim(v+1) += 1
    }

    def topologicalSort(V: Int, E: Int, G: Array[List[Edge]], Dim: Array[Int]): List[Int] = {
      val visit = new Array[Boolean](V+1)

      def loop(stack: List[Int], sorted: List[Int]): List[Int] =
        if (stack.nonEmpty) {
          val u = stack.head
          if (u < 0) {
            loop(stack.tail, -u :: sorted)
          } else if (!visit(u)) {
            visit(u) = true
            loop(G(u).foldLeft(-u :: stack.tail)((stack, edge) =>
              if (!visit(edge.v)) {
                edge.v :: stack
              } else stack), sorted)
          } else loop(stack.tail, sorted)
        } else sorted

      def eachRoot(s: Int, sorted: List[Int]): List[Int] =
        if (s <= V) {
          if (Dim(s) == 0) eachRoot(s + 1, loop(s :: Nil, Nil) ::: sorted)
          else eachRoot(s + 1, sorted)
        } else sorted

      eachRoot(1, Nil)
    }

    println(topologicalSort(V, E, G, Dim).map(_ - 1).mkString("\n"))
  }

}



Measured memory_bytes: 116904