akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<random>
#include<stdio.h>
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
using P=pair<ll,ll>;

int main(){
    ll R,C,K;
    scanf("%lld",&R);
    scanf("%lld",&C);
    scanf("%lld",&K);
    vector<vector<ll>> item(R,vector<ll>(C));
    for (ll i=0;i<K;i++){
        ll r,c,v;
        scanf("%lld",&r);
        scanf("%lld",&c);
        scanf("%lld",&v);
        item[r-1][c-1]=v;
    }

    vector<vector<ll>> dp(C,vector<ll>(3));
    if (item[R-1][C-1]!=0){
        dp[C-1][0]=item[R-1][C-1];
        dp[C-1][1]=item[R-1][C-1];
        dp[C-1][2]=item[R-1][C-1];
    }

    for (ll j=C-2;j>-1;j--){
        if (item[R-1][j]!=0){
            dp[j][0]=max(dp[j+1][1]+item[R-1][j],dp[j+1][0]);
            dp[j][1]=max(dp[j+1][2]+item[R-1][j],dp[j+1][1]);
            dp[j][2]=max(item[R-1][j],dp[j+1][2]);
        }
        else{
            dp[j][0]=dp[j+1][0];
            dp[j][1]=dp[j+1][1];
            dp[j][2]=dp[j+1][2];
        }
    }

    for (ll i=R-2;i>-1;i--){
        vector<vector<ll>> ndp(C,vector<ll>(3));
        if (item[i][C-1]!=0){
            ndp[C-1][0]=dp[C-1][0]+item[i][C-1];
            ndp[C-1][1]=dp[C-1][0]+item[i][C-1];
            ndp[C-1][2]=dp[C-1][0]+item[i][C-1];
        }
        else{
            ndp[C-1][0]=dp[C-1][0];
            ndp[C-1][1]=dp[C-1][0];
            ndp[C-1][2]=dp[C-1][0];
        }
        for (ll j=C-2;j>-1;j--){
            if (item[i][j]!=0){
                ndp[j][0]=max(max(dp[j][0],ndp[j+1][1])+item[i][j],ndp[j+1][0]);
                ndp[j][1]=max(max(dp[j][0],ndp[j+1][2])+item[i][j],ndp[j+1][1]);
                ndp[j][2]=max(dp[j][0]+item[i][j],ndp[j+1][2]);
            }
            else{
                ndp[j][0]=max(dp[j][0],ndp[j+1][0]);
                ndp[j][1]=max(dp[j][0],ndp[j+1][1]);
                ndp[j][2]=max(dp[j][0],ndp[j+1][2]);   
            }
        }
        dp=ndp;
    }
    cout<<dp[0][0]<<endl;
}

Measured memory_bytes: 74224
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

string s, t;
ll p = 0, ans = 0;
vector<vector<ll>> is(26);

int main() {
	cin >> s;
	rep(i, sz(s))is[s[i] - 'a'].pub(i);
	rep(i, sz(s))is[s[i] - 'a'].pub(i + sz(s));
	cin >> t;
	rep(i, sz(t)) {
		if (!sz(is[t[i] - 'a'])) {
			cout << -1 << endl;
			return 0;
		}
		p = is[t[i] - 'a'][LBI(is[t[i] - 'a'], p)] + 1;
		if (p >= sz(s)) {
			p -= sz(s);
			ans += sz(s);
		}
	}
	cout << ans + p << endl;
	return 0;
}

Measured memory_bytes: 2676
program main
  implicit none
  integer N, V(20), C(20), i, otoku
  
  read(*, *) N
  read(*, *) (V(i), i = 1,N)
  read(*, *) (C(i), i = 1,N)
  otoku = 0
  do i = 1,N
    if (V(i)-C(i) > 0) then
      otoku = otoku + V(i)-C(i)
    end if
  end do
    

  write(* ,'(i0)') otoku
end program main


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

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

	vector<pair<int,int>> av(n);

	for (int i = 0; i < n; ++i) {
		av[i].first = i + 1;
		cin >> av[i].second;
	}

	sort(av.begin(), av.end(), [](const pair<int, int>& a, const pair<int, int>& b) {
		return a.second < b.second;
	});

	for (auto& a : av) {
		cout << a.first << " ";
	}
	cout << endl;

	return 0;
}

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

class modint {
  private:
    ll m_val;
    ll m_mod;
  public:
    constexpr modint() : m_val(0), m_mod() { m_mod = MOD; }
    constexpr modint(const ll x) : m_val(0), m_mod(0) { m_mod = MOD; m_val = x % m_mod; }
    constexpr modint(const ll x, const ll mod) : m_val(0), m_mod(0) { m_mod = mod; m_val = x % m_mod; }
    constexpr ll val() const { return m_val; }
    constexpr modint operator+(const modint &rhs) const { return modint(*this) += rhs; }
    constexpr modint operator-(const modint &rhs) const { return modint(*this) -= rhs; }
    constexpr modint operator*(const modint &rhs) const { return modint(*this) *= rhs; }
    constexpr modint operator/(const modint &rhs) const { return modint(*this) /= rhs; }
    constexpr modint &operator+=(const modint &rhs) {
      m_val += rhs.m_val;
      if (m_val >= m_mod) m_val -= m_mod;
      return *this;
    }
    constexpr modint &operator-=(const modint &rhs) {
      if (m_val < rhs.m_val) m_val += m_mod;
      m_val -= rhs.m_val;
      return *this;
    }
    constexpr modint &operator*=(const modint &rhs) {
      m_val = m_val * rhs.m_val % m_mod;
      return *this;
    }
    constexpr modint &operator/=(const modint &rhs) {
      *this *= rhs.pow(m_mod - 2);
      return *this;
    }
    constexpr modint pow(ll n) const {
      if (n == 0) return 1;
      modint o = pow(n >> 1);
      o *= o;
      if (n & 1) o *= *this;
      return o;
    }
    friend ostream& operator<<(ostream& os, const modint &a) { os << a.val(); return os; }
};

