akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
 
#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<int,P> PP;
 
struct edge {
	int to,cost;
	edge(int t,ll c):to(t),cost(c) {}
};
 
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int ddx[]={1,1,1,0,-1,-1,-1,0},ddy[]={1,0,-1,-1,-1,0,1,1};
 
//-----------------------------------------------------------------------------
 
int n;
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	cin>>n;
	if(n==1) cout<<1<<endl;
	else {
		ll n1=2,n2=1,now;
		REP(i,n-1) {
			now=n1+n2;
			n1=n2,n2=now;
		}
		cout<<now<<endl;
	}
 
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n,m = map(int,input().split())
li = [list(map(int,input().split())) for _ in range(m)]

ans = 0
now = -1

li.sort(key = lambda x:x[1])

for i in range(m):
    if li[i][0] <= now and li[i][1] > now:
        pass
    else:
        ans += 1
        now = li[i][1] - 1

print(ans)


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

int main() {
  
  char i;
  cin >> i;
  
  if (i == 'a' || i == 'i' || i == 'u' || i == 'e' || i == 'o') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, init, n) for(int i = init; i < (n); i++)

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

ll dp[1024][1024];


int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> D(N), C(M);
    
    rep(i, N) cin >> D[i];
    rep(i, M) cin >> C[i];

    rep(i, N + 1) rep(j, M + 1) dp[i][j] = llINF;
    rep(i, M + 1) dp[0][i] = 0;

    rep(i, N)
    {
        rep(j, M)
        {
            dp[i][j + 1] = min(dp[i][j + 1], dp[i][j]);
            dp[i + 1][j + 1] = min(dp[i][j] + D[i] * C[j], dp[i + 1][j + 1]); 
        }
    }

    ll ans = llINF;

    rep(i, M + 1) ans = min(dp[N][i], ans);

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 9596
import java.util.*
class RollingHash(val N:Int,val S:String){
  val base = 101L
  val mod = 100000000003L
  val powBase = Array(N){1L}
  init{
    for(i in 1 until N){
      powBase[i] = powBase[i-1]*base%mod
    }
  }
  fun check(len:Int):Boolean{
    val T = TreeMap<Long,Int>()
    var hash = 0L
    for(i in 0 until len){
      hash = (hash + S[i].toLong()*powBase[len-i-1])%mod
    }
    T.put(hash,-1)
    for(i in 0 until N-len){
      hash = (hash - S[i].toLong()*powBase[len-1])*base+S[i+len].toLong()
      hash = hash%mod
      hash = if(hash>=0)hash else hash+mod
      if(T.containsKey(hash)){
        if(i-T[hash]!!>=len){
          return true
        }
      }
      else
      {
        T.put(hash,i)
      }
    }
    return false
 }
  fun maxlen():Int{
    var left = 0
    var right = N/2.toInt()+1
    while(right-left>1){
      val len = (right+left)/2.toInt()
      if(check(len))left = len else right = len
    }
    return left
  }
}
fun main(args:Array<String>){
  val rh = RollingHash(readLine()!!.toInt(),readLine()!!)
  println(rh.maxlen())
}


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

using namespace std;

int main(){
	int n,k,j=0;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=0;i<k;i++){
		j+=a[i];
	}
	cout<<j<<'\n';
	return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>
#include<string.h>
#define LEN 100005

/* プロセスを表す構造体 */
typedef struct pp {
	char name[100];
	int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x) {
	Q[tail] = x;
	tail = (tail + 1) % LEN;
}

P dequeue() {
	P x = Q[head];
	head = (head + 1) % LEN;
	return x;
}

int min(int a, int b) { return a < b ? a : b; }

int main() {
	int elaps = 0, c;
	int i, q;
	P u;
	scanf("%d %d", &n, &q);
	for ( i = 1; i <= n; i++) {
		scanf("%s", Q[i].name);
		scanf("%d",&Q[i].t);
	}
	head = 1; tail = n + 1;
	
	while ( head != tail ) {
		u = dequeue();
		c = min( q, u.t);
		u.t -= c;
		elaps += c;
		if ( u.t > 0 ) enqueue(u);
		else {
			printf("%s %d\n", u.name, elaps);
		}
	}
	
	return 0;
}


Measured memory_bytes: 11888
fn main() {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).ok();
    let mut it = input.trim().split_whitespace();
    let a:u32 = it.next().unwrap().parse().unwrap();
    let b:u32 = it.next().unwrap().parse().unwrap();
    let base:u32 = 100;
    println!("{}",if b < 100  {base.pow(a) * b} else {base.pow(a) * 101});
}

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

