akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use itertools_num::ItertoolsNum;
#[allow(unused_imports)]
use std::cmp;
use std::collections::BTreeSet;
#[allow(unused_imports)]
use std::iter;
#[allow(unused_imports)]
use superslice::*;

fn run() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let q: usize = sc.read();

    let mut event = vec![];
    for _ in 0..n {
        let s: i64 = sc.read();
        let t: i64 = sc.read();
        let x: i64 = sc.read();
        event.push((s - x, true, x));
        event.push((t - x, false, x));
    }

    event.sort();
    let mut cur = 0;
    let mut set = BTreeSet::new();
    for _ in 0..q {
        let d: i64 = sc.read();
        while cur < 2 * n && event[cur].0 <= d {
            if event[cur].1 {
                set.insert(event[cur].2);
            } else {
                set.remove(&event[cur].2);
            }
            cur += 1;
        }
        if let Some(v) = set.iter().next() {
            println!("{}", v);
        } else {
            println!("-1");
        }
    }
}

fn main() {
    std::thread::Builder::new()
        .name("run".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_pairs<T: std::str::FromStr>(&mut self, n: usize) -> Vec<(T, T)> {
        (0..n).map(|_| (self.read(), self.read())).collect()
    }
    pub fn read_pairs_1_indexed(&mut self, n: usize) -> Vec<(usize, usize)> {
        (0..n)
            .map(|_| (self.read::<usize>() - 1, self.read::<usize>() - 1))
            .collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}


Measured memory_bytes: 14476
x, k, d = map(int, input().split())

ax = abs(x)
t = k * d

if t == ax:
    print(0)
elif t < ax:
    print(ax - t)
else:
    a = ax % d
    b = d - a
    f = ax // d

    if k % 2 == f % 2:
        print(a)
    else:
        print(b)


Measured memory_bytes: 9176
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	lli A, B, C;
	cin >> A >> B >> C;

	cout << max({ A,B,C }) * 9 + A + B + C<< endl;


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
    int n,cnt;
    string s,t;
    while(cin >> n,n!=0){
        cin >> s;
        for(int i=0;i<n;i++){
            cnt = 1;
            t.clear();
            for(int j=0;j<s.size();j++){
                if(s[j] == s[j+1]){
                    cnt++;
                    continue;
                }
                if(cnt >= 10) t += '0' + cnt/10;
                t += '0' + cnt%10;
                t += s[j];
                cnt = 1;
            }
            s = t;
        }
        cout << s << endl;
    }
    return(0);
}



Measured memory_bytes: 3276
import java.util.*;
public class Main{
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        int[] B = new int[N];
        int[] C = new int[N-1];
        for(int i = 0; i < N; i++)A[i] = sc.nextInt();
        for(int i = 0; i < N; i++)B[i] = sc.nextInt();
        for(int i = 0; i < N-1; i++)C[i] = sc.nextInt();

        int P = B[A[0]-1];
        for(int i = 1; i < N; i++){
            if(A[i-1]+1 == A[i]){
                P = P+B[A[i]-1]+C[A[i]-2];
            }else{
                P = P+B[A[i]-1];
            }
        }
        System.out.println(P);
    }
}

Measured memory_bytes: 22996
#include <iostream>

using namespace std;

