akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



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

    int n = s.size();

    vector<vector<int>> v(n+1, vector<int>(26, 0));
    ll ans = 1;

    REP(i, n){
        REP(j, 26){
            v[i+1][j] = v[i][j];
        }
        v[i+1][s[i] - 'a']++;
    }

    REP(i, n){
        ans += i - v[i][s[i] - 'a'];
    }

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


Measured memory_bytes: 27012
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        // 変数宣言
        final int PAGE = 2;
        int inputFromKeyBoad;
        int min;

        // 標準入力
        Scanner sc = new Scanner( System.in );
        inputFromKeyBoad = sc.nextInt();

        // 演算処理
        min = (inputFromKeyBoad / PAGE) + (inputFromKeyBoad % PAGE);

        // 出力
        System.out.println( min );
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef vector < int > vint;
typedef pair < int, int > pii;
typedef pair < int, bool > pib;
typedef unsigned long long ull;

#define PB push_back
#define MP make_pair
#define RANGE(V) V.begin(), V.end()
#define FOR(i,n) for(int i=0;i<n;++i)
#define FORN(i,n) for(int i=1;i<=n;++i)
#define debug(x) cerr<<#x<<":"<<x<<"\n";
#define FORS(i,n) for(int i=0;i<n.length();++i)
const int INF = INT_MAX;
const int MAX = 10000001;
const int M = 1000000007;
int mod{ 1000000007 };
bool compare(string a, string b) {
	return (a + b < b + a);
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	//freopen("input.txt", "r", stdin);
	int n, l;
	cin >> n >>l;
	vector<string> v(n);
	FOR(i, n) cin >> v[i];
	sort(v.begin(), v.end(), compare);
	for (auto& i : v) {
		cout << i;
	}
	return 0;	
}






Measured memory_bytes: 3624
N, K = list(map(int, input().split()))
Ps = list(map(int, input().split()))


def expected(val):
    return (val*(val+1) / 2) / val

est = sum([expected(x) for x in Ps[:K]])
max_est = est
for i in range(K, N):
    est -= expected(Ps[i - K])
    est += expected(Ps[i])
    max_est = max(max_est, est)
print(max_est)



Measured memory_bytes: 77448
#pragma GCC optmize(3)
#include <cstdio>
#include <iostream>
#include <cstring>
#include <ctime>
#define rus register unsigned short
#define rs register short
using namespace std;

const int N = 15;

int G[N][N], dp[N][1 << N], cost[N][1 << N];
int n, m;

inline void upd(int &x, int y) {
  if (x == -1) x = y;
  else x = min(x, y);
}

inline int set_set(int x, int y) {
  int ret = 0;
  for (rs i = 0; i < n; i ++)
    if (x & (1 << i)) ret += cost[i][y];
  return ret;
}

int main() {
  memset(dp, -1, sizeof dp);
  scanf("%d%d", &n, &m);
  for (int i = 1, x, y, z; i <= m; i ++) {
    scanf("%d%d%d", &x, &y, &z);
    x --; y --;
    G[x][y] = G[y][x] = z;
  }
  int t = 1 << n;
  for (rus s = 1; s < t; s ++)
    for (rs i = 0; i < n; i ++)
      if (s & (1 << i)) {
	for (rs j = 0; j < n; j ++) cost[j][s] += G[i][j];
      }
  dp[0][1] = 0;
  for (rus s = 1; s < t; s += 2) {
    rus u = s ^ (t - 1);
    for (rs i = 0; i < n; i ++)
      if (s & (1 << i)) {
	if (dp[i][s] == -1) continue;
	for (rs j = 0; j < n; j ++)
	  if (!(s & (1 << j)) && G[i][j]) upd(dp[j][s | (1 << j)], dp[i][s] + cost[j][s ^ (1 << i)]);
	for (rus v = u; v; v = (v - 1) & u)
	  upd(dp[i][v | s], dp[i][s] + set_set(v, s ^ (1 << i)));
      }
  }
  printf("%d\n", dp[n - 1][t - 1]);
  return 0;
}


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

using ll = long long;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SIZE(a) ((int)(a).size())

const int mod = 998244353;

inline int add(int &x, int y) {
	x += y;
	if (x >= mod) x -= mod;
}

map<string,int> memo;

int calc(const string& s) {
	if (memo.count(s)) return memo[s];
	int n = SIZE(s);
	int f[n][n], g[n][n];
	memset(f, 0, sizeof f);
	memset(g, 0, sizeof g);
	REP(i, n) f[i][i] = g[i][i] = 1 + (s[i]=='1');
	for (int len = 2; len <= n; ++len) {
		REP(i, n) {
			int j = i + len - 1;
			if (j >= n) break;
			for (int l = 1; l < len; ++l) {
				if (len % l) continue;
				string now;
				REP(iter, l) now += s[i + iter];
				REP(iter, len) if (now[iter % l] == '1' && s[i + iter] == '0') now[iter % l] = '0';
				add(g[i][j], calc(now));
			}
			f[i][j] = g[i][j];
			for (int m = i; m < j; ++m) {
				f[i][j] = (f[i][j] + 1LL*g[i][m]*f[m+1][j]) % mod;
			}
		}
	}
	return memo[s] = f[0][n-1];
}

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

	string s;
	cin >> s;
	cout << calc(s) << '\n';

	return 0;
}

