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

using namespace std;
#define BUF (100005)
#define ll long long 

int n;
int v[BUF];
int v_odd[BUF];
int v_even[BUF];

int odd1, even1;
int odd2, even2;
int odd_max, odd_second;
int even_max, even_second;
int ans;

int main(void){
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >> v[i];
		if(i%2) v_odd[v[i]]++;
		else   v_even[v[i]]++;
	}

	for(int i=0;i<BUF;i++){
		if(v_odd[i]>odd_max){
			odd_second = odd_max;
			odd_max = v_odd[i];
			odd2 = odd1;
			odd1 = i;
		}else if(v_odd[i]>odd_second){
			odd_second = v_odd[i]; 
			odd2 = i;
		}
		
		if(v_even[i]>even_max){
			even_second = even_max;
			even_max = v_even[i];
			even2 = even1;
			even1 = i;
		}else if(v_even[i]>even_second){
			even_second = v_even[i]; 
			even2 = i;
		}
	}


	if(odd1!=even1){
		cout << n-odd_max - even_max << endl;
	}else{
		cout << n-max(odd_max+even_second, odd_second+even_max) << endl;
	}


	return 0;
}


Measured memory_bytes: 1408
"use strict"

function main(input) {
  input = input.split(/\n|\s/).map(v => ~~v)
  const k = input[1]
  const nums = input.slice(2, -1).sort((a, b) => a - b)
  let ans = 0

  let items = []
  let pointer = null
  for (let i = 0; i < nums.length; i++) {
    if (
      i == 0 ||
      items[pointer].key == undefined ||
      items[pointer].key != nums[i]
    ) {
      pointer = pointer === null ? 0 : pointer + 1
      items[pointer] = {
        key: nums[i],
        count: 1
      }
    } else {
      items[pointer].count += 1
    }
  }

  // sort by count
  items.sort((a, b) => {
    return a.count - b.count
  })

  const diff = items.length - k
  const tar = items.slice(0, diff)
  for (let i in tar) {
    ans += tar[i].count
  }

  console.log(ans)
}
main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 69968
#include <iostream>

using namespace std;

int main() {
    int n;

    cin >> n;

    switch (n % 10) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        cout << "hon" << endl;
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        cout << "pon" << endl;
        break;

    default:
        cout << "bon" << endl;
        break;
    }

    return 0;
}

Measured memory_bytes: 3128
use std::collections::HashSet;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();

    let mut set = buf.split_whitespace()
        .map(|s| s.parse::<usize>().unwrap())
        .collect::<HashSet<usize>>();

    let r = set.clone();
    let max = r.iter().max().unwrap();
    set.remove(max);

    println!("{}", set.iter().product::<usize>() / 2)
}


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

int main(){
	int n;
	int a[100] = {};
	cin >> n;

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

	sort(a, a+n);

	int wa = 0;
	for(int i = 0;i < n-1;i++){
		wa += a[i];
	}

	if(wa > a[n-1]){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}
			



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <set>

#define lowbit(x) (x&(-x))
#define MAX(a,b) (a<b?b:a)
#define MIN(a,b) (a<b?a:b)
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int N = 1e7;
const int maxn = 3e5 + 5;
ll mod = 1e9 + 7;

ll f[1005][1005];
ll g[1005], inv[1005], inv2[1005][1005];

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

int n, A, B, C, D;

ll per(ll n, ll m)
{
	return g[n] * inv[n - m] % mod;
}

int main()
{
	g[0] = inv[0] = 1;
	for (int i = 1; i <= 1000; i++)
	{
		g[i] = g[i - 1] * i%mod;
		inv[i] = ss(g[i], mod - 2);
	}

	scanf("%d%d%d%d%d", &n, &A, &B, &C, &D);
	for (int i = A; i <= B; i++)
	{
		for (int j = C; j <= D; j++)
		{
			inv2[i][j] = ss(ss(g[i], j), mod - 2);
		}
	}
	f[A - 1][0] = 1;
	for (int i = A; i <= B; i++)
	{
		f[i][0] = 1;
		for (int j = 1; j <= n; j++)
		{
			f[i][j] = f[i - 1][j];
			for (int k = C; k <= D && i*k<=j; k++)
			{
				f[i][j] += f[i - 1][j - i * k] * per(j, i*k) % mod * inv2[i][k] % mod *inv[k] % mod;
				if (f[i][j] >= mod) f[i][j] -= mod;
			}
		}
	}

	cout << f[B][n];
}

Measured memory_bytes: 16000
require "matrix"

while input = gets
    input = input.chomp.split.map(&:to_i)
    a = Matrix[[input[0], input[1]], [input[3], input[4]]]
    b = Vector[input[2], input[5]]
    puts (a.inv * b).map{|i| "%#.03f" % i.to_f.round(3)}.to_a.join(" ")
end



Measured memory_bytes: 7220
def fact(n)
  return 1 if n <= 1
  n * fact(n-1)
end

def dist(point1, point2)
  x1 = point1[0]
  y1 = point1[1]
  x2 = point2[0]
  y2 = point2[1]

  Math.sqrt((x1 - x2)**2 + (y1 - y2)**2)
end

n = gets.chomp.to_i
points = []
n.times do
  points << gets.chomp.split.map(&:to_i)
end
sum = 0.0
(0...n).to_a.permutation do |route|
  1.upto(n-1) do |i|
    sum += dist(points[route[i]], points[route[i-1]])
  end
end
puts sum / fact(n)

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

int main() {
  in(int, n, k);
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  int ans = 0;
  for (int l = 0; l <= min(k, n); ++l) {
    for (int r = 0; r + l <= min(k, n); ++r) {
      multiset<int> s;
      rep(i, l) s.insert(v[i]);
      rep(i, r) s.insert(v[n - 1 - i]);
      rep(i, k - (l + r)) {
        if (!s.empty() && *s.begin() < 0) s.erase(s.begin());
      }
      ans = max(ans, accumulate(all(s), 0));
    }
  }
  out(ans);
}


Measured memory_bytes: 3632
N = int(input())
data = [0]*N
count = 0
for i in range(N):
  data[i] = list(map(int,input().split()))
  if data[i][0] == data[i][1]:
    count = count + 1
    if count >= 3:
      print("Yes")
      break
    else:
      None
  else:
    count = 0

if count < 3:
  print("No")

Measured memory_bytes: 9184
#include <stdio.h>
#include <iostream>
#include <vector>

int main() {
	int x[5];
	for (int i = 0;i < 5;i++) {
		std::cin >> x[i];
		if (x[i] == 0)
		{
			printf("%d", i + 1);
			break;
		}
	}


	return 0;
}

Measured memory_bytes: 3692
import java.util.*;

public class Main {

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

        final int N = sc.nextInt();
        Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i < N; i++) {
            String s = sc.next();
            if (!map.containsKey(s)) map.put(s, 0);
            map.put(s, map.get(s) + 1);
        }

        final int M = sc.nextInt();
        for (int i = 0; i < M; i++) {
            String t = sc.next();
            if (!map.containsKey(t)) map.put(t, 0);
            if (map.get(t) > 0) map.put(t, map.get(t) - 1);
        }

        Map.Entry<String, Integer> ans = map.entrySet().stream()
                .max(Comparator.comparing(Map.Entry::getValue))
                .get();

        System.out.println(ans.getValue());
    }
}


