akhauriyash/Code-Regression huggingface dataset:
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	k := getNextInt(scanner)

	cm := Com{}
	cm.init(n << 1)

	var ans int64
	for i := 0; i < n && i <= k; i++ {
		ans += cm.calc(n, i) * cm.calc(n-1, i) % cm.mod
		ans %= cm.mod
	}
	fmt.Fprintln(writer, ans)
}

// Com ...
type Com struct {
	facs, invs []int64
	mod        int64
}

func (cm *Com) init(n int) {
	cm.facs = make([]int64, n+1)
	cm.invs = make([]int64, n+1)

	cm.facs[0] = 1
	cm.mod = int64(1e9 + 7)
	for i := 1; i <= n; i++ {
		cm.facs[i] = (cm.facs[i-1] * int64(i)) % cm.mod
	}
	cm.invs[n] = cm.inv(cm.facs[n])
	for i := n - 1; i >= 0; i-- {
		cm.invs[i] = cm.invs[i+1] * int64(i+1) % cm.mod
	}
}

func (cm *Com) inv(n int64) int64 {
	var ii [32]int64
	ii[0] = n
	for i := 1; i < 31; i++ {
		ii[i] = (ii[i-1] * ii[i-1]) % cm.mod
	}
	var ans int64
	ans = 1
	m := cm.mod - 2
	for i := 30; i >= 0; i-- {
		for m >= 1<<uint(i) {
			ans = (ans * ii[i]) % cm.mod
			m -= 1 << uint(i)
		}
	}

	return ans
}

func (cm *Com) calc(n, k int) int64 {
	ans := cm.facs[n] * cm.invs[k]
	ans %= cm.mod
	ans = ans * cm.invs[n-k]
	ans %= cm.mod
	return ans
}


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

sm = n*(n+1)//2
if n == 3:
  print(2)
  print(1, 3)
  print(2, 3)
elif n == 4:
  print(4)
  print(1, 2)
  print(1, 3)
  print(2, 4)
  print(3, 4)
elif n % 2:
  m = (n-1)//2
  print(m*4)
  a = [[i, n-i-2] for i in range(m)]
  for i in range(m-1):
    for j in range(2):
      for k in range(2):
        print(a[i][j]+1, a[i+1][k]+1)
  for i in range(2):
    print(a[m-1][i]+1, n)
    print(n, a[0][i]+1)