int main(){
	char str[5];
	cin >> str;

	for(int i=0; i<3; i++){
		if(str[i] == str[i+1]){
			cout << "Bad" << endl;
			return 0;
		}
	}
	cout << "Good" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define type 26

int constant(int day)//1~26 順番
{
  return day%type+1;
}
int get_random()//1~26 ランダム
{
  return rand()%type+1;
}
int max(int s[][type+1],int day)//その日の最大の満足度選ぶ
{
  int m,max_score=0,i;
  for(i=1;i<=type;i++)
  {
    if(s[day][i]>max_score){
      max_score=s[day][i];
      m=i;
    }
  }
  return m;
}
void cal(int select,int c[type+1],int last[type+1],int s[][type+1],int day,int sum[])
{
  int i;
  sum[day]=sum[day-1]+s[day][select];
  for(i=1;i<=type;i++){
    sum[day]-=c[i]*(day-last[i]);
  }
}
int change(int c[type+1],int last[type+1],int s[][type+1],int sum[],int schedul[],int D,int d)
//ランダムに変更
{
  int t,old,total=0,i,j;
  d+=(rand()%13+1);
  d=d%D;
  t=rand()%type+1;
  old=schedul[d];
  schedul[d]=t;
  for(i=1;i<=type;i++) last[i]=0;
  for(i=1;i<=D;i++){
    total+=s[i][schedul[i]];
    last[schedul[i]]=i;
    for(j=1;j<=type;j++){
     total-=c[j]*(i-last[j]);
   }
  }
  if(total>sum[D]){
  //  printf("change\n");
    sum[D]=total;
  }
  else{
    schedul[d]=old;
  }
  return d;
}
int main(void)
{
  int D,c[type+1],i,j;
  clock_t start,stop;
  srand((unsigned int)time(NULL));
  scanf("%d",&D);//D=365
  int s[D+1][type+1],last[type+1],sum[D+1],schedul[D+1];
  for(i=0;i<=D;i++) sum[i]=0;
  for(i=1;i<=type;i++) last[i]=0;
  for(i=1;i<=type;i++) scanf("%d",&c[i]);
  for(i=1;i<D+1;i++){
    for(j=1;j<=type;j++) scanf("%d",&s[i][j]);
  }
  start=clock();
  for(i=1;i<D+1;i++){
    int select;
    select=constant(i);
    last[select]=i;
    schedul[i]=select;
    cal(select,c,last,s,i,sum);
    //printf("%d\n",sum[i]);
  }
  int count=0,aa=0;
  stop=start;
  while((double)(stop - start) / CLOCKS_PER_SEC<1.98){
    aa=change(c,last,s,sum,schedul,D,aa);
    count++;
    stop=clock();
  }
  /*
  printf("count:%d\n",count);
  printf("time:%f\n",(double)(stop - start) / CLOCKS_PER_SEC);
  printf("%d\n",sum[D]);
  printf("確認\n");
  int total=0;
  for(i=1;i<=type;i++) last[i]=0;
  for(i=1;i<=D;i++){
    total+=s[i][schedul[i]];
    last[schedul[i]]=i;
    for(j=1;j<=type;j++){
     total-=c[j]*(i-last[j]);
   }
  }
  printf("%d\n",total);
  */
  for(i=1;i<=D;i++) printf("%d\n",schedul[i]);
  return 0;
}


Measured memory_bytes: 1816
#include <bits/stdc++.h>
using namespace std;
int main() {
  int l,r;
  cin >> l >> r;
  int ans=0;
  for(int a=1;a<10;a++) {
    for(int b=0;b<10;b++) {
      for(int c=0;c<10;c++) {
        int x=10001*a+1010*b+100*c;
        if(x>=l && x<=r) ans++;
      }}}
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

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

func main() {
	var A, B int
	fmt.Scan(&A)
	fmt.Scan(&B)
	d := gcd(A, B)
	fmt.Printf("%d\n", A*B/d)
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection) (collection).begin(), (collection).end()  // begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)       // repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)      // repeat reverse
#define size(collection) ((ll) (collection).size())               // collection size

#endif

vector<ull> lmax(50);
vector<ull> pmax(50);

void Solve(ll lv, ll& x, ll& ans)
{
	if (lv == 0)
	{
		x--;
		ans++;
		return;
	}

	x--;
	if (x <= 0)
		return;

	if (x <= lmax[lv - 1])
	{
		Solve(lv - 1, x, ans);
		return;
	}

	x -= lmax[lv - 1];
	ans += pmax[lv - 1];
	if (x <= 0)
		return;

	x--; ans++;
	if (x <= 0)
		return;

	if (x <= lmax[lv - 1])
	{
		Solve(lv - 1, x, ans);
		return;
	}

	x -= lmax[lv - 1];
	ans += pmax[lv - 1];
	if (x <= 0)
		return;

	x--;
}

int main(void)
{
	ll n, x; cin >> n >> x;

	lmax[0] = pmax[0] = 1;
	rep(i, 1, 50)
	{
		lmax[i] = lmax[i - 1] * 2 + 3;
		pmax[i] = pmax[i - 1] * 2 + 1;
	}

	ll ans = 0;
	Solve(n, x, ans);

	cout << ans;
	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const ll INF=1000000000000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	int n;
	int p[1002];
	int x[1002],y[1002];
	scanf("%d",&n);
	rep1(i,n-1){scanf("%d",&p[i]); p[i]--;}
	rep(i,n)scanf("%d",&x[i]);
	
	vector<P> vec[1002];
	rrep(i,n){
		bool dp[2][5002];
		int t = 0,t_ = 1;
		rep(j,5002){
			dp[t][j] = false;
		}
		dp[t][0] = true;
		rep(j,vec[i].size()){
			rep(k,5002){
				dp[t_][k] = false;
			}
			rep(k,5002){
				if(dp[t][k]){
					if(k+vec[i][j].fr <= x[i])dp[t_][k+vec[i][j].fr] = true;
					if(k+vec[i][j].sc <= x[i])dp[t_][k+vec[i][j].sc] = true;
				}
			}
			swap(t,t_);
		}
		int sum = 0;
		rep(j,vec[i].size())sum += vec[i][j].fr + vec[i][j].sc;
		for(int j = x[i] ; j >= -1 ; j --){
			if(j == -1){
				puts("IMPOSSIBLE");
				return 0;
			}
			if(dp[t][j]){
				sum += x[i]-j;
				y[i] = sum-x[i];
				break;
			}
		}
		if(i == 0){
			puts("POSSIBLE");
			return 0;
		}
		vec[p[i]].pb(P(x[i],y[i]));
		//cout << i << " " << x[i] << " " << y[i] << endl;
	}
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rem(i, m, n) for (int i = m; i < (n); i++)
#define eps (1e-7)
#define inf (1e9)
#define pi (acos(-1))
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

    int n, a, b;
    cin >> n >> a >> b;

    int sumsum = 0;
    rem(i, 1, n + 1)
    {
        //cout << "i : " << i << "\n";
        int sum = 0;
        int k = i;
        rep(j, 5)
        {
            sum += k % 10;
            k /= 10;
        }
        //cout << "sum : " << sum << "\n";

        if (a <= sum && sum <= b)
        {
            sumsum += i;
        }
    }

    cout << sumsum << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  int ans = n;
  for (int i = 0; i < m; ++i) {
    cin >> a[i];
    ans -= a[i];
  }
  if (ans < 0) ans = -1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    sort(a.begin(), a.end());
    int ans = a[n / 2] - a[n / 2 - 1];
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <queue>
#include <random>

using namespace std;

#define min(a,b) ((a)<(b) ? (a):(b))
#define max(a,b) ((a)>(b) ? (a):(b))

int gcd(int a, int b){
    while( b ){
        int m = a % b;
        a = b;
        b = m;
    }
    return a;
}

int lcm(int a, int  b){
    return (a*b)/gcd(a,b);
}

int isPrim(int a){
    if(a==1){
        return 0;
    }
    for(int i=2;i<=(a+1)/2;i++){
        if(a%i==0){
            return 0;
        }
    }
    return 1;
}

long long mod_pow(long long x, long long n, long long mod){
    //xのn乗を計算するのにn乗を2進表記にして計算
    //x^22 = x^16 + x^4 + x^2
    long long ret=1;
    while(n>0){
        if(n%2==1){
            ret=(ret*x)%mod;//答えに付加
        }
        x=(x*x)%mod;//2乗
        n=n/2;
    }
    return ret;
}

struct VV{
    int x;
    int y;
    int z;
};

class LessInt {
public:
    bool operator()(const VV& riLeft, const VV& riRight) const {
        if(riLeft.x == riRight.x){
            return riLeft.y > riRight.y;
        }
        return riLeft.x > riRight.x;
        
    }
};

class indInt {
public:
    bool operator()(const VV& riLeft, const VV& riRight) const {
        return riLeft.x < riRight.x;
        
    }
};

struct XX{
    int zenbu=0;
    int kidoku=0;
};

class xxIntu {
public:
    bool operator()(const VV& riLeft, const VV& riRight) const {
        //第1条件
        if(riLeft.z != riRight.z){
            return riLeft.z < riRight.z;//<:昇順(小さい順)、>:降順(大きい順)
        }
        //第2条件
        return riLeft.x < riRight.x;
    }
};
bool operator< (const VV &riLeft, const VV &riRight){
    return riLeft.z < riRight.z;
};
/*bool operator> (const XX &riLeft, const XX &riRight){
    return riLeft.a > riRight.a;
};*/



int main(int argc, const char * argv[])
{
    //std::ios::sync_with_stdio(false);
    //scanf("%s",S);
    //scanf("%d",&N);
    //getline(cin, target);
    //cin >> x >> y;
    //ここから
    
    long long A,B,C;
    cin >> A >> B >> C;

    long long min=1000000000000000000;
    long long amari=0;
    
    if(A%2==0||B%2==0||C%2==0){
        cout << 0 << endl;
        return 0;
    }
    
    
    
    if(A*B<min){
        min=A*B;
        amari=C;
    }
    if(A*C<min){
        min=A*C;
        amari=B;
    }
    if(C*B<min){
        min=C*B;
        amari=A;
    }
    
    cout << min << endl;
    
    
    
    //cout << "ans" << endl;

    
    //ここまで
    //cout << "ans" << endl;改行含む
    //printf("%.0f\n",ans);//小数点以下表示なし
    //printf("%.7f\n",p);
    //printf("%f\n",pow(2,ans.size()));
    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

bool ask(int x,int y) {
  printf("? %d %d\n",x-1,y-1);
  fflush(stdout);
  char str[5];
  scanf("%s",str);
  return str[0]=='Y';
}

int st[4005],top;
bool ans[4005];

int main() {
  int n,m;
  scanf("%d%d",&n,&m);
  if (n<=m) {
  	puts("Impossible");
  	return 0;
  }
  for(int i=1;i<=n+m;i++)
  	if (!top||ask(st[top],i)) st[++top]=i;
  	else top--;
  for(int i=1;i<=n+m;i++)
    if (ask(st[top],i)) ans[i]=1;
  printf("! ");
  for(int i=1;i<=n+m;i++) printf("%d",ans[i]);
  printf("\n");
  fflush(stdout);
  return 0;
}

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

int main(){
  int h,w;
  cin >> h >> w;
  vector<vector<string>> pic(h,vector<string>(w));
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      cin >> pic.at(i).at(j);
    }
  }
  
  for(int i=0; i<h; i++){
    
    for(int j=0; j<w; j++){
      cout<< pic.at(i).at(j);
      cout<<endl;
      cout<< pic.at(i).at(j)<<endl;
    }    
  }
}

Measured memory_bytes: 384
import Control.Applicative
import Control.Monad
import Data.List
import Data.Ratio
import Text.Printf
import System.IO

untilEOF :: IO () -> IO ()
untilEOF x = do
  e <- isEOF
  unless e $ x >> untilEOF x

main :: IO ()
main = do
  n <- readLn
  print $ solve n

solve :: Int -> Int
solve n = applyN n f (100000)
 where
  f x = (ceiling (x * 105 % 100000)) * 1000 
   
applyN :: Int -> (a -> a) -> a -> a
applyN 0 _ x = x
applyN n f x = applyN (n-1) f (f x)



Measured memory_bytes: 3800
#include <stdio.h>

int a[3000];

typedef long long ll;

int main() {
  int N;
  scanf("%d", &N);
  for (int i=0; i<N; i++) {
    scanf("%d", &a[i]);
  }

  ll acc = 0;
  for (int i=0; i<N; i++) {
    acc += a[i]-1;
  }
  printf("%lld\n", acc);
}



Measured memory_bytes: 128
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<vector<int>> a(n,vector<int>(3)),dp(n,vector<int>(3,INT_MIN));
	for(int i=0;i<n;i++)
		for(int j=0;j<3;j++)
			cin >> a[i][j];
	dp[0][0] = a[0][0];
	dp[0][1] = a[0][1];
	dp[0][2] = a[0][2];
	for(int i=1;i<n;i++)
		for(int j=0;j<3;j++)
			for(int k=0;k<3;k++)
				if(j != k)
					dp[i][j] = max(dp[i][j],dp[i-1][k] + a[i][j]);
	
	cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}


Measured memory_bytes: 14024
A, B, C = map(int, input().split())

for i in range(36):
    if A % 2 or B % 2 or C % 2:
        break

    tA = (B + C) // 2
    tB = (A + C) // 2
    tC = (B + A) // 2
    A = tA
    B = tB
    C = tC
else:
    i = -1

print(i)


Measured memory_bytes: 3060
//皆さん、第9回シンデレラガール総選挙は、トップでオンリーワンを目指す城ヶ崎美嘉に
//そしてボイスアイドルオーディションは、プログラミングが趣味の才女大石泉に、ぜひ投票をお願いします！
//#城ヶ崎美嘉を009のシンデレラに
//#大石泉の必勝プログラム
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int main()
{
	double r;cin>>r;
	cout<<r*6.28<<endl;
}


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

int main() {
	// your code goes here
	string s;
	cin >> s;
	int sum = 0;
	for(char c:s){
	    sum = (sum + (c-'0'))%9;
	}
	if(sum == 0)
	cout << "Yes";
	else
	cout << "No";
	return 0;
}


Measured memory_bytes: 3752
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<climits>
#include<map>

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); it++)