Measured memory_bytes: 28116
package main

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

func main() {
	N := ReadInt()
	sum := 0
	for i := 1; i <= N; i++ {
		sum += N / i * (i + N/i*i) / 2
	}
	fmt.Println(sum)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1872
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	resolve()
}

func resolve() {
	results := []int{}
	for true {
		w, h := scanInt(sc), scanInt(sc)
		if w == 0 && h == 0 {
			break
		}
		grid := make([][]int, h)
		for i := 0; i < h; i++ {
			grid[i] = make([]int, w)
			for j := 0; j < w; j++ {
				grid[i][j] = scanInt(sc)
			}
		}
		num := 0
		for i := range loop0(h) {
			for j := range loop0(w) {
				start := pos{y: i, x: j}
				if grid[start.y][start.x] == 0 {
					continue
				}
				num++
				_dfs(grid, w, h, start)
			}
		}
		results = append(results, num)
	}
	for _, v := range results {
		fmt.Println(v)
	}
	return
}

func _dfs(grid [][]int, w, h int, start pos) {
	grid[start.y][start.x] = 0
	for _, df := range []pos{
		pos{1, 0}, pos{-1, 0},
		pos{0, -1}, pos{0, 1},
		pos{1, 1}, pos{-1, -1},
		pos{-1, 1}, pos{1, -1},
	} {
		np := addPos(start, df)
		if np.y < 0 || h <= np.y || np.x < 0 || w <= np.x {
			continue
		}
		if grid[np.y][np.x] == 0 {
			continue
		}
		_dfs(grid, w, h, np)
	}
}

type pos struct{ x, y int }

func addPos(p, d pos) pos {
	return pos{
		x: p.x + d.x,
		y: p.y + d.y,
	}
}

func loop0(n int) chan int {
	return loop(0, n-1, 1)
}

func loop1(n int) chan int {
	return loop(1, n, 1)
}

func loop(s, e, d int) chan int {
	ch := make(chan int)
	go func() {
		for i := s; i <= e; i += d {
			ch <- i
		}
		close(ch)
	}()
	return ch
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}



Measured memory_bytes: 2456
#include <stdio.h>

int main()
{
    char s[12];
  	int i, c, j, k;
  	i = 0;
  	c = 0;
  	j = 0;
  	k = 0;
  	scanf("%s", &s);
    while (s[i] != '\0') {
      i = i + 1;
    }
      j = i - 1;
    i = 2;
    if (s[0] == 'A') {
        if ('a' <= s[1] && s[1] <= 'z') {
          while (s[i] != '\0') {
            if (s[i] == 'C') {
              i = i + 1;
              c = c + 1;
            }
            else if ('a' <= s[i] && s[i] <= 'z') {
              i = i + 1;
            } else {
              i = i + 1;
              k = k + 1;
            }
          }
          if (c == 1 && k == 0) {
            if ('a' <= s[j] && s[j] <= 'z') printf("AC");
            else printf("WA");
          } else {
            printf("WA");
          }
        } else {
          printf("WA");
        }
    } else {
        printf("WA");
    }
    return 0;
}

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

using namespace std;

const int N = 1e5 + 5;

int n;
int a[N];
int pos[N];
vector <pair <int, int> > v;

void solve() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		pos[a[i]] = i;
	}
	for (int i = 1; i <= n; i++) {
		cout << pos[i] << " ";
	}
}