int main() {
  ll n, k;
  cin >> n >> k;

  if (k > n) {
    cout << 1 << endl;
    return 0;
  }

  vector<ll> a(n+1);
  for (ll i = 1; i <= n; ++i) {
    a[i] = a[i-1] + i;
  }

  modint ans(1);
  for (ll i = k; i <= n; ++i) {
    ans += (a[n]-a[n-i]) - (a[i-1]-1);
  }

  cout << ans.val() << endl;
    
  return 0;
}

Measured memory_bytes: 4792
use std::io::prelude::*;
use std::io;
use std::str::FromStr;
#[cfg(local)]
use std::fs::File;
#[cfg(local)]
use std::io::BufReader;

#[cfg(local)]
fn buf_read() -> io::Result<(Vec<String>)> {
    let f = try!(File::open("input.txt"));
    let input_lines: Vec<_> = BufReader::new(f).lines().collect();
    let lines: Vec<String> = input_lines.into_iter().map(|e| e.unwrap()).collect();
    Ok((lines))
}

#[cfg(not(local))]
fn buf_read() -> io::Result<(Vec<String>)> {
    let stdin = io::stdin();
    let input_lines: Vec<_> = stdin.lock().lines().collect();
    let lines: Vec<String> = input_lines.into_iter().map(|e| e.unwrap()).collect();
    Ok((lines))
}

fn main() {
    type Element = String;
    // type Element = char;
    let input = buf_read().unwrap();
    let mut input_vectors: Vec<Vec<Element>> = vec![];
    for input_line in input {
        let input_str: Vec<String> = input_line.split(' ').map(String::from).collect();
        let mut input_vector: Vec<Element> = vec![];
        for input_elem_str in input_str {
            let elem: Element = Element::from_str(input_elem_str.as_str()).unwrap();
            input_vector.push(elem);
        }
        input_vectors.push(input_vector);
    }
    let mut input = input_vectors[0][0].chars();
    // match input_vectors[0][0].to_string() {
    match input.next() {
        // "a" | "i" | "u" | "e" | "o" => {
        Some('a') | Some('i') | Some('u') | Some('e') | Some('o') => {
            println!("vowel");
        }
        _ => {
            println!("consonant");
        }

    }
}


Measured memory_bytes: 380
N, M, K = map(int, input().split())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]


def cusum(array):
    for i in range(len(array) - 1):
        array[i + 1] += array[i]


cusum(A)
cusum(B)
A = [0] + A
B = [0] + B
tsundoku = 0
ia = 0
ib = M

for ia in range(N + 1):
    if A[ia] > K:
        break
    while A[ia] + B[ib] > K and ib >= 0:
        ib -= 1
    tsundoku = max(ia + ib, tsundoku)

print(tsundoku)


Measured memory_bytes: 40556
#include <stdio.h>
int main()
{
  int x,y,temp,min,d;

  scanf("%d%d",&x,&y);

  if(x>=y)
    {
      min=y;
      temp=x%y;
    }
  else
    {
      min=x;
      temp=y%x;
    }

  if(temp==0)
    {
      d=min;
    }
  else
    {
      for(d=temp;d>0;d--)
	{
	  if(temp%d==0 && min%d==0)
	    {
	      break;
	    }
	}
    }
  printf("%d\n",d);
  return 0;
}

Measured memory_bytes: 592
import java.util.Scanner;

class Main {
	static int x;
	static int minI;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		x = sc.nextInt();
		int i = 1;
		int sum = 0;
		while (true) {
			sum += i;
			if (sum >= x) {
				break;
			}
			i++;
		}

		System.out.println(i);

		sc.close();
	}

}


Measured memory_bytes: 23764
#include <stdio.h>

int main() {
  int i, n, k, A[251];

  for(i = 0;i < 251;i++)
    A[i] = 2000000001;

  scanf("%d", &n);
  for(i = 1;i < n + 1;i++)
    scanf("%d", &A[i]);

  for(i = 1;i < n + 1;i++) {
    printf("node %d: key = %d, ", i, A[i]);
    if(i != 1)
      printf("parent key = %d, ", A[i / 2]);

    if(i < n / 2 + 1) {
      if(A[i * 2] != 2000000001)
        printf("left key = %d, ", A[i * 2]);

      if(A[i * 2 + 1] != 2000000001)
        printf("right key = %d, ", A[i * 2 + 1]);
    }

    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2048
n = int(input())
h = list(map(int,input().split()))

dp = [0]*n
dp[0] = 0
dp[1] = abs(h[1]-h[0])

for i in range(2,n):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))

print(dp[n-1])


Measured memory_bytes: 52208
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

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

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

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