using namespace std;

typedef unsigned int uint;
typedef pair<int, uint> P;

uint encode(vector<int> vec){
    uint res=0;
    for (int i=0;i<vec.size();i++)
        res=(res<<4)+vec[i];
 
    return res;
}
 
vector<int> decode(uint a){
    vector<int> res;
    for (;a>0;a>>=4)res.push_back(a & 15);
	reverse(res.begin(),res.end());
	
    return res;
}
 
struct edge{uint to, cost; };
 
int V;
int c[10][10],ans;
map<uint,int>d;
 
void dijkstra(uint s){
  priority_queue<P, vector<P>, greater<P> >que;
  d[s] = 0;
  que.push(P(0, s));
 
  while(!que.empty()){
 
    P p = que.top();
    que.pop();
    uint v = p.second;
    if(d[v] < p.first)continue;

    vector<int>tmp=decode(v);
  
    for(int i=0;i<V;i++){
      for(int j=i+1;j<V;j++){
			edge e;
			e.cost=c[tmp[i]][tmp[j]];
			swap(tmp[i],tmp[j]);
			e.to=encode(tmp);
 
      	if(!d.count(e.to) || d[e.to] > d[v]+e.cost){
      		d[e.to] = d[v]+e.cost;
      		que.push(P(d[e.to], e.to));
    	}
    	swap(tmp[i],tmp[j]);
      }
    }
  }
}
 
 
int main(void){
 
  cin >> V;
 
  for(int i=1;i<=V;i++){
    for(int j=1;j<=V;j++){
      cin >> c[i][j];
    } 
  }
	
  vector<int>v;
  for(int i=1;i<=V;i++)v.push_back(i);
 
  uint s=encode(v);
 
  dijkstra(s);
 
  ans=0;
  foreach(i,d)ans=max(ans,i->second);
  cout << ans << endl;
 
  return 0;
}

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
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;}
const int MOD = 1000000007;

