akhauriyash/Code-Regression huggingface dataset:
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

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

  if(S=="RRR") cout << 3 << endl;
  else if(S=="SRR" || S=="RRS") cout << 2 << endl;
  else if(S=="SSS") cout << 0 << endl;
  else cout << 1 << endl;
  
  return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <math.h>
int main(void){
  int x,y,tmp,i,end=0;

  scanf("%d",&x); scanf("%d",&y);
  if(x < y) { //change
    tmp = x;
    x = y;
    y = tmp;
  }
  if(x == y) {
      i = x;
  }
  else {
    tmp = x%y;
      for(i=tmp;i>0;i--) {
        if(tmp%i == 0) {
            if(y%i == 0) {
	        end = 1;
	        break;
            }
        }
        if(end == 1) {
          break;
        }
      }
  }
  printf("%d\n",i);
  return(0);
}



Measured memory_bytes: 2688
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

int N, A[5005], ans;
string S, now;

int Z_Algorithm(){
  int L = now.length();
  A[0] = L;
  int i = 1, j = 0;
  while (i < L){
    while (i + j < L && now[j] == now[i + j]) j++;
    A[i] = j;
    if (j == 0){i++; continue;}
    
    int k = 1;
    while (i + k < L && k + A[k] < j){
      A[i + k] = A[k]; k++;
    }
    i += k; j -= k;
  }

  for (int i = 0; i < L; i++){
    ans = max(ans, min(i, A[i]));
  }
  
  return 0;
}

int main(){
  cin >> N >> S;
  for (int i = 0; i < N; i++){
    now = S.substr(i, N);
    Z_Algorithm();
  }
  
  cout << ans << endl;
  
  return 0;
}


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

using ll = long long;
using db = double;
using pll = pair < ll, ll >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define pb push_back
#define mp make_pair
#define fastIo() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;

bool check(ll x, const vector<ll> &curskill) {
	for(auto v: curskill) trace(v);
	for(ll i = 0; i < curskill.size(); i++) {
		if(curskill[i] < x) return false;
	}
	return true;
}

int main(){
	ll n, m, x; cin >> n >> m >> x;
	vector<pair<ll,vector<ll>>>vec;
	for(ll i = 0; i < n; i++){
		ll ci; cin >> ci;
		vector<ll> tmp;
		for(ll i = 0; i < m; i++){
			ll a; cin >> a; tmp.pb(a);
		}
		vec.pb({ci, tmp});
	}
	// for(auto v: vec) {
	// 	trace(v.first);
	// 	for(auto w: v.second) trace(w);
	// }
	// trace(ll(pow(2, 5)));
	vector<string>pos;
	ll combinations = ll(pow(2, n));
	for(ll i = 0; i <= combinations; i++) {
		string str;
		for(ll j = 0; j < n; j++) {
			if(i & 1 << j) 
				str += '1';
			else 
				str += '0';
		}
		pos.emplace_back(str);
	}
	ll cost = INF;
	for(ll i = 0; i <= combinations; i++){
		string str = pos[i];
		trace(str);
		ll tmpcost = 0;
		vector<ll>curskill(m, 0);
		for(ll j = 0; j < str.size(); j++){
			if(str[j] == '1') {
				// trace(j);
				tmpcost += vec[j].first;
				vector<ll>skill = vec[j].second;
				for(ll k = 0; k < m; k++){
					curskill[k] += skill[k];
				}
			}	
		}
		if(check(x, curskill)) {
			trace(cost);
			cost = min(cost, tmpcost);
		}
	}
	if(cost == INF) cout << -1 << endl;
	else cout << cost << endl;
}

Measured memory_bytes: 4236
package main

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

var sc = bufio.NewScanner(os.Stdin)

const inf = 1 << 60
const mod int = 1e9 + 7

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func rs() string {
	sc.Scan()
	return sc.Text()
}

type sortRunes []rune

func (s sortRunes) Less(i, j int) bool { return s[i] < s[j] }
func (s sortRunes) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortRunes) Len() int           { return len(s) }

func sortString(s string) string {
	r := []rune(s)
	sort.Sort(sortRunes(r))
	return string(r)
}

func sigma(x int) int {
	sig := 0
	for i := 1; i <= x; i++ {
		sig += i
	}
	return sig
}

