akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

#define MAX_LEN (80)

int main(void)
{
	char num1[100000];
	char num2[100000];

	int n, carry, sum;
	int i, j, len;
	
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		scanf("%s %s", num1, num2);
		if (strlen(num1) > MAX_LEN || strlen(num2) > MAX_LEN){
			printf("overflow\n");
			continue;
		}
		
		len = strlen(num1);
		for (j = MAX_LEN; j >= 0; j--){
			if (len > 0){
				num1[j] = num1[len - 1];
				len--;
			}
			else {
				num1[j] = '0';
			}
		}
		
		len = strlen(num2);
		for (j = MAX_LEN; j >= 0; j--){
			if (len > 0){
				num2[j] = num2[len - 1];
				len--;
			}
			else {
				num2[j] = '0';
			}
		}
		
		carry = 0;
		for (j = MAX_LEN; j >= 0; j--){
			sum = (num1[j] - '0') + (num2[j] - '0') + carry;
			num1[j] = (sum % 10) + '0';
			carry = sum / 10;
		}
		
		for (j = 0; j <= MAX_LEN; j++){
			if (num1[j] != '0'){
				break;
			}
		}
		if (j == 0){
			printf("overflow");
		}
		else if (j > MAX_LEN){
			printf("0");
		}
		else {
			while (j <= MAX_LEN){
				printf("%c", num1[j]);
				j++;
			}
		}
		printf("\n");
	}
	
	return (0);
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
int main(void){
	ll n,m;
	cin>>n>>m;
	vector<vector<int>> v(n,vector<int>(m));
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>v[i][j];
		}
	}
	int cnt=0;
	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			ld sum=0;
			for(int k=0;k<m;k++){
				sum+=pow(abs(v[i][k]-v[j][k]),2);
			}
			ld sqr=sqrt(sum);
			ll val=sqr;
			if(val==sqr) cnt++;
		}
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 256
n = int(input())

x = []
x = list(map(int, input().split()))

a1 = sum(x) // n
a2 = a1 + 1


ans1 = 0
ans2 = 0
for i in range(n):
    ans1 += (a1 - x[i])**2
    ans2 += (a2 - x[i])**2

if ans1<ans2:
    print(ans1)
else:
    print(ans2)


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

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
//while(1){
    long long a, b, c, tmp;
    cin >> a >> b >> c;
    c -= (a+b);                                     //         cout << c << endl;
    bool odd = false;
    if(c & 1) odd = true;
    c /= 2;                                            //      cout << c << endl;

    if(c > 0) {
        if (odd) tmp = c;
        c *= c;
        if (odd) c += tmp;
    }
    bool f = false;
    if(odd && a*b <= c) f =true;
    else if(a*b < c) f = true;      // cout<<f<<' '<<a<<' '<<b<<' '<<c<<endl;
    puts(f ? "Yes":"No");
return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	x, k, d := nextInt(), nextInt(), nextInt()
	if x < 0 {
		x = x * (-1)
	}
	var checker float64
	checkK := x / d
	if checkK > k {
		checker = math.Abs(float64(x) - float64(k)*float64(d))
	} else {
		first := math.Abs(float64(x) - float64(checkK)*float64(d))
		second := math.Abs(float64(x) - float64(checkK+1)*float64(d))
		if (k-checkK)%2 == 0 {
			checker = first
		} else {
			checker = second
		}
	}
	fmt.Fprintf(out, "%d\n", int(checker))
}

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

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

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

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func quickSort(val []int) []int {
	if len(val) < 2 {
		return val
	}

	pivot := val[0]

	left := []int{}
	right := []int{}

	for _, v := range val[1:] {
		if pivot > v {
			left = append(left, v)
		} else {
			right = append(right, v)
		}
	}

	left = quickSort(left)
	right = quickSort(right)

	ret := append(left, pivot)
	ret = append(ret, right...)

	return ret
}


Measured memory_bytes: 1812
n = int(input())
s = list(input())
x = 0
xmax = 0

for i in range(len(s)):
    if s[i] == 'I':
        x = x + 1
    elif s[i] == 'D':
        x = x - 1

    xmax = max(xmax, x)
    
print(xmax)

Measured memory_bytes: 3060
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
using namespace std;

struct node{int key; node *right,*left,*parent;};
node *root,*NIL;

void insert(int k)
{
	node *y=NIL;
	node *x=root;
	node *z;
	
	z=(node *)malloc(sizeof(node));
	z->key=k;
	z->left=NIL;
	z->right=NIL;
	
	while(x!=NIL)
	{
		y=x;
		if(z->key < x->key)
		{
			x=x->left;
		}
		else
		{
			x=x->right;
		}
	}
	
	z->parent=y;
	if(y==NIL)
	{
		root=z;
	}
	else
	{
		if(z->key < y->key)
		{
			y->left=z;
		}
		else
		{
			y->right=z;
		}
	}
}

node* find(node *x,int k)
{
	while(x!=NIL&&k!=x->key)
	{
		if(x->key > k)x=x->left;
		else x=x->right;
	}
	return x;
}

node* minimumNode(node *x)
{
	while(x->left!=NIL)x=x->left;
	return x;
}

node* successNode(node *x)
{
	if(x->right!=NIL)return minimumNode(x->right);
	node *y=x->parent;
	while(y!=NIL&&x==y->right)
	{
		x=y;
		y=y->parent;
	}
	return y;
}

