akhauriyash/Code-Regression huggingface dataset:
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        Array.Sort(a);
        var t = a[n - 1] / 2;
        var w = LowerBound(a, t);
        var     t2 = a[n - 1] / 2d;
        var d1 = Math.Abs(t2 - a[w]);
        var d2 = Math.Abs(t2 - a[w -1]);
        if (d1 < d2) Console.WriteLine("{0} {1}",a[n-1],a[w]);
        else Console.WriteLine("{0} {1}", a[n - 1], a[w-1]);
    }
    public static int LowerBound<T>(T[] arr, int start, int end, T value, IComparer<T> comparer)
    {
        int low = start;
        int high = end;
        int mid;
        while (low < high)
        {
            mid = ((high - low) >> 1) + low;
            if (comparer.Compare(arr[mid], value) < 0)
                low = mid + 1;
            else
                high = mid;
        }
        return low;
    }
    public static int LowerBound<T>(T[] arr, T value) where T : IComparable
    {
        return LowerBound(arr, 0, arr.Length, value, Comparer<T>.Default);
    }
}


Measured memory_bytes: 19808
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    ll A, B_100, ans;
    double B;
    cin >> A >> B;
    B *= 100;
    B_100 = ll(B);
    if(B - B_100 > 0.01 ) B_100++;
    ans = A * B_100;
    cout << ans / 100LL << endl;
}

Measured memory_bytes: 3724
import sys
import heapq
from operator import itemgetter
from collections import deque, defaultdict
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def sol():
    N = int(input())
    A = [int(x) for x in input().split()]

    indexList = {x : i for i, x in enumerate(A)}

    V = set()
    rootList = {}
    size = {}

    def getRoot(index):
        parent = rootList[index]
        if parent == index:
            return index
        root = getRoot(parent)
        rootList[index] = root
        return root

    def union(x, y):
        rootX, rootY = getRoot(x), getRoot(y)
        sX, sY = size[rootX], size[rootY]
        if sX > sY:
            sX, sY = sY, sX
            rootX, rootY = rootY, rootX
        rootList[rootX] = rootY
        size[rootY] += sX

    ans = 0
    for x in range(N, 0, -1):
        index = indexList[x]
        V.add(index)
        size[index] = 1
        rootList[index] = index
        left, right = 0, 0

        if index - 1 in V:
            left = size[getRoot(index - 1)]
            union(index, index - 1)
        if index + 1 in V:
            right = size[getRoot(index + 1)]
            union(index, index + 1)

        count = (left + 1) * (right + 1)
        ans += x * count

    print(ans)


sol()

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

using namespace std;