int main() {
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif*/
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 1536
import sys
input = sys.stdin.readline

N, Q = map(int, input().split())
S = input().rstrip()
Query = []
for _ in range(Q):
    Alp, LR = map(str, input().rstrip().split())
    Query.append((Alp, LR))

S = "a" + S + "a"

left = 1
for Alp, LR in reversed(Query):
    if S[left-1] == Alp and LR == "R":
        left -= 1
    elif S[left] == Alp and LR == "L":
        left += 1

right = 1
for Alp, LR in reversed(Query):
    if S[-right] == Alp and LR == "L":
        right -= 1
    elif S[-1-right] == Alp and LR == "R":
        right += 1

print(max(0, N+2-left-right))

Measured memory_bytes: 17840
#include <bits/stdc++.h>
#define REP(type, i, a, b) for( type i = a; i <= b; i++ )
using namespace std;

int main(){
    int N, M, si, ci;
    int c[6];

    scanf("%d %d",&N,&M);
    REP(int,i,1,N) c[i]=-1;
    REP(int,i,1,M) {
        scanf("%d %d",&si,&ci);
        if(c[si]==-1){
            c[si]=ci;
        }else if(c[si]!=ci){
            printf("%d",-1);
            return 0;
        }
    }
  	if(c[1]==0&&N>1){
    	printf("%d",-1);
    	return 0;
  	}

    REP(int,i,1,N){
        if(c[i]!=-1){
            printf("%d",c[i]);
        }else if(i==1&&N>1){
          	printf("%d",1);
    	}else{
            printf("%d",0);
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    FASTINOUT;
    ll a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
    return 0;
}


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

int main() {
    Int n, a, b; cin >> n >> a >> b;
    n;
    a--;
    b--;

    if ((b-a)%2 == 0) {
        cout << (b-a)/2 << endl;
    }
    else {
        Int ans = 0;
        ans = min(a, n-1-b)+1 + (b-a-1)/2;
        cout << ans << endl;
    }
}

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

int A, B, C;
int X;

int main(int argc, char **argv)
{
	cin >> A >> B >> C >> X;

	int counter = 0;
	for (int ia = 0; ia <= A; ++ia)
	{
		for (int ib = 0; ib <= B; ++ib)
		{
			for (int ic = 0; ic <= C; ++ic)
			{
				if (ia * 500 + ib * 100 + ic * 50 == X)
					counter ++;
			}
		}
	}

	std::cout << counter << std::endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		int[] s=sc.Ia;
		Uf uf=new Uf(s[0]);
		StringBuilder sb=new StringBuilder();
		for(int i = 0;i<s[1];i++) {
			var e=sc.Ia;
			if(e[0]==0){uf.Union(e[1],e[2]);}
			else{sb.Append((uf.Same(e[1],e[2])?1:0)+"\n");}
		}
		Console.Write(sb);
	}
}
public class Uf{
	private int[] arr,hi;
	public int all;
	public Uf(int n){
		arr=new int[n];
		hi=new int[n];
		all=n;
		for(int i=0;i<n;i++){arr[i]=-1;}
	}
	public void Union(int a,int b){
		a=Root(a);
		b=Root(b);
		if(a!=b){
			if(hi[a]<hi[b]){
				int v=b;
				b=a;
				a=v;
			}
			arr[a]+=arr[b];
			hi[a]=Math.Max(hi[a],hi[b]+1);
			arr[b]=a;
			all--;
		}
	}
	public bool Same(int a,int b){return Root(a)==Root(b);}
	public int Total(int a){return -arr[Root(a)];}
	public int Root(int a){return arr[a]<0?a:arr[a]=Root(arr[a]);}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}


Measured memory_bytes: 22044
macro_rules! input { (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        n: usize,
        a: [usize; n],
        b: [usize; n]
    }
    let mut max: usize = (0..n)
        .map(|e| a[0..e + 1].iter().sum::<usize>() + b[e..].iter().sum::<usize>())
        .max()
        .unwrap();
    println!("{}", max);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define initrand mt19937 mt_rand(time(0));
#define rand mt_rand()

using namespace std;
#define mid(l, u) ((l+u)/2)
#define lchild(i) (i*2 + 1)
#define rchild(i) (i*2 + 2)
#define INF 10000000000000000
#define int long long
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int k[n+1];
    for(int i = 1;i<=n;i++) k[i] = 0;
    vector<int> adj[n+1];
    for(int i = 1;i<n;i++){
        int u, v;
        cin>>u>>v;
        if(u>v) swap(u, v);
        k[v] = max(k[v], u);
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for(int i = 1;i<=n;i++) sort(adj[i].begin(), adj[i].end());
    int dp[n+1];
    dp[0] = 0;
    int ans = 0;
    for(int i = 1;i<=n;i++){
        dp[i] = dp[i-1] + (i - k[i]);
        int ind = 1;
        int sum = 0;
        for(;ind<adj[i].size() && adj[i][ind]<i;ind++){
            dp[i] -= adj[i][ind-1];
            //dp[i] -= sum;
        }
        ans += dp[i];
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  long long H;
  cin>>H;
  int a=0;
  while(H>0){
    H=H/2;
    a++;
  }
  long long b=1;
  for(int i=0;i<a;i++){
    b=b*2;
  }
  cout<<b-1<< endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include <vector>
#include <utility>
#include <math.h>
#include <climits>
#include <string.h>
#include <algorithm>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <iomanip>

#define loopi(i,n) for(int i=0;i<n;i++)
#define loopi1(i,n) for(int i=1;i<=n;i++)
#define vin vector<int>v(n,0)
#define pi pair<int,int>
#define f first
#define s second
#define lli long long int
#define ll long long
#define li long int
#define MODPRM  1000000009
#define MOD 1000000007



int main() {
	// your code goes here
	ios::sync_with_stdio(false);
	cin.tie(NULL);
/*	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);

    // Printing the Output to output.txt file
    freopen("output.txt", "w", stdout);

	#endif // ONLINE_JUDGE*/
    int r;
    cin>>r;
    cout<<r*r<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double N;
  int Q;
  cin >> N;
  Q = N;
  
  if(Q%2==0){
    cout << ((N/2)/N) <<endl;
  }
  else{
    cout << ((Q/2+1)/N) <<endl;
  }
}
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N, M, X; cin >> N >> M >> X;
	vector<vector<int>>vec(N, vector<int>(M + 1));
	rep(i, 0, N)rep(j, 0, M + 1)cin >> vec[i][j];
	int ans = INF;
	for (int bit = 0;bit < (1 << N);++bit) {
		int cnt = 0;
		vector<int>v(M, 0);
		rep(i, 0, N) {
			if (bit & (1 << i)) {
				cnt += vec[i][0];
				rep(j, 0, M) {
					v[j] += vec[i][j + 1];
				}
			}
		}
		bool ok = true;
		rep(i, 0, M) {
			if (v[i] < X)ok = false;
		}
		if (ok)chmin(ans, cnt);
	}
	if (ans != INF) {
		cout << ans << "\n";
	}
	else cout << -1 << "\n";

	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
string s;
void solve()
{
    cin>>s;
    if(s[1]=='B') cout<<"ARC";
    else cout<<"ABC";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
return 0;
}



Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D, w) for(auto vec : vec2D) { for (auto v : vec) cerr << setw(w) << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

const char en = '\n';

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

typedef vector<vector<int>> Graph;
void add_edge(Graph& g, int from, int to, bool isDirected) {
	g[from].push_back(to);
	if (!isDirected) g[to].push_back(from);
}

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

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

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

	ll n,k; cin >> n >> k;

	vector<ll> a(n);
  rep(i,n) cin >> a[i];

	if (n == 1) {
		if (a[0] >= k) cout << 0 << endl;
		else cout << 1 << endl;
		return 0;
	}

	vector<vector<bool>> dp(n, vector<bool>(k,false)), dpr(n, vector<bool>(k, false));
	dp[0][0] = dp[0][a[0] < k ? a[0] : 0 ] = true;
	dpr[n-1][0] = dpr[n-1][a[n-1] < k ? a[n-1] : 0] = true;
	rep(i, n-1) rep(j, k) {
		if (dp[i][j]) {
			dp[i+1][j] = true;
			if (j+a[i+1] < k) dp[i+1][j+a[i+1]] = true;
		}

		if (dpr[n-i-1][j]) {
			dpr[n-i-2][j] = true;
			if (j + a[n-i-2] < k) dpr[n-i-2][j + a[n-i-2]] = true;
		}
	}

	ll ans = 0;
	rep(i, a[0]) if (k-i-1 >= 0 && dpr[1][k-i-1]) {ans++; break;}
	rep(i, a[n-1]) if (k - i - 1 >= 0 && dp[n-2][k - i - 1]) { ans++; break;}
	REP(i,1,n-1) {
		vector<ll> sum(k + 1);
		sum[0] = 0;
		rep(j, k) {
			sum[j+1] = sum[j] + dp[i-1][j];
		}
		rep(j,k) {
		  if (dpr[i+1][j]) {
			  if (sum[k-j] - sum[max(0LL, k-a[i]-j)] > 0) {ans++;break;}
			}
		}
	}

	cout << n - ans << endl;
}



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

using namespace std;

typedef long long int64;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef complex<double> point;
struct circle { point p; double r; };
struct line { point p, q; };

const double eps = 1e-9;

double sign(double x) { return x < -eps ? -1 : x > eps; }

double dot(point a, point b) { return real(conj(a) * b); }

// circle-line intersection
vector<point> intersect(line L, circle C)
{
	point u = L.p - L.q, v = L.p - C.p;
	double a = dot(u, u), b = dot(u, v), c = dot(v, v) - C.r*C.r;
	double det = b*b - a*c;
	if (sign(det) < 0) return {};              // no solution
	if (sign(det) == 0) return {L.p - b/a*u}; // touch
	return {L.p + (-b + sqrt(det))/a*u,
			L.p + (-b - sqrt(det))/a*u};
}

point read(){
	double x, y; cin >> x >> y;
	return point(x, y);
}

namespace std
{
	bool operator<(point a, point b)
	{
		if (a.real() != b.real())
			return a.real() < b.real();
		return a.imag() < b.imag();
	}
}


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

	point c = read(); 
	double r; cin >> r;
	circle cir = {c, r};

	int n; cin >> n;

	for (int i = 0; i < n; ++i){
		point p = read(), q = read();
		line l = {p, q};
		auto ans = intersect(l, cir);
		if (ans.size() == 1) ans.push_back(ans[0]);
		sort(ans.begin(), ans.end());
		cout.precision(20);
		for (auto pp : ans)
			cout << fixed << pp.real() << " " << pp.imag() << " ";
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1308
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
/*bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
} */
int main()
{
     ll t,kk,pk;
     cin>>t;
     queue<ll>q;
     for(int i=1;i<=9;i++)
        q.push(i);
     for(int i=0;i<t;i++)
     {
         pk=q.front();
         q.pop();
         kk=pk%10;
         if(kk!=0)
         q.push(pk*10+kk-1);
         q.push(pk*10+kk);
         if(kk!=9)
            q.push(pk*10+1+kk);
     }
     cout<<pk<<endl;

}



Measured memory_bytes: 1792
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect
import functools

@functools.lru_cache(None)
def dfs(i,sum_v,val):
    if i == n:
        return sum_v == val
    if dfs(i+1,sum_v,val):
        return True
    if dfs(i+1,sum_v + A[i],val):
        return True
    return False
n = int(input())
A = list(map(int,input().split()))
q = int(input())
m = list(map(int,input().split()))

for i in range(q):
    if dfs(0,0,m[i]):
        print("yes")
    else:
        print("no")




Measured memory_bytes: 126024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X,Y,A,B,C;
    cin >> X >> Y >> A >> B >> C;
    vec<ll> P(A),Q(B),R(C);
    for(int i=0;i<A;i++) cin >> P[i];
    for(int i=0;i<B;i++) cin >> Q[i];
    for(int i=0;i<C;i++) cin >> R[i];
    sort(P.rbegin(),P.rend());
    sort(Q.rbegin(),Q.rend());
    sort(R.rbegin(),R.rend());
    ll ans = 0;
    priority_queue<ll> red,green;
    for(int i=0;i<X;i++){
        ans += P[i];
        red.push(-P[i]);
    }
    for(int i=0;i<Y;i++){
        ans += Q[i];
        red.push(-Q[i]);
    }
    ll inf = 1e18;
    for(int i=0;i<C;i++){
        ll r = -inf,g = -inf;
        if(!red.empty()) r = red.top();
        if(!green.empty()) g = green.top();
        if(r<g){
            if(-g>R[i]) break;
            ans += R[i]+g;
            green.pop();
        }else{
            if(-r>R[i]) break;
            ans += R[i]+r;
            red.pop();
        }
    }
    cout << ans << "\n";
}

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

int main() {
	// your code goes here
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;++i){ cin>>a[i]; }//cout<<a[i];}
	int dp[n];
	for(int i=1;i<n;i++)
	{
		dp[i]=999999999;
	}
	dp[0]=0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<=i+k;j++)
		{
			if(j<n)
			{
			dp[j]=min(dp[i]+abs(a[i]-a[j]),dp[j]);
			//cout<<dp[i]+abs(a[i]-a[j])<<endl;
			//cout<<dp[j]<<" ";
			}
		}
	}
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        long[] s = new long[n + 1];
        long sum = 0;
        for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextLong();
            sum += a[i];
            s[i + 1] = sum;
        }
        long ans = Long.MAX_VALUE;
        for (int i = 0 ; i < n ; i++) {
            long b = s[i + 1];
            long c = s[n] - s[i + 1];
            ans = Math.min(ans, Math.abs(c - b));
        }

        System.out.println(ans);

    }

}