void deleteNode(node *z)
{
	node *y;
	node *x;
	if(z->left==NIL||z->right==NIL)y=z;
	else y=successNode(z);
	
	if(y->left!=NIL)
	{
		x=y->left;
	}
	else
	{
		x=y->right;
	}
	
	if(x!=NIL)
	{
		x->parent=y->parent;
	}
	
	if(y->parent==NIL)
	{
		root=x;
	}
	else
	{
		if(y==y->parent->left)
		{
			y->parent->left=x;
		}
		else
		{
			y->parent->right=x;
		}
	}
	
	if(y!=z)
	{
		z->key=y->key;
	}
	
	free(y);
}

void ino(node *u)
{
	if(u==NIL)return;
	ino(u->left);
	printf(" %d",u->key);
	ino(u->right);
}

void preo(node *u)
{
	if(u==NIL)return;
	printf(" %d",u->key);
	preo(u->left);
	preo(u->right);
}

int main()
{
	int n,i,x;
	string com;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++)
	{
		cin>>com;
		if(com=="insert")
		{
			scanf("%d",&x);
			insert(x);
		}
		else if(com=="print")
		{
			ino(root);
			printf("\n");
			preo(root);
			printf("\n");
		}
		else if(com=="find")
		{
			scanf("%d",&x);
			node *t=find(root,x);
			if(t!=NIL)cout<<"yes"<<endl;
			else cout<<"no"<<endl;
		}
		else if(com=="delete")
		{
			scanf("%d",&x);
			deleteNode(find(root,x));
		}
	}
	
	return 0;
}

Measured memory_bytes: 22044
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int n, k;
    int[] as;
    int min = Integer.MAX_VALUE;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        k = sc.nextInt();
        as = new int[n];
        for (int i = 0; i < n; i++) {
            as[i] = sc.nextInt();
            if (as[i] < min) {
                min = as[i];
            }
        }
        solve();
    }

    void solve() {
        int minCount = 0;
        for (int i = 0; i < n; i++) {
            if (as[i] == min) {
                minCount++;
            }
        }
        if ((n - minCount) % (k - 1) == 0) {
            System.out.println((n - minCount) / (k - 1));
        } else {
            System.out.println((n - minCount) / (k - 1) + 1);
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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


Measured memory_bytes: 33352
import sys

rl = sys.stdin.readline


class SegmentTree:
    def __init__(self, init_value: list, segfunc, ide_ele):
        n = len(init_value)
        self.N0 = 1 << (n - 1).bit_length()
        self.ide_ele = ide_ele
        self.data = [ide_ele] * (2 * self.N0)
        self.segfunc = segfunc
        
        for i, x in enumerate(init_value):
            self.data[i + self.N0 - 1] = x
        for i in range(self.N0 - 2, -1, -1):
            self.data[i] = self.segfunc(self.data[2 * i + 1], self.data[2 * i + 2])
    
    def update(self, _k, x):
        k = _k + self.N0 - 1
        self.data[k] = x
        while k:
            k >>= 1
            self.data[k] = self.segfunc(self.data[k * 2 + 1], self.data[k * 2 + 2])
    
    def query(self, left, right):
        L = left + self.N0
        R = right + self.N0
        res = self.ide_ele
        
        while L < R:
            if L & 1:
                res = self.segfunc(res, self.data[L - 1])
                L += 1
            if R & 1:
                R -= 1
                res = self.segfunc(res, self.data[R - 1])
            L >>= 1
            R >>= 1
        
        return res


def solve():
    N, x = map(int, rl().split())
    a = list(map(int, rl().split()))
    
    seg_tree = SegmentTree(a, min, 10 ** 15)
    ans = 10 ** 15
    for i in range(N):
        get_cost = 0
        for j in range(N):
            if i <= j:
                get_cost += seg_tree.query(j - i, j + 1)
            else:
                get_cost += min(seg_tree.query(0, j + 1), seg_tree.query(N - i + j, N))
        ans = min(ans, i * x + get_cost)
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 55680
// #pragma GCC optimize("O3")
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

template <class T1, class T2>
ostream& operator << (ostream& out, pair <T1, T2> p)
{
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}

template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
	in >> p.first >> p.second;
	return in;
}

template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
	for (T &x : v)
		in >> x;
	return in;
}

template <class T>
ostream& operator << (ostream& out, vector<vector<T>> &v)
{
	for (vector<T> &x : v)
		out << x << '\n';
	return out;
}

template <class T>
ostream& operator << (ostream& out, vector<T> &v)
{
	for (T &x : v)
		out << x << ' ';
	return out;
}

long long gcd (long long a, long long b)
{
	if (b > a)
		swap(a, b);
	return (b ? gcd(b, a % b) : a);
}

using ll   = long long;
using pii  = pair<int, int>;
using pll  = pair<long long, long long>;
using tiii = pair<pair<int, int>, int>;
using vi   = vector<int>;
using vl   = vector<long long>;
using vvi  = vector<vector<int>>;
using vvl  = vector<vector<long long>>;

#define F          first
#define S          second
#define First      first.first
#define Second     first.second
#define Third      second
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i < b; i++)
#define per(i,b,a) for (int i = b; i > a; i--)
#define all(x)     x.begin(), x.end()
#define ret(x)     return cout << x, 0;
#define throwex    throw runtime_error ("Found the error.");