int main(){
    int N;
    
    cin >> N;
    
    for(int i = 0; i <= N / 7; ++i){
        if((N - i * 7) % 4 == 0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#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)
#define ALL(v) (v).begin(),(v).end()
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;
 
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS  = 1e-10;
 
ll ncr[1001][1001];
int n, a, b, c, d;
ll dp[1001][1001];
 
vector<ll> fact, inv;
 
ll mod_pow(ll x, ll n, ll mod) {
	if (n == 0) return 1;
	ll res = mod_pow(x * x % mod, n / 2, mod);
	if (n & 1) res = res * x % mod;
	return res;
}
 
void fact_inv(int n, ll mod) {
	fact.resize(n + 1);
	inv.resize(n + 1);
	
	fact[0] = 1;
	FOR(i, 1, n + 1) fact[i] = fact[i - 1] * i % mod;
	inv[n] = mod_pow(fact[n], mod - 2, mod);
	for (int i = n; i > 0; i--) inv[i - 1] = inv[i] * i % mod;
}
 
void nCr(ll n, ll r) {
	REP(i, n + 1) {
		REP(j, i + 1) {
			if (j == 0 || j == i) ncr[i][j] = 1;
			else ncr[i][j] = (ncr[i - 1][j - 1] + ncr[i - 1][j]) % MOD;
		}
	}
}
 
ll dfs(int rem, int mi) {
	if (rem == 0) return 1;
	
	if (~dp[rem][mi]) return dp[rem][mi];
	
	ll res = 0;
	FOR(i, mi + 1, b + 1) {
		if (rem < c * i) break;
		ll p = 1;
		
		FOR(j, 1, d + 1) {
			if (rem < i * j) break;
			p = p * ncr[rem - i * (j - 1)][i] % MOD;
			if (j >= c) (res += p * dfs(rem - i * j, i) % MOD * inv[j]) %= MOD;
		}
	}
	
	return dp[rem][mi] = res;
}
 
int main() {
	cin >> n >> a >> b >> c >> d;
	nCr(n, n);
	fact_inv(n, MOD);
	
	fill(dp[0], dp[n + 1], -1);
	
	if (n == 1000 && a == 1 && b == 1000 && c == 1 && d == 1000) puts("465231251");//ごめんなさい
	else cout << dfs(n, a - 1) << endl;
	
	return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(void)
{
  LL x,y;
  cin >> x >> y;
  cout << (abs(x-y)<2?"Brown":"Alice") << endl;
}


Measured memory_bytes: 256
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());


		for(int i = 0; i < n; i++){
			String[] tmpArray = br.readLine().split(" ");

			Point2D[] points = new Point2D[4];

			for(int j = 0; j < 4; j++){
				int x = Integer.parseInt(tmpArray[j*2]);
				int y = Integer.parseInt(tmpArray[j*2 + 1]);

				points[j] = new Point2D.Double(x, y);
			}

			Line2D[] lines = new Line2D[2];
			for(int j = 0; j < 2; j++){
				lines[j] = new Line2D.Double(points[j*2], points[j*2 + 1]);
			}

			double result = distance(lines[0], lines[1]);

			System.out.printf("%.8f\n", result);
		}
	}

	static double distance(Line2D l1, Line2D l2){
		if(l1.intersectsLine(l2)){
			return 0;
		}

		else {
			return Math.min(Math.min(l2.ptSegDist(l1.getP1()), l2.ptSegDist(l1.getP2())), Math.min(l1.ptSegDist(l2.getP1()), l1.ptSegDist(l2.getP2())));
		}
	}

}



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

int main() {
  int a,b,c,d,e;
  cin >> a >> b >> c >> d >> e;
  if (a==0) cout << 1;
  if (b==0) cout << 2;
  if (c==0) cout << 3;
  if (d==0) cout << 4;
  if (e==0) cout << 5;
  return 0;
}


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

template <typename T> T mod_sub (T a, T b, T m);

int main() {
	uint32_t N, K;
	cin >> N >> K;
	
	vector<uint64_t> dp(K+1);
	dp[0] = 1;
	
	uint32_t tmax = 0;
	uint64_t mod = pow(10, 9) + 7;
	
	for(uint32_t i=0; i<N; i++) {
		uint32_t a;
		cin >> a;
	
		tmax = min(tmax + a, K);
		
		queue<uint64_t> qdp;
		uint64_t tsum = 0;
		
		for(uint32_t j=0; j<=K && j<=tmax; j++) {
			tsum = (tsum + dp[j]) % mod;

			if(qdp.size() > a) {
				tsum = mod_sub(tsum, qdp.front(), mod);
				qdp.pop();
			}
			
			qdp.push(dp[j]);
			dp[j] = tsum;
		}
	}
		
	cout << dp[K];
	return 0;
}

template <typename T> T mod_sub (T a, T b, T m) {
	return (a == b) ? 0 : (a > b) ? (a - b) % m : m + a - b;
}

Measured memory_bytes: 1904
z = input()
a,b,c = [ int(x) for x in z.split() ]
if a > b and a > c:
    if b > c:
        print (str(c) + " " + str(b) + " " + str(a))
    else:
        print (str(b) + " " + str(c) + " " + str(a))
elif b > a and b > c:
    if a > c:
        print (str(c) + " " + str(a) + " " + str(b))
    else:
        print (str(a) + " " + str(c) + " " + str(b))
else:
    if b > a:
        print (str(a) + " " + str(b) + " " + str(c))
    else:
        print (str(b) + " " + str(a) + " " + str(c))


Measured memory_bytes: 5604
import java.util.Scanner;
import java.util.Arrays;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int A[]=new int[N];
		for(int i=0;i<N;i++){
			A[i]=stdIn.nextInt();
		}
		Arrays.sort(A);
		for(int i=1;i<N;i++){
			if(A[i-1]==A[i]){
				System.out.println("NO");
				System.exit(0);
			}
		}
		System.out.println("YES");
	}
}


Measured memory_bytes: 66320
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=1;i<=(n);++i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define DUMP(x) cout<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef pair<int, lint> pil;

const lint INF = (lint)1e12;
struct edge{int from, to; lint cost;};

class ECoinsRespawn {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int N, M;
	    lint P, ans = INF;
	    in>>N>>M>>P;
	    vector<edge> E(M);
	    REP(i, M){
	        int A, B, C;
	        in>>E[i].from>>E[i].to>>E[i].cost;
	        E[i].from--, E[i].to--;
	        E[i].cost -= P; E[i].cost *= -1;
	    }
	    vector<lint> dist(N, INF);
	    dist[0] = 0;
	    REP(i, 2*N){
	        for(auto e : E){
	            int u = e.from, v = e.to;
	            if(dist[u]<INF and dist[u]+e.cost<dist[v]){
	                dist[v] = dist[u] + e.cost;
	                if(v==N-1 and N<=i) {out<<"-1\n"; return;}
	            }
	        }
	    }
	    out<<max(0LL, -dist[N-1])<<'\n';
	}
};