int main() {
    string s;
    cin >> s;
    vector<int> v(26);
    REP(i, 4) {
        v[s[i] - 'A']++;
    }
    REP(i, 26) {
        if (v[i] != 0 && v[i] != 2) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y) {
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}
int main(){
  ll a,b,c;
  cin >> a >> b >> c;
  bool can = true;
  ll t1 = 4 * a * b;
  ll t2 = c - (a + b);
  if(t2 > 0 && t1 < t2 * t2){
    can = true;
  }else{
    can = false;
  }
  if(can){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define foi(i,k,n) for(int i = (int)k; i < (int)n; ++i)

using namespace std;
using ll = long long;
using ii = pair<int,int>;

constexpr int MAXN = 5 + 1e5;

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  string s,t; cin >> s >> t;
  foi (i,0,s.size()) {
    if (s[i] != t[i]) {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  return 0;
}


Measured memory_bytes: 3652
// CODE by Kazhybay Askar
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

using namespace std;
using namespace __gnu_pbds;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define iter   set<int>::iterator
#define f      first
#define s      second
#define pb     push_back
#define pf     push_front
#define mp     make_pair
#define cont   continue
#define ll     long long
#define Speed  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define sz     size()
#define all(x) x.begin(),x.end()
#define cont   continue
#define r0     return 0
#define endl   '\n'

const int MAXN = 1e5  + 7;
const int MOD  = 1e9  + 7;
const int INF  = 1e9  + 7;
const ll  MINF = 1e18 + 7;
const int EPS  = 1e-6;
const int dx[] = {0, 0, 1, -1, -1, -1, 1, 1};
const int dy[] = {1, -1, 0, 0, -1, 1, -1, 1};
const double pi = acos(-1.0);


typedef long double   ld;
typedef pair<ll,ll>   pll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;

ll a[MAXN],b[MAXN];
vector<int>g[MAXN],v;
bool used[MAXN];
int n,m,k,cnt=0,sum=0,ans=0,mx=0,mn=INF;
bool y=0;

void freopen(){
	freopen("A.in","r",stdin);
	freopen("A.out","w",stdout);
}


void solve(){
	cin>>n;
	cin>>k;
	for(int i=1;i<=n;i++){
        cin>>m;
        if(m>=k){
            cnt++;
        }
	}
	cout<<cnt;
}

int main(){
	Speed;
	ll T=1;
	//cin>>T;
	while(T--){
		solve();
	}
	r0;
}




Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

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

	int n, q;
	string s;
  cin >> n >> q >> s;
  vector<int> dp(n+1);

	for(int i = 1; i <= n; ++i) {
		dp[i+1] = dp[i];
		if (s[i-1]=='A' && s[i]=='C') ++dp[i+1];
	}
	rep(i, q) {
		int l, r; cin >> l >> r;
		cout << dp[r] - dp[l] << endl;
	}
	return 0;
}


Measured memory_bytes: 1488
from collections import Counter

count_by_kw = Counter()

n=int(input())
l=[]
dict={}
ans=0
for x in range(n):
  a=sorted(input())
  b=''.join(a)
  if not b in dict:
    dict[b]=x
    l.append(b)
    count_by_kw[b]+=1
  else:
    d=count_by_kw[b]
    count_by_kw[b]+=1
    
for y in range(len(l)):
  r=l[y]
  w=count_by_kw[r]
  ans+=w*(w-1)//2

print(ans)




Measured memory_bytes: 31316
n = gets.chomp.to_i

ans = Array.new(31) { false }

if n == 0
  puts 0
  exit
end

def calc(ans)
  ans.map { |t| t ? '1' : '0' }.join.reverse.sub(/\A0*/, '')
end

y = n
0.upto(31).each do |i|
  if y % (2 ** (i + 1)) != 0
    ans[i] = true
    y = y - ((-2) ** i)
    break if y == 0
  end
end
puts calc(ans)


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define MAX 1000005;
using namespace std;
int main(){

    int n, a, b; cin >> n >> a >> b;
    int ans = 0;
    for( int i = 1 ; i <= n ; ++i ){
        int aux = i, sum = 0;
        while( aux ){
            sum+=(aux%10);
            aux/=10;
        }
        if( sum >= a && sum <= b ) ans+=i;
    }
    cout << ans << '\n';
}


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

#define N_MAX 100000

typedef long long ll;

using namespace std;

int main(){
    int N;
    int A[N_MAX];
    ll max1st = 0;
    ll max2nd = 0;
    ll max4;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    sort(A, A+N);
    
    int cur, prev;
    prev = A[0];
    int count = 1;
    for(int i = 1; i < N; i++){
        cur = A[i];
        if(cur == prev) count++;
        if(cur != prev) count = 1;
        if(count == 2){
            max2nd = max1st;
            max1st = A[i];
        }
        if(count == 4){
            max4 = A[i];
        }
        prev = cur;
    }
    cout << max(max2nd * max1st, max4*max4) << endl;
}

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

int main() {
    int n,d,x,y=0;
    cin>>n>>d>>x;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++){
            int j=0;
            while((j*a[i])+1<=d){
                    y++;
                    j++;
            }
    }
    cout<<x+y;
return 0;
}


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

int main(){
    int N,X = 0;
    cin >> N >> X;
    int L[N]={0};
    int total = 0;
	  int count = 0;
    for(int i = 0;i<N;i++){
        cin >> L[i];
        total +=L[i];
        if(total<=X){
            count++;
        } 
    }
    cout << count + 1;

    


}

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

int N;
vector<int> edges[10000];
int C[10000];
int pt = 0;

int64_t ans;
int a[10000];

void dfs(int i, int p){
    for(int j : edges[i]) if(j != p){
        dfs(j, i);
    }
    a[i] = C[pt];
    pt++;
}

int main(){
    cin >> N;
    for(int i=0; i<N-1; i++){
        int a, b;
        cin >> a >> b;
        edges[a-1].push_back(b-1);
        edges[b-1].push_back(a-1);
    }
    for(int i=0; i<N; i++) cin >> C[i];
    sort(C, C+N);
    for(int i=0; i<N-1; i++) ans += C[i];

    for(int i=0; i<N; i++){
        if(N >= 3 && edges[i].size() == 1) continue;
        dfs(i, -1);
        cout << ans << endl;
        for(int i=0; i<N; i++) cout << a[i] << " \n"[i==N-1];
        return 0;
    }
    return 0;
}


Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var n = a[0];
            var m = a[1];
            var l = 0;
            var r = int.MaxValue;
            for (int i = 0; i < m; i++)
            {
                var aa = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
                l = Math.Max(aa[0], l);
                r = Math.Min(aa[1], r);
            }
            var result = Math.Max(r - l + 1, 0);
            Console.WriteLine(result);
        }
    }
}


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