string s;
bool b = false;
string n = "dreamer", m = "eraser";
void saiki(int a) {
	if (a == s.length()) { b =true; return; }
	if (s.length() - a >= 7) {
		bool k = true;
		for (int i = 0; i < 7; i++) {
			if (s[a + i] != n[i])k = false;
		}
		if (k)saiki(a + 7);
	}
	if (s.length() - a >= 6) {
		bool k = true;
		for (int i = 0; i < 6; i++) {
			if (s[a + i] != m[i])k = false;
		}
		if (k)saiki(a + 6);
	}
	if (s.length() - a >= 5) {
		bool k = true;
		for (int i = 0; i < 5; i++) {
			if (s[a + i] != n[i])k = false;
		}
		if (k)saiki(a + 5);
	}
	if (s.length() - a >= 5) {
		bool k = true;
		for (int i = 0; i < 5; i++) {
			if (s[a + i] != m[i])k = false;
		}
		if (k)saiki(a + 5);
	}
}
int main() {
	cin >> s;
	saiki(0);
	if (b)puts("YES");
	else puts("NO");
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int A,B,C,D,E,F;
double max_con;

int main(void){
  SPEEDUP
  cout << setprecision(15);
  cin >> A >> B >> C >> D >> E >> F;
  A*=100;
  B*=100;
  max_con = (double)E/(100.0+E);
  vector<int> x;
  vector<int> y;
  for(int i = 0; A*i <= F; ++i){
    for(int j = 0; A*i + B*j <= F; ++j) x.push_back(A*i + B*j);
  }
  for(int i = 0; C*i <= F; ++i){
    for(int j = 0; C*i + D*j <= F; ++j) y.push_back(C*i + D*j);
  }
  sort(all(x));
  x.erase(unique(all(x)),x.end());
  sort(all(y));
  y.erase(unique(all(y)),y.end());

  double maximum = 0.0;
  int water = A;
  int sugar = 0;
  rep(i,x.size()){
    rep(j,y.size()){
      if(x[i]+y[j]>F)break;
      double con = (double) y[j]/(x[i]+y[j]);
      if(con <= max_con && con > maximum){
        maximum = con;
        water = x[i];
        sugar = y[j];
      }
    }
  }
  cout << water+sugar SP sugar << endl;
  return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <chrono>
#include <random>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n;
	std::cin >> n;
	std::cout << (n - 2) * 180 << '\n';
}

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

use std::cmp::*;

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

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

fn read_tuple<T: std::str::FromStr + Copy>() -> (T, T) {
    let v: Vec<T> = read_vec();
    (v[0], v[1])
}

fn main() {
    let (N, K) = read_tuple::<usize>();
    let x: Vec<i64> = read_vec();
    let mut ans = i64::max_value();
    for i in 0..N-K+1 {
        let left = x[i];
        let right = x[i+K-1];
        ans = min(ans, if left > 0 {
            right
        } else if right < 0 {
            -left
        } else {
            min(-2*left + right, -left + 2*right)
        });
    }
    println!("{}", ans);
}


Measured memory_bytes: 8444
#include <algorithm>
#include <iostream>
#include<string>

 using namespace std  ;

   int main ()

   {
       string str ;
       while (cin>>str )
       {
           if (str.length () ==2 )  cout<<str ;
           else for (int i = str.length ()-1 ; i >= 0 ; i-- ) cout<<str.at (i) ;
           cout<<endl ;
       }

       return 0;
   }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin>>n;
  if(n%10==3){
    cout<<"bon"<<endl;
  }
  else if(n%10==0||n%10==1||n%10==6||n%10==8){
    cout<<"pon"<<endl;
  }
  else{
    cout<<"hon"<<endl;
  }
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<math.h>

int main(void)
{
	int i,j,n;
	scanf("%d",&n);
	int k;
	
	int num;
    int n_test;
    int person, honest;
    int sum=0;
    int max=0;

	num = (int)pow(2,n);
	
	int a[num][n];
    int judge[num];

    for(i=0;i<num;i++)
        judge[i]=1;

	for(i=0;i<num;i++){
        for(j=0;j<n;j++){
          	if(i%(int)pow(2,j+1)>=pow(2,j))
	        	a[i][n-1-j]=1;
          	else
              	a[i][n-1-j]=0;
		}
	}

for(i=0;i<n;i++){
    scanf("%d",&n_test);

    for(j=0;j<n_test;j++){
        scanf("%d%d",&person,&honest);

        for(k=0;k<num;k++){
            if(a[k][i]==1){
                if(a[k][person-1]!=honest)
                    judge[k]=0;
            }
        }
    }
}

for(i=0;i<num;i++){
    if(judge[i]==1){
        for(j=0;j<n;j++)
            sum+=a[i][j];
        if(sum>max)
            max = sum;
            sum =0;
    }
}

printf("%d",max);

	
	return 0;
}

Measured memory_bytes: 2176
import java.util.Scanner;
public class Main {
public static void main(String[]srgs) {
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	if(a%10==0) {
		System.out.println(10);
	}
	else {
		int ans=0;
		for(int i=0;i!=10;i++) {
			ans+=a%10;
			a/=10;
		}
		System.out.println(ans);
	}
	}
}

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

using namespace std;

#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define INF 1000000000
#define INFL (1LL << 60)
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

ll POW(ll a, ll b){
  if(b == 0) return 1;
  if(b == 1) return a;
  if(b%2 == 1) return (a*POW(a, b-1))%MOD;
  ll x = POW(a, b/2);
  return (x*x)%MOD;
}

int main(){
  string s;
  cin >> s;
  int n = s.size();
  int a[s.size()] = {}, c[s.size()] ={}, q[s.size()+1] = {};
  REP(i, n-1){
    if(s[i] == 'A') a[i+1] = a[i]+1;
    else a[i+1] = a[i];
    if(s[n-1-i] == 'C') c[n-i-2] = c[n-i-1] + 1;
    else c[n-i-2] = c[n-i-1];
    if(s[i] == '?') q[i+1] = q[i]+1;
    else q[i+1] = q[i];
  }
  q[n] = q[n-1] + (s[n-1] == '?'?1:0);
  ll ans = 0;
  FOR(i, 1, n-1){
    if(s[i] == 'B'){
      ans += ((((a[i]+(q[i]*POW(3, MOD-2)%MOD))*(c[i]+(q[n]-q[i+1])*POW(3, MOD-2)%MOD))%MOD)*POW(3, q[n]))%MOD;
      ans %= MOD;
    }
    if(s[i] == '?'){
      ans += ((((a[i]+(q[i]*POW(3, MOD-2)%MOD))*(c[i]+(q[n]-q[i+1])*POW(3, MOD-2)%MOD))%MOD)*POW(3, q[n]-1))%MOD;
      ans %= MOD;
    }
  }
  cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1664
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int n; cin >> n;
    if(n == 1){
        cout << "Hello World" << "\n";
        return 0;
    }
    int a, b; cin >> a >> b;
    cout << a + b << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
#define int long long

signed main(){
  int n,k,s;
  cin >> n >> k >> s;
  LOOP(i,k){
    cout << s << " ";
  }LOOP(i,n-k){
    if(s==1)cout << 10000 << " ";
    else  cout << s-1 << " ";
  }
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define repn(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) for(int i = 0; i < (a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'
const int maxn = 305;

int a[4];
double dp[maxn][maxn][maxn];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		a[x - 1]++;
	}
	for(int k = 0; k <= n; k++){
		for(int j = 0; j <= n; j++){
			for(int i = 0; i <= n; i++){
				int tc = i + j + k;
				if(!tc || tc > n) continue;
				dp[i][j][k] = 1;
				if(i) dp[i][j][k] += dp[i - 1][j][k] * i / n;
				if(j) dp[i][j][k] += dp[i + 1][j - 1][k] * j / n;
				if(k) dp[i][j][k] += dp[i][j + 1][k - 1] * k / n;
				dp[i][j][k] *= (double) n / tc;
			}
		}
	}
	cout << fixed << setprecision(15) << dp[a[0]][a[1]][a[2]] << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 219392
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

  int N, M; cin >> N >> M;
  vector<bool> b(N);
  REP(i,N){
	int x; cin >> x;
	b[i] = !!x;
  }

  VI p(M); REP(i,M) cin >> p[i];

  int ans = 123456789;
  REP(x,2){
	int i = 0;
	bool init = !!(x % 2);
	vector<bool> t(N), orig = b;
	REP(k,M){
	  REP(j,p[k])
		t[i++] = init;
	  init = !init;
	}
	if(count(ALL(t), true) != count(ALL(orig), true)) continue;

	int cnt = 0;
	for(int i=0;i<N;++i){
	  if(orig[i] != t[i]){
		int j = i;
		while(orig[j] != t[i]) ++j;
		cnt += j - i;
		for(;j>i;--j){
		  orig[j] = orig[j-1];
		  //orig[i] = t[i];
		}
	  }
	}
	ans = min(ans, cnt);
  }

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

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

#define int long long
#define ll long long
#define f1(i,a,b) for(int i=a;i<b;i++)
#define f2(i,a,b) for(int i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    // #ifndef ONLINE_JUDGE
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/in.txt","r",stdin);
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/out.txt","w",stdout);
    // #endif

    int n,k,s;
    cin>>n>>k>>s;
   	if(s!=mod-7)
   	{
   		f1(i,0,k)
   		cout<<s<<gp;
   		f1(i,0,n-k)
   		cout<<s+1<<gp;
   	}
   	else
   	{
   		f1(i,0,k)
   		cout<<mod-7<<gp;
   		f1(i,0,n-k)
   		cout<<1<<gp;
   	}
    return 0;
}

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

int main(){
    double x,h;
    while(1){
    	cin >> x >> h;
    	if(x == 0 && h == 0)break;
    	double p = 2 * x * sqrt((x / 2) * (x / 2) + h * h);
    	cout << fixed << setprecision(6) << x * x + p << endl;
    }
    return 0;
}


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

int main() {
  int D;
  cin >> D;
 if(D == 25) cout << "Christmas" << endl;
 if(D == 24)cout << "Christmas Eve" << endl;
 if(D == 23) cout << "Christmas Eve Eve" << endl;
  if(D == 22) cout << "Christmas Eve Eve Eve"<< endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
            int h = sc.nextInt();
            int w = sc.nextInt();

            if(h == 0 && w == 0) {
                break;
            }

            StringBuilder sb = new StringBuilder();

            for(int i=0; i<w; i++) {
                sb.append("#");
            }

            for(int i=0; i<h; i++) {
                System.out.println(sb);
            }

            System.out.println("");
        }
        sc.close();
    }
}



Measured memory_bytes: 27632
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: Digital Gifts
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const double JPB = 380000.0;

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  double sum = 0.0;
  for (int i = 0; i < n; i++) {
    double xi;
    char ui[8];
    scanf("%lf%s", &xi, ui);

    sum += (ui[0] == 'J') ? xi : xi * JPB;
  }

  printf("%.6lf\n", sum);
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace Test06
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			for (int i = 0; i < n; i++)
			{
				double[] nums = Console.ReadLine().Split().Select(double.Parse).ToArray();
				double a = Math.Pow(nums[0], 2);
				double b = Math.Pow(nums[1], 2);
				double c = Math.Pow(nums[2], 2);
				double max = Math.Pow(nums.Max(),2);


				if (max.Equals(a + b))
				{
					Console.WriteLine("YES");
				}
				else if (max.Equals(a + c))
				{
					Console.WriteLine("YES");
				}
				else if (max.Equals(b + c))
				{
					Console.WriteLine("YES");
				}
				else
				{
					Console.WriteLine("NO");
				}
			}
		}
	}
}