ll gcd(ll  a,ll b){
    ll r;
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return b;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

ll r_fuct[2000];
ll fuct[2000];

//MOD逆元
void conb(ll n,ll k){
    fuct[0] = 1;
    for(int i = 1;i < k+1;i++){
        fuct[i] *= fuct[i-1]%MOD;
        
        ll b = MOD, u = 1, v = 0;
        ll value = fuct[i];
        while (b) {
            ll t = value / b;
            value -= t * b;
            swap(value, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        r_fuct[i] = u;
    }
}

ll factrial(ll n){
    if(n == 0) return 1;
    ll p = factrial(n-1)*n%MOD;
    return p;
}

//MOD逆元
ll farmat(ll n,ll p){    
    if(p == 0) return 1;
    else if(p == 1) return n%MOD;
    ll d = farmat(n,p/2);
    if(p%2 == 0){
        return (d*d)%MOD;
    }else{
        return ((n*d)%MOD*d)%MOD;
    }
}

ll conbination(ll n,ll k){
    ll a = factrial(n);
    ll b = factrial(k);
    ll c = factrial(n-k);
    return (a*farmat(b,MOD-2)%MOD*farmat(c,MOD-2))%MOD;
}

int n;
int memo[10000000];

int fib(int i){
    if(i <= 1) return i;
    if(memo[i] != 0) return memo[i];
    return memo[i] = fib(i-1)+fib(i-2);
}


void solve() {
    string s;
    string t;
    cin >> s >> t;
    int ans = 0;
    for(int i = 0;i < 3;i++){
        if(s[i] == t[i]) ans++;
    }
    cout << ans << endl;
}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
const int N=500005,M=(1<<20)+5;
const int MOD=1000000007;
int n;
int a[N],s[N];
vector<int>pos[M];
long long dp[N];
long long f[M],g[M];
int sum[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sum[0]=1;
	for(int i=1;i<=n;i++)
	{
		s[i]=s[i-1]^a[i];
		pos[s[i]].push_back(i);
		sum[i]=sum[i-1];
		if(s[i]==0) sum[i]++;
	}
	for(int i=1;i<=n;i++)
		if(s[i])
		{
			dp[i]=1;
//			for(int j:pos[s[i]])
//			{
//				if(j>=i) break;
			dp[i]=(dp[i]+f[s[i]]*sum[i]%MOD-g[s[i]]+MOD)%MOD;
			f[s[i]]=(f[s[i]]+dp[i])%MOD,g[s[i]]=(g[s[i]]+dp[i]*sum[i]%MOD)%MOD;
//			}
		}
		else
		{
			dp[i]=1;
			dp[i]=(dp[i]+f[s[i]])%MOD;
			f[s[i]]=(f[s[i]]+dp[i])%MOD,g[s[i]]=(g[s[i]]+dp[i]*sum[i]%MOD)%MOD;
//			for(int j:pos[s[i]])
//			{
//				if(j>=i) break;
//				dp[i]=(dp[i]+dp[j])%MOD;
//			}
		}
	long long ans=dp[n];
	if(!s[n]) 
	{
		for(int i=1;i<=n;i++)
			if(s[i]) ans=(ans+dp[i])%MOD;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 63488
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (ql:quickload '(:cl-debug-print :fiveam))
  #-swank (set-dispatch-macro-character #\# #\> (lambda (s c p) (declare (ignore c p)) (read s nil (values) t))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)
#-swank (disable-debugger) ; for CS Academy

;; BEGIN_INSERTED_CONTENTS
(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (let* ((n (read))
         (as (make-array n :element-type 'int32))
         (absmax -1)
         (pivot 0))
    (dotimes (i n)
      (let ((a (read)))
        (setf (aref as i) a)
        (when (>= (abs a) absmax)
          (setf absmax (abs a)
                pivot i))))
    (println (* 2 (- n 1)))
    (labels ((display (x y)
               (format t "~D ~D~%" (+ 1 x) (+ 1 y))))
      (dotimes (i n)
        (unless (= i pivot)
          (display pivot i)
          (incf (aref as i) (aref as pivot))))
      (if (> (reduce #'max as) 0)
          (loop for i from 1 below n
                do (display (- i 1) i)
                   (incf (aref as i) (aref as (- i 1))))
          (loop for i from (- n 1) above 0
                do (display i (- i 1))
                   (incf (aref as (- i 1)) (aref as i)))))
    as))

#-swank (main)


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

int main() {
    int n,k,c;
    string s;
    cin>>n>>k>>c;
    cin>>s;
    vector<int> l(k),r(k);
    int nowork=c;
    int index=0;
    for (int i = 0; i < n; i++){
        if(nowork<c)nowork++;
        else if(s[i]=='o'){
            l[index]=i;
            index++;
            if(index==k)break;
            nowork=0;
        }else nowork++;
    }
    nowork=c;
    index=k-1;
    for (int i = n-1; i >= 0; i--){
        if(nowork<c)nowork++;
        else if(s[i]=='o'){
            r[index]=i;
            index--;
            if(index==-1)break;
            nowork=0;
        }else nowork++;
    }
    for (int i = 0; i < k; i++){
        if(l[i]==r[i])cout<<l[i]+1<<endl;
    }
}

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

int main(){
  
  int N, sum=0;
  cin>>N;
  
  int d[N];
  for(int i=0;i<N;i++){
  	cin>>d[i];
  }
  
  int rep=N*(N-1)/2;

  for(int i=0;i<N;i++){
   	for(int j=i;j<N;j++){
      if(i!=j){
      	sum+=d[i]*d[j];
      }
    }
  }
  
  cout<<sum<<endl;
  
 return 0; 
}

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

int main() {
  vector<int> v(3);
  cin >> v[0] >> v[1] >> v[2];
  sort(v.begin(), v.end());
  if(v[0] == v[1]) {
    cout << v[2] << "\n";
  } else {
    cout << v[0] << "\n";
  }
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x) ((x) * (x))
#define bit(n) (1LL<<(n))
#define pcnt(x) __builtin_popcountll(x)
#define PB push_back
#define MP make_pair
#define endl "\n"
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main() {
  int n,k; cin >> n >> k;
  ll a[n];
  FOR(i,0,n-1) cin >> a[i];

  ll ans = 20010010011;

  FOR(b,0,bit(n)-1){
    if(pcnt(b)<k) continue;
		ll nowh = 0;
    ll cost = 0;
		FOR(i,0,n-1){
			if(b & bit(i)){
				if(nowh<a[i]){
          nowh = a[i];
        } else {
          cost += nowh+1 - a[i];
          nowh = nowh+1;
        }
			}
      chmax(nowh,a[i]);
		}

    chmin(ans,cost);
	}

  cout << ans << endl;
}



Measured memory_bytes: 256
k,n=map(int,input().split())
A=list(map(int,input().split()))
B=[]
for i in range(n):
  if i!=0 and i!=n-1:
    B.append(min(k-(A[i]-A[i-1]),k-(A[i+1]-A[i])))
  elif i==0:
    B.append(min(k-(k-A[n-1]+A[0]),k-(A[i+1]-A[i])))
  elif i==n-1:
    B.append(min(k-(A[i]-A[i-1]),k-(A[0]+k-A[n-1])))
print(min(B))

Measured memory_bytes: 26444
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

int V;
int E;
struct edge { int from, to, cost; };

typedef pair<int, int> PP;

vector<edge> e;

int Par[100000];
int Rank[100000];

void init(int n) {
	for (int i = 0; i < n; i++) {
		Par[i] = i;
		Rank[i] = 0;
	}
}

int find(int x) {
	if (Par[x] == x) {
		return x;
	}
	else {
		return Par[x] = find(Par[x]);
	}
}

void unite(int  x, int y) {
	x = find(x);
	y = find(y);
	if (x == y) return;
	if (Rank[x] < Rank[y]) {
		Par[x] = y;
	}
	else {
		Par[y] = x;
		if (Rank[x] == Rank[y])Rank[x]++;
	}
}

bool same(int x, int y) {
	return find(x) == find(y);
}

// ソート時に比較するための関数 
bool comp(const edge& e1, const edge& e2) {
	return e1.cost < e2.cost;
}

int kruskal() {
	init(V);
	sort(e.begin(), e.end(), comp);
	int ans = 0;
	for (int i = 0; i<E; i++) {
		if (!same(e[i].from, e[i].to)) {
			unite(e[i].from, e[i].to);
			ans += e[i].cost;
		}
	}
	return ans;
}

int main() {
	cin >> V;
	REP(i, V)REP(j, V) {
		int num;
		cin >> num;
		if (num == -1)continue;
		e.emplace_back(edge{(int)i, (int)j, num});
		E++;
	}
	cout << kruskal() << endl;
}



Measured memory_bytes: 3264
N = int(input())
a = list(map(int,input().split()))
a = sorted(a)

cnt=[0]*(a[-1]+2)
for i in range(N):
    cnt[a[i]]+=1

out=0
dam = cnt[0] + cnt[1]
out=max(out,dam)
for i in range(1,a[-1]+1):
    dam = cnt[i-1] + cnt[i] + cnt[i+1]
    out=max(out,dam)
print(out)

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

int n, k, a[1000000], ans = 0;
map<int, int> m;
vector<int> v;

int main(){
    cin >> n >> k;
    for (int i = 1; i <= n; i++) cin >> a[i], m[a[i]]++;
    if (m.size() <= k) cout << 0;
    else{
        int t = m.size() - k;
        map<int, int>::iterator it;
        for (it = m.begin(); it != m.end(); it++) v.push_back(it->second);
        sort(v.begin(), v.end());
        for (int i = 0; i < t; i++) ans += v[i];
        cout << ans;
    }
}

Measured memory_bytes: 11516
#include <stdio.h>

void swap(int* a,int* b){
	int temp=*a;
	*a=*b;
	*b=temp;
}

int gcd(int x,int y){
	int r;
	while(y>0){
		r=x%y;
		x=y;
		y=r;
	}
	
	return x;
}
	
int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b) swap(&a,&b);
		
	printf("%d\n",gcd(a,b));
	
	return 0;
}
	

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

const long N=100001;

typedef struct{
	long parent;
	long left; //1????????????
	long right_sib; //??????????????????(????????????????????¬?????????????????¨?????????)
}Node;

long n, d[N];
Node t[N];

void print(long a){
	printf("node %ld: parent = %ld, depth = %ld, ", a, t[a].parent, d[a]);
	
	if(t[a].parent==-1) printf("root, ");
	else if(t[a].left==-1) printf("leaf, ");
	else printf("internal node, ");
	
	long c=t[a].left;
	printf("[");
	if(c!=-1){
		while(true){
			if(t[c].right_sib==-1){
				printf("%ld", c);
				break;	
			}
			printf("%ld, ", c);	
			c=t[c].right_sib;
		}
	}
	printf("]\n");
}

void setDepth(long u, long a){
	d[u]=a;
	if(t[u].right_sib != -1) setDepth(t[u].right_sib, a);
	if(t[u].left != -1) setDepth(t[u].left, a+1);
}

int main(){
	scanf(" %ld", &n);
	
	for(long i=0; i<n; ++i) 
	t[i].parent=t[i].left=t[i].right_sib=-1;
	
	for(long i=0; i<n; ++i){
		long x, k;
		scanf(" %ld %ld", &x, &k);
		
		long now;
		for(long j=0; j<k; ++j){
			long y;
			scanf(" %ld", &y);
			
			if(j==0) t[x].left=y;
			else t[now].right_sib=y;	
			
			t[y].parent=x;
			now=y;
		}	
		
	}
	
	long root;
	for(long i=0; i<n; ++i){
		if(t[i].parent==-1) root=i;
	}
	
	setDepth(root, 0);
	
	for(long i=0; i<n; ++i) print(i);
}

Measured memory_bytes: 7444
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
using namespace std;
 
int main(){
    
    int N,M,K,A,S[31]={},ans=0;

    cin >> N>>M;

    for(int j=1;j<=N;j++){
        cin >> K;
        for(int k=1;k<=K;k++){
            cin >> A;
            S[A]+=1;
            A=0;
        }
        K=0;
    }

    for(int i=1;i<=M;i++){
        if(S[i]==N){
            ans+=1;
        }
    }
    cout << ans;

    return 0;

}

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

d = [0] * 2001

d[0] = 0
d[1] = 0
d[2] = 0
d[3] = 1 # {3}
d[4] = 1 # {4}
d[5] = 1 # {5}
d[6] = 2 # {6}, {3, 3}
d[7] = 3 # {6}, {3, 4}, {4, 3}
d[8] = 4 # {8}, {3, 5}, {4, 4}, {5, 3}
d[9] = 6 # {9}, {3, 6}, {4, 5}, {5, 4}, {6, 3}, {3, 3, 3}

for i in range(10, 2001):
    summary = 1 # Myself
    for j in range(3, i):
        summary += d[i - j]
        summary = summary % (int(1e9) + 7)
    d[i] = summary

print(d[s])

Measured memory_bytes: 65292
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a, b;
		int ans[] = new int[7];
		for(int i = 0; i < 7; i++){
			a = scan.nextInt();
			b = scan.nextInt();
			
			ans[i] = a - b;
		}
		for(int i = 0; i < 7; i++){
			System.out.println(ans[i]);
		}
	}
}

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

/*条件分岐での判定が一番計算量が少ない？*/
int main(){
  int N;
  scanf("%d", &N);

  if(N < 10)
    cout << N << endl;                  //すべて満たす
  else if(N < 100)
    cout << 9 << endl;                  //10～99はすべて×
  else if(N < 1000)
    cout << N - 90 << endl;       //90は条件を満たさない整数の個数
  else if(N < 10000)
    cout << 909 << endl;           //909も1～9と100～999 1000以上は一つもない
  else if(N < 100000)
    cout << N - 9090 << endl;
  else if(N == 100000)
    cout << 99999 - 9090 << endl;    //最大数は5桁の最大値からの減算
  
  return 0;
}

Measured memory_bytes: 256
// Created by sz
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int N = 1e5 + 5;
int n;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> n;
    
    vector<ll> a(n), ans(n);
    
    ll odd_add = 0, even_add = 0;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        if(i&1) odd_add += 2*a[i];
        else even_add += 2*a[i];
    }
    
    ans[0] = (even_add - odd_add)/2;
    
    for (int i = 1; i < n; i++){
        ans[i] = 2*a[i-1] - ans[i-1];
    }
    
    for (int i = 0; i < n; i++){
        cout << ans[i] << " \n"[i==n-1];
    }
    
    
    
    
    return 0;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
#define ll long long

using namespace std ;

int main ()
{
    int a , b ;
    cin >> a >> b ;
    for ( int i = 1 ; i <= 10000 ; i++ )
    {
        if ( ( i * 8 ) / 100 == a && ( i * 10 ) / 100 == b )
        {
            cout << i ;
            return 0;
        }
    }
    cout << -1 ;

	return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::*;
use std::collections::*;

pub fn read_from<T: FromStr, R: Read>(s: &mut R) -> T {
    let s = s.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    if !s.is_empty() {
        if let Ok(s) = s.parse::<T>() {
            s
        } else {
            panic!("faild to parse {}", s);
        }
    } else {
        if cfg!(local) {
            // eprintln!("reached to EOF");
        }
        std::process::exit(0)
    }
}

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let mut stdin = stdin.lock();
    read_from(&mut stdin)
}

pub fn chars() -> Vec<char> {
    let stdin = stdin();
    let mut stdin = stdin.lock();
    let s: String = read_from(&mut stdin);
    s.chars().collect()
}

pub fn readn<T: FromStr>(n: usize) -> Vec<T> {
    let stdin = stdin();
    let mut stdin = stdin.lock();
    (0..n).map(|_| read_from(&mut stdin)).collect()
}

fn main() {
    loop {
        let n: usize = read();
        let m: usize = read();
        let q: usize = read();

        let tokens = readn(q*2+m*2);

        let mut to_l: Vec<_> = vec![HashSet::new(); n + 1];
        let mut to_r: Vec<_> = vec![HashSet::new(); n + 1];
        let mut rails: Vec<(usize, usize, usize)> = tokens.chunks(2).take(m).enumerate().map(|(i, lr)| (lr[0], lr[1], i)).collect();
        rails.sort();
        let mut rails: VecDeque<_> = rails.iter().cloned().collect();
        for &(l, r, i) in rails.iter() {
            to_l[r].insert((l, i));
            to_r[l].insert((r, i));
        }
        let mut qs: Vec<_> = tokens.chunks(2).skip(m).enumerate().map(|(i, lr)| (lr[0], lr[1], i)).collect();
        qs.sort();

        let mut ans = vec![0; q];
        for &(ql, qr, i) in qs.iter() {
            while rails.len() > 0 && rails.front().unwrap().0 < ql {
                let (l, r, i) = rails.pop_front().unwrap();
                to_l[r].remove(&(l, i));
                to_r[l].remove(&(r, i));
            }
            let mut cnt = 0;
            for r in ql..qr + 1 {
                cnt += to_l[r].len();
            }
            ans[i] = cnt;
        }

        let mut buf = String::new();
        for e in ans.iter() {
            buf.push_str(&format!("{}\n", e));
        }
        print!("{}", buf);
    }
}


Measured memory_bytes: 47956
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return (t * t) % mod;
    } else {
        return (modpow(m, n - 1) * m) % mod;
    }
}

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

struct LCA {
    vector<vector<int>> par;
    vector<int> d;
    int n;
    LCA(vector<vector<int>> graph, int root) {
        n = graph.size();
        par.resize(n, vector<int>(30));
        d.resize(n, 0);
        function<void(int, int, int)> dfs = [&](int c, int p, int depth) {
            d[c] = depth;
            par[c][0] = p;
            for (auto ch : graph[c]) {
                if (ch != p) dfs(ch, c, depth + 1);
            }
        };
        dfs(0, 0, 0);
        for (int j = 1; j < 30; j++) {
            REP(i, n) { par[i][j] = par[par[i][j - 1]][j - 1]; }
        }
    }
    int getdistance(int u, int v) { return (d[u] + d[v]) - 2 * (d[query(u, v)]); }
    int query(int u, int v) {
        if (d[u] > d[v]) {
            swap(u, v);
        }
        for (int i = 29; 0 <= i; i--) {
            if (d[u] <= d[par[v][i]]) {
                v = par[v][i];
            }
        }
        /* LCA */
        for (int i = 29; 0 <= i; i--) {
            if (par[v][i] != par[u][i]) {
                v = par[v][i];
                u = par[u][i];
            }
        }
        if (u == v) {
            return u;
        } else {
            return par[v][0];
        }
    }
};

struct UnionFind {
    vector<int> parent, size;
    UnionFind(int n) {
        parent.resize(n, -1);
        size.resize(n, 1);
    }
    void unite(int x, int y) {
        if (same(x, y)) {
            return;
        }
        x = root(x);
        y = root(y);
        if (size[x] <= size[y]) {
            swap(x, y);
        }
        parent[y] = x;
        size[x] += size[y];
    }
    bool same(int x, int y) { return (root(x) == root(y)); }
    int root(int x) {
        while (parent[x] != -1) {
            x = parent[x];
        }
        return x;
    }
    int getsize(int x) { return size[root(x)]; }
};
int n, m;
vector<vector<int>> graph;

signed main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '?') {
            s[i] = 'D';
        }
    }
    int ans;
    REP(i, s.size()) { cout << s[i]; }
}

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