const int h = 1000000007;

signed main()
{
	ios::sync_with_stdio(false);
	#ifdef ONLINE_JUDGE
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.setstate(ios::failbit);
	#endif

	vi 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};
	int k;
	cin >> k;
	cout << a[k-1];
}


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

signed main(void)
{
	int n;
	cin >> n;
	ll t[n], a[n];
	ll taka, aoki;
	rep(i,  n) cin >> t[i] >> a[i];
	taka = 1;
	aoki = 1;
	rep(i, n)
	{
		ll tmp_a, tmp_t;
		tmp_a = aoki / a[i];
		if (aoki % a[i] != 0) tmp_a++;	
		tmp_t = taka / t[i];
		if (taka % t[i] != 0) tmp_t++;	
		ll p = max(tmp_a, tmp_t);
		aoki = p * a[i];
		taka = p * t[i];
	}
	cout << taka + aoki << endl;
	return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let n: usize = read_line().parse().unwrap();
    let v: Vec<i32> = read_vec();
    let even: Vec<i32> = (0..n/2).map(|i| v[i*2]).collect();
    let odd: Vec<i32> = (0..n/2).map(|i| v[i*2+1]).collect();
    let mut hash = std::collections::HashMap::new();
    for i in even.iter() {
        let count = hash.entry(i).or_insert(0);
        *count += 1;
    }
    let mut even_max = (0, 0);
    let mut even_max2 = (0, 0);
    for (&&k, &v) in hash.iter() {
        if v >= even_max.1 {
            even_max2 = even_max;
            even_max = (k, v);
        } else if v > even_max2.1 {
            even_max2 = (k, v);
        }
    }
    hash.clear();
    for i in odd.iter() {
        let count = hash.entry(i).or_insert(0);
        *count += 1;
    }
    let mut odd_max = (0, 0);
    let mut odd_max2 = (0, 0);
    for (&&k, &v) in hash.iter() {
        if v >= odd_max.1 {
            odd_max2 = odd_max;
            odd_max = (k, v);
        } else if v > odd_max2.1 {
            odd_max2 = (k, v);
        }
    }
    let ans = if even_max.0 != odd_max.0 {
        n - even_max.1 - odd_max.1
    } else {
        std::cmp::min(n - even_max.1 - odd_max2.1, n - even_max2.1 - odd_max.1)
    };
    println!("{}", ans);
}


Measured memory_bytes: 8444
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
double p,e,t;
double fi(int k,double l,double r){
  double c=(l+r)/2;
  if(!k)
    return fabs(c-t)<=e;
  if(t-e<l&&r<t+e)
    return 1;
  if(t-e>r||l>t+e)
    return 0;
  if(c<t)
    return fi(k-1,c,r)*(1-p)+fi(k-1,l,c)*p;
  else
    return fi(k-1,l,c)*(1-p)+fi(k-1,c,r)*p;
}
int main(){
  int k,l,r;
  scanf("%d%d%d",&k,&l,&r);
  //double p,e,t;
  scanf("%lf%lf%lf",&p,&e,&t);
  printf("%.6f\n",fi(k,l,r));
  return 0;
}

Measured memory_bytes: 0
import numpy as np
N, K = map(int, input().split())
h = np.array(list(map(int, input().split())))
dp = np.zeros(N, dtype=int)
for i in range(1, N):
  j = max(0, i-K)
  dp[i] = np.min(dp[j:i]+np.abs(h[i]-h[j:i]))
                 
print(dp[N-1])

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	string s;
	cin >> n >> s;

	int ans = 0;
	for(int i = 1; i < n; i++)
	{
		string s1 = s.substr(0,i);
		string s2 = s.substr(i);
		map<char,int> s1m, s2m;
		for(char c = 'a'; c <= 'z'; c++) s1m[c] = 0;
		for(char c = 'a'; c <= 'z'; c++) s2m[c] = 0;
		rep(j,s1.size()) s1m[s1[j]] = 1;
		rep(j,s2.size()) s2m[s2[j]] = 1;

		int cnt = 0;
		for(char c ='a'; c <= 'z'; c++)
		{
			if(s1m[c] == 1 && s2m[c] == 1) cnt++;
		}
		ans =  (cnt > ans) ? cnt : ans;
	}

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

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		long k = sc.nextLong();

		int[] a = new int[n];
		int[] f = new int[n];

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

		int ls = 0;
		int le = 0;
		int x = 1;
		f[0] = 1;
		int p = a[0];
		while ( le==0 && k>x ) {
			x++;
			if ( f[p]==0 ) {
				f[p] = x;
			} else {
				le = x;
				ls = f[p];
			}
			p = a[p];
		}

		if ( k==x ) {
			System.out.println(p+1);
		} else {
			int pp = (int)(( k - (long)(ls-1) )%(le-ls) + (long)(ls-1));
			int t = 0;
			for ( int i=0; i<pp; i++ ) {
				t = a[t];
			}
			System.out.println(t+1);
		}
	}
}

Measured memory_bytes: 61772
#169A
# A * B を整数として出力せよ

# !. 入力をプログラムで扱えるように受け取ること
a, b = map(int, input().split())
# print(a,b)

# 2. 受け取った入力値を使って、適切に処理(計算)すること
answer = a * b