Measured memory_bytes: 9836
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const int INF=1000100010;
const int D=60;
const int MAX_N=200010;
int t[D][MAX_N];
int main(){
    int n;
    ll k;
    cin>>n>>k;
    rep(i,n){
        cin>>t[0][i];
        t[0][i]--;
    }
    rep(i,D-1)rep(j,n){
            t[i+1][j]=t[i][t[i][j]];
        }
    int v=0;
    for(int i=D-1;i>=0;i--){
        ll l=1LL<<i;
        if(k>=l){
            v=t[i][v];
            k-=l;
        }
    }
    cout<<v+1<<endl;
    return 0;
}

Measured memory_bytes: 50476
function main(){
 
var seats = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
var groupMembers = [2,5,2,2,2];
var eatTimes = [19,39,25,36,22,42];
 
var headGroup = -1;
var pastMinutes = 0;
var waitTime = [];
 
while(waitTime.length < 100){
  // たべおわる
  var slen = seats.length;
  for(; slen--;){
    seats[slen] = mx(seats[slen] - 1, 0);
  }
 
  // 来店
  if(headGroup == -1 && pastMinutes % 5 == 0){
    headGroup = pastMinutes / 5;
  }
 
  // ちゃくせき
  while(headGroup != -1){
    var needsSequencialSeats = groupMembers[headGroup % 5];
    var sequencialSeats = 0;
    var startIndex = -1;
    for(var i = 0, sl = seats.length; i < sl; i++){
      sequencialSeats = seats[i] == 0 ? sequencialSeats + 1 : 0;
 
      if(sequencialSeats == needsSequencialSeats){
        startIndex = i - (needsSequencialSeats - 1);
        break;
      }
    }
 
    if(startIndex != -1){
      // すわれたみたい
      waitTime[headGroup] = pastMinutes - (headGroup * 5);
      for(var i = startIndex, total = (needsSequencialSeats + startIndex); i < total; i++){
        seats[i] = eatTimes[headGroup % 6];
      }
       
      headGroup = (((headGroup + 1) * 5) <= pastMinutes) ? headGroup + 1 : -1;
    }else{
      // すわれなかったみたい
      break;
    }
 
  }
 
  pastMinutes++;
 
}
 
for(var i = 0, ilen = (input.length - 1); i < ilen; i++){
  console.log(waitTime[parseInt(input[i], 10)]);
}
 
}