signed main() {
	int n, k;
	string s;
	cin >> n >> s >> k;

	char c = s[k - 1];
	for (int i = 0; i < n; ++i) if (s[i] != c) s[i] = '*';

	cout << s << endl;
	return 0;
}


Measured memory_bytes: 3480
S = str(input())
N = len(S)
b = [0] * 2019
count = 0
b[0] = 1
t = 0
k = 1

if len(S) < 4:
    print(0)
else:
    t = int(S[-1])
    b[t] += 1
    for i in range(1,N):
        k = k * 10 % 2019
        t = (k * int(S[-i-1]) + t) % 2019 
        b[t] += 1

    for i in b:
        count += i*(i-1)//2

    print(count)

Measured memory_bytes: 9168
#include<stdio.h>
int main()
{
	int N,sisa;
	scanf("%d", &N);
	if(N%1000 ==0){
		printf("0");
	}else if(N%1000!=0)
	{
		sisa= 1000-(N%1000);
		printf("%d", sisa);
	}
	return 0;
}

Measured memory_bytes: 2116
import java.util.Scanner;

public class Main {

    static Scanner stdIn = new Scanner(System.in);
    public static void main(String[] args) {
        int n = stdIn.nextInt();
        int k = stdIn.nextInt();

        double kakuritu;
        
        int length;
        if(n<k){
            length = n;
            kakuritu = 0.0;
        }else{
            length = k;
            kakuritu = ((double)1/n)*(n-k);
        }

        for(int i=1; i<=length; i++){
            double tempkakuritu = 1;
            tempkakuritu *= (double)1/n;

            int tempi= i;
            for(; tempi<k; tempi*=2){
                tempkakuritu *= 0.5;
            }

            kakuritu += tempkakuritu;
        }

        System.out.println(kakuritu);

    }
}