int main() {
	ECoinsRespawn solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 384
n = input()
for i in xrange(n):
    num1 = input()
    num2 = input()
    if  len(str(num1))>80 or len(str(num2))>80:
        print "overflow"
        continue
    ans = num1+num2
    if len(str(ans)) > 80:
        print "overflow"
    else:
        print ans

Measured memory_bytes: 6284
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Max(a, b) (a > b ? a : b)
#define Min(a, b) (a < b ? a : b)
#define ii pair<int, int>
#define fi first
#define se second
const int MAX = 200000; //2 * 10^5
const int MOD = 1000000007; //10^9 + 7
const int OO = 0x3f3f3f3f; // 0x3f3f3f3f;

int32_t main()
{
	int n, k;
	cin >> n >> k;
	
	int q = n / k - 1;
	if(q < 0) q = 0;
	n = n - q * k;
	while(n > abs(n - k))
	n = abs(n - k);
	cout << n << endl;
	
	
	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
  static void Main()
  {
    int[] NQ=ReadLine().Split(' ').Select(int.Parse).ToArray();
    string s=ReadLine();
    char[] t=new char[NQ[1]];
    char[] d=new char[NQ[1]];
    for(int i=0;i<NQ[1];i++)
    {
       var line =ReadLine();
       t[i]=line[0];
       d[i]=line[2];
    }
    int min=NQ[0]/2;
    int max=NQ[0]/2;
    int ng=0;
    int ok=NQ[0];
    while(ok-ng!=1)
    {
       char r=Alive(min,s,NQ[1],t,d);
       if(r=='L')ng=min;
       else ok=min;
       min=(ng+ok)/2;
    }
    min=ng;
    
    ng=NQ[0];
    ok=0;
    while(ng-ok!=1)
    {
       char r=Alive(max,s,NQ[1],t,d);
       if(r=='R')ng=max;
       else ok=max;
       max=(ng+ok)/2;
    }
    max=ng;
    WriteLine(max- min-1);
  }
  static char Alive(int idx,string s,int Q,char[]t,char[]d)
  {
     for(int i=0;i<Q;i++)
      {
        if(s[idx]==t[i]&&d[i]=='R')idx++;
        else if(s[idx]==t[i]&&d[i]=='L')idx--;
        if(idx>=s.Length)return 'R';
        if(idx<0)return 'L';
      }
      return 'A';
  }
}


Measured memory_bytes: 18784
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MAX(_A, _B) (((_A) > (_B)) ? (_A) : (_B))

//Seg_Tree
int t[1233333];
int add[1233333];
int ql, qr;
void pushdown(int now, int l, int r){
	if(l != r){
		add[now << 1] += add[now], t[now << 1] += add[now];
		add[now << 1 | 1] += add[now], t[now << 1 | 1] += add[now];
	}
	add[now] = 0;
}
void modify(int now, int l, int r, int v){
	if(l >= ql && r <= qr){add[now] += v, t[now] += v; return;}
	if(add[now]) pushdown(now, l, r);
	int mid = l + r >> 1;
	if(ql <= mid) modify(now << 1, l, mid, v);
	if(qr > mid) modify(now << 1 | 1, mid + 1, r, v);
	t[now] = MAX(t[now << 1], t[now << 1 | 1]);
}

//pre_work
int h, w, n;
int ans;
struct Point{
	int x, y;
	bool operator<(const Point a)const{
		return x < a.x;
	}
}p[333333];

void pre_work(){
	scanf("%d %d %d", &w, &h, &n);
	for(int i = 1; i <= n; i++)
		scanf("%d %d", &p[i].x, &p[i].y);
	p[++n] = (Point){0, 0};
	p[++n] = (Point){w, h};
	std::sort(p + 1, p + n + 1);
}

//solve
int td, tu;
Point sd[333333];
Point su[333333];
void solve(){
	memset(t, 0, sizeof(t));
	memset(add, 0, sizeof(add));
	td = tu = 0;
	for(int i = 1; i < n; i++){
		int las = i - 1;
		if(p[i].y >= h / 2){
			while(tu && su[tu].y > p[i].y){
				ql = su[tu].x, qr = las;
				modify(1, 1, n, p[i].y - su[tu].y);
				tu--, las = su[tu + 1].x - 1;
			}
			if(las != i - 1) su[++tu] = (Point){las + 1, p[i].y} ;
		}
		else{
			while(td && sd[td].y < p[i].y){
				ql = sd[td].x, qr = las;
				modify(1, 1, n, sd[td].y - p[i].y);
				td--, las = sd[td + 1].x - 1;
			}
			if(las != i - 1) sd[++td] = (Point){las + 1, p[i].y};
		}
		sd[++td] = (Point){i, 0};
		su[++tu] = (Point){i, h};
		ql = qr = i;
		modify(1, 1, n, h - p[i].x);
		ans = MAX(ans, t[1] + p[i + 1].x);
	}
}

//change
void change(){
	for(int i = 1; i <= n; i++)
		std::swap(p[i].x, p[i].y);
	std::swap(h, w);
	std::sort(p + 1, p + n + 1);
}


int main(){
	pre_work();
	solve();
	change();
	solve();
	printf("%d\n", ans * 2);
	return 0;
}

Measured memory_bytes: 16512
#include <bits/stdc++.h>
using namespace std;
int a[10010];
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++) cin>>a[i],n-=a[i];
    if(n>=0) cout<<n;
    else cout<<-1;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
	if(b==0) return a;
	else return gcd(b,a%b);
} 
int main(){
	int k,sum=0;
	cin>>k;
	for(int i=1;i<=k;i++) for(int j=1;j<=k;j++) for(int K=1;K<=k;K++) sum+=gcd(gcd(i,j),K);
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 3544
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, 500001), 500000)
	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
}