Measured memory_bytes: 93208
#include<iostream>
int main(){
	std::ios_base::sync_with_stdio(false);std::cin.tie(NULL);
	int s,k; std::cin>>k>>s;
	std::cout << ((s+2)*(s+1)-(k>s?0:3*(s-k+1)*(s-k))+(k*2>s?0:3*(s-2*k)*(s-2*k-1)))/2;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	x=0;char c=getchar();bool f=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return  x;
}
template<class t> inline void write(t x){
	if(x<0){putchar('-'),write(-x);}
	else{if(x>9)write(x/10);putchar('0'+x%10);}
}

int n;

signed main(){
	read(n);
	for(int i=1;i<=n;i++) if(floor(i*1.08)==1.0*n){
		write(i);
		return 0;
	}
	printf(":(");
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;
int POW(int x,int y){return int(pow(double(x),double(y)));}



int main(){
	
	int a,b,c,x,y;
	cin>>a>>b>>c>>x>>y;
	int M=INF;
	int d=min(b,2*c);
	FOR(i,0,x+1){
		int z=a*(x-i)+2*c*i+d*max(y-i,0);
		M=min(M,z);
	}
	cout<<M<<endl;
}


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

using namespace std;
typedef long long ll;

int main() {
	int N, K;
	ll v[100];

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

	ll ans = 0;
	for (int left = 0; left <= min(K, N); left++) {
		for (int right = 0; left + right <= min(K, N); right++) {
			priority_queue<ll> pq;
			ll tmp = 0;
			for (int i = 0; i < left; i++) {
				tmp += v[i];
				if(v[i] < 0) pq.push(v[i] * -1);
			}

			for (int i = 0; i < right; i++) {
				tmp += v[N - 1 - i];
				if(v[N - 1 - i] < 0) pq.push(v[N - 1 - i] * -1);
			}
			int rest = K - left - right;
			while (pq.size() && rest > 0) {
				rest--;
				tmp += pq.top();
				pq.pop();
			}
			ans = max(ans, tmp);
		}
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long int ll;
#define    mod      1000000007
#define    speed    ios_base::sync_with_stdio(false);
#define    up       cin.tie(NULL);
#define    pb       push_back
#define    mp       make_pair
#define    T        int t; cin >> t; while(t--)
ll dp[100005] , arr[100005];
int n;

ll solve(int i){
    if(i > n){
        return 100000;
    }
    if(i==n){
        return 0;
    }
    if(dp[i]!=-1){
        return dp[i];
    }
    ll temp1 = abs(arr[i+1] - arr[i]) + solve(i+1);
    ll temp2 = abs(arr[i+2] - arr[i]) + solve(i+2);
    return (dp[i] = min(temp1 , temp2));
}

int main(){
  for(int i = 0; i <= 100000; i++){
      dp[i] = -1;
  }
  cin >> n;
  for(int i = 1; i <= n; i++){
      cin >> arr[i];
  }
  cout << solve(1) << '\n';
}

Measured memory_bytes: 4864
def mp(a,n)
  10*(a.size-1) + (a.inject(:+)-n).abs
end
def calc(a,b,c)
  mp(a,A)+mp(b,B)+mp(c,C)
end
def dfs(a,b,c,i)
  return (a.empty? || b.empty? || c.empty?) ? 10**10 : calc(a,b,c) if i==N
  [dfs(a,b,c,i+1),dfs(a+[L[i]],b,c,i+1), dfs(a,b+[L[i]],c,i+1),dfs(a,b,c+[L[i]],i+1)].min
end
N,A,B,C=gets.split.map(&:to_i)
L=N.times.map{gets.to_i}
p dfs([],[],[],0)

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[201], s2[101], p[101];
  cin >> s;
  cin >> p;
  strcpy(s2, s);
  strcat(s, s2);
  if (strstr(s, p)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3100
#include<stdio.h>
#include <assert.h>
#include <stdio.h>
#include <string.h>

/*
	入力例：
	3
	1 1 3
*/
int main(){
	char strInput[1];
	int i,j;
	for(i=0;i<1;i++){
	 scanf("%c", &strInput[i]);
	}

	if( 'a'<=strInput[0] && strInput[0] <='z'){
		printf("a");
	} else {
		printf("A");
	}
  return 0;
}

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

ll findpow(ll a,ll b){
    ll cnt=0,i,j;
    while(a>1){
        a=a/b;
        cnt++;
    }
    return cnt;
}

int main() {
	
	ll n,m,i,j,k,l,t,y,x,flag=0,flag1=0;
//	cin>>t;
	ll a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	cin>>k;
	cout<<a[k-1];
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n;
    scanf("%d", &n);
    char name[11]; 
    int count[5] = {0};
    long ans = 0;
    for (int i = 0; i < n; i++){
        scanf("%s", name);
        switch(name[0]){
            case 'M':
            count[0] += 1;
            break;
            case 'A':
            count[1] += 1;
            break;
            case 'R':
            count[2] += 1;
            break;
            case 'C':
            count[3] += 1;
            break;
            case 'H':
            count[4] += 1;
            break;
            default:
            break;
        }
    }

    for(int i = 0; i < 3; i++){
        for(int j = i+1; j < 4; j++){
            for(int k = j+1; k < 5; k++){
                ans += (long) count[i] * count[j] * count[k];
            }
        }
    }
    printf("%ld\n", ans);
    return 0; 
}

Measured memory_bytes: 128
string = input()

ret = 0
i = 0
j = 0
if string == "keyence":
    ret = 1

while i < len(string):
    j = i 
    while j < len(string):
        kiritori = string[:i] + string[j:]
        if kiritori == "keyence":
            ret = 1
        j += 1
    i += 1


if ret == 1:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;

typedef pair < int , int > Pi;
typedef pair < int , Pi > Pii;
#define fr first
#define sc second
#define INF ( 1 << 30 )

int L, n;
Pii data[1000];
map< int , int > used;

int dis( int a, int b){
  return b - a;
}


int rec( int point, int pos){
  if(used.find(point) != used.end()) return used[point];

  if(pos == n){
    return dis( point, L);
  }
  if( point == data[pos].fr ){
    int ret = dis( point, L);
    if(pos + 1 < n) ret = min( rec( data[pos + 1].fr, pos + 1) + dis( data[pos].fr, data[pos + 1].fr), ret);
    ret = min( ret, rec( point + data[pos].sc.fr, pos + 1) + data[pos].sc.sc);
    return used[point] = ret;
  }else if(point > data[pos].fr){
    return rec( point , pos + 1);
  }else{
    return rec( data[pos].fr, pos) + dis( point, data[pos].fr);
  }
}


int main(){
  cin >> L >> n;
  for(int i = 0 ; i < n ; i++ ){
    cin >> data[i].fr >> data[i].sc.fr >> data[i].sc.sc;
  }
  sort( data, data + n);

  cout << rec( 0, 0) << endl;
}


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

int main(){
    int h,w;
    while(1){
        cin>>h>>w;
        if(h==0&&w==0){
            break;
        }
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(i==0||i==h-1||j==0||j==w-1){
                    cout<<"#";
                }else{
                    cout<<".";
                }
            }
            cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3052
#include <bits/stdc++.h> 
using namespace std; 
double a, b, x; 
double Rad_to_deg = 45.0 / atan(1.0); 
int main (void ) {
	cin >> a >> b >> x; 
	if (x >= (a * a * b)/2) {
		double C = 2.0 * b - (2.0 * x / (a * a)); 
		double hu = atan (a / C); 
		hu = hu * Rad_to_deg * 1.0; 
		printf ("%.10lf\n", 90.0000000 - hu); 
	}
	else {
		double A = (2.0 * x)/(a * b); 
		double hu = atan (A / b); 	
		hu = hu * Rad_to_deg * 1.0; 
		printf ("%.10lf\n", 90.0000000 - hu); 
	}
	return 0; 
}

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

int n, m;
vector<int> g[100001];
bool vis[100001];

int main(){
	scanf("%d%d", &n, &m);
	f(i, 0, m){
		int a, b;
		scanf("%d%d", &a, &b);
		g[a].push_back(b);
		g[b].push_back(a);
	}
	deque<int> q;
	q.push_back(1);
	q.push_back(g[1][0]);
	vis[1] = vis[g[1][0]] = true;
	while (true){
		int v = q.front();
		f(i, 0, g[v].size()){
			int u = g[v][i];
			if (vis[u])continue;
			vis[u] = true;
			q.push_front(u);
			break;
		}
		if (q.front() == v)break;
	}
	while (true){
		int v = q.back();
		f(i, 0, g[v].size()){
			int u = g[v][i];
			if (vis[u])continue;
			vis[u] = true;
			q.push_back(u);
			break;
		}
		if (q.back() == v)break;
	}
	printf("%d\n%d", (int)q.size(), q.front());
	q.pop_front();
	while (!q.empty()){
		printf(" %d", q.front());
		q.pop_front();
	}
	printf("\n");
}

Measured memory_bytes: 7808
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
#define forg(i,x) for(int i=first[x];i;i=nxt[i])
#define uu unsigned
#define fi first
#define se second
#define lam(z,k) [&](const z &a,const z &b){ return k; }
#define od(x) ((x)&1)
#define ev(x) (od(x)^1)
#define mi2(x) (1<<(x))
#define scanf a1234=scanf
int a1234;
char buf[1<<18],*bufs=buf,*buft=buf;
inline int gc(){
    return bufs==buft&&(buft=(bufs=buf)+fread(buf,1,1<<18,stdin)),bufs==buft?-1:*bufs++;
}
inline void xxx(){for(;;);}

const int mxn=2003,mod=1e9+7;
int n,k;
int dp[mxn][mxn],fac[mxn*mxn],inv[mxn*mxn];
inline int por(long long a,int b){
    long long res=1;
    for(;b;b>>=1){
        if(b&1)res=res*a%mod;
        a=a*a%mod;
    }
    return res;
}
inline long long C(int a,int b){return 1ll*fac[a]*inv[a-b]%mod*inv[b]%mod;}
inline long long P(int a,int b){return 1ll*fac[a]*inv[a-b]%mod;}
inline long long cha(int a,int b){return C(a+b,a);}
template<class T>inline void tsum(T &a,int b){a+=b;if(a>=mod)a-=mod;}
int main(){
    scanf("%d%d",&n,&k);if(k==1)return puts("1"),0;
    fac[0]=inv[0]=1;for(int i=1;i<=n*k;++i)fac[i]=1ll*fac[i-1]*i%mod;
    inv[n*k]=por(fac[n*k],mod-2);for(int i=n*k-1;i;--i)inv[i]=1ll*inv[i+1]*(i+1)%mod;
    dp[1][1]=1;
    for(int i=1;i<=n;++i)for(int j=i;j;--j){
        //printf("%d %d %d\n",i,j,dp[i][j]);
        tsum(dp[i][j-1],dp[i][j]);
        if(!dp[i][j])continue;
        dp[i][j]=dp[i][j]*cha((i-1)*k-j+1,k-2)%mod;
        
        tsum(dp[i+1][j+1],dp[i][j]);
//        for(int jj=1;jj<=j+1;++jj)tsum(dp[i+1][jj],dp[i][j]*cha(i*k-jj+1,k-2)%mod);//,printf("%d %d %d\n",i+1,jj,dp[i+1][jj]);
    }
    long long ans=0;
    for(int i=1;i<=n;++i)tsum(ans,dp[n][i]);
    printf("%lld\n",ans*fac[n]%mod);
    return 0;
}


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

// LCA
vector<vector<array<int,3>>> v(100010);
int depth[100010];
int par[100010][20];

// 根からの深さと1つ上の親を求める. initの中で使う
void dfs2(int p,int d,int pre){
    depth[p] = d;
    for(auto e:v[p]){
        int i=e[0], c=e[1], di=e[2];
        if(i!=pre){
            dfs2(i,d+1,p);
            par[i][0] = p;
        }
    }
}

// init(n, root) でダブリングテーブルを作製する, nは頂点数
void init(int n,int root=0){
    for(int i=0;i<n;i++){
        for(int j=0;j<20;j++){
            par[i][j] = -1;
        }
    }
    dfs2(root,0,-1);
    for(int j=1;j<20;j++){
        for(int i=0;i<n;i++){
            if(par[i][j-1] == -1) continue;
            par[i][j] = par[par[i][j-1]][j-1];
        }
    }
}

//頂点aのd個上の親を求める
ll get_nyaa(ll a,ll d){
    for(ll i=19;i>=0;i--){
        if(d & (1<<i)) a = par[a][i];
    }
    return a;
}

// a,bのLCAを求める
int lca(int a,int b){
    if(depth[a] < depth[b]) swap(a,b);
    int dif = depth[a] - depth[b];
    for(int i=19;i>=0;i--){
        if(dif & (1<<i)) a = par[a][i];
    }
    if(a==b) return a;
    for(int i=19;i>=0;i--){
        if(par[a][i]!=par[b][i]){
            a = par[a][i], b = par[b][i];
        }
    }
    return par[a][0];
}

ll dist[100020];
int cnt[100010];
ll dc[100010];
map<int,int> col[100010];
map<int,ll> dcol[100010];

void dfs(int p,int d,int pre){
    dist[p]=d;
    for(auto e:v[p]){
        int i=e[0],c=e[1],di=e[2];
        if(i != pre){
            cnt[c]++;
            dc[c] += di;
            for(auto &k:col[i]){
                k.second = cnt[k.first];
                dcol[i][k.first] = dc[k.first];
            }
            dfs(i,d+di,p);
            cnt[c]--;
            dc[c] -= di;
        }
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
 
    int n,q;
    cin>>n>>q;
    for(int i=0;i<n-1;i++){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        a--,b--;
        v[a].push_back({b,c,d});
        v[b].push_back({a,c,d});
    }
    init(n,0);
    array<int,5> a[q];
    for(int i=0;i<q;i++){
        int c,d,x,y;
        cin>>c>>d>>x>>y;
        x--,y--;
        int l = lca(x,y);
        a[i] = {c,d,x,y,l};
        col[x][c]=0;
        col[y][c]=0;
        col[l][c]=0;
    }
    dfs(0,0,-1);
    for(int i=0;i<q;i++){
        int x=a[i][2],y=a[i][3],l=a[i][4];
        ll c=a[i][0],d=a[i][1];
        ll ans = dist[x]+dist[y]-2*dist[l] + (col[x][c]+col[y][c]-2*col[l][c])*d;
        ans -= dcol[x][c] + dcol[y][c] - 2*dcol[l][c];
        cout << ans << "\n";
    }


    
}

Measured memory_bytes: 59064
#include <iostream>

using namespace std;

int color[6];

class DICE
{
public:
    void set_num (int a[])
    {
        for (int i=0; i<6; i++)
        {
            dicenum[i]=a[i];
        }
    }
    void make_move (char c)
    {
        int temp;
        if (c=='N')
        {
            temp=dicenum[4];
            dicenum[4]=dicenum[0];
            dicenum[0]=dicenum[1];
            dicenum[1]=dicenum[5];
            dicenum[5]=temp;
        }
        if (c=='S')
        {
            temp=dicenum[1];
            dicenum[1]=dicenum[0];
            dicenum[0]=dicenum[4];
            dicenum[4]=dicenum[5];
            dicenum[5]=temp;
        }
        if (c=='E')
        {
            temp=dicenum[2];
            dicenum[2]=dicenum[0];
            dicenum[0]=dicenum[3];
            dicenum[3]=dicenum[5];
            dicenum[5]=temp;
        }
        if (c=='W')
        {
            temp=dicenum[3];
            dicenum[3]=dicenum[0];
            dicenum[0]=dicenum[2];
            dicenum[2]=dicenum[5];
            dicenum[5]=temp;
        }
    }
    void get_color ()
    {
        for (int i=0; i<6; i++) color[i]=dicenum[i];
    }
private:
    int dicenum[6];
};

int main()
{
    int a[6], b[6];
    bool ok=false, f;
    DICE dice;
    for (int i=0; i<6; i++) cin>>a[i];
    for (int i=0; i<6; i++) cin>>b[i];
    dice.set_num(a);
    for (int i=0; i<5; i++)
    {
        for (int j=0; j<5; j++)
        {
            for (int k=0; k<5; k++)
            {
                for (int l=0; l<5; l++)
                {
                    for (int m=0; m<=i; m++) dice.make_move('N');
                    for (int m=0; m<=j; m++) dice.make_move('S');
                    for (int m=0; m<=k; m++) dice.make_move('E');
                    for (int m=0; m<=l; m++) dice.make_move('W');
                    f=true;
                    dice.get_color();
                    for (int m=0; m<6; m++)
                    {
                        if (color[m]!=b[m]) f=false;
                    }
                    if (f)
                    {
                        cout<<"Yes\n";
                        ok=true; i=4; j=4; k=4; l=4;
                    }
                }
            }
        }
    }
    if (!ok) cout<<"No\n";
    return 0;
}



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

using namespace std;

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


int n;
int A[200005];
int B[200005];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n;
    for(int i=0;i<n;i++) cin>>A[i];
    int p=0;
    for(int i=n-1;i>=0;i-=2) B[p++] = A[i];
    for(int i=(n)%2;i<n;i+=2) B[p++] = A[i];
    for(int i=0;i<n;i++) cout<<B[i]<<' ';
    return 0;
}


Measured memory_bytes: 3712
import sys,math
from collections import deque,defaultdict
import operator as op
from functools import reduce

sys.setrecursionlimit(10**6) 

I=sys.stdin.readline

 #s="abcdefghijklmnopqrstuvwxyz"

"""
x_move=[-1,0,1,0,-1,1,1,-1]
y_move=[0,1,0,-1,1,1,-1,-1]
"""
def ii():
	return int(I().strip())
def li():
	return list(map(int,I().strip().split()))
def mi():
	return map(int,I().strip().split())

def ncr(n, r):
    r = min(r, n-r)
    numer = reduce(op.mul, range(n, n-r, -1), 1)
    denom = reduce(op.mul, range(1, r+1), 1)
    return numer // denom

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x




	
def main():
	s=I().strip()
	t=I().strip()
	win=len(t)
	ans=999999
	for i in range(len(s)-win+1):
		x=0
		for j in range(win):
			if s[i+j]!=t[j]:
				x+=1
		ans=min(ans,x)
	print(ans)

			


	

























	
	
	





if __name__ == '__main__':
	main()

Measured memory_bytes: 9440
#include <iostream>
#include <unordered_map>

using namespace std;

int main(void)
{
  int n;
  cin >> n;
  string si;
  int i;
  unordered_map<string, int> keihin;
  for (i = 0; i < n; i++) {
    cin >> si;
    if (keihin.find(si) == keihin.end()) keihin[si] = 1;
  }
  cout << keihin.size() << endl;

  return 0;
}


Measured memory_bytes: 17688
n = int(input())
a = list(map(int,input().split()))
q = a[-1]

s = []

for i in range(n):
	s.append(0)

if n%2==1:
	for i in range(n//2+1):
		s[i]=a[-1-2*i]
	for i in range(n//2):
		s[n//2+1+i]=a[2*i+1]
else:
	for i in range(n//2):
		s[i]=a[-1-2*i]
	for i in range(n//2):
		s[n//2+i]=a[2*i]
s = map(str,s)
print(" ".join(s))


Measured memory_bytes: 29456
#include<iostream>
#include<algorithm>
using namespace std;
int isprime(int n)
{
int check=1;
for(int i=2;i<n/2;i++)
{
if(n%i==0)
	{check=0;break;}
else continue;}
return check;
}
int main()
{
string s;
cin>>s;
int a[4];
for(int i=0;i<4;i++)
	a[i]=s[i]-48;
int x=a[0]*10+a[1],y=a[2]*10+a[3];
int check[100]={0};
for(int i=1;i<=12;i++)
	check[i]=1;
if(check[x] and check[y])
	cout<<"AMBIGUOUS";
else if(check[x] and !check[y])
	cout<<"MMYY";
else if(!check[x] and check[y])
	cout<<"YYMM";
else cout<<"NA";
return 0;
}


Measured memory_bytes: 384