Measured memory_bytes: 21076
#include<stdio.h>

int main(){
int n,t,min = 1001;
int gc,gt,i;
scanf("%d %d",&n,&t);
for(i = 0;i < n;i++){
scanf("%d %d",&gc,&gt);
if(gt <= t && gc < min){min = gc;}
}
if(min == 1001){printf("TLE\n");}
else{printf("%d\n",min);}
return 0;
}


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

#define ll long long
#define vecll vector<ll>
#define vecpair vector<pair<ll, ll>>
#define print(x) cout << x << endl
#define prints(x) cout << x << " "
#define printline cout << endl

int main()
{
    std::ios_base::sync_with_stdio(false);
    ll n, m, k;
    cin >> n >> m >> k;
    vecll arr(n + m);
    vecll Np(n + m);
    for (ll i = 0; i < n; i++)
    {
        cin >> arr[n - i - 1];
    }
    for (ll i = 0; i < m; i++)
    {
        cin >> arr[n + i];
    }

    Np[0] = arr[0];
    for (ll i = 1; i < n + m; i++)
    {
        Np[i] = Np[i - 1] + arr[i];
    }

    ll res = 0;
    for (ll i = 0; i <= n; i++)
    {
        ll s=0;
        // if(i<n)
        //     s = upper_bound(Np.begin(), Np.end(), Np[i]+k-arr[n-i-1]) - Np.begin();
        // else
            s = upper_bound(Np.begin(), Np.end(), Np[i]+k-arr[i]) - Np.begin();
        // prints(i);
        // print(s);
        if(s>=n && i<=s)
            res = max(res, s-i);
    }
    print(res);

    return 0;
}

Measured memory_bytes: 9572
import java.io.*;
import java.util.*;
public class Main{
    public static Scanner scn=new Scanner(System.in);
    public static void main(String args[]){
        ans();
    }
    public static void ans(){
        int n=scn.nextInt();
        long count=0;
        // if(n>=1000000)
        // System.out.print(266666333332);
        
      for(int i=1;i<=n;i++){
      
          if(i%3!=0 && i%5!=0){
         count+=i;       
    }
}
// if(n<1000000)
System.out.print(count);
}
}

Measured memory_bytes: 35728
N, x = list(map(int, input().split()))
A = list(map(int, input().split()))

#print(N, x)
A.sort()
#print(A)

cnt = 0
for a in A:
  if x >= a:
    x -= a
    cnt += 1
  
  else:
    break

if cnt == N and x > 0:
  cnt = cnt - 1
print(cnt)

Measured memory_bytes: 3064
//Md Fahad
// CSE 18

#include<bits/stdc++.h>


using  namespace  std;