function mx(a, b){
 var t = (a-b);
 return a - (t & (t >> 31));
}
 
var
input = '';
 
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

Measured memory_bytes: 8700
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn ff(n: usize) -> usize {
    if n % 2 == 0 {
        return n / 2;
    } else {
        return 3 * n + 1;
    }
}

fn main() {
    input! {
        s: usize,
    }

    let mut a = vec![0; 1000100];
    a[1] = s;
    for i in 2..1000100 {
        a[i] = ff(a[i-1]);
        for j in 1..i {
            if a[i] == a[j] {
                println!("{}", i);
                return;
            }
        }
    }
}

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

int main() {
  int a,b,c,x,y;cin>>a>>b>>c>>x>>y;
  ll ans=1e9;
  for(int i=0;i<=max(x,y);i++){
    ll cnt=c*i*2+max(0,a*(x-i))+max(0,b*(y-i));
    ans=min(ans,cnt);
  }
  cout<<ans<<endl;
}

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

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

ll MOD = (ll)(1000 * 1000 * 1000 + 7);
const int SIZE = 1000000;
//const int SIZE = 1000;                                     
ll inv[SIZE];
ll fac[SIZE];
ll facinv[SIZE];

void init() {
  inv[1] = 1;
  for(int i = 2; i < SIZE; i++) {
    inv[i] = MOD - (MOD	/ i) * inv[(int)MOD % i] % MOD;
  }
  fac[0] = facinv[0] =	1;
  for(int i = 1; i < SIZE; i++) {
    fac[i] = (fac[i-1] * (ll)i) % MOD;
    facinv[i] =	(facinv[i-1] * inv[i]) % MOD;
  }
}