int main ()
{
    int dice[7];
    string direction;
    for (int i = 1;i <= 6;i++) cin >> dice[i];
    cin >> direction;
    
    for (int i = 0;i < direction.size();i++)
    {
        char d = direction[i];
        int temp;
        switch(d)
        {
            case 'E': temp    = dice[1];
                      dice[1] = dice[4];
                      dice[4] = dice[6];
                      dice[6] = dice[3];
                      dice[3] = temp;
                      break;
            case 'S': temp    = dice[1];
                      dice[1] = dice[5];
                      dice[5] = dice[6];
                      dice[6] = dice[2];
                      dice[2] = temp;
                      break;
            case 'W': temp    = dice[1];
                      dice[1] = dice[3];
                      dice[3] = dice[6];
                      dice[6] = dice[4];
                      dice[4] = temp;
                      break;
            case 'N': temp    = dice[1];
                      dice[1] = dice[2];
                      dice[2] = dice[6];
                      dice[6] = dice[5];
                      dice[5] = temp;
                      break;
        }
    }
    cout << dice[1] << endl;
    
    return 0;
}


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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	ll h[n];
	rep(i, n) cin >> h[i];
	
	ll sum = 0;
	rep(i, n - 1) {
		if (h[i] > h[i + 1]) {
			sum += h[i] - h[i + 1];
		}
	}
	sum += h[n - 1];
	
	cout << sum << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    FastScanner in;
    PrintWriter out;

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

    void solve() {
        String input1 = in.nextToken();
        String input2 = in.nextToken();
        if (input1.charAt(0) == input2.charAt(2) && input1.charAt(2) == input2.charAt(0)&& input1.charAt(1) == input2.charAt(1)) {
            out.println("YES");
        } else {
            out.println("NO");
        }
    }



    void run() {
        in = new FastScanner();
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    public class FastScanner {
        BufferedReader br;
        StringTokenizer st;

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

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

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

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

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

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

}

Measured memory_bytes: 21204
import java.util.Scanner;
import java.lang.Math.*;

public class Main {

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

		int[] dp = new int[N];
		int[] h = new int[N];

		for (int i = 0; i < N; i++) {
			h[i] = sc.nextInt();
		}

		dp[0] = 0;

		for (int i = 1; i < N; i++) {
			dp[i] = Integer.MAX_VALUE;
		}

		for (int i = 1; i < N; i++) {
			for (int j = 1; j <= K; j++) {
				if (i - j >= 0) {
					int cost = Math.abs(h[i] - h[i - j]);
					dp[i] = Math.min(dp[i], dp[i - j] + cost);
				}
			}
		}
		System.out.println(dp[N - 1]);
	}

}


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