else:
  print(n*2)
  a = [[i, n-i-1] for i in range(n//2)]
  for i in range(n//2):
    for j in range(2):
      for k in range(2):
        print(a[i][j]+1, a[(i+1)%(n//2)][k]+1)

Measured memory_bytes: 3064
// C.

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <cstring>

using namespace std;
typedef long long LL;

int main(int argc, char *argv[])
{
	LL N, T, A;
	cin >> N >> T >> A;
	for (int i = 1; i < N; ++i) {
		LL t, a;
		cin >> t >> a;
		LL b = max(T / t, A / a);
		LL x = b * t, y = b * a;
		while (x < T || y < A) {
			x += t, y += a;
		}
		T = x, A = y;
	}
	cout << (T + A) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n, m; cin >> n >> m;
    ll sum = 0, ans = 0;
    map<ll, ll> cnt;
    cnt[sum]++;
    vi a(n);
    rep(i, n){
        cin >> a[i];
        sum += a[i];
        cnt[sum%m]++;
    }
    for(auto &num: cnt) ans += num.second*(num.second-1)/2;
    cout << ans << endl;
}

Measured memory_bytes: 7800
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

/** direction */
enum class Direction(val dx: Int, val dy: Int) {
    UP(0, -1),
    DOWN(0, 1),
    LEFT(-1, 0),
    RIGHT(1, 0),
}

data class Point(val i: Int, val j: Int)
fun solve() {
    val (h, w) = readIntegerList()
    val map = Array(h) { br.readLine()!! }
    val countMap = Array(h) { LongArray(w) }
    val checkedMap = Array(h) { BooleanArray(w) }
    val queue = LinkedList<Point>()
    queue.addLast(Point(0, 0))
    checkedMap[0][0] = true
    while (queue.isNotEmpty()) {
        val node = queue.removeFirst()
        for (d in Direction.values()) {
            val y= node.i + d.dy
            val x = node.j + d.dx
            if (!(y in 0 until h && x in 0 until w)) continue
            if (checkedMap[y][x]) continue
            if (map[y][x] == '#') continue

            countMap[y][x] = countMap[node.i][node.j] + 1
            checkedMap[y][x] = true
            queue.addLast(Point(y, x))
        }
    }

    val tmp = countMap[h - 1][w - 1]
    if (tmp == 0L) {
        out.println(-1)
        return
    }

    val whiteCount = map.fold(0L) { acc, s -> acc + s.count { it == '.' } } - 1
    out.println(whiteCount - tmp)
}


fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vi vector<ll>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define el printf("\n")
#define pb push_back
#define f first
#define s second
#define arrondi(a) (long long)floor(a+0.5);
#define NIL -1
ll N=500005;
ll MAX=9223372036854775807;
ll MOD=1000000007;
long double PI =4*atan(1);

int main()
{
	IOS;
    cout.precision(30);
    ll a,b,c,d,k1,k2,h; cin >> a >> b >> c >> d; h=(c*d)/(__gcd(d,c));
    ll nbr1=0,nbr2=0,nbr3=0;
    if (a%c==0) k1=0; else k1=c-a%c;
    if (a+k1>b) nbr1=0;
    else
    {
        k2=b%c;
        nbr1=((b-k2)-(a+k1))/c + 1;
    }

    if (a%d==0) k1=0; else k1=d-a%d;
    if (a+k1>b) nbr2=0;
    else
    {
        k2=b%d;
        nbr2=((b-k2)-(a+k1))/d + 1;
    }
    if (a%h==0) k1=0; else k1=h-a%h;
    if (a+k1>b) nbr3=0;
    else
    {
        k2=b%h;
        nbr3=((b-k2)-(a+k1))/h + 1;
    }
    cout << b - a + 1 - (nbr1 + nbr2 - nbr3);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define REP(i, n) for (LL i = 0; i < (LL)(n); i++)
#define REP2(i, n) for (LL i = 1; i <= (LL)(n); i++)
#define FOR(i, m, n) for (LL i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(x.begin(), x.end(),0)
#define vLL(v,n) vector<LL> v(n); REP(i,n)cin>>v[i];
#define vstr(v,n) vector<string> v(n); REP(i,n)REP(i,n)cin>>v[i];
LL INF = 1e9 + 1;
LL MOD = 1e9+7;
  LL a,b,c,d,e,n,m,l,k,r,x,y,z,ans=0,ans2=0;
string s,S,t;
int main() {
ios_base::sync_with_stdio(false);
cin >> n;
REP(i,n){
    cin >> l >> r;
    ans+=r-l+1;
}
cout <<ans<<endl;
}


Measured memory_bytes: 3588
#include <stdio.h>
int main(void)
{
	int a;
	char op;
	int b;
	int c;
	int d;

	for (;;)
	{
	
		scanf("%d %c %d", &a, &op, &b);
		 if (op == '+')
		 {
		 	c=a+b;
		 	printf("%d\n", c);
		 }
		 else if (op == '-')
		 {
		 	c=a-b;
		 	printf("%d\n", c);
		 }
		 else if (op == '*')
		 {
		 	c=a*b;
		 	printf("%d\n", c);
		 }
		 else if (op == '/')
		 {
		 	c=a/b;
		 	printf("%d\n", c);
		 }
		 else if (op == '?')
		 {
		 	return 0;
		 } 
		 	
	}

	 return 0;
}

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

int main() {
	int A, B, C, D ;
  	int L, R;
  cin >> A >> B >> C >> D;
  L = A + B;
  R = C + D;
  
  if(L > R)
    cout << "Left" << endl;
  else if(L < R)
    cout << "Right" << endl;
  else
    cout << "Balanced" << endl;
}


Measured memory_bytes: 256
W = input()
counter = 0
T = []
while True:
    string = input()
    if string == "END_OF_TEXT":
        break
    else:
        T.append(string)
for i in range(len(T)):
    memo = T[i].split()
    for j in range(len(memo)):
        if memo[j].lower() == W:
            counter += 1
print(counter)

Measured memory_bytes: 7356
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>

int main() {
	std::cin.tie(0); std::cin.sync_with_stdio(false);
	int n; std::cin >> n;
	std::vector<int> bars(n); for (auto& b : bars) std::cin >> b;
	std::sort(bars.begin(), bars.end());
	int count = 0;
	for (auto i = 1; i < n; ++i) {
		int last = i + 1;
		for (auto j = 0; j < i; ++j) {
			while (last < n && bars[last] < bars[i] + bars[j]) ++last;
			count += last - i - 1;
		}
	}
	std::cout << count << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
bool isPrime(int num)
{
  	if(num == 2 || num == 3)
    {
     	return true; 
    }
  
  	if(num % 2 == 0 || num % 3 == 0)
    {
     	return false; 
    }
  
  	bool jelTacno = false;
  
  	for(int i = 5; i * i <= num; )
    {
      	if(num % i == 0)
        {
          	return false;
        }
      
      	if(!jelTacno)
        {	
          	i+=2;
          	jelTacno = true;
        }
      
      	else
        {	
          	i+=4;
          	jelTacno = false;
        }
    }
  
  	return true;
}
 
int main()
{
 	int x;
  	cin >> x;
  
  	for(int i = x; ; i++)
    {
     	 if(isPrime(i))
         {
          	cout << i << '\n';
           	return 0;
         }
    }
  	
  	return 0;
}

Measured memory_bytes: 256
n, k = map(int,input().split())
r, s, p = map(int,input().split())
t = input()
cnt = 0
for i in range(k):
    lst = [t[i]]
    cont_cnt = 1
    for j in range(i+k, n, k):
        if t[j] == t[j-k]:
            cont_cnt += 1
        else:
            lst.append(cont_cnt)
            lst.append(t[j])
            cont_cnt = 1
    lst.append(cont_cnt)
    for j in range(0,len(lst), 2):
        if lst[j] == "r":
            cnt += (lst[j+1]+1) // 2 * p
        elif lst[j] == "s":
            cnt += (lst[j+1]+1) // 2 * r
        elif lst[j] == "p":
            cnt += (lst[j+1]+1) // 2 * s
print(cnt)


Measured memory_bytes: 4468
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   

int main(){
    std::ios::sync_with_stdio(false);
    int a,b,x;
    cin>>a>>b>>x;
    if(a<=x && x<=a+b){
    	cout<<"YES"<<endl;
    }
    else{
    	cout<<"NO"<<endl;
    }
    return 0;  
    
}



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

int main()
{
  int n, l;
  std::cin >> n >> l;
  std::vector<std::string> sv;
  std::string sout;
  for(int i = 0; i < n; i++) {
    std::string s;
    std::cin >> s;
    sv.push_back(s);
  }
  std::sort(sv.begin(), sv.end(),
      [](std::string a, std::string b){
        return a < b;
      });
  for(auto&& so : sv) {
    sout += so;
  }
  std::cout << sout << std::endl;
  return 0;
}


Measured memory_bytes: 256
fun <T> List<T>.upperBound(element: T): Int where T : Comparable<T> {
    return this
        .binarySearch { if (it > element) 1 else -1 }
        .let { -(it + 1) }
}

fun main(args: Array<String>) {
    val s = readLine()!!
    val t = readLine()!!

    val table = Array(26) { mutableListOf<Int>() }
    for ((i, c) in s.withIndex()) {
        table[c - 'a'].add(i + 1)
    }

    var cur = 0L
    for (c in t) {
        val i = c - 'a'
        if (table[i].isEmpty()) {
            cur = -1
            break
        }

        val p1 = (cur % s.length).toInt()
        val p2 = table[i].upperBound(p1)
        cur += if (p2 < table[i].size) {
            table[i][p2] - p1
        } else {
            s.length - p1 + table[i][0]
        }
    }
    println(cur)
}


Measured memory_bytes: 41324
s = gets.chomp

i = 0
ans = 0

s.each_char do |s_current|
    if i == 0 && s_current == 'Y'
        ans += 1
    end
    if i == 1 && s_current == "A"
        ans += 1
    end
    if i == 2 && s_current == "K"
        ans += 1
    end
    if i == 3 && s_current == "I"
        ans += 1
    end
    i +=1
end

if ans == 4
    puts "Yes"
else
    puts "No"
end


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

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()

template <typename T> inline void assign_min(T& x, const T& value) noexcept { x = min(x, value); }

int main() {
    int N, K; cin >> N >> K;
    vector<int> h(N);
    REP(i, N) cin >> h[i];

    // dp[i]: i番目の足場に辿り着くまでに支払うコストの総和の最小値
    vector<int> dp(N);
    FOR(i, 1, N) {
        dp[i] = numeric_limits<int>::max();
        FOR(k, 1, K+1) {
            if (i-k < 0) break;
            assign_min(dp[i], dp[i-k] + abs(h[i] - h[i-k]));
        }
    }

    cout << dp[N-1] << '\n';
}


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

using namespace std;


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

int main(void){

    double n;
    cin >> n;
    double pi = acos(-1);

    printf("%.6lf %.6lf\n", n*n*pi, 2*n*pi);
    // cout << n*n*pi << " " << 2*n*pi << endl;

    return 0;
}


Measured memory_bytes: 3184
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	bf := make([]byte, 10*1024*1024)
	sc.Buffer(bf, 10*1024*1024)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	s := sc.Text()

	c := 0

	for i := range s {
		c += int(s[i] - '0')
		c = c % 9
	}

	if c == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


Measured memory_bytes: 2612
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-4;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	llint X,D,n,G,ans=0,i;cin>>n>>X>>D;
	
	if(D==0){
		if(X!=0){cout<<n+1<<endl;return 0;}
		else{cout<<1<<endl;return 0;}
	}
	if(D<0){X*=-1;D*=-1;}
	G=gcd(X,D);X/=G;D/=G;
	//前とかぶらなければ大丈夫
	for(i=0;i<=n;i++){
		if(i<D){ans+=1+i*(n-i);}
		else{
			llint j=i-D;
			llint mL=j*(j-1)/2;
			llint mU=j*(n-1)-j*(j-1)/2;
			llint nL=i*(i-1)/2+X;
			llint nU=i*(n-1)-i*(i-1)/2+X;
			ans+=1+i*(n-i);
			ans-=max(0LL,min(mU,nU)-max(mL,nL)+1);
			//cerr<<mL<<" "<<mU<<" "<<nL<<" "<<nU<<endl;
		}
		//cerr<<ans<<endl;
	}
	cout<<ans<<endl;
	return 0;
}
/*
0
2,3,4
5,6,7
9
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
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;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  ll n,k;
  cin>>n>>k;
  vector<P> v(n);
  rep(i,n) cin>>v[i].fi>>v[i].se;
  sort(all(v));
  rep(i,n){
    k-=v[i].se;
    if(k<=0){
      out(v[i].fi);
      return;
    }
  }
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N,A,B; cin>>N>>A>>B;
    if(A+B-1>N){cout<< -1 <<"\n"; return;}
    if(A*B<N){cout<< -1 <<"\n"; return;}
    vector<ll> ans;
    ll num=N-B;
    vector<ll> ct(B,1);
    // B個のブロックに分ける,最初にA個上昇で入れて、Nあまりが足りるまで入れる。
    rep(i,B){
        ll buf=min(A-1,num);
        num-=buf;
        ct[i]+=buf;
    }
    ll saidai=N;
    rep(i,B){
        rep(j,ct[i]){
            ans.emplace_back(saidai-ct[i]+1+j);
        }
        saidai-=ct[i];
    }
    rep(i,N){
        cout<< ans[i] <<"\n";
    }
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

int main() {
  long N, M;
  cin >> N >> M;
  if(N==1 && M!=1) cout << M-2 << endl;
  else if(N!=1 && M==1) cout << N-2 << endl;
  else if(N==1 && M==1) cout << 1 << endl;
  else cout << (N-2)*(M-2) << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
MOD = 10**9+7

if N % 2 == 1: # 0を2個にする
  A.append(0)

A.sort()
od = tuple(A[::2])
ev = tuple(A[1::2])
# Ai と Biで、ある値の登場する回数が等しくなかった場合、明らかに答えは 0 
if od == ev:
  comb = (2**(N//2)) % MOD
  print(comb)
else:
  # 左右対称じゃなく報告と矛盾
  print(0)

Measured memory_bytes: 13880
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <sstream>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef long long ll;

const int MAX_SIZE = 10000;

struct edge{
	int to;
	int cost;
};

typedef pair<int,int> P;
int V;

const int MAX_V = 5000;

vector<edge> G[MAX_V];
int d[MAX_V];
const int INF = 100000000;

int prevv[MAX_V];

class Situation{
public:
	int ttl;
	int node;
	int dist;

	Situation();
	Situation(int ttl_,int node_,int dist_){
		ttl=ttl_;
		node=node_;
		dist=dist_;
	}

	bool operator<(const Situation &sit)const{
		return sit.dist > this->dist;
	}
};

void dijkstra(int s,int ttl){
	priority_queue<Situation > que;
	fill(d,d+MAX_V,INF);
	d[s] = 0;
	que.push(Situation(ttl,s,0));
	while(!que.empty()){
		Situation p = que.top();
		que.pop();
		int v = p.node;
		if(d[v] < p.dist)
			continue;
		if(p.ttl<=1)
			continue;
		for(int i = 0; i < G[v].size(); i++){
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(Situation(p.ttl-1,e.to,d[e.to]));
			}
		}
	}
}


int main(){

	int n;
	cin>>n;
	for(int i = 0; i < n; i++){
		int from;
		cin>>from;
		int m;
		cin>>m;
		for(int j = 0; j < m; j++){
			int to;
			cin>>to;
			edge e;
			e.cost=1;
			e.to=to;
			G[from].push_back(e);
		}
	}
	int l;
	cin>>l;
	for(int j = 0; j < l; j++){
		int s,dd,v;
		cin>>s>>dd>>v;
		dijkstra(s,v);
		if(d[dd]==INF)
			cout<<"NA"<<endl;
		else
			cout<<d[dd]+1<<endl;
	}


	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main(void)
{
    int b,c,d,i,j,h[101],m[101],k[101],g[101],a[200];
    scanf("%d",&b);
    
    for(i=0;i<b;i++){
        scanf("%d%d",&h[i],&m[i]);
        m[i]+=h[i]*60;
    }
    m[i]=1440;
    
    scanf("%d",&c);
    for(i=0;i<c;i++){
    scanf("%d%d",&k[i],&g[i]);
    g[i]+=k[i]*60;
    }
    g[i]=1440;
    
    i=0;
    j=0;
    d=0;
    while(1){
       if(m[i]==g[j]){
           printf("%d:%02d",m[i]/60,m[i]%60);
           i++;
           j++;
           d+=2;
       }
       else if(m[i]<g[j]){
            printf("%d:%02d",m[i]/60,m[i]%60);
            d++;
            i++;
        }
        else{
            printf("%d:%02d",g[j]/60,g[j]%60);
            d++;
            j++;
        }
        if(d!=b+c){printf(" ");}
        else{printf("\n"); break;}
    }
    return 0;
}

Measured memory_bytes: 620
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n;
  vector<int> t(n);
  for (int i=0;i<n;i++){
    cin >> t[i];
  }
  cin >> m;
  vector<int> p(m),x(m);
  for (int i=0;i<m;i++){
    cin >> p[i] >> x[i];
  }
  int sum=0;
  for (int i=0;i<n;i++){
    sum+=t[i];
  }
  for(int i=0;i<m;i++){
    cout << sum+x[i]-t[p[i]-1] << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
using namespace std;



int main()
{
    int n = 0, x;
    cin >> n >> x; 

    vector<int> v;
    int min = 1500000000;
    for(int i = 0; i < n; i++)
    {   
        int buf = 0;
        cin >> buf;
        buf = abs(buf - x);
        if (buf < min) min = buf;
        v.push_back(buf);
    }

    int D = min;

    while(true){
        int f = true;
        for(int i = 0; i< v.size(); i++)
        {
            if ( (v[i]%D) != 0)
            {
                f = false;
                break;
            }
        }

        if(f) 
        {
            break;
        }

        D--;
    }
    cout << D << endl;
    
    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define int long long
using vec_int = vector<int>;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int N; cin>>N;
    vec_int A(N);
    rep(i,N)cin>>A.at(i);

    multiset<int> numset;

    map<int, int> numcount;

    rep(i,N){
        auto pos = numset.lower_bound(A.at(i));
        
        if(pos==numset.begin()){
            numset.insert(A.at(i));
            numcount[A.at(i)]++;
        }else{
            --pos;
            numcount[*pos]--;
            if(numcount[*pos]<1){
                numset.erase(*pos);
            }

            numset.insert(A.at(i));
            numcount[A.at(i)]++;
        }
    }
    int count=0;
    for(auto temp: numcount){
        count+=temp.second;

    }
    cout<<count<<endl;




    return 0;
}

Measured memory_bytes: 14884
#include <bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000000

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};


const int MOD = 1000000007;
using mint = Fp<MOD>;


int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}
int gyaku(int n){
    return modpow(n,MOD-2);
}

//素因数分解でそれぞれの素数がいくつ出てきたかを保存するmap
auto pfactor(int n){
  map<int,int> res;
  int t=sqrt(n);
  for(int i=2;i<=t;i++){
    for(;n%i==0;n/=i)res[i]++;
  }
  if(n>1)res[n]++;
  return res;
}
vector<int>kai(0);
void kaizyou(vector<int>&kai){
    rep(i,kai.size()){
        kai[i+1]=kai[i]*(i+1)%MOD;
      }
  }
int comb(int a,int b){
  return (kai[a]*gyaku(kai[a-b]))%MOD*gyaku(kai[b])%MOD;
}
////////////////////////////////////////////////////////////////////////
signed main() {
  int k;
  cin>>k;
  if(k%2==0||k%5==0){
    cout<<-1<<endl;
    exit(0);
  }
  int n=7;
  int cnt=1;
  while(true){
    int t=n%k;
    if(t==0){
      cout<<cnt<<endl;
      exit(0);
    }
    else{
      cnt++;
      n=t*10+7;
    }
  }
  }


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

const long long int mod=1e9+7; 
const long long int limit=1e5; 

int a[limit];
bool check[limit];

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

long long int get2(long long int n){
    if(n==1) return 2;
    else return (2*(get2(n-1)%mod))%mod;
}

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

    if(n==1){
        int tmp;cin >> tmp;
        p((tmp==0?1:0))
        return 0;
    }

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

        if(n%2==0){
            if(a[tmp]==2) check[tmp]=true;
            else check[tmp]=false;
        } else {
            if(tmp==0){
                if(a[tmp]==1) check[tmp]=true;
                else check[tmp]=false;
            }
            else {
                if(a[tmp]==2) check[tmp]=true;
                else check[tmp]=false;
            }
        }
    }

    bool ans=true;
    if(n%2==0){
        for(int i=0;i<n;i++){
            if(i%2==0) ans = !check[i];
            else ans = check[i];

            if(!ans) break;
        }
    } else {
        for(int i=0;i<n;i++){
            if(i%2==1) ans = !check[i];
            else ans = check[i];

            if(!ans) break;            
        }            
    }

    if(!ans){
        p(0)
    } else {
        p(get2(n/2))
    }

}

Measured memory_bytes: 1536
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
typedef long long ll;
const int N=100100;
int a[N*3];
int n,m;
int main()
{
	scanf("%d",&n),m=n*3;
	for(int i=1;i<=m;i++)scanf("%d",a+i);
	std::sort(a+1,a+m+1);
	ll ans=0;
	int pos=m-1;
	for(int i=1;i<=n;i++)
	{
		ans+=a[pos];
		pos-=2;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;

const int MXN = 100005;
bool win[MXN];
bool calc[MXN];

int n, k;
vector<int> ops;

bool canwin(int x) {
	if (calc[x]) return win[x];
	calc[x] = true;
	if (x == 0) return win[x] = false;
	for (int i=0; i<n; i++) {
		if (x >= ops[i]) {
			if (!canwin(x-ops[i])) return win[x] = true;
		}
	}
	return win[x] = false;
}

int main() {
	
	cin >> n >> k;
	for (int i=0; i<n; i++) {
		int x;
		cin >> x;
		ops.push_back(x);
	}
	if (canwin(k)) {
		cout << "First" << endl;
	}
	else {
		cout << "Second" << endl;
	}
}




Measured memory_bytes: 5120
#!/usr/bin/env python3
import sys


def solve(K: int, N: int, A: "List[int]"):
    max_len = 0
    for i in range(len(A)):
        if i == 0:
            max_len = A[0] + K - A[N-1]
        else:
            if A[i] - A[i-1] > max_len:
                max_len = A[i] - A[i-1]
    print(K - max_len)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(K, N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 27072
#include <iostream>
#include <vector>
#include <cmath>
#include <typeinfo>
#include <set>
#include <bitset>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
using namespace std;
typedef long long ll;



int main(){
  long long  n,k;
  cin >> n >> k;
  vector<long long > h(n,0);
  for(long long i=0; i<n; i++){
    cin >> h[i];
  }
  sort(h.begin(), h.end(), greater<long long>());
  long long count = 0;
  for(long long i=k; i<n; i++){
    count += h[i];
  }
  cout << count << endl;
}

Measured memory_bytes: 1920
#include <iostream>
#include <bits/stdc++.h>
#define MAX_NUM 2001
#define MAX_SIZE 21
using namespace std;

class Point {
    public:
    double x, y; 

    Point(double x=0, double y=0): x(x), y(y) {};
    Point operator + (Point p) { return Point(x + p.x, y + p.y);}
    Point operator - (Point p) { return Point(x - p.x, y - p.y);}
    Point operator * (double a) { return Point(x * a, y * a);}
    Point operator / (double a) { return Point(x / a, y / a);}
    void print () { printf("%.5f %.5f\n", x, y); }
};

void koch(int d, Point p1, Point p2) {
    double th = M_PI * 60.0 / 180.0;

    if (d == 0) return;
    Point p12 = p2 - p1;
    Point s = p1 + p12 / 3;
    Point t = p1 + p12 * 2 / 3;
    Point st = t - s;
    Point u = s + Point(st.x * cos(th) - st.y * sin(th), st.x * sin(th) + st.y * cos(th));
    koch(d-1, p1, s);
    s.print();
    koch(d-1, s, u);
    u.print();
    koch(d-1, u, t);
    t.print();
    koch(d-1, t, p2);
}
    
int main(){
    Point p1(0, 0), p2(100, 0);
    int n;
    cin >> n;
    p1.print();
    koch(n, p1, p2);
    p2.print();
    return 0;
} 


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

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

    cout << n*(n+1)/2 - b << endl;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
x = list(map(int,input().split()))

ans = 10**9+7

for i in range(N-K+1):
    left = x[i]
    right = x[i+K-1]
    time = min(abs(right),abs(left))+abs(right-left)
    ans = min(ans,time)
    
print(ans)

Measured memory_bytes: 62576
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi atan(1.0)*4
#define pb(x) push_back(x)
#define in(x) insert(x)
#define fl(x,y) for(ll i=x;i<y;i++)

double min(double x, double y)
{
    return (x < y)? x: y;

}

double calcAngle(double h, double m)
{
    if (h == 12) h = 0;
    if (m == 60) m = 0;
    double hour_angle = 0.5 * (h * 60 + m);
    double minute_angle = 6 * m;
    double angle = abs(hour_angle - minute_angle);
    angle = min(360 - angle, angle);
    return angle;
}

int main()
{
    double a,b,c,h,m,t,n,k,p,q,r,sum,ct=0,flag=0;
    string s,s1,s2,s3;
    set<ll>st;
    map<ll,ll>mp;
    vector<ll>v;
    cin>>a>>b>>h>>m;
    c=calcAngle(h,m);
    c=c*pi/180;
    p=a*a+b*b- 2*a*b*cos(c);
    p=sqrt(p);
    cout<<fixed<<setprecision(20)<<p<<endl;
}





Measured memory_bytes: 4248
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
long long a[200001];
int main() {
    unsigned n;
    scanf("%u", &n);
    for (size_t i = 1; i <= n; i++) {
        scanf("%lld", &a[i]);
        a[i] -= i;
    }
    sort(a + 1, a + n + 1);
    unsigned mid = (1 + n) >> 1;
    long long ans = 0;
    long long b = a[mid];
    for (size_t i = 1; i < mid; i++) {
        ans += b - a[i];
    }
    for (size_t i = mid; i <= n; i++) {
        ans += a[i] - b;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1664
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        boolean[] eat = new boolean[n];
        ArrayList<Dish> li = new ArrayList<Dish>();
        for(int i = 0; i < n; i++){
            long a = sc.nextLong();
            long b = sc.nextLong();
            li.add(new Dish(a,b,i));
        }
        Collections.sort(li);
        long ans = 0;
        for(int i = 0; i < n; i++){
            Dish d = li.get(i);
            if(i % 2 == 0){
                ans += d.a;
            }else{
                ans -= d.b;
            }
        }
        System.out.println(ans);
    }
}
class Dish implements Comparable<Dish>{
    int i;
    long a,b,diff;
    public Dish(long a,long b,int i){
        this.a = a;
        this.b = b;
        this.diff = b+a;
        this.i = i;
    }
    
    public int compareTo(Dish d){
        if(this.diff > d.diff){
            return -1;
        }else if(this.diff < d.diff){
            return 1;
        }else{
            return 0;
        }
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


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

int main(){
    int n; cin>>n;
    vector<int> vec;
    if(n%2){
        for(int i=0;i<n;i++){
            int k; cin>>k;
            if(i%2)vec.push_back(k);
            else vec.insert(vec.begin(),k);
        }
    }
    if(n%2==0){
        for(int i=0;i<n;i++){
            int k; cin>>k;
            if(i%2==0)vec.push_back(k);
            else vec.insert(vec.begin(),k);
        }
    }
    for(int i=0;i<vec.size()-1;i++)cout<<vec.at(i)<<" ";
    cout<<vec.at(vec.size()-1)<<endl;
}

Measured memory_bytes: 3060
import std.stdio, std.math;

void main() {
  for(int n; readf("%d\n", &n), n != 0;) {
    double bmi = double.max;
    long id = long.max;
    for(long k = 0; k < n; k++) {
      long num, height, weight;
      readf("%d %d %d\n", &num, &height, &weight);
      double d = abs((weight * 10000.0) / (height * height) - 22.0);
      if (d < bmi) {bmi = d; id = num;}
    }
    writeln(id);
  }
}

Measured memory_bytes: 1072
n = int(input())
a = [int(i) for i in input().split(' ')]
ave = sum(a) / n
if (ave - int(ave)) < 0.5:
    ave = int(ave)
else:
    ave = int(ave) + 1
res = 0
for i in a:
    res += (i - ave)**2
print(res)

Measured memory_bytes: 3064
#-------------------------------------------------------------------
import sys
def p(*a):
  s=" ".join(map(str,a))
  #print(s)
  sys.stderr.write(s+"\n")
#-------------------------------------------------------------------

N, K = map(int, input().split())			# "5 7" -> ["5", "7"] -> 5, 7 => N=5,K=7
S = input()


a=""
b=S[K-1].lower()
c=S[K:]
if K-1>=0: a=S[:K-1]
print(a + b + c)

#p(a)
#p(b)
#p(c)


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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n, u, v;
    static vector<int> edge[100001];
    cin >> n >> u >> v;
    for(int i=1;i<n;++i){
        int a, b;
        cin >> a >> b;
        edge[a].emplace_back(b);
        edge[b].emplace_back(a);
    }

    static int p[100001];
    queue<int> q;
    p[u] = -1;
    q.push(u);
    while(!q.empty()){
        int t = q.front();
        q.pop();
        for(int nx: edge[t]){
            if(p[nx] != 0) continue;
            p[nx] = t;
            q.push(nx);
        }
    }
    vector<int> path;
    int pos = v;
    while(pos != u){
        path.emplace_back(pos);
        pos = p[pos];
    }
    path.emplace_back(u);
    int len = path.size() - 1;
    int start = path[len / 2 + 1], wall = path[len / 2];
    static int depth[100001];
    q.push(start);
    depth[start] = 1;
    depth[wall] = -1;
    while(!q.empty()){
        int t = q.front();
        q.pop();
        for(int nx: edge[t]){
            if(depth[nx] != 0) continue;
            depth[nx] = depth[t] + 1;
            q.push(nx);
        }
    }
    cout << len / 2 + *max_element(depth, depth + n + 1) - 1 << endl;
    
    return 0;
}

Measured memory_bytes: 6784
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <iterator>
#include <queue>
#include <stack>
#include <deque>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <string>
#include <cmath>
#include <complex>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cstdlib>
#include <cctype>

#define REP(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(int)c.size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(u) (u).rbegin(),(u).rend()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl
#define v_delete(a,b) (a).erase(remove((a).begin(), (a).end(), b), (a).end())
#define v_unique(a) (a).erase(unique((a).begin(), (a).end()), (a).end())
#define VV(T) vector<vector< T > >
#define init(a,b) memset((a), (b), sizeof((a)))

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double EPS=1e-9;
const long long INF = 100001000010000100ll;

template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}

template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
typedef pair<int,int> pii;

int D, N, M;

vi tokei;
vi hantokei;

int main(){
	while(cin >> D, D){
		tokei.clear();
		hantokei.clear();
		cin >> N;
		cin >> M;
		tokei.pb(0);
		rep(i, N-1){
			int t;
			cin >> t;
			tokei.pb(t);
			hantokei.pb(D - t);
		}
		sort(all(tokei));
		sort(all(hantokei));
		tokei.pb(D);
		hantokei.pb(D);

		ll ans=0;

		rep(i, M){
			int t;
			cin >> t;
			int left = lower_bound(all(tokei), t) - tokei.begin();
			int right = lower_bound(all(hantokei), D - t) - hantokei.begin();
			ans += min(abs(tokei[left] - t), abs(hantokei[right] - (D - t)));
		}
		cout << ans << endl;
	}



	return 0;

}

Measured memory_bytes: 2200
def disc(s,d):
	ans[d][0] = s
	s += 1
	if main[d][0] != 0:
		for l in range(1,int(main[d][0])+1):
			if ans[int(main[d][l])-1][0] == 0:
				s = disc(int(s),int(main[d][l])-1)
	ans[d][1] = s
	return s+1

n = int(input())

main = []

for i in range(n):
	a = input().split()
	if int(a[1]) > 0:
		main.append(a[1:])
	else:
		main.append([0])

del a

ans = [[0] * 2 for i in range(n)]

ls = disc(1,0)
for i in range(n):
	if ans[i][0] == 0:
		ls = disc(int(ls),i)


for i in range(n):
	print(str(i+1) + " " + str(ans[i][0]) + " " + str(ans[i][1]))



Measured memory_bytes: 5640
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int n,a[3];
ll dp[4][1<<8];

int main(){
	cin>>n>>a[2]>>a[1]>>a[0];
	vector<int>l(n);
	rep(i,n){
		cin>>l[i];
	}
	memset(dp,0x3f,sizeof(dp));
	dp[0][0]=0;
	rep(i,3)rep(j,1<<n){
		if(dp[i][j]==INFL)continue;
		rep(k,1<<n){
			if(k==0)continue;
			if(j&k)continue;
			int cnt=0;
			rep(t,n){
				if(k>>t&1)cnt+=l[t];
			}
			dp[i+1][j|k]=min(dp[i+1][j|k],dp[i][j]+abs(cnt-a[i])+10*(__builtin_popcount(k)-1));
		}
	}
	cout<<*min_element(dp[3],dp[3]+(1<<n))<<endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int[] mtns = new int[10];
		int first, second, third;
		
		for(int i=0; i<10; i++) {
			mtns[i] = sc.nextInt();
		}
		
		Arrays.sort(mtns);
		
		System.out.println(mtns[9]);
		System.out.println(mtns[8]);
		System.out.println(mtns[7]);
		
	}

}

Measured memory_bytes: 17168