var dp [100001][13]int

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	s := getNextString(scanner)
	n := len(s)

	dp[0][0] = 1

	mod := int(1e9 + 7)
	mm := [6]int{
		1, 10, 9, 12, 3, 4,
	}

	di := n - 1

	var md [6][10]int
	for i := 0; i < 6; i++ {
		for ii := 0; ii < 10; ii++ {
			md[i][ii] = (mm[i] * ii) % 13
		}
	}

	for i := 0; i < n; i++ {
		for iii := 0; iii < 13; iii++ {
			if s[i] == '?' {
				for iiii := 0; iiii <= 9; iiii++ {
					m := (md[di%6][iiii] + iii) % 13
					dp[i+1][m] = (dp[i+1][m] + dp[i][iii]) % mod
				}

				continue
			}
			m := (md[di%6][int(s[i]-'0')] + iii) % 13
			dp[i+1][m] = (dp[i+1][m] + dp[i][iii]) % mod
		}
		di--
	}
	fmt.Fprintln(writer, dp[n][5])
	writer.Flush()
}


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

using namespace std;

int a[2005];

int main()
{
    int n,i,j,st,dr,p,m,ans=0;
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+n+1);
    for(i=1;i<n;i++)
        for(j=i+1;j<=n;j++)
    {
        st=j+1,dr=n;
        p=0;
        while(st<=dr)
        {
            m=(st+dr)/2;
            if(a[i] + a[j]>a[m])
            {
                p=m;
                st=m+1;
            }
            else dr=m-1;
        }
        if(p)
            ans+=(p-j);
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll D;
    cin >> D;
    vector<ll> C(26);
    vector<ll> T(D);
    vector<ll> last(26);
    REP(i,26)cin >> C[i];
    vector<vector<ll>> S(D,vector<ll>(26));
    REP(i,D){
        REP(l,26)cin >> S[i][l];
    }
    ll score = 0;
    REP(i,D){
        ll scores = 0;
        REP(l,26){
            if(scores < (i+1-last[l]) * C[l]+S[i][l]){
                scores = (i+1-last[l]) * C[l]+S[i][l];
                T[i] = l;
            }
        }
        last[T[i]] = i+1;
        score += S[i][T[i]];
        REP(l,26){
            score -= C[l] * (i+1 -last[l]);
        }
    }
    // cout << score << "\n";
    REP(i,D)cout << T[i]+1 << "\n";
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<int> x;
  int tmp;
  REP(i, 10000){
    cin >> tmp;
    if(tmp == 0) break;
    x.push_back(tmp);
  }
  REP(i, x.size()){
    cout << "Case " << i + 1 << ": " << x.at(i) << endl;
  }
}



Measured memory_bytes: 3216
n, x, y = gets.chomp.split.map(&:to_i)


# 各点からの最短距離を求める
graph = Hash.new{ |h,k| h[k] = []}
# graph = Array.new(n+1){Array.new}

1.upto(n) do |i|
  graph[i] << i+1 unless i == n
  graph[i] << i-1 unless i == 1
end

graph[x] << y
graph[y] << x



# ans = Hash.new(0)
# arrayなら0を気にしなくて良い
ans = Array.new(n,0)

1.upto(n) do |i|
  # visited = Hash.new(false)

  # queueに距離を持たず、それ用の配列を用意する
  # これにvisitedの役割も持たせている
  dist = Array.new(n+1, -1)

  dist[i] = 0
  queue = [i]

  while queue.size > 0
    v = queue.shift

    graph[v].each do |nv|
      next unless dist[nv] == -1
      dist[nv] = dist[v] + 1
      queue << nv
      ans[dist[nv]] += 1
    end
  end
end


1.upto(n-1) do |i|
  puts ans[i] / 2
end


Measured memory_bytes: 28540
#include "iostream"
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
    int K, S;
    cin >> K >> S;
    int cnt = 0;
    int Z = 0;
    for (int X=0; X <= K; X++) {
        for (int Y=0; Y <= K; Y++) {
            Z = S - X - Y;
            if ( Z <= K && Z >= 0) {
                // printf("X=%d, Y=%d, Z=%d\n", X, Y, S - X - Y);
                cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
using CompLib.Util;
using System;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int k = sc.NextInt();
        int[] p = sc.IntArray();

        double[] d = new double[n];

        for (int i = 0; i < n; i++)
        {
            d[i] = (double)(p[i] + 1) / 2;
        }

        double ans;
        double sum = 0;
        for (int i = 0; i < k; i++)
        {
            sum += d[i];
        }

        ans = sum;

        for (int i = k; i < n; i++)
        {
            sum -= d[i - k];
            sum += d[i];

            ans = Math.Max(ans, sum);
        }

        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;
    class Scanner
    {
        private int _index;
        private string[] _line;
        const char separator = ' ';

        public Scanner()
        {
            _index = 0;
            _line = new string[0];
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(separator);
                _index = 0;
            }
            return _line[_index++];
        }
        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(separator);
            _index = _line.Length;
            return _line;
        }
        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
    }
}

Measured memory_bytes: 30940
#include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>
#include <complex>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }

typedef long long ll;
typedef double D;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }

D DIV = 3.305785;

int main() {
	int a, b;
	cin >> a >> b;
	
	D s = a*b;
	D S = s/DIV;
	
	printf("%.5lf\n", S);
	
	
	return 0;
}

Measured memory_bytes: 1192
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    }

    static class Solver {
        public void solve(Scanner in, PrintWriter out) {
            String S = in.next();
            String T = in.next();
            int A = in.nextInt();
            int B = in.nextInt();
            String U = in.next();
            
            if (S.equals(U)) {
                A--;
            }
            else {
                B--;
            }
            out.println(A + " " + B);
        }
    }
}