int main()
{
    int n;
    cin >> n;
    int tho = n/1000;
    int hun = (n%1000)/100;
    int o = n%10;
    int ten = (n%100)/10;
    if(tho == hun && hun == ten){
        cout << "Yes" << endl;
    }
    else if(hun == ten && ten == o){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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; }

int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};


int main(){
  int H,W; cin >> H >> W;
  int n; cin >> n;
  vi a(n); rep(i, n) cin >> a[i];

  vvi c(H,vi(W,-1));

  int h = 0, w = 0;
  int col = 0;
  int cnt = 1;
  int dir = 0;
  while (col < n) {
    //printf("h:%d w:%d\n",h, w );
    c[h][w] = col+1;
    if(cnt+1 <= a[col]) cnt++;
    else{
      cnt = 1;
      col++;
    }
    int nh = h + dh[dir];
    int nw = w + dw[dir];
    if(nh < 0 || nh == H || nw < 0 || nw == W || c[nh][nw] != -1){
      dir = (dir + 1)%4;
      nh = h + dh[dir];
      nw = w + dw[dir];
    }
    h = nh;
    w = nw;
  }

  rep(h, H){
    rep(w, W){
      if(w < W-1) std::cout << c[h][w] << " ";
      else std::cout << c[h][w] << '\n';
    }
  }
}


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