# 3. 計算した結果を出力すること
print(answer)

Measured memory_bytes: 9124
import java.util.*;

public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
          Set<Integer> set1 = new HashSet<>();
          for(int i = 0; i < 3; i++){
            set1.add(sc.nextInt());
          }
          System.out.println(set1.size());
          }
}

Measured memory_bytes: 21844
#include<iostream>
using namespace std;
int main(){
  string s;
  int n,i,ans=0;
  cin >> n >> s;
  for(i=0;i<n-2;i++){
    if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
/*Kadai3_2
  saitomo*/

#include<stdio.h>

int main(void){
  int num,first_num;//first_numは1の位
  scanf("%d",&num);
  first_num = num%10;//1の位を求める
  if(first_num==3){//問題文の通りに条件分岐
    printf("bon\n");
  }else if(first_num==0 || first_num==1 || first_num==6 || first_num==8){
    printf("pon\n");
  }else{
    printf("hon\n");
  }
  return 0;
}


Measured memory_bytes: 1644
// Fuwa Fuwa Time!

#include <bits/stdc++.h>

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

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

const int MAXN = (int) 1e5;

int n, l, t;

int x[MAXN + 5], w[MAXN + 5];

inline void input()
{
	n = read<int>(), l = read<int>(), t = read<int>();
	for(int i = 0; i < n; ++i) x[i] = read<int>(), w[i] = read<int>();
}

inline void solve()
{
	static int pos[MAXN + 5];

	int p = 0;
	for(int i = 0; i < n; ++i)
		if(w[i] == 1)
		{
			(p += t >= l - x[i]) %= n;
			(p += max(0, t - (l - x[i])) / l) %= n;
			pos[i] = (x[i] + t) % l;
		}
		else
		{
			(p -= t >= x[i] + 1) %= n;
			(p -= max(0, t - x[i] - 1) / l) %= n;
			pos[i] = ((x[i] - t) % l + l) % l;
		}

	(p += n) %= n;
	sort(pos, pos + n);
	for(int i = p; i < n; ++i) printf("%d\n", pos[i]);
	for(int i = 0; i < p; ++i) printf("%d\n", pos[i]);
	puts("");
}

int main()
{
#ifdef K_ON // K-ON!
	freopen("C.in", "r", stdin);
	freopen("C.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}



Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef set<int> si;
const int inf = 1e9;
const int mod = 1e9+7;

int h, w, n, a, li[10000];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> h >> w >> n;
  int c = 0;
  FOR(i, 1, n+1){
    cin >> a;
    FOR(j, 0, a){
      li[c] = i;
      c++;
    }
  }
  FOR(i, 0, h){
    if(i%2 == 0){
      FOR(j, 0, w){
        cout << li[i * w + j];
        if(j < w-1)cout << " ";
      }
    }else{
      FORR(j, w-1, 0){
        cout << li[i * w + j];
        if(j > 0)cout << " ";
      }
    }
    cout << endl;
  }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
    
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define ST first
#define ND second
#define MP make_pair
#define PB push_back
    
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef set<int> SI;
typedef long long LL;
    
#ifdef DEBUG
const bool debug = true;
#else
const bool debug = false;
#endif

// #define MULTI_TASK true

const int inf = 1000 * 1000 * 1000;
const int MAKSN = 1000 * 1000 + 13;
const LL MOD = 123456789LL;
int n, m, k, l, x, y, a, b;
string s;
vector<int> v;


void zeruj() {
    v.clear();
}

void readIn() {
    cin >> k >> n;
    REP(i, n) {
        cin >> a;
        v.PB(a);
    }
}
        
void solve() {
    int ans = inf;
    for (int i = 0; i < n; i++) {
        int leftpos = v[(i - 1 + n) % n];
        int rightpos = v[(i + 1 + n) % n];

        int toleft = k - v[i] + leftpos;
        int toRight = v[i] + (k - rightpos);

        if (leftpos > v[i]) {
            toleft = leftpos - v[i];
        }   
        if (rightpos < v[i]) {
            toRight = v[i] - rightpos;
        }

        // cerr << i << " " << toleft << " " << toRight << "\n";
        ans = min(ans, min(toleft, toRight));
    }

    cout << ans << "\n";
    
}

int main() {
    ios_base::sync_with_stdio(0);
#ifdef MULTI_TASK
    int test;
    cin >> test;
    while (test--) {
#endif
        zeruj();
        readIn();
        solve();
#ifdef MULTI_TASK
    }
#endif 
    return 0;
}


Measured memory_bytes: 1400
//2020年3月21日現在

#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>
#include <cstdio>

using namespace std;

template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }

namespace {
    // printElems(&a[0], &a[n]);　みたいな感じで使う。
    void printElems(const int* begin, const int* end)
    {
        for (const int* p = begin; p != end; ++p) {
            std::cout << *p << ' ';
        }
        std::cout << std::endl;
    }
}

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define FOR(i,j,n) for(int i=j; i < n; i++)
#define souatari rep1(i,n-1)rep(j,i)
#define souatari1 for(int i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef array<int,3> arr3;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;
const ll BIG = 10000000000000000;


ll a[200005];
ll c[200005];
ll cc[200005];
ll cni[200005];

int main(){
	ll n;
	cin >> n;
	rep(i,n) {
		ll tmp;
		cin >> tmp;
		a[i] = tmp;
		c[tmp]++;
	}
	ll s = 0;
	rep1(i,n){
		if(c[i]!=0){
			cc[i] = c[i]*(c[i]-1)/2;
			s+=cc[i];
			if(c[i]!=1){
				cni[i] = (c[i]-2)*(c[i]-1)/2;
			}
		}
	}

	rep(i,n){
		prints(s-(cc[a[i]]-cni[a[i]]));
	}




	return 0;
}



Measured memory_bytes: 7808
//雪花飄飄北風嘯嘯
//天地一片蒼茫

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
//change less to less_equal for non distinct pbds, but erase will bug

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin.exceptions(ios::badbit | ios::failbit);
	
	int n;
	cin>>n;
	rep(x,0,n) cout<<"ACL";
}


Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String in = sc.next();
        String[] input = in.split("");
        int wFixNum = Integer.MIN_VALUE;
        long count = 0;
        for (int i = 0; i < input.length; i++) {
            if ("W".equals(input[i])) {
                if (wFixNum < 0) {
                    wFixNum = 0;
                    input[0] = "W";
                    input[i] = "B";
                    count += i;
                    continue;
                }
                input[++wFixNum] = "W";
                input[i] = "B";
                count += i - wFixNum;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 54564
#include<stdio.h>
#include<string.h>

int tri(int a,int b,int c);



int main(void){
  int n;
  scanf("%d",&n);
  int l[n];
  int i,j,k;
  int ans=0;
  int checker=1;
  int tmp;
  for(i=0;i<n;i++){
    scanf("%d",&l[i]);
    }

  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      if(l[i]<l[j]){
        tmp=l[i];
        l[i]=l[j];
        l[j]=tmp;
      }
    }
  }

  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      for(k=j+1;k<n;k++){
        checker=tri(l[i],l[j],l[k]);
        if(checker==1)
        ans++;
        else
        break;
      }
    }
  }

printf("%d",ans);

    return 0;
}