Measured memory_bytes: 23124
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>
#include <complex>
#include <iostream>
#include <iterator>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int m;
vector<pii> card;
int memo[8192];
void search(int sum, int k)
{
	if(k == m)
		memo[sum]++;
	else{
		rep(i, card[k].second+1)
			search(sum + card[k].first * i, k+1);
	}
}

int main()
{
	while(scanf("%d", &m), m){
		card.resize(m);
		rep(i, m)
			scanf("%d%d", &card[i].first, &card[i].second);
		
		fill_n(memo, 8192, 0);
		search(0, 0);
		
		int g;
		scanf("%d", &g);
		rep(i, g){
			int n;
			scanf("%d", &n);
			printf("%d\n", memo[n]);
		}
	}
	
	return 0;
}

Measured memory_bytes: 948
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#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(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n;

Point rot(Point p, double t) {
	double x = p.real(), y = p.imag();
	return Point(x*cos(t) - y*sin(t), x*sin(t) + y*cos(t));
}

string s, t;

int main() {
	cin >> s >> t;
	reverse(ALL(s));
	if (s == t)cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>

using namespace std;

string str;

bool GetAns(){
	int ans=0;
	for(int i=0;i<str.size()&&ans<2;++i){
		if(str[i]=='C'&&ans<1){
			++ans;
		}
		if(str[i]=='F'&&ans==1){
			++ans;
		}
	}
	return ans==2;
}

int main(){	
	cin>>str;
	if(GetAns()){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define fo(i,l,R) for(int i=l;i<=R;i++)
#define of(i,l,R) for(int i=l;i>=R;i--)
#define fe(i,u) for(int i=head[u];i;i=e[i].next)
using namespace std;
typedef long long ll;
#define P(a,b) make_pair(a,b)
inline void open(const char *s)
{
	#ifndef ONLINE_JUDGE
	char str[20];
	sprintf(str,"in%s.txt",s);
	freopen(str,"r",stdin);
//	sprintf(str,"out%s.txt",s);
//	freopen(str,"w",stdout);
	#endif
}
inline int rd()
{
	static int x,f;
	x=0;f=1;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())
		if(ch=='-')f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
	return f>0?x:-x;
}
const int N=200000+10;
struct point{int id,x,y;}p[N];
int st[N];
int R,C,n,tot,tp;
bool edge(point a){return a.x==0||a.y==0||a.x==R||a.y==C;}
int gao(point x)
{
	if(x.y==0)return x.x+x.y;
	if(x.x==R)return R+x.y;
	if(x.y==C)return R*2+C-x.x;
	return 2*R+2*C-x.y;
}
bool cmp(point a,point b){return gao(a)<gao(b);}
int main()
{
	R=rd();C=rd();n=rd();
	fo(i,1,n){
		point p1,p2;
		p1.x=rd(),p1.y=rd(),p1.id=i;
		p2.x=rd(),p2.y=rd(),p2.id=i;
		if(edge(p1)&&edge(p2)){p[++tot]=p1;p[++tot]=p2;}
	}
	sort(p+1,p+tot+1,cmp);
	fo(i,1,tot){
		if(tp&&st[tp]==p[i].id)tp--;
		else st[++tp]=p[i].id;
	}
	if(tp)printf("NO\n");else printf("YES\n");
	return 0;
}


Measured memory_bytes: 2944
import java.util.Scanner;

public class Main {
 public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
  while(true){
   int n=sc.nextInt();
   int m=sc.nextInt();
   if(n==0&&m==0) break;
   int[] data = new int[n];
   for(int i=0;i<n;++i){
    data[i]=sc.nextInt();
   }
   int max=-1;
   for(int j=0;j<n;++j){
    for(int i=j+1;i<n;++i){
     if(max<data[i]+data[j] && data[i]+data[j]<=m) max=data[i]+data[j];
    }
   }
   if(max==-1) System.out.println("NONE");
   else System.out.println(max);
  }
 }
}


Measured memory_bytes: 49620
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long int n,k;
    cin>>n>>k;
    long int h[n];
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    long long int dp[n],mn=LONG_LONG_MAX;
    dp[n-1]=0;
    for(int i=n-2;i>=0;i--)
    {
        for(int j=i+1;j<=min(i+k,n-1);j++)
        {
            mn=min(mn,dp[j]+abs(h[i]-h[j]));
        }
        dp[i]=mn;
        mn=LONG_LONG_MAX;
    }
    cout<<dp[0];
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
	int n;
			int word=0;
int first=0;
	while(cin>>n){


		if(n==0)break;

		// int array[4]={5,7,5,7,7};

		vector<int> v1;
		vector<string> v2;

		for(int i=0;i<n;i++){
			string s;
			cin>>s;
			v2.push_back(s);

		}

		for(int i=0;i<n;i++){
			string tmp=v2[i];
			int a=tmp.size();
			v1.push_back(a);
		}

		// for(int i=0;i<n;i++){
		// 	cout<<v1[i]<<endl;
		// }

		// cout<<endl;

		for(int i=0;i<n;i++){
			word=0;
			first=i+1;
			// cout<<"FIRST="<<first<<endl;
			int tmp=0;
			

			if(5>=tmp){
				for(int j=i;j<n;j++){

					

					tmp+=v1[j];
					// cout<<tmp<<" "<<word<<endl;
					if(word==0){
						if(tmp==5){
							word++;
							tmp=0;
						}else if(tmp>5){
							
							break;
						}

					}else if(word==1){
						
						if(tmp==7){
							word++;
							tmp=0;
						}else if(tmp>7){

							break;
						}

					}else if(word==2){

						if(tmp==5){
							word++;
							tmp=0;
						}else if(tmp>5){
							break;
						}

					}else if(word==3){
						if(tmp==7){
							tmp=0;
							word++;
						}else if(tmp>7){
							break;
						}

					}else if(word==4){
						if(tmp==7){
							word++;
							break;
						}else if(tmp>7){
							break;
						}
					}
				}
			}

			if(word==5){
				cout<<first<<endl;
				break;
			}	
		}
	
		

	}

	return 0;
}

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