#define PI              acos(-1.0)
#define lcm(a,b)        (a * (b / __gcd(a,b)))
#define en '\n'

#define READ_IN freopen("Input.txt","r",stdin);
#define READ_OUT freopen("Output.txt","w",stdout);
#define Infi                0x3f3f3f3f

const int fx[] = {+1,-1,+0,+0};                         // 4 X directions
const int fy[] = {+0,+0,+1,-1};                         // 4 Y directions
const int fx8[] = {+0,+0,+1,-1,-1,+1,-1,+1};            // King X Moves
const int fy8[] = {-1,+1,+0,+0,+1,+1,-1,-1};            // King Y Moves
const int kx[] = {-2, -2, -1, -1,  1,  1,  2,  2};      // Knight X Moves
const int ky[] = {-1,  1, -2,  2, -2,  2, -1,  1};      // Knight Y Moves



int  Set    (int N,int pos) {return N=N | (1<<pos);}    /// turn a bit on
int  reset  (int N,int pos) {return N= N & ~(1<<pos);}  /// turn a bit off
bool check  (int N,int pos) {return (bool)(N & (1<<pos));} /// check, if a bit is on or not

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define trace(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define trace(x...)
#endif


typedef long long int           ll;
typedef unsigned long long int  llu;

int main(void)
{
    //READ_IN;
    llu n,a,b;
    cin >> n >> a >> b;

    llu r = n/(a+b);
    llu sum = r*a;

    llu ck = n%(a+b);

    while(ck>0){

        if(ck<a){
            sum+=ck;
            break;
        }
        else{
            sum+=a;
            break;

        }
    }
    cout << sum << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(){
 
    int m, f, r;
 
    while(1){
        cin >> m >> f >> r;
        if(m == -1 && f == -1 && r == -1){
            break;
        }else if(m == -1 || f == -1){
            cout << 'F' << endl;
        }else if((m + f) >= 80){
            cout << 'A' << endl;
        }else if((m + f) >= 65){
            cout << 'B' << endl;
        }else if((m + f) >= 50){
            cout << 'C' << endl;
        }else if((m + f) >= 30){
            if(r >= 50){
                cout << 'C' << endl;
            }else{
                cout << 'D' << endl;
            }
        }else{
            cout << 'F' << endl;
        }
    }
 
    return 0;
}

Measured memory_bytes: 3056
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <utility>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define MOD 1000000007

int main(int argc, char const *argv[]) {
  int N;
  scanf("%d",&N);
  int table[N];
  REP(i,N) table[i] = 0;
  REP(i,N){
    int num;
    scanf("%d",&num);
    table[num] += 1;
  }
  //search
  if(N%2 == 0){//奇数しかありえない
    for(int i = 1; i < N; i += 2){
      if(table[i] != 2){
        printf("0\n");
        return 0;
      }
    }
  }else{//偶数しかありえない
    if(table[0] != 1){
      printf("0\n");
      return 0;
    }
    for(int i = 2; i < N; i += 2){
      if(table[i] != 2){
        printf("0\n");
        return 0;
      }
    }
  }
  //問題ないなら
  int p = (N - (N%2)) / 2;
  long ans = 1;
  REP(i,p){
    ans *= 2;
    if(ans > MOD) ans = ans % MOD;
  }
  printf("%ld\n", ans);
}


Measured memory_bytes: 760
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int, int>
#define pb(a) push_back(a)
#define all(v) v.begin(), v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	int N;
	string S;
	cin >> N >> S;

	int ans = 0;
	for (int i = 2; i < N; i++) {
		if (S[i - 2] == 'A')
			if (S[i - 1] == 'B')
				if (S[i] == 'C')
					ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	int n;
	cin >> n;
	vector<int> x(n), y(n);
	REP(i, n) {
		cin >> x[i] >> y[i];
	}
	double sum = 0;
	vector<int> fac;
	REP(i, n) {
		fac.push_back(i);
	}
	do {
		REP(i, n - 1) {
			sum += sqrtl((x[fac[i + 1]] - x[fac[i]]) * (x[fac[i + 1]] - x[fac[i]]) + (y[fac[i + 1]] - y[fac[i]]) * (y[fac[i + 1]] - y[fac[i]]));
		}
	} while (next_permutation(all(fac)));
	REP(i, n) {
		sum /= (double)(i + 1);
	}
	cout << setprecision(20) << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()) {
  v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t) {
  stringstream ss;
  ss << f;
  ss >> t;
}


#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb push_back


#define MOD 1000000007LL
#define EPS 1e-8

LL fact(int N) {
  LL res = 1;
  for (int i = 2; i <= N; ++i) {
    res *= i;
  }
  return res;
}

int main() {
  int N, M;
  cin >> N >> M;
  int a[1000], b[1000], c[1000];
  int g[100][100];
  LL inf = 100000000;
  rep(i, M) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
  }
  rep(i, N) {
    rep(j, N) {
      g[i][j] = inf;
      if (i == j) g[i][j] = 0;
    }
  }
  rep(i, M) {
    g[a[i]][b[i]] = min(g[a[i]][b[i]], c[i]);
    g[b[i]][a[i]] = min(g[b[i]][a[i]], c[i]);
  }
  rep(k, N) {
    rep(i, N) {
      rep(j, N) {
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }

  int res = M;
  rep(i, M) {
    bool s = false;
    rep(j, N) {
      if (g[j][a[i]] + c[i] == g[j][b[i]]) s = true;
    }
    if (s)
      res = res - 1;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<long int> a(N);
  long int tmp;
  long int sum = 0;

  for(int i=0;i<N;i++){
   cin >> a.at(i); 
   sum += a.at(i) -1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define rrep(i,n) for (int i = (n - 1);i >= 0;i--)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    deque<char> ans;
    rep(i,s.size()){
        if(s[i] == '0') ans.push_back('0');
        else if(s[i] == '1') ans.push_back('1');
        else if(ans.empty()) continue;
        else ans.pop_back();
    }
    while(!ans.empty()){
        cout << ans.front();
        ans.pop_front();
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//Micro Futures scalping to get my tendies
vector<ll> v; ll n;
int main(){
	cin>>n;
	for(int i = 0; i < n; i++){
		ll x; cin>>x;
		v.push_back(x);
	}
	ll amt = 1000; ll ma = v[0], mi = v[0];
	for(int i = 1; i < n; i++){
		if(v[i] < v[i-1]){
			ll bal = amt/mi;
			bal = (amt-(bal*mi)) + (bal*ma);
			amt = bal;
			mi = ma = v[i];
		}
		else{
			mi = min(mi,v[i]);
			ma = max(ma,v[i]);
		}
	}
	ll bal = amt/mi;
	bal = (amt-(bal*mi)) + (bal*ma);
	amt = bal;
	cout<<amt<<"\n";
}

Measured memory_bytes: 3612
nk = input().split()
seisuuretu_2 = input().split()
nk1 = int(nk[1])

#seisuuretu = [int(i) for i in seisuuretu_2]
seisuuretu = list(map(int, seisuuretu_2))

list_max = set()
beautiful_list = []
for start in range(len(seisuuretu) + 1):
    for end in range(len(seisuuretu) + 1):
        if start < end:
            temp_pattern = bin(sum(seisuuretu[start:end]))[2:]
            beautiful_list.append(temp_pattern)
            list_max |= {len(temp_pattern),}

list_max = -max(list_max)

status = True
while status == True:
    temp = []
    count = 0
    for i in beautiful_list:
        try:
            if i[list_max] == "1":
                count += 1
                temp.append(i)
        except:
            continue
    if count > nk1:
        list_max += 1
        beautiful_list = temp
    elif count == nk1:
        num_count = True
        for num in temp:
            if num_count == True:
                ronriseki = int(num, 2)
            else:
                ronriseki = ronriseki & int(num, 2)
            num_count = False
        print(ronriseki)
        exit()
        status = False
    elif list_max == -1:
        num_count = True
        for num in beautiful_list:
            if num_count == True:
                ronriseki = int(num, 2)
            else:
                ronriseki = ronriseki & int(num, 2)
            num_count = False
        print(ronriseki)
        exit()
        status = False
    else:
        list_max += 1


Measured memory_bytes: 51532
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define pp pair<ll,ll>
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll mod=INF;


int main() {
    ll a,v,b,w,t;
    cin >> a >> v >> b >> w >> t;
    ll p=max(a-b,b-a);
    if (p<=t*(v-w)) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int dp[1100][10010];
int main(){
    for(int i=0;i<1100;i++){
        for(int j=0;j<10010;j++){
            dp[i][j]=inf;
        }
    }
    int h,n;
    cin>>h>>n;
    for(int i=0;i<1100;i++) dp[i][0]=0;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        for(int j=0;j<=h;j++) dp[i+1][j]=dp[i][j];
        for(int j=0;j<=h;j++){
            int nj = min(h,j+a);
            dp[i+1][nj] = min(dp[i+1][j]+b,dp[i+1][nj]);
        }
    }
    cout<<dp[n][h]<<endl;
    return 0;
}


Measured memory_bytes: 43392
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<iostream>
#include<string.h>
using namespace std;
int a[111],n;
void shuchu()
{
    for(int i=0; i<n; i++)
    {
        if(i==n-1)
            printf("%d",a[i]);
        else
            printf("%d ",a[i]);
    }
    printf("\n");
}
void charupx(int a[],int n)
{
    int i,j,t;
    for(int i=1; i<n; i++)
    {
        j=i-1;
        t=a[i];
        while(a[j]>=0 && t<a[j])
        {
            a[j+1]=a[j];
            j--;
        }
        a[j+1]=t;
        shuchu();
    }

}
int main()
{
    scanf("%d",&n);
    for(int i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
    }
    shuchu();
    charupx(a,n);
    return 0;
}
/*

*/



Measured memory_bytes: 3232
n = gets.to_i
nums = [0]
nums =gets.chomp.split(" ").map(&:to_i);

nums = nums.sort
i = 2.0

sum = 0.0
sum = (nums[0] + nums[1])/2.0

#puts sum

if n >= 3 
	while i <=  n-1 do
		sum = (sum + nums[i])/2.0
		i = i + 1
	end
end

puts sum

Measured memory_bytes: 1916