#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/2;
const ll MOD = 1e9+7;
const double EPS=1e-12;

double lmin=INF,lmax=-INF,rmin=INF,rmax=-INF,umin=INF,umax=-INF,dmin=INF,dmax=-INF,xcmin=INF,xcmax=-INF,ycmin=INF,ycmax=-INF;

double xlength(double t){
  return max({rmax+t,lmax-t,xcmax})-min({rmin+t,lmin-t,xcmin});
}
double ylength(double t){
  return max({umax+t,dmax-t,ycmax})-min({umin+t,dmin-t,ycmin});
}
double box(double t){
  return xlength(t)*ylength(t);
}
double golden_search(double a, double b, double f(double)) {
  const double r = 2 / (3 + sqrt(5));
  double c = a + r * (b - a), d = b - r * (b - a);
  double fc = f(c), fd = f(d);
  while (d - c > EPS) {
    if (fc > fd) { // '<': maximum, '>': minimum
      a = c; c = d; d = b - r * (b - a);
      fc = fd; fd = f(d);
    } else {
      b = d; d = c; c = a + r * (b - a);
      fd = fc; fc = f(c);
    }
  }
  return c;
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;cin>>N;
  for(ll i=0;i<N;i++){
    double x,y;char d;cin>>x>>y>>d;
    if(d=='R'){
      rmin=min(rmin,x);
      rmax=max(rmax,x);
      ycmin=min(ycmin,y);
      ycmax=max(ycmax,y);
    }else if(d=='L'){
      lmin=min(lmin,x);
      lmax=max(lmax,x);
      ycmin=min(ycmin,y);
      ycmax=max(ycmax,y);
    }else if(d=='U'){
      umin=min(umin,y);
      umax=max(umax,y);
      xcmin=min(xcmin,x);
      xcmax=max(xcmax,x);
    }else{
      dmin=min(dmin,y);
      dmax=max(dmax,y);
      xcmin=min(xcmin,x);
      xcmax=max(xcmax,x);
    }
  }
  double ans = box(0);
  ans = min(ans,box(golden_search(0,1e9,box)));
  printf("%.10lf\n",ans);
  return 0;
}