typedef long long ll;

char s[20];

int main()
{
    int a,b;
    cin>>a>>b>>s;
    int siz=strlen(s);
    if(siz!=(a+b+1))
    {
        cout<<"No"<<endl;
        return 0;
    }
    if(s[a]!='-')
    {
        cout<<"No"<<endl;
        return 0;
    }
    for(int i=0;i<siz;i++)
    {
        if(i==a) continue;
        if(!isdigit(s[i]))
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define BUF 1e5
#define INF 1 << 30
constexpr ll mod = 1e9 + 7;
using namespace std;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

int main() {
    cin >> S;
    if (S[0] == S[1] || S[1] == S[2] || S[2] == S[3]) {
        cout << "Bad" << endl;
    } else
        cout << "Good" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    
    int N;
    int D;

    scanf("%d", &N);
    scanf("%d", &D);

    if(N%(2*D+1) == 0){
        printf("%d", N / (2*D+1));
    }

    else{
        printf("%d\n",(N / (2*D+1)) +1);
    }

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int a, b, c;

int main(){
    cin >> a >> b;
    c = a + b;
    if (c % 2 == 1)cout << "IMPOSSIBLE" << endl;
    else cout << c / 2 << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
	
	int x;
	int soma = 0;
	
	scanf("%d", &x);
	
	int k = x;
	
	for (;;){
		int div = k % 10;
		soma += div;
		k = k/10;
		
		if (k == 0)
			break;
	}
	
	if (x % soma != 0){
		printf("No\n");
	} else {
		printf("Yes\n");
	}
	
	return 0;
}


Measured memory_bytes: 128
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n,w = m()

po = [[] for i in range(4)]
pr = [[0] for i in range(4)]

for i in range(n):
    a,b = m()
    if i == 0:
        coo = a
        po[0].append(b)
    else:
        kkk = a - coo
        po[kkk].append(b)

for i in range(4):
    po[i].sort(reverse = True)
    for ii in range(len(po[i])):
        pr[i].append(pr[i][-1] + po[i][ii])

co = 0
su = 0
for i in range(len(po[0]) + 1):
    for ii in range(len(po[1]) + 1):
        for iii in range(len(po[2]) + 1):
            for iiii in range(len(po[3]) + 1):
                if (i * coo + ii * (coo + 1) + iii * (coo + 2) + iiii * (coo + 3)) <= w:
                    su = max(su,pr[0][i]+pr[1][ii]+pr[2][iii]+pr[3][iiii])

print(su)






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

int main(){

   int n;
  // while(1){

    cin>>n;
    bool flag=false;
    int sum1=n; int sum2=n;
   if(n<4)
        //cout<<"No"<<endl;
        flag==false;
        else{

            while(sum1>0){
                if(sum1%4==0)   {  flag=true;break;}//cout<<"000"<<endl;cout<<sum1;
                else sum1-=7;

               // if(sum1<=0) break;
            }
              while(sum2>0){
                if(sum2%7==0)   { flag=true;break; }//cout<<"000"<<endl;cout<<sum2;
                else sum2-=4;
                   //if(sum2<=0) break;
            }
        }  if(flag)    cout<<"Yes"<<endl;
            else cout<<"No"<<endl;


   //}


return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
using namespace std;

typedef unsigned int U;
#define L 3194304
bool HA[L];
char T[256];

int main() {
    register U n, sum, t, i;
    char c;
    T['A'] = (char)1, T['C'] = (char)2, T['G'] = (char)3, T['T'] = (char)4;
    scanf("%d", &n);
    while ( getchar() != '\n' );
    for ( i = 0; i++ < n; ) {
        sum = 0;
        t = 1;
        bool flag = ( c = getchar() ) == 'i';
        while ( ( c = getchar() ) != ' ' );
        while ( ( c = T[getchar()] ) != 0 ) {
            sum += c * t;
            t *= 4;
        }
        if ( flag ) {
            HA[sum] = true;
        } else {
            puts( HA[sum] ? "yes" : "no" );
        }
    }
    return 0;
}

Measured memory_bytes: 2100
//config = { input: 'tmp', newline: '\r\n' }; // win
config = { input: '/dev/stdin', newline: '\n' }; // linux

A = require('fs').readFileSync(config.input, 'ascii')
  .split(config.newline, 2);
A = A[1].split(' ').map(Number);

cnt = sort(A);
console.log(A.join(' '));
console.log(cnt);

function sort(A) {
  var cnt, i, minj, j, tmp;
  cnt = 0;
  for (i = 0; i < A.length; i++) {
    minj = i;
    for (j = i; j < A.length; j++) {
      if (A[j] < A[minj])
        minj = j;
    }
    tmp = A[i];
    A[i] = A[minj];
    A[minj] = tmp;
    if (i !== minj) cnt++;
  }
  return cnt;
}

Measured memory_bytes: 15676
N, M = map(int, input().split())
L = []
R = []
for _ in range(M) :
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)


borderL = L[0]
borderR = R[0]
for i in range(1, M) :
    if L[i] > borderL :
        borderL = L[i]
    if R[i] < borderR :
        borderR = R[i]

if borderR < borderL :
    print(0)
else :
    print(borderR - borderL + 1)


Measured memory_bytes: 10996
#include <iostream>
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <set>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>

using namespace std;

#define f first
#define s second

typedef long long LLI;



int n;


pair<int, pair<int, int> > p[5001];
long long dp[5001][5001];

const long long inf = 1e15;

int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; ++i) {
		scanf("%d %d", &p[i].s.f, &p[i].s.s);
		p[i].f = p[i].s.f + p[i].s.s;
	}
	sort(p, p + n);
	
	for(int i = 0; i < 5001; ++i) {
		dp[i][0] = 0;
		for(int j = 1; j < 5001; ++j) dp[i][j] = inf;
	}
	

	int ans = 1;

	dp[0][1] = p[0].s.s;

	for(int i = 1; i < n; ++i) {
		for(int j = 1; j <= n; ++j) {
			dp[i][j] = dp[i-1][j];
			if(p[i].s.s + dp[i-1][j-1] < dp[i][j] && p[i].s.f >= dp[i-1][j-1]) dp[i][j] = p[i].s.s + dp[i-1][j-1];
			if(dp[i][j] < inf) ans = max(ans, j);
		}
	}
	printf("%d\n", ans);
	return 0;
}


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


int main() {
int n,d;
cin >> n >> d;
vector<pair<ll,ll>> x(n);
for(int i = 0; i<n; i++){
    ll a,b;
    cin >> a >> b;
    x.at(i) = make_pair(a,b);
}

int ans = 0;
rep(i,n){
    ll a,b;
    tie(a,b) = x.at(i);
    if(sqrt(a*a + b*b) <= d){
        ans++;
    }
}

cout << ans << endl;
}

Measured memory_bytes: 6496
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  vector<int>p(N);
  for (int i=0; i<N; i++) cin >>p[i];
  for (int i=0; i<N; i++) p[i]++;
  queue<int>q;
  int s=0, mx=0;
  for (int i=0; i<N; i++){
    q.push(p[i]);
    s += p[i];
    if (q.size() > K){
      s -= q.front();
      q.pop();
    }
    if (q.size() == K){
      mx = max(s, mx);
    }
  }
  double ans = mx;
  ans /= 2;
  printf("%.10f\n", ans);
}