inline ll c(int a, int b) {
  return (fac[a] * facinv[b] % MOD) * facinv[a-b] % MOD;
}

int main() {
  init();
  int N, M;
  cin >> N >> M;
  vector<int> num;
  int rem = M;
  for(int i = 2; i <= rem; i++) {
    if(rem % i == 0) {
      int cnt = 0;
      while(rem % i == 0) {
	rem /= i;
        cnt++;
      }
      num.push_back(cnt);
    }
  }
  ll ans = 1LL;
  for(int i = 0; i < num.size(); i++) {
    int n = num[i];
    ans = (ans * c(n+N-1, n)) % MOD;
    //    cout << i << " " << n << " " << ans << endl;       
  }
  //  cout << "Answer=";                                     
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 23808
let n = stdin.ReadLine() |> int
let h = stdin.ReadLine().Split() |> Array.map int

let rec isAdding (candidate:Option<int>) i (h:array<int>) =
    if i >= n - 1 then "Yes"
    else
        match h.[i],h.[i+1],candidate with
        |x,y,_ when x < y -> isAdding None (i + 1) h
        |x,y,_ when x - y >= 2 -> "No"
        |x,y,z when x - y = 1 && z.IsSome -> "No"
        |x,y,z when x - y = 1 && z.IsNone -> isAdding (Some x) (i + 1) h
        |x,y,z when x = y -> isAdding z (i + 1) h

isAdding None 0 h |> stdout.WriteLine

Measured memory_bytes: 31836
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    char x,y;
    scanf("%d%c%d%c%d",&a,&x,&b,&y,&c);
    if(a<=2019&&b<=4&&c<=30)
    {
        printf("Heisei\n");
    }
    else
    {
        printf("TBD\n");
    }
    return 0;
}


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


int main()
{
	int n;
	cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h.at(i);
	}

	int h_max = h.at(0);
	int ans = 1;
	for (int i = 1; i < n; i++) {
		if (h.at(i) >= h_max) {
			h_max = h.at(i);
			ans++;
		}
	}

	cout << ans << endl;
}

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

long long ps[200001][2];
int n, m, k;

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

    for (int i = 1 ; i <= n ; i++) {
        long long a;
        cin >> a;
        ps[i][0] = a;
        if (i > 0) ps[i][0] += ps[i-1][0]; 
    }

    for (int i = 1 ; i <= m ; i++) {
        long long a;
        cin >> a;
        ps[i][1] = a;
        if (i > 0) ps[i][1] += ps[i-1][1]; 
    }
    
    int a = n, b = 0, da = 0;
    for (int i = a, j = 0 ; i >= 0 ; i--) {
        if (ps[i][0] + ps[j][1] > k) continue;
        while (ps[i][0] + ps[j+1][1] <= k && j < m) j++;
        da = max(da, i+j); 
    }
    cout << da;
}

Measured memory_bytes: 6756
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

string ntos(long long n){
  string s;
  stringstream ss;
  ss << n;
  ss >> s;
  return s;
}

int main(){
  ll n;
  cin>>n;
  vector<ll> v;
  rep(i,0,n){
  	ll a;
  	cin>>a;
  	v.pb(a);
  }
  ll flag = 1;
  v[0]--;
  rep(i,1,v.sz){
  	if(v[i-1]<v[i]){
  		v[i]--;
  	}
  	else if(v[i-1]==v[i]){

  	}
  	else{
  		flag = 0;
  	}
  }
  if(flag==1){
      cout << "Yes" << endl;
  }
  else{
      cout << "No" << endl;
  }
  return 0;
}

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

long long comb(int n, int r) {
    if (r < 0 || n < r) return 0;
    long long ret = 1;
    for (int i = 1; i <= r; i++) (ret *= n--) /= i;
    return ret;
}