func main() {
	sc.Split(bufio.ScanWords)
	n := ri()

	keys := make(map[string]int)
	for i := 0; i < n; i++ {
		s := rs()
		sSorted := sortString(s)
		keys[sSorted]++
	}

	ans := 0
	for _, v := range keys {
		if v == 0 || v == 1 {
			continue
		}

		ans += sigma(v - 1)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 11520
#include <iostream>
#include <vector>
#include <string>
#include <locale>
#include <algorithm>

using namespace std;

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

	int N, M;
	cin >> N >> M;

	int l = 1;
	int r = N;
	for (int i=0; i<M; i++) {
		int L, R;
		cin >> L >> R;
		l = max(l, L);
		r = min(r, R);
	}

	if (l <= r) {
		cout << (r - l + 1) << endl;
	} else {
		cout << 0 << endl;
	}
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define ll unsigned long long
#define mod 1000000007
#define vi vector<ll>
#define pb push_back
#define mp make_pair
#define sp(x,y) fixed<<setprecision(y)<<x
#define mk(arr,n,type) type *arr=new type[n];
#define w(x) ll x; cin>>x; while(x--)
#define endl '\n'
#define str string
#define all(v) v.begin(),v.end()
void kehsihba() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int32_t main(){
	//kehsihba();
	ll x;
	cin>>x;
	ll a=100;
	ll ans=0;
	while(a<x){
		a+=(a/100);
		ans+=1;
	}
	cout<<ans;
}

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

int main(){

  int n;
  cin >> n;
  string s[n];
  cin >> s[0];
  for(int i=1;i<n;i++){
    cin >> s[i];
    if(s[i-1][s[i-1].size()-1]!=s[i][0]){
      cout << "No" << endl;
      return 0;
    }
  }

  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      if(s[i]==s[j]){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
/********************************************************************
* @brief https://atcoder.jp/contests/abc175/tasks/abc175_d
* @date 2020/08/16
*********************************************************************/

#include <bits/stdc++.h> //全てのヘッダファイルをインクルード
 
//ループ
#define rep(i, n) for(int i = 0; i < (n); i++) //普通のループ
#define repr(i, n) for(int i = n; i >= 0; i--) //逆ループ
 
//型名省略
typedef long long ll;
//値
static const ll MX = 100005;
static const ll MX_ll = 1e18;
const double PI = acos(-1); //π
 
using namespace std;
 
//ソート
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 
//#include "./lib/generic/search.h"

//文字列入力した小数値を小数点なくして返す
int changeDoubleToInt(string decimal){ 
    decimal.erase(1, 1); //小数点削除
    int n_decimal = atoi(decimal.c_str()); //c_strでchar*に変換後、atoiでintに変換
    return n_decimal;
}

//最大公約数
int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
}

//素数判定(True/Falseを返却)
int IsPrime_tf(ll num){
    if (num < 2) return false; //0、1は素数でない
    else if (num == 2) return true; //2は素数
    else if (num%2==0) return false; // 偶数はあらかじめ除く
    for (ll i = 3; i*i <= num; i += 2){ //チェックは2～√nで十分
        if (num % i == 0) return false; //素数でない
    }
    return true; //素数である
}

//素数判定(割れる値を返却)
ll IsPrime_value(ll num){
    if (num < 2) return -1; //0、1は素数でない
    else if (num == 2) return 2; //2は素数
    for (ll i = 2; i*i <= num; i += 1){ //チェックは2～√nで十分
        if (num % i == 0) return i; //素数でない
    }
    return num; //素数である
}

int main(){
   string n;
   cin >> n;
   int sum=0;
   rep(i,n.length()){
       string tmp =  n.substr(i,1);
       sum+=stoi(tmp);
   }
   if(sum%9==0) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
}

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

int main(){
    int N,M;
    cin>>N>>M;
    vector<int> A(M);
    vector<int> B(M);
    for(int i=0; i<M; i++) cin>>A[i]>>B[i];

    vector<pair<int,int>> p(M);
    for(int i=0; i<M; i++){
        p[i].first = B[i];
        p[i].second = A[i];
    }

    sort(p.begin(),p.end());

    int ans = 1;
    int last = p[0].first;

    for(int i=1; i<M; i++){
        if(last <= p[i].second){
            ans++;
            last = p[i].first;
        }
    }

    cout<<ans<<endl;

    return 0;
}

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


int main() {
    std::string S;
    std::cin >> S;
    if (S[0] == S[1] && S[2] == S[3] && S[0] != S[2]) {
        std::cout << "Yes" << std::endl;
        return 0;
    }
    if (S[0] == S[2] && S[1] == S[3] && S[0] != S[1]) {
        std::cout << "Yes" << std::endl;
        return 0;
    }
    if (S[0] == S[3] && S[1] == S[2] && S[0] != S[1]) {
        std::cout << "Yes" << std::endl;
        return 0;
    }
    std::cout << "No" << std::endl;
}


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

int main() {
    
  string str;
  int N[4];
  int sum = 0;

  cin >> str ;

  transform(begin(str), end(str), N, [](char c) {return c - '0'; });
  
  for (int i = 1; i < 4; ++i) {
      
    if (N[i-1] == N[i]){
      sum += 1;
      if (sum >= 2){
        cout << "Yes" << endl;
        break;
      }
    }
    else {
      sum = 0;
    }
  }
  
  if (sum < 2) {
    cout << "No" << endl;
  }
  
  return 0;

}

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

int main() {
  int N;
  cin >>N;
  int K;
  cin >>K;
  int m=N%K;

  if (m!=0) {
    cout << 1 << endl;
  }
  	 else{
      cout << 0 << endl;
  }
}


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

void input(int n, int* array, bool isC){
	if(isC)
		n--;
	for(int i = 0; i < n; i++){
		cin >> array[i];
	}
}

signed main() {
	int n,a[20], b[20], c[19];
	cin >> n;
	input(n,a,false);
	input(n,b,false);
	input(n,c,true);

	int prev = -1;
	int sat = 0;
	for(int i = 0; i < n; i++){
		int curr = a[i];
		sat += b[curr - 1];
		if(curr == prev + 1){
			sat += c[curr - 2];	
		}
		prev = curr;
	}
	cout << sat << endl;
	return 0;
}

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

int main(){

  int n;

  cin >> n;

  int c[n][n];

  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      c[i][j] = 0;
    }
  }

  for(int i = 0; i < n; i++){
    int x;
    cin >> x;
    int k;
    cin >> k;
    for(int j = 0; j < k; j++){
      int v;
      cin >> v;
      c[i][v - 1] = 1;
    }
  }

  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(j == 0) cout << c[i][j];
      else cout << " " << c[i][j];
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3096
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;

int main(){
	double A, B, H, M;
	cin >> A >> B >> H >> M;
	
	double h, m, Cpow, C, d;
	h = (60*H+M)/(12*60) /**2*M_PI*/;
	m = M/60 /**2*M_PI*/;
	d = h-m;
	
	double pi = 3.1415926535;
	Cpow = pow(A,2) + pow(B,2) - 2*A*B*cos(2*pi*d);
	C = sqrt(Cpow);
	
	cout << fixed << setprecision(10) << C << endl;
	
	return 0;
}


Measured memory_bytes: 4248
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1165&lang=jp>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

int N;
int dy[4] = {0,1,0,-1};
int dx[4] = {-1,0,1,0};
void solve(){
    vector<pll> box(N);
    for(int i = 1; i < N;i++){
        int n,d; cin >> n >> d;
        box[i] = {box[n].first+dy[d],box[n].second+dx[d]};
    }
    
    //cout << box << endl;
    auto H = minmax_element(box.begin(),box.end(),[](const pll& c1,const pll& c2){return c1.first < c2.first;});
    auto W = minmax_element(box.begin(),box.end(),[](const pll& c1,const pll& c2){return c1.second < c2.second;});
    cout << W.second->second - W.first->second + 1 << " " << H.second->first - H.first->first + 1 << endl;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    while(cin >> N,N){
        solve();
    }
    return 0;
}



Measured memory_bytes: 3172
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#define F first
#define S second

using namespace std;

typedef pair<int,int> P;

bool cmp_x( const pair<P,P> &p , const pair<P,P> &q ){
  return p.F < q.F;
}

bool cmp_y( const pair<P,P> &p , const pair<P,P> &q ){
  return p.S < q.S;
}

int main(void){
  
  int n,r,x1,x2,y1,y2;
  
  while(cin >> n >> r){
    if(n==0 && r==0)break;
    
    vector<pair<P,P> > in;
    
    for(int i=0;i<n;i++){
      scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
      in.push_back(make_pair(make_pair(x1,x2), make_pair(y1,y2)));
    }
    
    sort(in.begin(),in.end(),cmp_x);
    
    int S=0,L=0;
    vector<P>v;
    for(int i=0;i+1<10001;i++){
      v.clear();
      for(int j=0;j<n;j++){
	if(in[j].S.S>=i+1 && i>=in[j].S.F){
	  v.push_back(make_pair(in[j].F.F,in[j].F.S));
	}
      }
      
      if(v.size()!=0){
	//sort(v.begin(),v.end());
	int b=v[0].F,e=v[0].S;
	for(int j=1;j<v.size();j++){
	  int B=v[j].F,E=v[j].S;
	  if(e>=B)e=max(e,E);
	  else S+=e-b, b=B, e=E, L+=2;
	}
	S+=e-b, L+=2;
      }
    }
    cout << S << endl;
    
    
    if(r==2){
      
      sort(in.begin(),in.end(),cmp_y);
      
      for(int i=0;i+1<10001;i++){
	
	v.clear();
	for(int j=0;j<n;j++){
	  if(in[j].F.S>=i+1 && i>=in[j].F.F)
	    v.push_back(make_pair(in[j].S.F,in[j].S.S));

	}
	if(v.size()!=0){
	  //sort(v.begin(),v.end());
	  int b=v[0].F,e=v[0].S;
	  
	  for(int j=1;j<v.size();j++){
	    int B=v[j].F,E=v[j].S;
	    
	    if(e>=B)e=max(e,E);
	    else b=B, e=E, L+=2;
	  }
	  L+=2;
	}
      }
      cout << L << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1628
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    int N, M;
    cin >> N >> M;
    vector<string> vc( N * M );
    for( auto &x : vc )
    {
        cin >> x;
    }
    vector<string> W{"A","B","C","D","E","F","G","H","I","J","K","L","M","N",
                     "O","P","Q","R","S","T","U","V","W","X","Y","Z"};
    REP( i, N * M )
    {
        if( vc[ i ] == "snuke" )
        {
            cout << W[ i % M ] << i / M + 1 << endl;
        }
    }
    return 0;
}

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

// #define ANS  //for answer
#define CMP  //for compe
#ifdef CMP
using namespace std;
#else
#endif

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define nv(x) #x, (x)
#define ncv(x) #x, ":", (x)
#define ncvc(x) #x, ":", (x), ","
#define GETIN2MACRO(_1, _2, NAME, ...) NAME
#define GETIN3MACRO(_1, _2, _3, NAME, ...) NAME
#define GETIN4MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define GETIN5MACRO(_1, _2, _3, _4, _5, NAME, ...) NAME
#define GETIN6MACRO(_1, _2, _3, _4, _5, _6, NAME, ...) NAME
#define GETIN7MACRO(_1, _2, _3, _4, _5, _6, _7, NAME, ...) NAME
#define INPUT1(n) \
  ll n;           \
  cin >> n
#define INPUT2(a, b) \
  ll a, b;           \
  cin >> a >> b
#define INPUT3(n, a, b) \
  ll n, a, b;           \
  cin >> n >> a >> b
#define INPUT4(n, m, a, b) \
  ll n, m, a, b;           \
  cin >> n >> m >> a >> b
#define INPUT(...) GETIN4MACRO(__VA_ARGS__, INPUT4, INPUT3, INPUT2, INPUT1) \
(__VA_ARGS__)
#define INPUTARR(n, a) \
  ll n;                \
  cin >> n;            \
  ll a[n];             \
  REP(i, n) { cin >> a[i]; }
using ll = long long;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
void pPRINT(std::ostream& ost) {}
template <class T, class... U>
void pPRINT(std::ostream& ost, const T t, const U... u) {
  ost << t << " ";
  pPRINT(ost, u...);
}
template <class... T>
void PRINT(const T... t) { pPRINT(std::cout, t...); }
template <class... T>
void PRINTl(const T... t) {
  pPRINT(std::cout, t...);
  std::cout << "\n";
}
template <class T>
void PRINTa(const T* const t, const ll size) {
  REP(i, size)
  PRINT(t[i]);
  PRINTl();
}
template <class T>
void PRINTal(const T* const t, const ll size) {
  REP(i, size)
  PRINTl(i, ":", t[i]);
}
#ifndef DBG
#define DEBUG(...)
void init() {}
#else
#define DEBUG(...)                                                     \
  {                                                                    \
    PRINT("##DEBUG##", "file :", __FILE__, ", line :", __LINE__, "["); \
    PRINT(__VA_ARGS__);                                                \
    PRINTl("]");                                                       \
  }
void init() {
  DEBUG("INIT");
  cin.tie(0);
  ios::sync_with_stdio(false);
}
#endif
#ifdef ANS
#else
#endif

// search max depth
ll dfs(vector<vector<ll>>& tree, ll parent, ll now, ll depth) {
  ll d = depth;
  for (auto i : tree[now]) {
    if (i == parent) continue;
    d = max(d, dfs(tree, now, i, depth + 1));
  }
  return d;
}

void solve();

int main(int argc, char* argv[]) {
  DEBUG("MAIN");
  init();
  solve();

  return 0;
}

void solve() {
  DEBUG("SOLVE START");

  string s,t;
  cin>>s>>t;

  cout<<t<<s;


  return;
}

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

using namespace std;


int main(){
    string S;
    cin >> S;
    int len = S.size();
    int diff0 = 0;
    int diff1 = 0;

    for(int i = 0; i < len; i++){
        char check;
        if(i % 2 == 0) check = '0';
        else check = '1';
        if(S[i] != check) diff0++;
    }

    for(int i = 0; i < len; i++){
        char check;
        if(i % 2 == 0) check = '1';
        else check = '0';
        if(S[i] != check) diff1++;
    }

    cout << min(diff0, diff1) << endl;
}

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

using namespace std;
typedef long long ll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;

int main() {
  int N;
  cin >> N;
  vector<pair<int, int> > l(N);
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >>  a >> b;
    l[i] = make_pair(a, b);
  }

  auto dist = [&](pair<int,int> f, pair<int,int> s) {
    int x = f.first - s.first;
    int y = f.second - s.second;
    return sqrt(x * x + y * y);
  };

  double len = 0;
  int cnt = 0;
  sort(l.begin(), l.end());
  do {
    for (int i = 0; i < N - 1; i++) {
      len += dist(l[i], l[i + 1]);
    }
    cnt++;
  } while(next_permutation(l.begin(), l.end()));

  cout << fixed << len/cnt << endl;
  return 0;
}

Measured memory_bytes: 384
// unolight {{{
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(c) begin(c),end(c)
#define REP(i,n) for ( int i=0; i<(int)(n); i++ )
#define REP1(i,a,b) for ( int i=(int)(a); i<=(int)(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;

void RI() {}

template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}

template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
// }}}

LL n;

void input() {
    scanf("%lld", &n);
}

void solve() {
    if(n%2) {
        printf("0\n");
        return;
    }
    n = n / 2;
    LL a = 5;
    LL ans = 0;

    while(a <= n) {
        ans += n / a;
        a *= 5;
    }

    printf("%lld\n", ans);
}

int main( int argc, char *argv[] ) {
    input(); solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll h1,m1,h2,m2,k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	cout << h2*60+m2 - (h1*60+m1) -k << endl;
}

Measured memory_bytes: 3652
N, K = map(int, input().split())
A = [None] * K
for i in range(K):
    d = int(input())
    A[i] = list(map(int, input().split()))

flat_list = [s for a in A for s in a]
set_a = set(flat_list)
ans = 0

for i in range(1, N + 1):
    if not i in set_a:
        ans += 1

print(ans)


Measured memory_bytes: 9184
#include <iostream>
#include <cstring>
using namespace std;
char s[1100],t[1100];
int ans=2333333;
int main(void)
{
    cin>>s>>t;
    int ls=strlen(s),lt=strlen(t);
    for(int i=0;i<=ls-lt;i++)
    {
        int k=0;
        for(int j=0;j<lt;j++)
        {
            if(s[i+j]!=t[j])k++;
        }
        ans=min(ans,k);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3172
d1=list(map(int,input().split()))
d2=list(map(int,input().split()))
n=0

for i in range(4):
	d2[0],d2[1],d2[4],d2[5]=d2[1],d2[5],d2[0],d2[4]
	for i in range(4):
		d2[1],d2[3],d2[4],d2[2]=d2[3],d2[4],d2[2],d2[1]
		if d1[0]==d2[0] and d1[1]==d2[1] and d1[2]==d2[2] and d1[3]==d2[3] and d1[4]==d2[4] and d1[5]==d2[5]:
			n+=1
for i in range(4):
	d2[0],d2[3],d2[5],d2[2]=d2[3],d2[5],d2[2],d2[0]
	for i in range(4):
		d2[1],d2[3],d2[4],d2[2]=d2[3],d2[4],d2[2],d2[1]
		if d1[0]==d2[0] and d1[1]==d2[1] and d1[2]==d2[2] and d1[3]==d2[3] and d1[4]==d2[4] and d1[5]==d2[5]:
			n+=1		

if n==0:
	print('No')
elif n>0:
	print('Yes')


Measured memory_bytes: 5616
#include <cstdio>

using namespace std;

int main() {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    if (a==b && b==c) {
        printf("1\n");
    } else if (a==b || b==c || c==a) {
        printf("2\n");
    } else {
        printf("3\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,d;
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;
	if(b<=c||d<=a)cout<<0;
	else if (a >= c&&b <= d) cout << b - a;
	else if (c >= a && d <= b)cout << d - c;
	else if (c >= a&&b >=c)cout << b - c;
	else cout << d - a;
	return 0;
}

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

#define int long long

using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};


char s;

signed main(){
    rep(i,0,3){
        cin>>s;
        if(s=='1')cout<<"9";
        else cout<<"1";
    }
    cout<<endl;
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m;
vector<int> adj[100001];
bool visited[100001]={};

vector<int> v;
void dfs(int s){
	visited[s]=true;
	for(int i=0;i<adj[s].size();++i){
		if(visited[adj[s][i]]==false)
		dfs(adj[s][i]);
	}
	v.push_back(s);
}
int main() {
	cin>>n>>m;
	int x,y;
	for(int i=0;i<m;i++){
		cin>>x>>y;
		adj[x].push_back(y);
	}
	for(int i=1;i<=n;i++){
		if(visited[i]==false)
		dfs(i);
	}
	vector<int> dp(n+1,0);
	reverse(v.begin(),v.end());
	for(int i=v.size()-1;i>=0;i--){
		for(int j=0;j<adj[v[i]].size();j++){
			dp[v[i]]=max(dp[v[i]],dp[adj[v[i]][j]]+1);
		}
	}
	int max=0;
	for(int i=1;i<=n;i++){
		if(max<dp[i])
		max=dp[i];
	}
	cout<<max;
	return 0;
}

Measured memory_bytes: 8056
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 main() {
    input!{
        r: usize,
    }
    println!("{}", r*r)
}


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

using namespace std;

#define long long long
#define INF 2e18
#define MOD (long) (998244353)
#define umap unordered_map

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

    long t = 1;
    //cin >> t;

    while (t--) {
        long s, w;
        cin >> s >> w;

        if (w >= s) puts("unsafe");
        else puts("safe");
    }
}


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

int main(){
	int x[4],y[4];
	cin >> x[0] >> y[0] >> x[1] >> y[1];
	x[2]=x[1]-(y[1]-y[0]);
	y[2]=y[1]-(x[0]-x[1]);
	x[3]=x[0]-(y[1]-y[0]);
	y[3]=y[0]-(x[0]-x[1]);
	cout << x[2] << " " << y[2] << " " << x[3] << " " << y[3] << endl;
}


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

using namespace std;

namespace IntegerMath
{
  int64_t floor_div(int64_t x, int64_t y) {
    return static_cast<int64_t>(
      ::floorl(
        static_cast<long double>(x)
        /
        static_cast<long double>(y)
      )
    );
  }

  int64_t ceil_div(int64_t x, int64_t y) {
    return static_cast<int64_t>(
      ::ceill(
        static_cast<long double>(x)
        /
        static_cast<long double>(y)
      )
    );
  }

  int64_t sqrt(int64_t x) {
    return static_cast<int64_t>(
      ::floorl( ::sqrtl( 
        static_cast<long double>(x)
      ) )
    );
  }

  int64_t log2(int64_t x) {
    return static_cast<int64_t>(
      ::floorl( ::log2l( 
        static_cast<long double>(x)
      ) )
    );
  }    

  int64_t log10(int64_t x) {
    return static_cast<int64_t>(
      ::floorl( ::log10l( 
        static_cast<long double>(x)
      ) )
    );
  }

  int64_t number_of_digits(int64_t x) {
    return static_cast<int64_t>(
      ::ceill( ::log10l( 
        static_cast<long double>(x + 1)
      ) )
    );
  }

  uint64_t gcd(uint64_t a, uint64_t b)
  {
    uint64_t n = std::min(a, b), m = std::max(a, b);
    return (n == 0) ? m : gcd(m % n, n);
  }

  uint64_t lcm(uint64_t a, uint64_t b)
  {
    uint64_t d = gcd(a, b);
    return (a % d == 0) ? (a / d) * b : a * (b / d);
  }
};

bool binary_search_query(
  uint64_t N, uint64_t K, 
  const vector<uint64_t> &A, const vector<uint64_t> &F, 
  uint64_t z
)
{
  for (uint64_t n = 0; n < N; ++n) {
    uint64_t c = A[n] * F[n];
    if (c > z) {
      uint64_t k = IntegerMath::ceil_div(c - z, F[n]);
      if (k > K) { return false; }
      K -= k;
    }
  }
  return true;
}

uint64_t binary_search(
  uint64_t N, uint64_t K, 
  const vector<uint64_t> &A, const vector<uint64_t> &F
)
{
  uint64_t hi = 0, lo = 0;
  for (uint64_t n = 0; n < N; ++n) {
    hi = max(hi, A[n] * F[n]);
  }
  
  while (hi - lo > 1) {
    uint64_t mid = (hi + lo) >> 1;
    if (binary_search_query(N, K, A, F, mid)) {
      hi = mid;
    } else {
      lo = mid;
    }
  }
  
  return binary_search_query(N, K, A, F, lo) ? lo : hi;
}

int main()
{
  uint64_t N, K;
  cin >> N >> K;
  
  vector<uint64_t> A(N), F(N);
  for (uint64_t n = 0; n < N; ++n) { cin >> A[n]; }
  for (uint64_t n = 0; n < N; ++n) { cin >> F[n]; }
  
  sort(A.begin(), A.end(),    less<uint64_t>());
  sort(F.begin(), F.end(), greater<uint64_t>());
  
  cout << binary_search(N, K, A, F) << endl;
  
  return 0;
}

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

int main(){
    int a,b,d,r;
    double f;
    
    cin >> a >> b;
    
    d = a/b;
    r = a%b;
    f = 1.00000 * a/b;
    
    cout << d << " " << r << " ";
    
    printf("%.5lf", f);
    
    return 0;
}


Measured memory_bytes: 3248
#include <algorithm>
#include <fstream>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <math.h>
using namespace std;

int main(){
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int N;
    cin >>N;
    vector<int> w(N);
    int min=0;
    int sum=0;
    for(int i =0;i<N;i++){
        cin >> w[i];
        sum+=w[i];
    }

    min =sum;
    int b = 0;
    int a = sum;
    int d =sum;

    for(int i = 0;i<N;i++){
        b+=w[i];
        a-=w[i];
        d=abs(a-b);
        if (d<min){
            min=d;
        }
    }

    cout << min <<endl;
    
}

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

#define filein freopen ("in.txt", "r", stdin)
#define fileout freopen ("out.txt", "w", stdout)
#define dbg(x) cerr << #x << ": " << x << endl

using namespace std;
typedef long long ll;

const int maxn = 3005;

char s[maxn], t[maxn];
int slen, tlen;
ll dp[maxn][maxn];
string ans;

int main(){
	scanf ("%s%s", s, t);
	slen = strlen (s);
	tlen = strlen (t);
	for (int i = 1; i <= slen; i++){
		for (int j = 1; j <= tlen; j++){
			if (s[i - 1] == t[j - 1])
				dp[i][j] = 1 + dp[i - 1][j - 1];
			else
				dp[i][j] = max (dp[i - 1][j], dp[i][j - 1]);
		}
	}
	// for (int i = 0; i <= slen; i++){
	// 	for (int j = 0; j <= tlen; j++){
	// 		cout << dp[i][j] << ' ';
	// 	}
	// 	cout << endl;
	// }
	int i = slen, j = tlen;
	while (i and j){
		if (s[i - 1] == t[j - 1]){
			ans += s[i - 1];
			i--; j--;
		}
		else if (dp[i][j] == dp[i - 1][j])
			i--;
		else
			j--;
	}
	for (int i = (int) ans.size() - 1; i >= 0; i--)
		cout << ans[i];
	cout << '\n';
	return 0;
}

Measured memory_bytes: 70656
#include <iostream>
#include <vector>

using namespace std;

void swap(vector<long long> &heap, int i, int j){
    long long tmp = heap[i];
    heap[i]=heap[j];
    heap[j]=tmp;
}

void maxHeapify(vector<long long> &heap, int n){
    int l,r,largest,last;
    l=2*n+1;
    r=2*n+2;
    largest=n;
    last=heap.size();

    if (l<last && heap[l] > heap[largest])largest=l;
    if (r<last && heap[r] > heap[largest])largest=r;
    if(largest!=n){
        swap(heap,n,largest);
        maxHeapify(heap,largest);
    }
}

long long maxHeapPop(vector<long long> &heap){
    long long max_=heap[0];
    heap[0]=heap[heap.size()-1];
    heap.pop_back();
    maxHeapify(heap,0);

    return max_;
}

void maxHeapPush(vector<long long> &heap, long long num){
    heap.push_back(num);
    int i = heap.size()-1;
    int parent = (i-1)/2;
    while (i>0 && heap[parent] < heap[i]){
        swap(heap,i,parent);
        i=parent;
        parent=(i-1)/2;
    }
}

void buildMaxHeap(vector<long long> &heap){
    int size=heap.size();
    for(int i=(size-1)/2; i>=0; i--){
        maxHeapify(heap,i);
    }
}

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

    vector<long long> A(N);
    vector<long long> B(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    for(int i=0; i<N; i++){
        cin >> B[i];
    }

    vector<long long> heapDiff(0);
    long long diffSum=0;
    int cnt=0;
    for(int i=0; i<N; i++){
        long long diff=A[i]-B[i];
        if(diff<0){
            diffSum+=-diff;
            cnt++;
        }else if(diff>0){
            maxHeapPush(heapDiff, diff);
        }
    }

    while(diffSum>0 && heapDiff.size()>0){
        diffSum-=maxHeapPop(heapDiff);
        cnt++;
    }
    if(diffSum<=0){
        cout << cnt << endl;
    }else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 2428
#include <stdio.h>
#include <string.h>
#define Fori(g) for(int i=0;i<g;i++)
#define	Forj(g) for(int j=0;j<g;j++)
#define min(aa,bb) return (aa<bb)?aa:bb
#define max(aa,bb) return (aa<bb)?bb:aa

int main(){
	int n,flag=0;
	char s[100];
	scanf("%d",&n);
	scanf("%s",s);
	int j=n/2;
	if(n==1 || n%2==1){
		printf("No\n");
		return 0;
	}
	for(int i=0;i<n/2;i++){
		if(s[i]==s[j])flag++;
		j++;
	}
	if(flag==n/2)printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using stkll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

int main() {
    cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(20);

    ll N; cin >> N;
    vll h(N); rep(i,N) cin >> h[i];

    vll dp(N+1, INF);
    dp[0] = 0;
    rep(i, N) {
        if(i-1 >= 0) chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
        if(i-2 >= 0) chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }
    cout << dp[N-1] << endl;
}


Measured memory_bytes: 1792
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N, M; cin >> N >> M;

    ll K; cin >> K;
    ll A[N], B[M]; F0R(i, N) cin >> A[i];
    F0R(i, M) cin >> B[i];

    ll as = 0; F0R(i, N) as += A[i];
    ll bs = 0;
    int bp = 0;
    int ans = 0;
    F0Rd(i, N+1) {
        if (i < N) as -= A[i];
        if (as <= K) {
            while (bp < M && as + bs + B[bp] <= K) {
                 bs += B[bp]; bp++;
            }
            ckmax(ans, i + bp);
        }
//        cout << as << " " << bs << " " << bp << nl;
    }
    cout << ans << nl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 6756
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n][3];
   int dp[n][3];
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      cin>>a[i][j];
      dp[i][j]=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++){
  dp[i][0]+=max(dp[i-1][1],dp[i-1][2]);
  dp[i][1]+=max(dp[i-1][0],dp[i-1][2]);
   dp[i][2]+=max(dp[i-1][0],dp[i-1][1]);
  }
  
  cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
return 0;}

Measured memory_bytes: 2560
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const double pi = acos(-1.0);
template <class A>ostream & operator<<(ostream & o, const vector<A> & p) { o << "{"; for (int i = 0; i < (int)p.size(); ++i)o << (i > 0 ? ", " : "") << p[i]; o << "}"; return o; }
template <class A, class B>ostream & operator<<(ostream & o, const pair<A, B> & p) { o << "{" << p.first << ", " << p.second << "}"; return o; }
template <class A, class B>ostream& operator<<(ostream & o, const map<A, B> & p) { o << "{"; for (auto it = p.begin(); it != p.end(); ++it) o << (it != p.begin() ? ", " : "") << *it; o << "}"; return o; }
template <class A>ostream & operator<<(ostream & o, const set<A> & p) { o << "{"; for (auto it = p.begin(); it != p.end(); ++it) o << (it != p.begin() ? ", " : "") << *it; o << "}"; return o; }
void print() { cerr << endl; }
template <class H> void print(H && h) { cerr << h << endl; }
template <class H, class... T> void print(H && h, T && ... t) { cerr << h << " "; print(forward<T>(t)...); }

//a^n
long long Pow(long long a, long long n) {
	long long ans = 1;
	while (n > 0) {
		if (n & 1)ans *= a;
		a *= a; n >>= 1;
	}
	return ans;
}

int re(int n, int m) {
	return n == m ? n : max(n, m) - min(n, m);
}

VI vec(VI a) {
	VI ret;
	for (int i = 0; i < sz(a); i += 2) {
		ret.pb(re(a[i], a[i + 1]));
	}
	return ret;
}

int main() {
	int n; cin >> n;
	VI a(Pow(2, n)); rep(i, Pow(2, n))cin >> a[i];
	while (sz(a) != 1) {
		a = vec(a);
	}
	Cout(a[0]);
}

Measured memory_bytes: 2940
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
//#define ll __int64
#define ll long long
#define P pair<ll,ll>
int n;
int ma,mb;
int a[100],b[100],c[100];
const int M=401;
int dp[41][M][M];//[n][a][b]
const int INF=100000000;

int main(){
	cin>>n>>ma>>mb;
	rep(i,n)cin>>a[i]>>b[i]>>c[i];
	rep(i,41)rep(j,M)rep(k,M)dp[i][j][k]=INF;

	dp[0][0][0]=0;
	rep(i,n){
		rep(j,M){
			rep(k,M){
				if(dp[i][j][k]!=INF){
					dp[i+1][j+a[i]][k+b[i]]=min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);
					dp[i+1][j][k]=min(dp[i][j][k],dp[i+1][j][k]);
				}
			}
		}
	}
	int ans=INF;
	for(int i=1;i<=M;i++){
		if(i*ma>=M||i*mb>=M)break;
		ans=min(ans,dp[n][i*ma][i*mb]);
	}
	if(ans==INF)cout<<-1<<endl;
	else cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 25984
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>
#include <bitset>

using namespace std;
typedef long long ll;

set<string> s;

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        string ss;
        cin >> ss;
        s.insert(ss);
    }
    int m;
    cin >> m;
    bool now = false;
    for (int i = 0; i < m; i++) {
        string a;
        cin >> a;
        if (s.count(a)) {
            now = !now;
            if (now) {
                cout << "Opened by " << a << endl;
            } else {
                cout << "Closed by " << a << endl;
            }
        } else {
            cout << "Unknown " << a << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1232
using System;
class ss
{
  static void Main()
  {
    var n=Console.ReadLine().Split(" ");
    int a=int.Parse(n[0]);
    int b=int.Parse(n[1]);
    int c=int.Parse(n[2]);
    int k=int.Parse(n[3]);
    int sum=0;
    if(k>=a)
    {
      sum+=a;
      k-=a;
    }
    else
    {
      sum+=k;
      k=0;
    }
     if(k>=b)
      k-=b;
    else
      k=0;
     if(k>=c)
    {
      sum-=c;
    }
    else
      sum-=k;
    Console.WriteLine(sum);
      
    
   
  }
}

Measured memory_bytes: 27560
#include <bits/stdc++.h>
using namespace std;
#define ff        first
#define ss        second
#define ll        long long
#define int       long long
#define inf       ((ll)1e18)
#define mod       1000000007
#define double    long double
#define ull       unsigned long long
#define vi        vector<ll>
#define ppi       pair<int,int>
#define pii       pair<pair<int,int>,int>
#define pb        push_back
#define pi        2*acos(0.0)
#define rev       greater<int>()
#define pr(a,x,y) for(int i=x;i<y;i++){cout<<a[i]<<" ";}
#define ps(s)     for(auto i:s){cout<<i<<" ";}
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define rall(v)   v.rbegin(), v.rend()
#define test      cout<<"This is test"<<endl;
#define str       string
#define endl      '\n'
#define e         cout<<'\n';
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
void solve(){
	str s;cin>>s;
	if(s.back()=='s'){
		cout<<s<<"es";
	}
	else{
		cout<<s<<"s";
	}
}
int32_t main(){
	kehsihba();
	//init();
	ll t=1;
	//cin>>t;
	for(int k=1;k<=t;k++){
		//cout<<"Case "<<k<<": ";
		solve();
		//e;
	}
}

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

int main() {
  int a,b;
  cin >> a >> b;
  int i;
  int p=0;
  for(i=a;i<=b;i++){
    if(i/10000==i%10&&(i/1000)%10==(i/10)%10){
      p++;
    }
  }
  cout << p << endl;
}


Measured memory_bytes: 256
N = int(input())
A = []
for _ in range(N):
  A.append(int(input()))

B = sorted(A, reverse=True)
  
max_ = B[0]
max__ = B[1]

for i in range(N):
  if A[i] == max_:
    print(max__)
  else:
    print(max_)

Measured memory_bytes: 14112
H,W,N = map(int,input().split())
SR,SC = map(int,input().split())
S = input()
T = input()

y = SR
for s,t in zip(S,T):
    if s=='U':
        y -= 1
        if y==0:
            print('NO')
            exit()
    if t=='D' and y < H:
        y += 1

y = SR
for s,t in zip(S,T):
    if s=='D':
        y += 1
        if y==H+1:
            print('NO')
            exit()
    if t=='U' and y > 1:
        y -= 1

x = SC
for s,t in zip(S,T):
    if s=='L':
        x -= 1
        if x==0:
            print('NO')
            exit()
    if t=='R' and x < W:
        x += 1

x = SC
for s,t in zip(S,T):
    if s=='R':
        x += 1
        if x==W+1:
            print('NO')
            exit()
    if t=='L' and x > 1:
        x -= 1

print('YES')

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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

const double pi = 3.141592653589793;

#define xx          first
#define yy          second
#define mp          make_pair
#define intl        long long
#define filein      freopen("input.txt", "r", stdin)
#define fileout     freopen("output.txt", "w", stdout)
#define debug       cout << "YES" << endl
#define what_is(x)  cout << #x << " is " << x << endl
#define pb          push_back
#define pii         pair<int, int>

//find_by_order(int) and order_of_key(int)
//typedef tree < intl , null_type ,less<intl>,rb_tree_tag,tree_order_statistics_node_update > ordered_set;
const int M = 345678;
int k, dist[123456];

int dijkstra()
{
    priority_queue<pii>q; //sum, rem
    for (int i = 0 ; i < k ; i++) {
        dist[i] = 1000000000;
    }
    q.push(mp(0,0));
    dist[0] = 0;
    while( !q.empty() )
    {
        pii a = q.top();
        q.pop();
        int r = a.yy, s = dist[a.yy];
        if( r == 0 && s != 0 ) return s;
        for( int i = 0; i < 2; i++ )
        {
            if( s == 0 && i == 0 ) continue;
            int tr = (r*10 + i)%k;
            if( (tr == 0 && dist[tr] == 0) || dist[tr] > s + i )
            {
                dist[tr] = s+i;
                q.push( mp( -dist[tr], tr ) );
            }
        }
    }
    return dist[0];
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    //filein;
    cin >> k;
    cout << dijkstra() << endl;
    return 0;
}



Measured memory_bytes: 1276
import java.util.*;

public class Main {

	public static void main(String[] args) {
		
		char[] l= {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
		
		Scanner sc = new Scanner(System.in);
		
		String w = sc.nextLine();
		
		String ans = "Yes";
		
		if (w.length()%2 == 0) {
			char[] c = w.toCharArray();
			for (int i=0; i<l.length; i++) {
				int count = 0;
				for (int j=0; j<c.length; j++) {
					if (l[i] == c[j]) {
						count++;
					}
				}
				if (count%2 !=0) {
					ans = "No";
					break;
				}
			}
			
			
		} else {
			ans = "No";
		}
		
		System.out.println(ans);
		sc.close();
	}

}

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

int main(){
  int N,Y;
  cin>>N>>Y;
  Y/=1000;
  bool bo=false;
  for(int i=0;i*10<=Y;i++){
    int x=Y-i*10;
    for(int j=0;j*5<=x;j++){
      int k=x-j*5;
      if(i+j+k==N){
        cout<<i<<' '<<j<<' '<<k<<endl;
        bo=true;
        break;
      }
    }
    if(bo)
      break;
  }
  if(!bo)
    cout<<"-1 -1 -1"<<endl;
}

Measured memory_bytes: 256