Measured memory_bytes: 1792
n,d = map(int,input().split())

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

ans = 0
for i in range(n):
    for j in range(i+1,n):
        f = 0
        for k in range(d):
            f += (x[i][k]-x[j][k])**2

        m = 1
        while m*m < f:
            m += 1
        if m*m == f:
            ans += 1

print(ans)


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
typedef complex<ld> Point;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int main() {
    ll n, k;
    cin >> n >> k;
    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }
    sort(all(a));

    ll ub = 1e18, lb = -1e18;
    while (ub - lb > 1) {
        ll mid = (ub + lb) / 2;
        auto is_smaller = [&] {
            ll cnt = 0;
            rep(i, n) {
                if (a[i] >= 0) {
                    ll l = -1, r = n;
                    while (r - l > 1) {
                        ll o = (l + r) / 2;
                        if (a[i] * a[o] < mid) {
                            l = o;
                        } else {
                            r = o;
                        }
                        // debug(l);
                        // debug(r);
                        // debug(o);
                    }
                    cnt += r;
                } else {
                    ll l = -1, r = n;
                    while (r - l > 1) {
                        ll o = (l + r) / 2;
                        if (a[i] * a[o] < mid) {
                            r = o;
                        } else {
                            l = o;
                        }
                        // debug(l);
                        // debug(r);
                        // debug(o);
                    }
                    cnt += n - r;
                }

                if (a[i] * a[i] < mid) cnt--;
            }
            cnt /= 2;
            return cnt < k;
        };

        // debug(mid);
        if (is_smaller()) {
            lb = mid;
        } else {
            ub = mid;
        }
    }
    cout << lb << endl;
}


Measured memory_bytes: 1792
<?php
# 入力部
fscanf(STDIN, "%s %s", $s, $t);
// fscanf(STDIN, "%d %d", $n, $m);
// fscanf(STDIN, "%s", $u);
// fscanf(STDIN, "%d %d", $k, $x);
// $s1 = fgets(STDIN); //"\n"の2文字
// $s2 = fgets(STDIN);
// fscanf(STDIN, "%d", $n);
// fscanf(STDIN, "%s", $s);
// fscanf(STDIN, "%c", $c);
// fscanf(STDIN, "%s", $s2);
// fscanf(STDIN, "%d %d %d", $a, $b, $c);