#include <iomanip>
int main() {
    cout << fixed << setprecision(12);
    int n; cin >> n;
    int a, b; cin >> a >> b;
    vector<long long> v(n);
    for (auto &vi: v) cin >> vi;
    sort(v.rbegin(), v.rend());
    auto sum = accumulate(begin(v), begin(v) + a, 0.0);
    cout << sum / a << endl;
    int l = a - 1, r = a - 1;
    while (l > 0 && v[l - 1] == v[a - 1]) l--;
    while (r + 1 < n && v[r + 1] == v[a - 1]) r++;
    if (l == 0) {
        long long cnt = 0;
        for (int i = a; i <= b; i++) cnt += comb(r + 1, i);
        cout << cnt << endl;
    } else {
        cout << comb(r - l + 1, a - l) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	scanInit()

	H = nextInt()
	W = nextInt()
	s := nextGrid(H, W)

	for i := 0; i < H; i++ {
		allw := true
		for j := 0; j < W; j++ {
			if s[i][j] == "#" {
				allw = false
			}
		}
		if allw == true {
			for j := 0; j < W; j++ {
				s[i][j] = "D"
			}
		}
	}
	for i := 0; i < W; i++ {
		allw := true
		for j := 0; j < H; j++ {
			if s[j][i] == "#" {
				allw = false
			}
		}
		if allw == true {
			for j := 0; j < H; j++ {
				s[j][i] = "D"
			}
		}
	}

	for i := 0; i < H; i++ {
		any := false
		for j := 0; j < W; j++ {
			if s[i][j] != "D" {
				fmt.Printf("%s", s[i][j])
				any = true
			}
		}
		if any == true {
			fmt.Printf("\n")
		}
	}

}

// ---- readfunc
var sc = bufio.NewScanner(os.Stdin)

func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

// read func
func nextGrid(a int, b int) [][]string {
	mat := make([][]string, a)
	for i := 0; i < a; i++ {
		mat[i] = make([]string, b)
		tmp := nextStr()
		mat[i] = strings.Split(tmp, "")
	}
	return mat
}

// H =height
var H int

// W =witdh
var W int

// DBGprintGrid print the grid
//! DBG
func DBGprintGrid(g [][]string) {
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			fmt.Printf("%s", g[i][j])
		}
		fmt.Printf("\n")
	}
}


Measured memory_bytes: 2316
s = list(input())

c = -1
i = 1
while i < len(s)-1 and len(s) > 2:
    if s[i-1] != s[i+1]:
        s.pop(i)
        i = 1
        c *= (-1)
    else:
        i += 1
        
if c > 0:
    print("First")
else:
    print("Second")

Measured memory_bytes: 4084
#include <iostream>
#include <string>
#include <sstream>

using namespace std;


int main() {
  string str;
  while(getline(cin, str)) {
    stringstream sin;
    bool flag = true;
    if((int)str.length() % 2 == 0) {
      for(int i = 0; i < str.length(); i+=2) {
	int tm1 = (int)str[i] - (int)'0';
	int tm2 = (int)str[i+1] - (int)'0';

	if(!(tm1 >= 1 && tm1 <= 6 && tm2 >= 1 && tm2 <= 5)) {
	  flag = false;
	  break;
	}
	char c;
	if(tm1 == 6 && tm2 >= 2) {
	  switch(tm2) {
	  case 2:
	    c = '.'; break;
	  case 3:
	    c = '?'; break;
	  case 4:
	    c = '!'; break;
	  case 5:
	    c = ' '; break;
	  }
	} else {
	  c = (char)((tm1-1) * 5 + tm2 - 1 + (int)'a');
	}
	sin << c;
      }
    } else {
      flag = false;
    }

    if(!flag) {
      cout << "NA" << endl;
    } else {
      cout << sin.str() << endl;
    }
  }
  return 0;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    int K2 = K + K, x, y;
    int sum[K2+1][K2+1] = {};
    rep(i, N) {
        char c;
        cin >> x >> y >> c;
        if (c == 'W') y += K;
        x %= K2;
        y %= K2;
        sum[x+1][y+1]++;
    }
    rep(y, K2) {
        rep(x, K2) {
            sum[y+1][x+1] += sum[y+1][x] + sum[y][x+1] - sum[y][x];
        }
    }
    int ans = 0;
    rep(y, K + 1) {
        rep(x, K + 1) {
            int tmp = sum[y][x] - sum[y][0] - sum[0][x] + sum[0][0];
            tmp += sum[y][K2] - sum[y][x+K] - sum[0][K2] + sum[0][x+K];
            tmp += sum[y+K][x+K] - sum[y+K][x] - sum[y][x+K] + sum[y][x];
            tmp += sum[K2][x] - sum[K2][0] - sum[y+K][x] + sum[y+K][0];
            tmp += sum[K2][K2] - sum[K2][x+K] - sum[y+K][K2] + sum[y+K][x+K];
            tmp = max(tmp, N - tmp);
            ans = max(ans, tmp);
        }
    }
    cout << ans << endl;
}

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

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

  if (s[0] == s[1] && s[1] == s[2]) {
    printf("Yes\n");
  } else if (s[1] == s[2] && s[2] == s[3]) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;
         