int tri(int a,int b,int c){
  if(a<b+c&&b<c+a&&c<a+b){
    return 1;

  }
  else
  return 0;
}


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << fixed << setprecision(20) << (long double)(w * h) / 2;
    cout << " " << (x * 2 == w && y * 2 == h) << endl;
    return 0;
}

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

int main() {
  long long int N;
  long long int A;
  long long int B;
  
  cin >> N >> A >> B;
  
  long long int q = N/(A+B);
  long long int r = N%(A+B);
  
  long long int count = q*A;
  
  if (r >= A) {
    count += A;
  }
  else {
    count += r;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin, (x).end()
#define SORT(v,n) sort(v,v+n)
#define VSORT(v) sort(all(x))
#define inf 999999999
#define debug(x) cout<<#x<<":"<<x<<endl;
#define min(a,b) ((a)>(b)?(b):(a))
#define max(a,b) ((a)>(b)?(a):(b))
#define pi 2*acos(0.0)
#define in scanf
#define out printf
#define pb push_back
#define mp make_pair
#define F first
#define S second

// --
#define bit(n) (1LL<<(n)) // ???bit?????????
// --

using namespace std;

typedef long long llong;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<llong, pll> plp;

const int MOD=1000000007;
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};  // ????????????


int main(int argc, char**argv){
	stack<int> s;
	char c[20 + 2];
	int a, b;

	while (in("%s", c) != EOF){
		if (c[0] == '+' || c[0] == '-' || c[0] == '*'){
			a = s.top(); s.pop();
			b = s.top(); s.pop();
			if (c[0] == '+') s.push(b+a);
			else if (c[0] == '-') s.push(b-a);
			else s.push(b*a);
		}else{
			s.push(atoi(c));
		}
	}
	cout << s.top() << endl;

	return 0;
}

Measured memory_bytes: 3156
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>	

using namespace std;

int main() {
	int N, L;
	cin >> N >> L;
	vector<int> aji;
	int ans = 0;
	for (int i = 1; i <= N; ++i) {
		aji.push_back(L + i - 1);
		ans += L + i - 1;
	}
	sort(aji.begin(), aji.end());
	if (L < 0) {
		if (L + N - 1 >= 0)cout << ans << endl;
		else cout << ans - aji[N - 1] << endl;
	}
	else {
		cout << ans - aji[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
// finish date: 2018/09/30

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>>
        vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>>
        vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


int main() {
    string s;
    cin >> s;
    int n = s.length();
    if (s[0] == '0' || s[n - 1] == '1') {
        cout << -1 << endl;
        return 0;
    }
    rep(i, n - 1) {
        if (s[max(i, n - i - 2)] != s[min(i, n - i - 2)]) {
            cout << -1 << endl;
            return 0;
        }
    }
    int tmp = 0;
    vi o1, o2;
    FOR(i, 1, n) {
        if (s[i] == '1') {
            while (tmp != i) {
                o1.push_back(i);
                o2.push_back(tmp);
                tmp++;
            }
        }
    }
    o1.push_back(n - 1);
    o2.push_back(n - 2);
    rep(i, o1.size()) {
        cout << o1[i] + 1 << " " << o2[i] + 1 << endl;
    }


    return 0;
}



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

int main() {
  int x,a,b;
  cin >>x >>a >>b;
  if(a<b){
    if(b<x){
      cout <<"B" <<endl; //a b x
    }
    else{
      if(x<a){
        cout <<"A" <<endl;  // x a b
      }
      else{
        if((b-x)>(x-a)){
          cout <<"A" <<endl;  // xa b
        }
        else{
          cout <<"B" <<endl;  // a xb
        }
      }
    }
  }
  else{ //a>b
    if(x>a){
      cout <<"A" <<endl; // b a x
    }
    else{ //a>b a>x
      if(x<b){
        cout <<"B" <<endl; //x b a
      }
      else{ //b x a
        if((a-x)>(x-b)){
          cout <<"B" <<endl;
        }
        else{
          cout <<"A" <<endl;
        }
      }
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void swap(int *x, int *y){ int t = *x; *x = *y; *y = t;}

int main(){
  int n, a[101], min, i, j, c = 0;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) scanf("%d", a + i);

  for(i = 0; i < n; ++i){
    min = i;
    for(j = i + 1; j < n; ++j)
      if(a[j] < a[min]) min = j;
    if(min != i){
      swap(&a[i], &a[min]);
      c++;
    }
  }

  for(i = 0; i < n; ++i) printf(i != 0 ? " %d" : "%d", a[i]);
  printf("\n%d\n", c);
  return 0;
}



Measured memory_bytes: 2140
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通りに実装したソースコード
 * 
 * https://atcoder.jp/contests/abc167/submissions/13128568 にも参照
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			List<Data> ls = new ArrayList<>(), rs = new ArrayList<>();
			long sum = IntStream.range(0, n).mapToLong(i -> {
				char[] s = scanner.next().toCharArray();
				int total = 0, min = 0;
				for (char c : s) {
					total += ('(' == c) ? 1 : -1;
					min = Math.min(total, min);
				}
				if (total >= 0) {
					ls.add(new Data(total, min));
				} else {
					rs.add(new Data(-total, min - total));
				}
				return total;
			}).sum();
			Collections.sort(ls);
			Collections.sort(rs);
			System.out.println((check(ls) && check(rs) && (sum == 0L)) ? "Yes" : "No");
		}
	}

	/**
	 * リストの実現可能性をチェックする
	 * 
	 * @param list データのリスト
	 * @return リストが実現可能かどうか
	 */
	private static boolean check(List<Data> list) {
		long total = 0L;
		for (Data data : list) {
			if (total + data.min < 0) {
				return false;
			}
			total += data.total;
		}
		return true;
	}

	/**
	 * 個々のsを表す用クラス
	 */
	private static class Data implements Comparable<Data> {
		int total;
		int min;

		public Data(int total, int min) {
			super();
			this.total = total;
			this.min = min;
		}

		@Override
		public int compareTo(Data o) {
			return Integer.compare(o.min, this.min);
		}
	}
}


Measured memory_bytes: 94668
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)


long long MOD = 1e9 + 7;
std::vector<long long> func(2e5+2);
void build_func(){
  func[0] = 1;
  func[1] = 1;
  for(int i=2;i<2e5+2;i++)func[i] = func[i-1]*i%MOD;
}

template <typename T>
T ext_gcd(T a, T b, T&x, T&y){
  if(b==0){
    x=1;y=0;return a;
  }
  T q=a/b;
  T g=ext_gcd(b,a-q*b,x,y);
  T z=x-q*y;
  x=y;y=z;
  return g;
}

// aは割る言、mがmod
template <typename T>
T invmod(T a, T m){
  T x,y;
  ext_gcd(a,m,x,y);
  x%=m;
  if(x<0)x+=m;
  return x;
}

long long comb(long long n, long long k){
  if(n <= k || n<=0 || k<=0) return 1;
  long long x = func[n-k]; 
  long long y = func[k]; 
  return (long long)func[n] * invmod(x, MOD)%MOD * invmod(y, MOD)%MOD;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    build_func();
    ll n,k;
    cin>>n>>k;
    ll ans = 0;
    FOR(i,0,min(n,k+1))ans = (ans + comb(n,i)* comb(n-1,i))%MOD;
    cout<<ans<<endl;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n, m;
	cin >> n >> m;
	priority_queue<ll> pq;
	for(int i=0; i<n; i++){
		ll a;
		cin >> a;
		pq.push(a);
	}
	for(int i=0; i<m; i++){
		ll t=pq.top();
		pq.pop();
		pq.push(t/2);
	}

	ll ans=0;
	for(int i=0; i<n; i++){
		ans+=pq.top();
		pq.pop();
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define ll long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=200005;
const ll mod=1e9+7;
inline int read()
{
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9') {x=x*10+ch-'0',ch=getchar();}
    return x*f;
}
int n,tot;
ll ans;
void dfs(int u,int d,ll num)
{
	if(ans) return;
	if(u==1){
		tot++;
		if(tot==n) ans=num;
		return;
	}
	if(d>0) dfs(u-1, d-1, num*10+d-1);
	dfs(u-1, d, num*10+d);
	if(d<9) dfs(u-1, d+1, num*10+d+1);
}
int main()
{
	n=read();
	for(int i=1; i<=10; i++){
		for(int j=1; j<=9; j++){
			dfs(i, j, j);
			if(ans){
				printf("%lld\n",ans); return 0;
			}
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define retunr return
#define pb push_back
#define mp make_pair
#define null NULL
#define sc(x) scanf("%d", &x)
#define sc64(x) scanf("%lld", &x)
#define pr(x) printf("%d", (x))
#define pr64(x) printf("%lld", (x))
#define sp putchar(' ')
#define ln putchar('\n')
#define rep(i,l,r) for (int i = l, lim = r;i <= lim; ++i)
#define repr(i,l,r) for (int i = r, lim = l;i >= lim; --i)
#define fi first
#define se second
#define SET(__set, val) memset(__set, val, sizeof __set)
#define fill(a,v,n) memset((a),(v),sizeof(a[0])*(n))
#define copy(a,b,n) memcpy((a),(b),sizeof(a[0])*(n))
#define ALL(x) (x.begin(),x.end())
#define prf(x) printf("%.20f", x)
#define for_each_edge(u) for(int i = point[u];i;i=G[i].n)
typedef unsigned int uint;
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define N 100010
#define M 1024
#define MOD 1000000007
void _add(int &a, int b){a = (a+b)%MOD;}
void _sub(int &a, int b){a = (a+MOD-b)%MOD;}
void _mul(int &a, int b){a = (ll)a*b%MOD;}
void _max(int &a, int b){a = max(a,b);}
void _min(int &a, int b){a = min(a,b);}
ll gcd(ll a, ll b){if(!b)return a;return gcd(b,a%b);}
ll pw(ll a, ll b){ll res(1);while(b){if(b&1)res=res*a%MOD;a=a*a%MOD;b>>=1;}return res;}
ll pwM(ll a, ll b, ll mod){ll res(1);while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

const int infi = 2147483647;
const ll infl = 9223372036854775807ll;
const db PI = 3.14159265358979323846;

/*
struct E{
	int v, w, n;
}G[N];
int cnt, point[N];
void adde(int u, int v, int w = 0){
	G[++cnt]=(E){v,w,point[u]},point[u]=cnt;
	G[++cnt]=(E){u,w,point[v]},point[v]=cnt;
}
void Ginit(int n){
	cnt = 0;
	fill(point,0,n+1);
}
*/
/*
struct hh{
	int a, b;
	bool operator < (const hh &x) const{
		if(a==x.a)return b<x.b;
		return a<x.a;
	}
}a[N];
*/
int n, m, k,q;
int main(){
//	freopen("1", "r", stdin);
	sc(n),sc(m);
	k = infi;
	rep(i,1,n){
		int c, t;
		sc(c),sc(t);
		if(t <= m){
			k = min(k, c);
		}
	}
	if(k<infi)
		pr(k),ln;
	else
		puts("TLE");
/*
	int Case;
	sc(Case);
	rep(ca, 1, Case){
	    printf("Case #%d: ", ca);
	}
*/
	return 0;
}


Measured memory_bytes: 256
n, x, y = map(int, input().split())

edges = [[] for _ in range(n)]
for i in range(n-1):
    edges[i].append((i+1, 1))
    edges[i+1].append((i, 1))
edges[x-1].append((y-1, 1))
edges[y-1].append((x-1, 1))

import heapq

def dijkstra(start, edge, n):

    dist = [float('inf')] * n
    dist[start] = 0

    pq = [(dist[start], start)]

    while len(pq):
        d, frm = heapq.heappop(pq)
        if dist[frm] < d:
            continue
        for to, cost in edge[frm]:
            if dist[frm] + cost < dist[to]:
                dist[to] = dist[frm] + cost
                heapq.heappush(pq, (dist[to], to))

    return dist

cnt = [0] * n

for i in range(n):
    dist = dijkstra(i, edges, n)
    for d in dist:
        cnt[d] += 1

cnt2 = []
for c in cnt:
    c //= 2
    cnt2.append(c)

for i in range(1, n):
    print(cnt2[i])



Measured memory_bytes: 89564
package main

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

func main(){
  defer stdout.Flush()
  
  n := readInt()
  m := n*3
  ans := 0
  a := make([]int, m)
  for i := range a {
    a[i] = readInt()
  }
  sort.Ints(a)
  cnt := 0
  for i := m-2; i >= 0; i-=2 {
    if cnt == n {
      break
    }
    ans+=a[i]
    cnt++
  }
  fmt.Println(ans)
}

//====  ↓↓↓ Scanner ↓↓↓  ============================

var (
	readString func() string
	stdout     *bufio.Writer
)
 
func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}
 
func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
 
	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}
 
func readInt() int {
	return int(readInt64())
}
 
func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}
 
func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}
 
func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

//====  ↓↓↓ template functions ↓↓↓  ======================

func minInt(a, b int) int{
  if a < b {
    return a
  }
  return b
}

func minInt64(a, b int64) int64{
  if a < b {
    return a
  }
  return b
}

func minFloat64(a, b float64) float64{
  if a < b {
    return a
  }
  return b
}

func maxInt(a, b int) int{
  if a > b {
    return a
  }
  return b
}

func maxInt64(a, b int64) int64{
  if a > b {
    return a
  }
  return b
}

func maxFloat64(a, b float64) float64{
  if a > b {
    return a
  }
  return b
}

func absInt(x int) int{
  if x < 0 {
    return -x
  }
  return x
}

func absInt64(x int64) int64{
  if x < 0 {
    return -x
  }
  return x
}

func absFloat64(x float64) float64{
  if x < 0 {
    return -x
  }
  return x
}

func gcdInt(a, b int) int{
  if b == 0 {
    return a
  }else{
    return gcdInt(b, a%b)
  }
}

func gcdInt64(a, b int64) int64{
  if b == 0 {
    return a
  }else{
    return gcdInt64(b, a%b)
  }
}

func lcmInt(a, b int) int{
  return a*b/gcdInt(a, b);
}

func lcmInt64(a, b int64) int64{
  return a*b/gcdInt64(a, b);
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
//constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

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

  cout << (S <= "2019/04/30" ? "Heisei" : "TBD") << endl;
}

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

C = [list(map(int, input().split())) for i in range(n)]

ans = 10**9
for i in range(n):
    if C[i][1] <= t and C[i][0] < ans:
        ans = C[i][0]
    if i == n-1 and ans == 10**9:
        print("TLE")
        exit()
print(ans)


Measured memory_bytes: 3060
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

#define INF 100000000

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int ans;
	ans = min(b+c,min(a + b, a + c));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main
{
    public static void main(String... args)
    {
        final Scanner scanner = new Scanner(System.in);
        final int set = scanner.nextInt();
        for (int i = 0; i < set; i++) {
            final List<Integer> integers = Arrays.asList(scanner.nextInt(), scanner.nextInt(), scanner.nextInt());
            Collections.sort(integers);
            final double a = Math.pow(integers.get(0), 2);
            final double b = Math.pow(integers.get(1), 2);
            final double c = Math.pow(integers.get(2), 2);
            System.out.println(c == a + b ? "YES" : "NO");
        }
    }
}

Measured memory_bytes: 23392
import java.util.*;
import static java.lang.System.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if((a+b)%2==0) {
			out.println((a+b)/2);
		}
		else out.println("IMPOSSIBLE");
		sc.close();
	}
}

Measured memory_bytes: 21844
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;

string A[800];
bool reachable_in_one[800][800];

int h_moves[4] = {-1, 1, 0, 0};
int w_moves[4] = {0, 0, -1, 1};
int ans;

void bfs(int s_h, int s_w, int K, int H, int W){
    queue <pair <int, pair<int, int> > > q;
    q.push(make_pair(0, make_pair(s_h, s_w)));
    reachable_in_one[s_h][s_w] = true;
    while(!q.empty()){
        auto tmp = q.front();
        q.pop();
        int cur_dist = tmp.first;
        int cur_h = tmp.second.first;
        int cur_w = tmp.second.second;
        ans = min(ans, min(min(cur_h, H - 1 - cur_h), min(cur_w, W - 1 - cur_w)));
        if(cur_dist < K){
            for(int i = 0; i < 4; i++){
                int next_h = cur_h + h_moves[i];
                int next_w = cur_w + w_moves[i];
                if(0 <= next_h && next_h < H && 0 <= next_w && next_w < W 
                    && !reachable_in_one[next_h][next_w] && A[next_h][next_w] != '#'){
                        q.push(make_pair(cur_dist + 1, make_pair(next_h, next_w)));
                        reachable_in_one[next_h][next_w] = true;
                }
            }
        }

    }
}
/*
int dijikstra(int s_h, int s_w, int H, int W){
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            d[i][j] = INT_MAX;
        }
    }
 
    priority_queue < pair <int, pair<int, int> > , vector <pair <int, pair<int, int> > >, greater<pair <int, pair<int, int> > > > pq;
    d[s_h][s_w] = 0;
    pq.push(make_pair(0, make_pair(s_h, s_w)));
    while(!pq.empty()){
        auto cur = pq.top();
        auto cur_cost = cur.first;
        auto cur_h = cur.second.first;
        auto cur_w = cur.second.second;
        pq.pop();
        if(cur_h == 0 || cur_h == H - 1 || cur_w == 0 || cur_w == W){
          return cur_cost;
        }
        if(d[cur_h][cur_w] < cur_cost){
            continue;
        }
        
        for(int i = 0; i < 4; i++){
          int next_h = cur_h + h_moves[i];
          int next_w = cur_w + w_moves[i];
          if(0 <= next_h && next_h < H && 0 <= next_w && next_w < W){
            int next_cost = cur_cost;
            if(A[next_h][next_w] == '#'){
              next_cost ++;
            }

            if(d[next_h][next_w] > next_cost){
              d[next_h][next_w] = next_cost;
              pq.push(make_pair(next_cost, make_pair(next_h, next_w)));
            }
          }
        }
    }
    return INT_MAX;
}
*/

int main(){
  int H;
  int W;
  int K;

  cin >> H >> W >> K;
  for(int i = 0; i < H; i++){
    cin >> A[i];
  }

  int s_h;
  int s_w;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(A[i][j] == 'S'){
        s_h = i;
        s_w = j;
        break;
      }
    }
  }
  
  ans = INT_MAX;
  bfs(s_h, s_w, K, H, W);
  if(ans % K == 0){
      cout << ans / K + 1 << endl;
  } else {
      cout << ans / K + 1 + 1 << endl;
  }
  return 0;
}

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

int main(){
double n,min,max,f;

scanf("%lf",&n);
min=n;
max=n;
while(scanf("%lf",&n)!=EOF){
if(max<n){
max=n;
}
if(min>n){
min=n;
}
}
f=max-min;
printf("%.1f",f);

return 0;
}

Measured memory_bytes: 1080