Measured memory_bytes: 256
unittest
{
	assert( [ "3", "1 5", "3 9", "7 8" ].parse.expand.solve == 3 );
	assert( [ "6", "8 3", "4 9", "12 19", "18 1", "13 5", "7 6" ].parse.expand.solve == 8 );
}



import std.algorithm;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	auto xyis = new long[ 3 ][ n ];
	foreach( i, ref xyi; xyis )
	{
		input.popFront;
		xyi = input.front.split.to!( long[] ) ~ i;
	}
	return tuple( xyis );
}

auto solve( long[ 3 ][] xyis )
{
	// xでソートして隣同士の頂点を結ぶ辺配列を作成
	// （コストはΔxとΔyのminを取るので、xとyは別々の辺と考えてよい。大きいほうのΔの辺は作るけど使われない）
	auto es = new long[ 3 ][ ( xyis.length - 1 ) * 2 ];
	xyis.sort();
	for( auto i = 0L; i + 1 < xyis.length; i++ )
	{
		es[ i ] = [ xyis[ i ][ 2 ], xyis[ i + 1 ][ 2 ], ( xyis[ i ][ 0 ] - xyis[ i + 1 ][ 0 ] ).abs ];
	}
	
	// yでソートして隣同士の頂点を結ぶ辺配列を作成
	xyis.sort!( ( a, b ) => a[ 1 ] < b[ 1 ] );
	for( auto i = 0L; i + 1 < xyis.length; i++ )
	{
		es[ xyis.length - 1 + i ] = [ xyis[ i ][ 2 ], xyis[ i + 1 ][ 2 ], ( xyis[ i ][ 1 ] - xyis[ i + 1 ][ 1 ] ).abs ];
	}
	
	// 全頂点が木構造になるように、辺をコストが小さい順で使う
	es.sort!( ( a, b ) => a[ 2 ] < b[ 2 ] );
	auto ans = 0L;
	auto uft = UnionFindTree( xyis.length );
	foreach( e; es )
	{
		if( uft.same( e[ 0 ], e[ 1 ] ) ) continue;		// もう行き来できるので辺の追加は不要
		uft.unite( e[ 0 ], e[ 1 ] );
		ans += e[ 2 ];
	}
	return ans;
}

// UnionFind木
struct UnionFindTree
{
	private long[] ps;
	
	// 重み無し初期化
	public this( long n )
	{
		ps.length = n;
		ps[] = -1;		// マイナスは根であり、その木に属するノードの数でもある。
	}
	