Measured memory_bytes: 1536
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let 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 solve(a: i32, b: i32, op: char) -> i32{
    match op {
        '+' => a + b,
        '-' => a - b,
        _ => panic!()
    }
}

fn main() {
    input!{
        a: i32,
        op: chars,
        b: i32,
    }
    println!("{}", solve(a, b, op[0]));
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;

int N;
int K;
char D[9+2] = {0};
int  d[9+2] = {0};
vector<int> vd; //嫌いな数字ではない数字

int getNDigit(int x){
	if(x == 0) return 1;
	int u = x;
	int ret = 0;
	while(u > 0){
		ret++;
		u /= 10;
	}
	return ret;
}

//右からn桁目の数字を返す
int getRDigit(int x, int n){
	int u = x;
	int ret = 0;
	for(int i=0; i<n; i++){
		ret = u % 10;
		u = u / 10;
	}
	return ret;
}

//xの各桁がvで構成されている場合に、各桁がvで構成されている次の数を返す
int getNextNumber(vector<int>v, int x){
	int ndx = getNDigit(x);
	int ret = 0, MAX= 0;
	int max = v[v.size()-1];
	for(int i=0; i<ndx; i++){
		MAX += max * ((int)pow(10, i)) ;
	}
	if(x == MAX){
		int c = v[0];
		if(v[0] == 0){
			c = v[1];
		}
		ret = c * ((int)pow(10, ndx));
		for(int i=0; i<ndx; i++){
			ret += v[0] * ((int)pow(10, i));
		}
	}
	for(int i=1; i<=ndx; i++){
		int c = getRDigit(x, i);
		int C = 0;
		if(c == v[v.size()-1]){
			//桁上がり処理
			if(v.size() > 1){
				x = x - (c - v[0]) * ((int)pow(10, i-1));
			}
			continue;
		}
		else{
			for(int j=0; j<v.size()-1; j++){
				if(c == v[j]){
					C = v[j+1];
					break;
				}
			}
			ret = x + (C - c) * ((int)pow(10, i-1));
			break;
		}
	}
	return ret;
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N >> K;
	for(int i=1; i<=K; i++){
		char c;
		char s[2] = {0};
		cin >> c;
		s[0] = c;
		D[i] = c;
		d[i] = atoi(s);
	}
	for(int i=0; i<=9; i++){
		int exist = 0;
		for(int j=1; j<=K; j++){
			if(i == d[j]){ exist = 1; }
		}
		if(exist == 0){ vd.push_back(i); }
	}
	sort(vd.begin(), vd.end());
	int nd = getNDigit(N);
	int min = 0;
	for(int i=0; i<nd; i++){
		int c = vd[0];
		if(i == nd - 1 && c == 0){
				c = vd[1];
		}
		min += c * ((int)pow(10, i));
	}
	int ans = min;
	while(ans < N){
		ans = getNextNumber(vd, ans);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 4040
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int l[n];
    int ans=0;
    for(int i=0;i<n;i++)cin >> l[i];
    sort(l,l+n);
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            for(int k=j+1;k<n;k++){
                if((l[i]+l[j]>l[k]) && (l[i]!=l[j]) && (l[j]!=l[k]))ans++;
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 3636
//===================================================================================
//!
//!  @file   
//!  @brief  
//!
//!  @author Katsuya Kikuchi
//!
//===================================================================================

#include <iostream>
#include <algorithm>

using namespace std;
typedef long long int ll;

#define REP(i,n) for(ll i=0;i<(ll)n;++i)

ll I[200005];

int main()
{
	int A, B;
	cin >> A >> B;
	cout << std::max(A + B, std::max(A - B, A*B)) << endl;
	return 0;
}

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

struct Node{
    int key;
    Node *right,*left,*parent;
};

Node *root,*NIL;

void insert(int k){
    Node *y=NIL;
    Node *x=root;
    Node *z;

    z=(Node *)malloc(sizeof(Node));
    z->key=k;
    z->left=NIL;
    z->right=NIL;
    
    while(x!=NIL){
        y=x;
        if(z->key < x->key){
            x = x->left;
        } else {
            x = x->right;
        }
    }
    z->parent = y;
    if ( y == NIL ){
        root =z;
    } else {
        if (z ->key < y->key ){
            y->left = z;
        } else {
            y->right = z;
            }
        }
    }

void inorder(Node *u) {
    if ( u == NIL ) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u){
    if (u == NIL ) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(){
    int n, i, x;
    string com;
    scanf("%d", &n);

    for ( i = 0; i < n; i++ ){
        cin >>com;
        if ( com == "insert" ){
            scanf("%d", &x);
            insert(x);
        } else if ( com == "print" ) {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
        }

        return 0;
    }



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

int main(void) {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> v(N + 1);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    v[b].push_back(a);
  }
  bool flag = false;
  for (auto e : v[N]) {
    if (find(v[e].begin(), v[e].end(), 1) != v[e].end()) {
      flag = true;
      break;
    }
  }

  cout << (flag ? "POSSIBLE" : "IMPOSSIBLE") << endl;

  return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int>p(N);
    for(int i = 0; i < N; i++) {
        cin >> p[i];
    }
    int ans = 0;
    for(int i = 0; i < N; i++) {
        if(p[i] == i+1) {
            swap(p[i],p[i+1]);
            ans++;
        }
    }
    cout << ans << endl;
}


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

using namespace std;

# define REP(i, a, b) for(int i = a; i <= b; ++ i)
# define CLR(i, a) memset(i, a, sizeof(i))
# define REPD(i, a, b) for(int i = a; i >= b; -- i)
# define REPG(i, h, x) for(int i = h[x], v; ~i; i = edge[i].next)

const int N = 1e5 + 5;

int n, k;
int head[N], cnt, a[N], dep[N], mxdep[N];
struct qwq { int v, next; } edge[N << 1];
inline void add(int u, int v) { edge[++ cnt] = (qwq) { v, head[u] }, head[u] = cnt; }

int f[N], ans;

void dfs(int x, int fa) {
	f[x] = 1;
	REPG(i, head, x) if((v = edge[i].v) != fa) {
		dfs(v, x), f[x] = max(f[v] + 1, f[x]);
	}
	if(f[x] == k && fa != 1 && x != 1) { ++ ans, f[x] = 0; }
}

int main() {
	CLR(head, -1);
	scanf("%d%d", &n, &k);
	REP(i, 1, n) scanf("%d", &a[i]);
	REP(i, 2, n) add(a[i], i);
	dfs(1, 0);
	if(a[1] != 1) ++ ans;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 6912
use std::cmp::max;
use std::cmp::min;
use std::io::stdin;

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let n: i64 = s.trim().parse().unwrap();
    s.clear();
    stdin().read_line(&mut s).ok();
    let k: i64 = s.trim().parse().unwrap();
    s.clear();
    stdin().read_line(&mut s).ok();
    let x: i64 = s.trim().parse().unwrap();
    s.clear();
    stdin().read_line(&mut s).ok();
    let y: i64 = s.trim().parse().unwrap();

    println!("{}", min(k, n) * x + max(0, n - k) * y);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007

using namespace std;

long long N;
long long P[20005];
long long A[20005];
long long B[20005];


int main(){
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> P[i];
		P[i]--;
	}

	for(int i = 0; i < N; i++){
		A[i] = (i+1) * 20005;
		B[i] = (N +1- i)*20005;
	}

	for(int i = 0; i < N; i++){
		B[P[i]] += i;
	}


	/*
	for(int i = 0; i < N; i++){
		cout << A[P[i]] + B[P[i]] << endl;
		//cout << "A[" << i << "]=" << A[i] << endl;
	}
	*/

	/*
	for(int i = 0; i < N; i++){
		cout << "B[" << i << "]=" << B[i] << endl;
	}
	*/



	for(int i = 0; i < N; i++){
		if(i != N-1){
			cout << A[i] << " ";
		}else{
			cout << A[i] << endl;;
		}
	}
	for(int i = 0; i < N; i++){
		if(i != N-1){
			cout << B[i] << " ";
		}else{
			cout << B[i] << endl;;
		}
	}
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

const int INF = 1e9;
vecveci dist(210,veci(210,INF));

int main() {
    int N,M,R; cin >> N >> M >> R;

    vector<int> ri(R);
    REP(i,R) {
        cin >> ri[i];
        ri[i]--;
    }
    
    REP(i,M) {
        int a,b,c; cin >> a >> b >> c;
        a--; b--;
        dist[a][b] = min(dist[a][b],c);
        dist[b][a] = min(dist[b][a],c);
    }

    REP(k,N) REP(i,N) REP(j,N) dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j]);

    int ans = INF;

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

    do{
        int total = 0;
        REP(i,R-1) {
            total += dist[ri[i]][ri[i+1]];
        }
        chmin(ans,total);
    }while(next_permutation(ri.begin(),ri.end()));

    cout << ans << endl;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 2000000000000099;

ll BF(ll s,vector<vector<ll>>& v ,ll V){//Vは頂点の数
  vector<ll> d(V,INF);
  d[s]=0;
  ll cnt=0,pofv;
  bool update=false;

  while(1){
    update=false;
    for(int i=0;i < (ll)v.size();i++)
    {
      for(int j=0;j < (ll)v.size();j++)
      {
        //d[i]<INFにより、始点から順番に進んでいっていることになる
        if(v[i][j]<INF && d[i] < INF/*更新済みか */ && d[j]> d[i]+v[i][j]){
          update=true;
          d[j]=d[i]+v[i][j];
        }
      }
    }
    if(!update)break;
    cnt++;
    //cout<<cnt<<endl;

    if(V-1==cnt){
      pofv=d[V-1];
    }else if(2*V==cnt){
      if(d[V-1]!=pofv){
        return INF;
      }else{
        return d[V-1];
      }
    }
  }

  return d[V-1];
}


signed main(){
  ll n,m;cin>>n>>m;
  vector<vector<ll>> G(n,vector<ll>(n,INF));

  for(int i=0;i < m;i++)
  {
    ll a,b,c;cin>>a>>b>>c;
    G[a-1][b-1]=-c;
  }

  ll ans=-BF(0,G,n);

  if(ans==-INF)cout<<"inf"<<endl;
  else cout<<ans<<endl;
}

Measured memory_bytes: 8064
#include<iostream>
using namespace std;
#define M 1000000
#define NIL -1
struct N{ int p,cl,sr;};
N nd[M];
int de[M];

void print(int x){
  int i,j;
  cout<<"node "<<x<<": parent = "<<nd[x].p<<", depth = ";
  cout<<de[x]<<", ";
  if(nd[x].p==NIL)cout<<"root, [";
  else if(nd[x].cl==NIL)cout<<"leaf, [";
  else cout<<"internal node, [";
  
  if(nd[x].cl!=NIL){
    cout<<nd[x].cl;
    j=nd[x].cl;
    while(nd[j].sr!=NIL){
      cout<<", ";
      cout<<nd[j].sr;
      j=nd[j].sr;
    }
  }
  cout<<"]"<<endl;
}

void cde(int x,int p){
  de[x]=p;
  if(nd[x].cl!=NIL)cde(nd[x].cl,p+1);
  if(nd[x].sr!=NIL)cde(nd[x].sr,p);
}

int main(){
  int i,j,n,id,k,c,m;
  cin>>n;
  for(i=0;i<n;i++)nd[i].p=nd[i].cl=nd[i].sr=NIL;

  for(i=0;i<n;i++){
    cin>>id>>k;
    for(j=0;j<k;j++){
      cin>>c;
      if(j==0)nd[id].cl=c;
      else nd[m].sr=c;
      m=c;
      nd[c].p=id;
    }
  }
  for(i=0;i<n;i++){
    if(nd[i].p==NIL)m=i;
  }
  cde(m,0);
  for(i=0;i<n;i++)print(i);

  return 0;
}



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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1e9+7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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

template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
///////////////////////////////////////////////
/*(._.)*/
int main(){
	double dom = 0;
	int N; cin >> N;
	REP(i,N){
	    double a; cin >> a;
	    dom += (1/a);
	}

	cout << 1/dom << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define mod 1000000007
#define pb push_back
#define pob pop_back
#define N 200005
using namespace std;

ll n,dizi[N],dizi1[N],m,x,y,ans;
ll t[4*N];
ll query(ll v,ll l,ll r,ll tl,ll tr){
	if(l>r){
		return 0;
	}
	if(l==tl && r==tr){
		return t[v];
	}
	ll tm=(tl+tr)/2;
	return max(  query( 2*v, l, min( r, tm ), tl, tm ), query( 2*v+1, max( l, tm+1 ), r, tm+1, tr )   );
}
void update(ll v,ll tl,ll tr,ll indis,ll deger){
	// prllf("%d\n", v);
	if(tl==tr){
		t[v]=deger;
		return ;
	}
	ll tm=(tl+tr)/2;
	if(indis<=tm){
		update( v*2, tl, tm, indis, deger );
	}
	else{
		update( v*2+1, tm+1, tr, indis, deger );
	}
	t[v]=max( t[v*2], t[v*2+1] );
}

int main(){
	// freopen("a.gir","r",stdin);
	// freopen("a.cik","w",stdout);
	scanf("%lld",&n);
	for(ll i=0;i<n;i++){
		scanf("%lld",&dizi[i]);
	}
	for(ll i=0;i<n;i++){
		scanf("%lld",&dizi1[i]);
	}
	for(ll i=(n-1);i>=0;i--){
		m=query(1,dizi[i],n,1,n);
		update(1,1,n,dizi[i],m+dizi1[i]);
	}
	printf("%lld\n", query(1,1,n,1,n));
}

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

int main(){
  int n;
  string s;
  cin>>n>>s;
  int ans=0;
  for(int i=0;i<n;i++){
    set<char> a,b;
    int anss=0;
    for(int j=0;j<i;j++)a.insert(s[j]);
    for(int j=i;j<n;j++)if(a.count(s[j])&&!b.count(s[j]))anss++,b.insert(s[j]);
    ans=max(ans,anss);
  }
  cout<<ans<<endl;
  return 0;
}


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

int main()
{
	int n, m;
	std::vector<std::vector<int> > S;
	std::vector<int> P;
	std::cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		int k;
		std::vector<int> r;
		std::cin >> k;
		for (int j = 0; j < k; j++)
		{
			int s;
			std::cin >> s;
			--s;
			r.push_back(s);
		}
		S.push_back(r);
	}
	for (int i = 0; i < m; i++)
	{
		int p;
		std::cin >> p;
		P.push_back(p);
	}
	long long ans = 0;
	for (int bit = 0; bit < (1 << n); bit++)
	{
		bool flag = true;
		for (int i = 0; i < m; i++)
		{
			int con = 0;
			for (int v = 0; v < S.at(i).size(); v++)
			{
				if (bit & (1 << S.at(i).at(v)))
					++con;
			}
			if (con % 2 != P.at(i))
			{
				flag = false;
				break;
			}
		}
		if (flag)
			++ans;
	}
	std::cout << ans << '\n';

}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
long int k=0,i;
string s;
cin>>s;
for(i=0;i<s.size();i++)
{
	if(i%2==0)
	{
		if(s[i]=='L')
			{
				k=1;
				break;}
				}
	else
	{
		if(s[i]=='R')			
    {k=1;
    break;}
    }
    }
    if(k==1)
    cout<<"No";
    else
    cout<<"Yes";
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  
  if (A + B < C + D) {
    cout << "Right" << endl;
  }
  
  if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
}  

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

using namespace std;

const int C = 36;

int main(){
    int N, M, Q;
    while(cin >> N >> M >> Q && N > 0) {
        bitset<C> sw;
        vector<bitset<C>> state(M);
        REP(i, M) REP(j, N) state[i][j] = true; // all true
        REP(_, Q) {
            bitset<C> ope;
            string s;
            cin >> s;
            REP(i, N) ope[i] = (s[i] == '1');
            sw ^= ope;

            string t;
            cin >> t;
            REP(i, M) {
                if(t[i] == '1') {
                    state[i] &= sw;
                } else {
                    state[i] &= ~sw;
                }
            }
        }

        REP(i, M) {
            if(state[i].count() == 1) {
                REP(j, N) if(state[i][j]) {
                    cout << (char)(j < 10 ? '0' + j : 'A' + (j - 10));
                }
            } else {
                cout << '?';
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1216
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String... args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        String s = reader.readLine();
        String[] NM = s.split("\\s+");
        int N = Integer.parseInt(NM[0]);
        int M = Integer.parseInt(NM[1]);

        int bitset = 0;
        for (int i = 1; i <= M; i++) bitset |= 1 << i;

        for (int i = 0; i < N; i++) {
            int bits = 0;
            String[] split = reader.readLine().split("\\s+");
            for (int r = 1; r < split.length; r++) {
                String num = split[r];
                bits |= 1 << Integer.parseInt(num);
            }
            bitset &= bits;
        }

        bitset = (bitset & 0x55555555) + ((bitset & 0xAAAAAAAA) >>> 1);
        bitset = (bitset & 0x33333333) + ((bitset & 0xCCCCCCCC) >>> 2);
        bitset = (bitset & 0x0F0F0F0F) + ((bitset & 0xF0F0F0F0) >>> 4);
        bitset = (bitset & 0x00FF00FF) + ((bitset & 0xFF00FF00) >>> 8);
        bitset = (bitset & 0x0000FFFF) + ((bitset & 0xFFFF0000) >>> 16);
        System.out.println(bitset);
    }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	ll a[114514];
	cin>>n>>m;
	ll sum[114514];
	sum[0]=0;
	REP(i, n){
		cin>>a[i];
		sum[i+1]=(sum[i]+a[i])%m;
	}
	sort(sum, sum+n+1);
	ll cnt=1;
	ll ans=0;
	REP(i, n){
		if(sum[i+1]==sum[i]){
			++cnt;
		}
		else{
			ans+=cnt*(cnt-1)/2;
			cnt=1;
		}
	}
	ans+=cnt*(cnt-1)/2;
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String[] s = sc.next().split("");
        String[] t = sc.next().split("");
        boolean b = true;
        ArrayList<String> S = new ArrayList<>();
        ArrayList<String> T = new ArrayList<>();
        for (int i=0;i<s.length&&b;i++){
            if (!S.contains(s[i])){
                S.add(s[i]);
            }
            s[i] = Integer.toString(S.indexOf(s[i]));
            if (!T.contains(t[i])){
                T.add(t[i]);
            }
            t[i] = Integer.toString(T.indexOf(t[i]));
            if (!s[i].equals(t[i]))b=false;
        }

        if (b){
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 66764
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
n=int(input())
p=num2alpha(n)
p=p.lower()
print(str(p))

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

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

template<typename A, typename B>
multimap<B, A, greater<int>> flip_map(const map<A, B> &src)
{
  multimap<B, A, greater<int>> dst;
  transform(src.begin(), src.end(), inserter(dst, dst.begin()), flip_pair<A, B>);
  return dst;
}

int main()
{
  int n;
  cin >> n;
  
  string pollName;
  map<string, int> poll;
  for (int i = 0; i < n; i ++)
  {
    cin >> pollName;
    auto it = poll.find(pollName);
    if (it != poll.end()) it->second ++;
    else poll[pollName] = 1;
  }

  multimap<int, string, greater<int>> flip_poll = flip_map(poll);
  
  int numPoll;
  for (auto it = flip_poll.begin(); it != flip_poll.end(); it ++)
  {
    if (it->first < numPoll) break;
    cout << it->second << endl;
    numPoll = it->first;
  }
  
  return 0;
}


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

#include <iostream>

long long func(long long first_piece,long long h, long long w){
    if(h <= 1) return 1e9;
    long long small = (h/2) * w;
    long long large = (h+1) / 2 * w;
    return std::max(first_piece, large) - std::min(first_piece, small);
}

class CChocolateBar {
public:
    void solve(std::istream& in, std::ostream& out) {
        long long h, w;
        in >> h >> w;
        long long ans = 1e9;
        for(int i = 1; i < h; i++){
            ans = std::min(ans, func(w*i, h-i, w));
            ans = std::min(ans, func(w*i, w, h-i));
        }
        for(int i = 1; i < w; i++){
            ans = std::min(ans, func(h*i, w-i, h));
            ans = std::min(ans, func(h*i, h, w-i));
        }
        out << ans << std::endl;
    }
};


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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) long long((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;

int main(){
    int n,m; cin>>n>>m;
    priority_queue<int> a;
    for(int i=0; i<n; i++){
        int tmp; cin>>tmp;
        a.push(tmp);
    }
    for(int i=0; i<m; i++){
        int x = a.top();
        a.pop();
        x /= 2;
        a.push(x);
    }
    ll ans = 0;
    for(int i=0; i<n; i++){
        ans += a.top();
        a.pop();
    }
    OUT(ans);
}


Measured memory_bytes: 892
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] bl = new int[4];
		
		while(sc.hasNext()){
			String s = sc.next();
			int i=0;
			while(s.substring(i,i+1).compareTo(",")!=0)i++;		
			String t = s.substring(i+1,s.length());
			if(t.compareTo("A")==0)bl[0]++;
			if(t.compareTo("B")==0)bl[1]++;
			if(t.compareTo("AB")==0)bl[2]++;
			if(t.compareTo("O")==0)bl[3]++;
		}
		for(int i=0;i<4;i++){
			System.out.println(bl[i]);
		}
	}
}

Measured memory_bytes: 17144
#include <iostream>
#include <string>

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

    std::string t;
    std::string p;
    std::cin >> t;
    std::cin >> p;
    int pl = p.length();
    int tl = t.length();
    for(int i = 0; i < tl;){
        bool ok = true;
        for(int j = pl - 1; j >= 0; --j){
            if(t[i+j] != p[j]){
                ok = false;
                break;
            }
        }
        if(ok){
            std::cout << i << "\n";
        }
        char x = t[i + pl - 1];
        int count = 1;
        for(int j = pl - 2; j >= 0; --j){
            if( p[j] == x) break;
            count++;
        }
        i += count;
    }
    return 0;
}



Measured memory_bytes: 3228
#include <algorithm>
#include <iostream>
#include <vector>

#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using ll = long long;
using namespace std;

#define INF_INT 1001001001
// Edu DP -A
int main() {
    int n;
    cin >> n;
    vector<int> height(n);
    rep(i, 0, n) { cin >> height[i]; }

    vector<int> cost(n, INF_INT);
    cost[0] = 0;
    rep(i, 1, n) {
        int val = cost[i - 1] + abs(height[i] - height[i - 1]);
        if (i >= 2) val = min(val, cost[i - 2] + abs(height[i] - height[i - 2]));
        cost[i] = val;
    }

    cout << cost[n - 1] << endl;

    return 0;
}


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

int main () {
  int N;
  cin >> N;
  vector<int> dia(N + 1);
  for (int i = 0; i < N; i++)
    cin >> dia.at(i);
  dia.at(N) = 0;
  
  for (int i = 0; i < N; i++) {
     for (int j = i; j < N; j++) {
       if (dia.at(i) < dia.at(j)) {
         int x;
         x = dia.at(i);
         dia.at(i) = dia.at(j);
         dia.at(j) = x;
       }
     }
  }
  
  int pile = 0;
  for (int i = 0; i < N; i++) {
    if (dia.at(i) > dia.at(i + 1))
      pile++;         
  }
  
  cout << pile << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	int n,k;
	cin>>n>>k;
	vector<int> v(n);
	for(int &x: v)cin>>x;
	sort(v.begin(),v.end());
	int ans=0;
	for(int i=0;i<k;i++)ans+=v[i];
	cout<<ans<<'\n';
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//ユークリッドの互除法
//最大公約数
ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

//最小公倍数
ll lcm(ll x, ll y){
	ll g = gcd(x,y);
	return x/g*y;
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}
int main() {
    int n;cin>>n;
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    int cnt = 0;
    rep(i,n){
        if(v[i]!=i+1)cnt++;
    }
    if(cnt<=2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, m;
vector <int> a[N];
bool vis[N] = {0};
int tr[N] = {0};

int main() {
    //freopen("013B.txt", "r", stdin);
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= m; i++) {
        int x, y; scanf("%d %d", &x, &y);
        a[x].push_back(y);
        a[y].push_back(x);
    }
    queue <int> q;
    q.push(1);
    int boss;
    while (q.size()) {
        int u = q.front(); q.pop();
        vis[u] = true;
        for (int i = 0; i < a[u].size(); i++) {
            int v = a[u][i];
            if (!vis[v]) {
                q.push(v);
                boss = v;
                tr[v] = u;
                break;
            }
        }
    }
    q.push(1);
    while (q.size()) {
        int u = q.front(); q.pop();
        vis[u] = true;
        for (int i = 0; i < a[u].size(); i++) {
            int v = a[u][i];
            if (!vis[v]) {
                q.push(v);
                tr[u] = v;
                break;
            }
        }
    }
    vector <int> res;
    while (boss) {
        res.push_back(boss);
        boss = tr[boss];
    }
    cout << res.size() << endl;
    for (int i = 0; i < res.size(); i++) cout << res[i] << " ";
}


Measured memory_bytes: 7288
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef  double ld;
#define A 1000000007ll
#define D 100000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n" 

int main() 
{
    FAST;
    ll a,b,n;
    cin>>a>>b>>n;
    ll ans=(a*min(b-1,n))/b;
    cout<<ans;
    subt;
    return 0;
}

Measured memory_bytes: 3804
//
//  main.cpp
//  atcoder
//
//  Created by cfhaiteeh on 11/03/2018.
//  Copyright © 2018 cfhaiteeh. All rights reserved.
//

#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
char ch[4][4];
int ai[123456];
  int ci[6];
int main() {
    for(int i=10000;i<=99999;i++){
      
        int st=0;
        int t=i;
        while(t>0){
            int p=t%10;
            t=t/10;
            ci[++st]=p;
        }
        bool flag=1;
        for(int j=1;j<=2;j++){
            if(ci[j]==ci[5-j+1]){
                continue;
            }
            flag=0;
            break;
        }
        if(flag)ai[i]=1;
    }
    for(int i=10000;i<=99999;i++)ai[i]+=ai[i-1];
    int l,r;
    while(scanf("%d%d",&l,&r)!=EOF){
        printf("%d\n",ai[r]-ai[l-1]);
    }
    return 0;
}


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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


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

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const int INF = 100000000;


int main() {

    
    int N, M;
    cin >> N >> M;
    vector<int> k(M);
    vector<int> sw(N);
    vector<vector<int>> s(M);
    vector<int> p(M);
    int ans = 0;
    REP(i, M){
        cin >> k[i];
        REP(j, k[i]){
            int tmp;
            cin >> tmp;
            s[i].push_back(tmp-1);
        }
    }
    REP(i, M){
        cin >> p[i];
    }
    int flag=0;

    for (int bit = 0; bit < (1<<N); ++bit) {
        fill(sw.begin(), sw.end(), 0);
        flag = 0;
        for (int i = 0; i < N; ++i) {
            if (bit & (1<<i)) { // 列挙に i が含まれるか
                sw[i] = 1;
            }
        }
        REP(i, M){
            int count = 0;
            REP(j, k[i]){
                if(sw[s[i][j]] == 1)count++;
            }
            if(count % 2 != p[i]){
                flag = 1;
                break;
            }
        }
        if(flag==0) ans++;

    }

    cout << ans << endl;
    
    

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


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

int main()
{
	//freopen("in","r",stdin);
	string S,T;
	cin>>S>>T;

	size_t found= T.find(S); 
	if(found!=string::npos && T.size()==S.size()+1&& S[0]==T[0])
		cout<<"Yes";
	else 
		cout<<"No";

	return 0;
}

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

ll gcd(ll a, ll b) {
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll fac(ll x) {
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll npr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

int main() {
	ll n,a,b; cin >> n >> a >> b;
	if(a>b) swap(a,b);
	if((b-a)%2==0) {
		cout << (b-a)/2 << endl;
		return 0;
	}
	if(a-1<n-b) cout << a+(b-a-1)/2;
	else        cout << n-b+1+(b-a-1)/2;
	cout << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  string s;
  int d[26] = {0};
  cin >> s;
  int offset = 'a';
  for (int i = 0; i < s.size(); i++) {
    int j = s[i] - offset;
    d[j]++;
  }
  bool ok = false;
  for (int i = 0; i < 26; i++) {
    if (d[i] == 0) {
      char c = (char)(i + offset);
      cout << c << endl;
      ok = true;
      break;
    }
  }
  if (!ok) {
    cout << "None" << endl;
  }
  return 0;
}


Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007

#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 pb push_back

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<vi> vvi;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
ll inv[10000100];
ll FactorialInv[10000100];
ll Factorial[10000100];

ll mymod(ll a,ll b){
    a%=MOD;
    ll result=1;
    while(b>0){
        if(b&1){
            result=(result*a)%MOD;
        }
        a=(a*a)%MOD;
        b>>=1;
    }
    return result;
    
}
ll modInverse(ll n){
    return mymod(n,MOD-2);
}

void init_combination(){
    const int MAX = 10000002;   //1e6+2
    Factorial[0]=1;
    inv[0]=1;
    for(int i=1;i<=MAX;i++){
        Factorial[i]=(Factorial[i-1]*i)%MOD;
    }
    FactorialInv[MAX]=modInverse(Factorial[MAX]);
    for(int i=MAX-1;i>=0;i--){
        FactorialInv[i]=FactorialInv[i+1]*(i+1)%MOD;
    }
    for(int i=1;i<=MAX;i++){
        inv[i]=(FactorialInv[i]*FactorialInv[i-1])%MOD;
    }
}

ll combination(ll n,ll k){
    if(n==k||k==0){
        return 1;
    }
    if(n<k){
        return 0;
    }
    ll ans=(Factorial[n]*FactorialInv[k])%MOD;
    ans=(ans*FactorialInv[n-k])%MOD;
    return ans;
}


int main(){
    ll n,k;
    cin>>n>>k;
    init_combination();
    ll ans=0;
    for(int i=0;i<=min(k,n-1);i++){
        ll temp=combination(n,i);
        ll num=n-i;
        temp*=combination(n-1,num-1);
        temp%=MOD;
        ans+=temp;
        ans%=MOD;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 234624
#include <cstdio>
int n,a[100005],ok=1,mx,mn,tot;
int main()
{
	scanf("%d",&n);mn=n+1;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
	{
		if(a[i]<mn) mn=a[i],tot=1;else if(mn==a[i]) tot++;
		if(a[i]!=mx&&i>1) ok=0;if(a[i]>mx) mx=a[i];
	}
	if(ok) (mx==n-1||(mx!=n-1&&mx*2<=n))?puts("Yes"):puts("No");
	else (mx!=mn+1||(mx==mn+1&&!(mx>tot&&n-tot>=(mx-tot)*2)))?puts("No"):puts("Yes");
}

Measured memory_bytes: 512
package main

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

var sc = bufio.NewScanner(os.Stdin)

const MaxInt = int(^uint(0) >> 1)

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

func removeDuplicate1(args []bool) []bool {

	results := make([]bool, 0, len(args))
	encountered := map[bool]bool{}
	for _, arg := range args {
		if !encountered[arg] {
			encountered[arg] = true
			results = append(results, arg)
		}
	}
	return results
}

var pubout [][]bool

func perm(head []bool, rest []bool) {
	if len(rest) == 0 {

		pubout = append(pubout, head)

	} else {

		result := removeDuplicate1(rest)

		for _, v := range result {

			restx := make([]bool, len(rest))
			copy(restx, rest)

			for i, x := range restx {
				if x == v {
					restx = append(restx[:i], restx[i+1:]...)
					break
				}
			}

			headx := append(head, v)

			perm(headx, restx)
		}
	}
}

type open struct {
	day  [10]bool
	prof [11]int
}

func main() {
	line := nextLine()

	N, _ := strconv.Atoi(line)

	opens := []open{}

	for i := 0; i < N; i++ {
		line = nextLine()
		cols := strings.Split(line, " ")
		tmp := open{}

		for j, s := range cols {
			n, _ := strconv.ParseBool(s)
			tmp.day[j] = n
		}
		opens = append(opens, tmp)
	}

	for i := 0; i < N; i++ {
		line = nextLine()
		cols := strings.Split(line, " ")

		for j, s := range cols {
			n, _ := strconv.Atoi(s)
			opens[i].prof[j] = n
		}
	}

	max := -MaxInt - 1

	for i := 1; i <= 10; i++ {
		openlength := []bool{}
		for j := 1; j <= 10; j++ {
			if j <= i {
				openlength = append(openlength, true)
			} else {
				openlength = append(openlength, false)
			}
		}
		allopen := []bool{}
		pubout = [][]bool{}
		perm(allopen, openlength)

		for _, dual := range pubout {
			if len(dual) > 0 {
				tmpsum := 0
				for k := 0; k < N; k++ {
					count := 0
					for l := 0; l < 10; l++ {
						if dual[l] && dual[l] == opens[k].day[l] {
							count++
						}
					}
					tmpsum += opens[k].prof[count]
				}
				if tmpsum > max {
					max = tmpsum
				}
			}
		}
	}

	fmt.Println(max)

}

Measured memory_bytes: 1024
n, k = list(map(int, input().split()))
mod = 1000000007
fac = [1]
inv = [1]
for i in range(n * 2):
    fac.append(fac[-1] * (i + 1) % mod)
    inv.append(pow(fac[-1], mod - 2, mod))


def cmb(n, k):
    if k < 0 or k > n:
        return 0
    return ((fac[n] * inv[k]) % mod * inv[n - k]) % mod


ret = 0
for m in range(min(k + 1, n)):
    ret = (ret + (cmb(n, m) * cmb(n - 1, n - m - 1)) % mod) % mod
print(ret)


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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
#define curtime chrono::steady_clock::now().time_since_epoch().count
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m) {
  int ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}

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

void solution() {
  int n;
  cin >> n;
  int mul = 1;
  int has_zero = 0;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x == 0) has_zero = 1;
    v.pb(x);
  }
  if (has_zero == 1) {
    cout << 0 << endl;
    return;
  }
  for (int x : v) {
    if (mul > (int)(1e18) / x) {
      cout << -1 << endl;
      return;
    }
    mul *= x;
    if (mul > 1000000000000000000) {
      cout << -1 << endl;
      return;
    }
  }
  cout << mul << endl;
}

int32_t main() {
  DESYNC;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  solution();
}


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

using namespace std;

int main(){
  int N, M;
  cin >> N >> M;
  
  vector<int> cnt(M, 0);
  for (int i=0; i<N; i++) {
	int Ki;
	cin >> Ki;
	for (int j=0; j<Ki; j++){
	  int Aij;
	  cin >> Aij;
	  cnt.at(Aij - 1) += 1;
	}	
  }

  int ans = 0;
  for (int k=0; k<M; k++) {
	if (cnt.at(k) >= N) {
	  ans += 1;
	}
  }

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

Measured memory_bytes: 256
using System;

class Program
{
	static void Main(string[] args)
	{
		string A = Console.ReadLine();
		string B = Console.ReadLine();

		int N = A.Length;
		int M = B.Length;

		if(N > M)
			Console.WriteLine("GREATER");
		else if(N < M)
			Console.WriteLine("LESS");
		else
		{
			bool flag = true;
			for (int i = 0; i < N; i++)
			{
				if(Convert.ToInt16(A[i]) > Convert.ToInt16(B[i])){
					Console.WriteLine("GREATER");
					flag = false;
					break;
				}
				if (Convert.ToInt16(A[i]) < Convert.ToInt16(B[i]))
				{
					Console.WriteLine("LESS");
					flag = false;
					break;
				}
			}
			if(flag)
			Console.WriteLine("EQUAL");
		}
	}
}


Measured memory_bytes: 11220