class Main{
    public static void main(String[] args) {
        
        try(Scanner sc = new Scanner(System.in)){
 
            List<Integer> line = new ArrayList<>();
            line.add(1);
            line.add(1);
            line.add(1);
            line.add(2);
            line.add(1);
            line.add(2);
            line.add(1);
            line.add(5);
            line.add(2);
            line.add(2);
            line.add(1);
            line.add(5);
            line.add(1);
            line.add(2);
            line.add(1);
            line.add(14);
            line.add(1);
            line.add(5);
            line.add(1);
            line.add(5);
            line.add(2);
            line.add(2);
            line.add(1);
            line.add(15);
            line.add(2);
            line.add(2);
            line.add(5);
            line.add(4);
            line.add(1);
            line.add(4);
            line.add(1);
            line.add(51);

            System.out.println(line.get(Integer.valueOf(sc.next())-1));
 
        }catch(Exception e){
            e.printStackTrace();
        }        
    }
}

Measured memory_bytes: 22736
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9 +7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

a = inputI()
b = inputI()

print(6-a-b)

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}


int main(){
    COMinit();
    ll n,m,k;cin >>n>>m>>k;
    ll ans=0;
    for (int i = 1; i <n; ++i) {
        ans+=i*(n-i)*COM(n*m-2,k-2)*(m*m)%mod;
        ans%=mod;
    }
    swap(n,m);
    for (int i = 1; i <n; ++i) {
        ans+=i*(n-i)%mod*COM(n*m-2,k-2)*(m*m)%mod;
        ans%=mod;
    }
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 12160
import sys
n = int(input())
plot = []
for i in range(n):
    x, y, h = map(int, input().split())
    plot.append([x,y,h])

for cx in range(101):
    for cy in range(101):
        d = set()
        for i in range(n):
            h = 0
            if plot[i][2] > 0:
                h = abs(plot[i][0] - cx) + abs(plot[i][1] - cy) + plot[i][2]
                d.add(h)
        if len(d) == 1:
            flag = True
            for i in range(n):
                H = list(d)[0]
                h = max(H - abs(plot[i][0] - cx) - abs(plot[i][1] - cy), 0)
                if h != plot[i][2]:
                    flag = False
            if flag:
                print(cx,cy,H)
                sys.exit(0)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
string s1="CODEFESTIVAL2016",s2;
int main(){
	int sum=0;
	cin>>s2;
	for(int i=0;i<16;i++){
		if(s1[i]!=s2[i]) sum++;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>

typedef long long ll;
#define fi first
#define se second

int N;
double v[55];
int A, B;

using namespace std;

int main(){
  
  cin>>N>>A>>B;
  
  int i;
  int j;
  double sum = 0.0;
  double ava = 0.0;
  ll num;
  int cnt = 0;
  int a = 0;
  ll d = 1;
  ll ans = 0;
  
  for( i = 0; i < N; i++ ){
    scanf("%lf", v+i);
  }
  
  sort( v, v+N );
  reverse( v, v+N );
  
  
  for( i = 0; i < A; i++ ){
    sum += v[i];
    num = v[i];
  }
  
  //printf("%lf %lf\n", sum, (double)A);
  ava = sum/(double)A;
  
  for( j = 0; j < N; j++ ){
    if( v[j] == num ){
      cnt++;
      if( j < A ) a++;
    }
  }
  
  //printf("%d %d\n", cnt, a);
  
  if( v[0] != v[A-1] ) B = a;
  
  for( i = a; i <= B; i++ ){
    d = 1;
    for( j = 0; j < i; j++ ){
      d *= cnt-j;
      d /= j+1;
    }
    ans += d;
  }
  
  printf("%f\n", ava);
  cout<<ans<<endl;
    
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

Int solve(Int P, Int Q) {
  if (P < Q) {
    return solve(Q, P);
  }
  if (P % Q == 0) {
    return (2 * P / Q - 1) * Q;
  }
  return (2 * (P / Q)) * Q + solve(Q, P % Q);
}

int main() {
  Int N = lin();
  Int X = lin();

  printf("%lld\n", N + solve(X, N - X));

  return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#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 OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n;
    cin >> n;
    int h[n + 2];
    h[0] = 0, h[n + 1] = 0;
    for (int i = 1; i <= n; i++)
        cin >> h[i];

    int cnt = 0;
    int left = 0, right = 0;

    while (left != -1)
    {

        left = -1, right = -1;
        for (int i = 0; i <= n; i++)
        {
            if (h[i] == 0 && h[i + 1] != 0)
            {
                left = i + 1;
                break;
            }
        }

        for (int i = 1; i <= n + 1; i++)
        {
            if (h[i] == 0 && h[i - 1] != 0)
            {
                right = i - 1;
                break;
            }
        }

        if (left != -1)
        {
            for (int i = left; i <= right; i++)
                h[i]--;
            cnt++;
        }
    }

    OP(cnt);

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1
def ceil(x,y):
  return (x-1)//y+1

n,k = map(int,input().split())
A = list(map(int,input().split()))
for i,ai in enumerate(A):
  if ai == 1:
    ind1 = i
print(ceil(n-1,k-1))

Measured memory_bytes: 59376
def ans(x,y,z):
  z+=1
  x = x%y
  x,y = y,x
  if y == 0:return x,z
  return ans(x,y,z)
while True:
  a,b = map(int,raw_input().split())
  if a+b == 0: break
  if b > a: a,b =b,a
  d=0
  c,e =ans(a,b,d)
  print c,e

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

int main(){
  ll h;
  int n;
  std::cin >> h>>n;
  std::vector<int> a(n);
  for (int i = 0; i < n; i++) {
    std::cin >> a[i];
    h-=a[i];
  }
  if(h<=0)std::cout << "Yes" << '\n';
  else std::cout << "No" << '\n';
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
#define ll long long

int main(){
    ll N;
    ll i;
    ll A;
    cin >> N;
    ll mn=1111111111,sum=0,cnt=0;
    for(i=0;i<N;i++){
        cin >> A;
        if(A<0)cnt=(cnt+1)%2;
        A=abs(A);
        sum+=A;
        mn=min(mn,A);
    }
    cout << sum-2*cnt*mn;
    return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(long long i=s;i<n;i++)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
const double pi = acos(-1.0);
const ll mod = pow(10,9) + 7;
const ll INF = pow(2,31) - 1;

int main()
{
    string s;
    ll ans = 0;
    cin >> s;
    int n = s.size();

    rep(i,n/2){
        if(s[i] != s[n-i-1])ans++;
    }

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

Measured memory_bytes: 256
n = gets.chomp.to_i
ta = []
n.times do
  ta.push gets.split.map(&:to_i)
end
prev = ta[0]
1.upto(n-1) do |i|
  if prev.first <= ta[i].first && prev.last <= ta[i].last
    prev = ta[i]
  else
    mul0, mul1 = [prev.first / ta[i].first, prev.last / ta[i].last]
    if mul0 > mul1
      if prev.first % ta[i].first == 0
        mul = prev.first / ta[i].first
      else
        mul = prev.first / ta[i].first + 1
      end
    else
      if prev.last % ta[i].last == 0
        mul = prev.last / ta[i].last
      else
        mul = prev.last / ta[i].last + 1
      end
    end
    prev = [ta[i].first * mul, ta[i].last * mul]
  end
end
puts prev.first + prev.last


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
const int N = 100 + 5;
const int inf = 0x3f3f3f3f;
int n, m, edgeNum, head[N];

struct edge {
    int v, w, next, id;
} e[N*N];

void init() {
    memset(head, -1, sizeof(head));
    edgeNum = 0;
}

void addEdge(int u, int v, int w, int id) {
    e[edgeNum] = (edge){v, w, head[u], id};
    head[u] = edgeNum++;
}

int d[N], done[N], ok[N*N];

void Dijkstra(int s, int n) {
    memset(d, inf, sizeof(d));
    memset(done, 0, sizeof(done));
    d[s] = 0;
    while(1) {
        int x = -1, y = inf;
        for(int i = 1; i <= n; i++) {
            if(!done[i] && d[i] < y) {
                y = d[x=i];
            }
        }
        if(x == -1) {
            break;
        }
        done[x] = 1;
        for(int i = head[x]; ~i; i = e[i].next) {
            int v = e[i].v;
            if(done[v]) {
                continue;
            }
            d[v] = min(d[v], d[x]+e[i].w);
        }
    }
    queue<int> Q;
    Q.push(s);
    done[s] = 0;
    while(Q.size()) {
        int u = Q.front();
        Q.pop();
        for(int i = head[u]; ~i; i = e[i].next) {
            int v = e[i].v;
            if(d[u]+e[i].w == d[v]) {
                ok[e[i].id] = 1;
                if(done[v]) {
                    Q.push(v);
                    done[v] = 0;
                }
            }
        }
    }
}

int main() {
    init();
    scanf("%d%d", &n, &m);
    for(int i = 0; i < m; i++) {
        int u, v, w;
        scanf("%d%d%d", &u, &v, &w);
        addEdge(u, v, w, i);
        addEdge(v, u, w, i);
    }
    for(int i = 1; i <= n; i++) {
        Dijkstra(i,n);
    }
    printf("%d\n", m-accumulate(ok,ok+m,0));
    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <vector>
typedef long long ll;

using namespace std;

int main() {
    int N, M;

    cin >> N >> M;

    vector< ll > x(N), y(N), z(N);

    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i] >> z[i];
    }

    ll ans = 0;
    for (int i = 0; i < (1 << 4); i++) {
        vector< ll > score;
        ll sign[3];

        for (int j = 0; j < 3; j++) {
            if ((i >> j) & 1) {
                sign[j] = 1;
            } else {
                sign[j] = -1;
            }
        }

        for (int j = 0; j < N; j++) {
            score.push_back(sign[0] * x[j] + sign[1] * y[j] + sign[2] * z[j]);
        }

        sort(score.rbegin(), score.rend());

        ll tmp = 0;
        for (int j = 0; j < M; j++) {
            tmp += score[j];
        }

        ans = max(tmp, ans);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256