	public long root( long i )
	{
		if( ps[ i ] < 0 ) return i;
		else              return ps[ i ] = root( ps[ i ] );
	}
	
	public bool same( long i, long j )
	{
		return root( i ) == root( j );
	}
	
	public void unite( long i, long j )
	{
		i = root( i );
		j = root( j );
		if( i == j ) return;
		if( ps[ i ] <= ps[ j ] ){ ps[ i ] += ps[ j ]; ps[ j ] = i; }
		else                    { ps[ j ] += ps[ i ]; ps[ i ] = j; }
	}
}


Measured memory_bytes: 12028
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int k;
    
    scanf("%d", &k);
    
    printf("%d", (k/2)*(k-(k/2)));
    
    return 0;
}



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

using ll = long long;
using namespace std;

const int N = 1001;
bool visited[N][N];

void solveCase() {
   int n;
   cin >> n;
   vector <int> a(n);
   int x = 0;
   for(int i = 0; i < n; i++) {
      cin >> a[i];
      x ^= a[i];
   }

   cout << ((x == 0)?"Yes": "No") << endl;
}


int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   
   int testcase = 1;
   // cin >> testcase;
 
   for(int i = 0; i < testcase; i++) {
      solveCase();
   }
 
   return 0;
}


Measured memory_bytes: 3688
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int n,i,mn=2*nmax;
ll x,ans[nmax],tot;
pair<ll,int>f,s;
multiset<pair<ll,int> >st;
multiset<pair<ll,int> >::reverse_iterator it;
int main()
{
    //freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>x;
		st.in({x,i});
	}
	it=st.rbegin();
	while(1)
	{
		for(;it!=st.rend();it++)
		{
			tot++;
			f=(*it),mn=min(mn,f.sc);
			it++;
			if(it==st.rend())
			{
				ans[mn]+=tot*f.fr;
				break;
			}
			s=(*it);
			if(f.fr!=s.fr)break;
			it--;
		}
		if(it==st.rend())break;
		ans[mn]+=tot*(f.fr-s.fr);
	}
	for(i=1;i<=n;i++)cout<<ans[i]<<endl;
	return 0;
}

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

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int start = 0;
    int end = 0;
    int ans = 0;

    if (d <= a)
    {
        cout << 0 << endl;
        return 0;
    }
    else if (b <= c)
    {
        cout << 0 << endl;
        return 0;
    }
    else
    {
        start = max(a, c);
        end = min(b, d);
        ans = end - start;
        cout << ans << endl;
        return 0;
    }
}

Measured memory_bytes: 256
h, w = map(int, input().split())
n = int(input())
list_a = list(map(int, input().split()))
result = []

row = []
for i in range(n):
  temp_a = list_a[i]
  for _ in range(temp_a):
    row.append(i+1)
    if len(row) == w:
      if len(result) % 2 != 0:
        row = row[::-1]
      result.append(row)
      row = []

for one_row in result:
  print(*one_row)

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

const ll MAXN = 200000;

ll N, K, ans=0, tmp=0;
vector<ll> A, F;

signed main(){
    cin >> N >> K;
    for(int i=0;i<N;i++) {
        ll a;
        cin >> a;
        A.push_back(a);
    }
    for(int i=0;i<N;i++) {
        ll a;
        cin >> a;
        F.push_back(a);
    }
    sort(A.begin(), A.end());
    sort(F.begin(), F.end());
    reverse(F.begin(), F.end());
    ll ok=pow(10,12)+5;
    ll ng=-1;
    while(ng+1!=ok) {
        ll l = K;
        ll mid = (ok+ng)/2;
        for(int i=0;i<N;i++) {
            //cout << A[i] << " : "  << A[i]-mid/F[i] << endl;
            //l-=max(0LL,A[i]-mid/F[i]);
            if(A[i]>mid/F[i]) {
                l -= (A[i]-mid/F[i]);
            }
        }
        if(l>=0) ok = mid;
        else ng = mid;
        //cout << ok << " : " << ng << " : " << l << endl;
    }
    cout << ok << endl;
    return 0;
}

Measured memory_bytes: 4848
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	// write your code here
        Scanner scanner=new Scanner(System.in);
        Deque<Task> deque=new ArrayDeque<>();
        long time=0;
        int n=scanner.nextInt();
        final int limit=scanner.nextInt();
        for(int i=0;i<n;i++){
            deque.addLast(new Task(scanner.next(),scanner.nextInt()));
        }
        while(deque.size()>0){
            Task currentTask=deque.removeFirst();
            if(currentTask.time<=limit){
                time+=currentTask.time;
                System.out.println(String.format("%s %d",currentTask.name,time));
            }else{
                currentTask.time=currentTask.time-limit;
                deque.addLast(currentTask);
                time+=limit;
            }
        }
    }
    public static class Task{
        public String name;
        public int time;
        public Task(String name,int time){
            this.name=name;
            this.time=time;
        }
    }
}



Measured memory_bytes: 92736
n=int(input())
l=[list(map(int,input().split()))]
for i in range(1,n):
  a,b,c=map(int,input().split())
  x=a+max(l[-1][1:])
  y=b+max(l[-1][0],l[-1][2])
  z=c+max(l[-1][:2])
  l.append([x,y,z])
print(max(l[-1]))

Measured memory_bytes: 22796
import java.util.*;

public class Main {
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int x = sc.nextInt();
		int cnt = 0;
		while (sc.hasNext()) {
			if (x < sc.nextInt()) {
				cnt++;
			} 
		}
		System.out.println(m / 2 >= cnt ? cnt : m - cnt);
	}
}

Measured memory_bytes: 21844