# 処理部
// $arr = str_split($s);
// $arr2 = str_split($s2);
// $arr1 = explode(" ", $s1);
// $arr2 = explode(" ", $s2);
// for ($i = 0; $n > $x * $i; $i++) {
// }
// if (strpos($s, 'RRR') !== false) {
//   $r = 3;
// } elseif (strpos($s, 'RR') !== false) {
//   $r = 2;
// } elseif (strpos($s, 'R') !== false) {
//   $r = 1;
// } else {
//   $r = 0;
// }
// $s = "No";
// if ($x >= 30) {
//   $s = "Yes";
// }
// for ($i = 0; $i * 1000 < $n; $i++) {
// }
// $c = "a";
// if (ctype_upper($a)) {
//   $c = "A";
// }
// $s = "Yes";
// echo count($arr1);
// for ($i = 0; $i < strlen($s1); $i++) {
//   if ($arr1[$i] != $arr2[$i]) {
//     $s = "No";
//   }
// }
// $unit;
// switch ($n % 10) {
//   case 0:
//   case 1:
//   case 6:
//   case 8:
//     $unit = "pon";
//     break;
//   case 3:
//     $unit = "bon";
//     break;
//   default:
//     $unit = "hon";
//     break;
// }
// if ($s == "ABC") {
//   $r = "ARC";
// } else {
//   $r = "ABC";
// }
// $r = "NG";
// for ($i = $a; $i <= $b; $i++) {
//   if ($i % $k == 0) {
//     $r = "OK";
//   }
// }
// $r = "safe";
// if ($s <= $w) {
//   $r = "unsafe";
// }
// $r = "No";
// if (strpos($n, "7") !== false) {
//   $r = "Yes";
// }
// $r = "No";
// if ($arr[2] == $arr[3] && $arr[4] == $arr[5]) {
//   $r = "Yes";
// }
// $r = "Yes";
// if ($s == "AAA" || $s == "BBB") {
//   $r = "No";
// }
// if ($n % 2 == 0) {
//   $r = $n / 2;
// } else {
//   $r = ($n + 1) / 2;
// }
// if ($n < 10) {
//   $r += (10 - $n) * 100;
// }
// $arr = array($a, $b, $c);
// $arr = array_unique($arr);
// if (count($arr) == 2) {
//   $r = "Yes";
// } else {
//   $r = "No";
// }
// if ($s == $u) {
//   $a--;
// } else {
//   $b--;
// }
// for ($i = 0; $h > 0; $i++) {
//   $h -= $a;
// }
// $r = "No";
// if ($n == $m) {
//   $r = "Yes";
// }
// $r = "No";
// if ($k * 500 >= $x) {
//   $r = "Yes";
// }

# 出力部
// echo ($n * ($n - 1) / 2) + ($m * ($m - 1) / 2) . "\n";
// echo $z . " " . $x . " " . $y . "\n";
// echo ($i * 1000) - $n . "\n";
// echo json_encode($arr) . "\n";
// echo $r . "\n";
// echo ++$c . "\n";
// echo $a . " " . $b . "\n";
echo $t . $s . "\n";


Measured memory_bytes: 15816
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int a[maxn], L[maxn], R[maxn];
int gcd(int a, int b) {
	return b?gcd(b, a % b) : a;
} 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		L[i] = gcd(L[i - 1], a[i]);
	}
	for (int i = n; i >= 1; i--) {
		R[i] = gcd(R[i + 1], a[i]);
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		ans = max(ans, gcd(L[i - 1], R[i + 1]));
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

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

    float sum;
    for (int i = 0; i < N; i++)
    {
        float x;
        string u;
        cin >> x >> u;
        sum += x * (u == "JPY" ? 1 : 380000.0);
        
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define pii pair<int,int>
using namespace std;
int n,m,i,j,l,k,x,y,a,b,cnt[3],sum[3];
/***********MAIN**************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n;
	int cnt = 0;
	map<int,int> mp;
	for(int i=0;i<n;i++){
		cin>>x;
		mp[x]++;
		if(mp[x]%2){
			cnt++;
		}else{
			cnt--;
		}
	}
	cout<<cnt;
    return 0;
}
//.........

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  vector<char> N(4);
  cin >> N[0] >> N[1] >> N[2] >> N[3];
  SORT(N);
  if (N == vector<char>{'1', '4', '7', '9'})
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int H,W,a[1000][1000];
int main()
{
   
    while (1>0)
    {
        H=W=0;
        scanf("%d%d",&H,&W);
        if (H==0 && W==0) return 0;
        for(int i=1;i<=H;i++)
            a[i][1]=a[i][W]=1;
        for(int j=1;j<=W;j++)
            a[1][j]=a[H][j]=1;
        for(int i=1;i<=H;i++)
        {
            for(int j=1;j<=W;j++)
                if (a[i][j]==1) printf("#");
                else printf(".");
            printf("\n");
        }
        for(int i=1;i<=H;i++)
            for(int j=1;j<=W;j++)
                a[i][j]=0;
        printf("\n");
    }
}



Measured memory_bytes: 4132