akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
// -----------------------------------------------

//
// Macro debug!
//

#[cfg(debug_assertions)]
include!{"./procon/debug.rs"}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($($arg:expr),*) => {};
}

//
// Macro input!
//

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

//
// IteratorExt
//

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}





fn main() {
    input! {
        xs: [usize; 3],
    }
    let mut xs = xs;
    xs.sort();
    let ans = xs[0] + xs[1];
    println!("{}", ans);
}


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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

int sum_digits(int x) {
	int sum = 0;
	while(x) {
		sum += x % 10;
		x /= 10;
	}
	return sum;
}

int main() {
	ios_base::sync_with_stdio(false);

	int n;
	cin >> n;

	int ans = 1 << 30;
	fori(i, 1, n) {
		int b = n - i;
		ans = min(ans, sum_digits(i) + sum_digits(b));
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int n,x,y,ans,vis[maxn];
int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
void print(int x){
    if(x<0)putchar('-'),x=-x;
    if(x>9)print(x/10);
    putchar(x%10+'0');
}
void write(int x){print(x);puts("");}
struct Heavy_Light_Decomposition{
    struct edge{int to,nxt;}e[maxn<<1];int tot,head[maxn];
    int idx,fa[maxn],dfn[maxn],dep[maxn],son[maxn],top[maxn],size[maxn];
    void add(int u,int v){e[++tot].to=v;e[tot].nxt=head[u];head[u]=tot;}
    void insert(int u,int v){add(u,v);add(v,u);}
    void build(int x){
        dep[x]=dep[fa[x]]+1;size[x]=1;int mx=0;
        for(int i=head[x],v=e[i].to;i;i=e[i].nxt,v=e[i].to){
            if(v==fa[x])continue;
            fa[v]=x;build(v);size[x]+=size[v];
            if(size[v]>mx)mx=size[v],son[x]=v;
        }
    }
    void dfs(int x){
        if(!x)return ;dfn[x]=++idx;
        top[x]=son[fa[x]]==x?top[fa[x]]:x;
        dfs(son[x]);
        for(int i=head[x],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
            if(v!=fa[x]&&v!=son[x])dfs(v);
    }
    int query(int u,int v){
        while(top[u]!=top[v]){
            if(dep[top[u]]<dep[top[v]])swap(u,v);
            u=fa[top[u]];
        }if(dep[u]>dep[v])swap(u,v);
        return u;
    }
    int get_dis(int u,int v){return dep[u]+dep[v]-2*dep[query(u,v)];}
}HLD[2];
void init(int S){
    queue<int >q;
    q.push(S);vis[S]=1;
    while(!q.empty()){
        int x=q.front();q.pop();
        for(int i=HLD[0].head[x],v=HLD[0].e[i].to;i;i=HLD[0].e[i].nxt,v=HLD[0].e[i].to)
            if(!vis[v]&&HLD[0].dep[v]<HLD[1].dep[v])vis[v]=1,q.push(v);
    }
}
void solve(){
    for(int x=1;x<=n;x++){
        if(!vis[x])continue;
        ans=max(ans,HLD[1].dep[x]-1);
        for(int i=HLD[0].head[x],v=HLD[0].e[i].to;i;i=HLD[0].e[i].nxt,v=HLD[0].e[i].to)
            if(HLD[1].get_dis(v,x)>2){puts("-1");return ;}
    }write(ans<<1);
}
int main(){
    n=read();x=read();y=read();
    if(x==y){puts("0");return 0;}
    for(int i=1;i<n;i++)HLD[0].insert(read(),read());
    for(int i=1;i<n;i++)HLD[1].insert(read(),read());
    HLD[0].build(x);HLD[0].dfs(x);HLD[1].build(y);HLD[1].dfs(y);
    init(x);solve();
    return 0;
}

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

const long long INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)

string S, T;
int dp[3100][3100];

int main() {

	cin >> S >> T;
	int ls = S.size();
	int lt = T.size();

	rep1(i, ls + 1) {
		rep1(j, lt + 1) {
			chmax(dp[i][j], dp[i - 1][j]);
			chmax(dp[i][j], dp[i][j - 1]);
			if (S[i - 1] == T[j - 1]) {
				chmax(dp[i][j], dp[i - 1][j - 1] + 1);
			}
		}
	}

	string sna = "";
	int l_ans = dp[ls][lt];

	while (ls > 0 && lt > 0) {
		if (dp[ls][lt] == dp[ls - 1][lt]) ls--;
		else if (dp[ls][lt] == dp[ls][lt - 1]) lt--;
		else {
			sna += S[ls-1];
			ls--; lt--;
		}
	}

	string ans = "";
	rep(i, l_ans) cout << sna[l_ans - 1 - i];
	cout << endl;

}

Measured memory_bytes: 37120
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>

using namespace std;
long long int wari = 1000000007;
const int MAX = 510000;

long long int fac[MAX], finv[MAX], inv[MAX];

long long int twopow(long long int n);
long long int COM(long long int n, long long int k);
void COMinit();

int main(void)
{
    long long int n, a, b, res;
    cin >> n >> a >> b;
    COMinit();
    res = (twopow(n) - 1);
    // cout << res << endl;
    res = res - COM(n, a) - COM(n, b);
    // cout << res << endl;
    res = res % wari;
    // cout << res << endl;
    if (res < 0)
        res += wari;
    cout << res << endl;
    return 0;
}

long long int twopow(long long int n)
{
    if (n == 1)
    {
        return 2;
    }
    else if (n % 2 == 1)
    {
        long long int a;
        a = twopow(n / 2) % wari;
        return (a * a * 2) % wari;
    }
    else
    {
        long long int a;
        a = twopow(n / 2) % wari;
        return (a * a) % wari;
    }
}

void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % wari;
        inv[i] = wari - inv[wari % i] * (wari / i) % wari;
        finv[i] = finv[i - 1] * inv[i] % wari;
    }
}

long long int COM(long long int n, long long int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    long long int res = 1;
    for (int i = 0; i < k; i++)
    {
        res *= (n - i);
        res %= wari;
    }
    return res * (finv[k] % wari) % wari;
}

Measured memory_bytes: 12160
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;

using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	vector<int> l(m), r(m);
	rep(i, m) cin >> l[i] >> r[i];
	sort(l.begin(), l.end());
	sort(r.begin(), r.end());
	if (l[m - 1] <= r[0]) cout << r[0]-l[m-1] + 1 << endl;
	else cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const ll MOD = (ll) 998244353;
const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << setiosflags(ios::fixed);
    int a, b;
    cin >> a >> b;
    cout << max(0, a - b * 2) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
    double x1,x2,y1,y2,sum;
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    sum=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
    printf("%f\n",sqrt(sum));
    return 0;
}

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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
int main(){
	string a,b;
  cin >> a >> b;
  froop1(0,b.length() - 1){
    if(a[i] != b[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define PI 3.14159265358979323
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
lld bin_ (lld A[], lld l ,lld n, lld x)
{
	return (upper_bound(A + l, A + n, x) - (A + l));
}
int main ()
{
	FastIO
	lld n, i;
	cin >> n;
	lld j, c;
	lld A[n];
	set <lld> present;
	foi(i, n)
	{
		cin >> A[i];
		present.insert(A[i]);

	}
		sort(A,A+n);
	c = 0;
	foi(i, n)
	{
		for(j = i+1; j < n; j += 1)
		{
			lld x  = A[i] + A[j];
			if (present.count(x))
				x--;
			c += bin_(A,j+1,n,x);
		}
	}
	cout<< c;
	return 0;
}

Measured memory_bytes: 384
import fractions

A, B, C, D = map(int, input().split())

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def count_multiple(n):
    return (B // n) - ((A - 1) // n)

def count_not_multiple(n):
    return (B - A + 1) - count_multiple(n)

cnm = count_not_multiple
print(cnm(C) + cnm(D) - cnm(lcm(C, D)))


Measured memory_bytes: 5076
#include<stdio.h>
#include<stdlib.h>

int solve(int,int);
int A[20];
int n;

int main(){
  int q;
  int *m;
  int i;
  int jg;

  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  scanf("%d",&q);
  m=(int *)malloc(q*sizeof(int));
  for(i=0;i<q;i++)scanf("%d",&m[i]);
  
  for(i=0;i<q;i++){
  jg=solve(0,m[i]);
  if(jg==1)printf("yes\n");
  else printf("no\n");
  }
  


  return 0;
}


int solve(int i,int m){
  int res;
  if(m==0)return 1;
  if(i>=n)return 0;
  res=solve(i+1,m);
  if(res==0){
  res=solve(i+1,m-A[i]);
  }
  return res;
}



Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
using namespace std;
using ll = long long;

int main(){
    ll a1,b1,a,b,c=0,d=0,e,m,n,k,o=0,p,l,q,x1,y1,z,max1=0,s=0,ans,r,i1=-1,x,w,h,y,j1;
    string t,u;
    
    cin>>a>>b>>c>>d;
    a1=c;
    b1=d;
    while(1) {
    if(a1 < b1) swap(a1, b1);
    if(!b1) break;
    a1 %= b1;
  }
  a1=d*c/a1;
  ans=b-a+1-(b/c-(a-1)/c+b/d-(a-1)/d-b/a1+(a-1)/a1);
    cout<<ans<<endl;
    
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int main(){
	long long int n, k;
	cin >> n >> k;
	COMinit();
	long long int ans = 0;
	if (k >= 200000) {
		k = 200000;
	}
	for (long long int i = 0; i <= k; i++) {
		long long int sum = COM(n, i) * COM(n - 1, i) % MOD;
		ans = ans + sum;
		ans = ans % MOD;
	}
	cout << ans;
}


Measured memory_bytes: 16640
#include <algorithm>
#include <iterator>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <string>
#include <vector>
#include <limits>
#include <queue>
#include <cmath>
#include <map>
#include <set>

using namespace std;

using ll = long long;

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

    vector<int> v(n);

    for(int i = 0; i < n; ++i)
        cin >> v[i];

    --v[0];

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

        if(v[i - 1] == v[i])
            continue;

        --v[i];
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 640
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 200010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n, a[MAXN], cnt[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n) cin >> a[i];
    FOR(i,1,n) cnt[a[i]]++;
    ll res = 0;
    FOR(i,1,n) res += (ll) cnt[i] * (cnt[i] - 1) / 2;
    FOR(i,1,n) {
        int g = a[i];
        cout << res - (cnt[g]-1) << "\n";
    }
    return 0;
}


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

using namespace std;

const int N = 2e5 + 5;
const int INF = -1e9;

int dp[N][3];

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin>>s;
  int length = s.size();
  if(length == 1){
    cout << 1 << endl;
    return 0;
  }
  else if(length == 2){
    if(s[0] == s[1]){
      cout << 1 << endl;
    }
    else{
      cout << 2 << endl;
    }
    return 0;
  }

  dp[0][1] = 1;
  dp[0][2] = INF;
  dp[1][2] = 1;
  dp[2][2] = 2;
  if(s[0] == s[1]){
    dp[1][1] = INF;
  }
  else{
    dp[1][1] = 2;
  }
  if(s[0] != s[1] && s[1] != s[2]){
    dp[2][1] = 3;
  }
  else{
    dp[2][1] = 2;
  }
  for(int i = 3; i < length; ++i){
    if(s[i] == s[i-1]){
      dp[i][1] = 1 + dp[i-1][2];
    }
    else{
      dp[i][1] = 1 + max(dp[i-1][1], dp[i-1][2]);
    }

    if(s[i] == s[i-2] && s[i - 1] == s[i - 3]){
      dp[i][2] = 1 + dp[i-2][1];
    }
    else{
      dp[i][2] = 1 + max(dp[i-2][2], dp[i-2][1]);
    }
  }

  cout << max(dp[length-1][1], dp[length - 1][2]) << endl;
  return 0;
}


Measured memory_bytes: 2964
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <algorithm>
#define repeat_from(i,m,n) for (int i = (m); (i) < (n); ++(i))
#define repeat(i,n) repeat_from(i,0,n)
using namespace std;
struct mobile_t {
    int w; // weight
    double l; // left
    double r; // right
};
const double eps = 0.0001;
double evaluate(vector<int> const & p, double r) {
    stack<mobile_t> stk;
    for (int w : p) {
        if (w == 0) {
            if (stk.size() < 2) return -1;
            mobile_t x = stk.top(); stk.pop();
            mobile_t y = stk.top(); stk.pop();
            mobile_t z;
            z.w = x.w + y.w;
            double dx = y.w /(double) (x.w + y.w);
            double dy = x.w /(double) (x.w + y.w);
            z.l = max(x.l + dx, y.l - dy);
            z.r = max(x.r - dx, y.r + dy);
            if (r + eps < z.r + z.l) return -1;
            stk.push(z);
        } else {
            stk.push((mobile_t){ w, 0.0, 0.0 });
        }
    }
    if (stk.size() != 1) return -1;
    return stk.top().l + stk.top().r;
}
int main() {
    int datasets; cin >> datasets;
    repeat (dataset, datasets) {
        double r; cin >> r;
        int s; cin >> s;
        vector<int> w(s); repeat (i,s) cin >> w[i];
        double result = -1;
        vector<int> p;
        repeat (i,s)   p.push_back(w[i]);
        repeat (i,s-1) p.push_back(0);
        sort(p.begin(), p.end());
        do {
            result = max(result, evaluate(p, r));
        } while (next_permutation(p.begin(), p.end()));
        if (result == -1) {
            printf("-1\n");
        } else {
            printf("%.16lf\n", result);
        }
    }
    return 0;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    for (int i=0;i<N;i++) {
        cin >> A.at(i);
    }
    int total_vote=accumulate(A.begin(),A.end(),0);
    sort(A.begin(), A.end());
    
    if (A.at(A.size()-M)>=((double)total_vote/(4*M))) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

typedef long long ll;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl

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

	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	if(a>=k)	cout<<k<<endl;
  	else if(a+b>=k)	cout<<a<<endl;
	else	cout<<2*a+b-k<<endl;

    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
const long long MOD = 1e9 + 7, INF = 1e18;
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a=b;return true;}return false;}



signed main(){
	int N,M;
	cin>>N>>M;
	vector<vector<int>>a(N,vector<int>(M));
	REP(i,N)REP(j,M){
		cin>>a[i][j];
		a[i][j]--;
	}
	auto f = [&](int x)->bool{
		vector<int>ng(M,0);
		REP(_,M){
			vector<int>tmp(N,-1);
			vector<int>sum(M,0);
			REP(j,M){
				int flg = 0;
				REP(i,N){
					if(tmp[i]!=-1)continue;
					if(ng[a[i][j]])continue;
					sum[a[i][j]]++;
					tmp[i] = a[i][j];
					if(sum[a[i][j]]>x){
						ng[a[i][j]] = true;
						flg = true;
						break;
					}
				}
				if(flg)break;
			}
			int ok = 1;
			REP(i,N)if(tmp[i]==-1)ok = 0;
			REP(j,M)if(sum[j]>x)ok = 0;
			if(ok)return true;
		}
		return false;
	};
	int l = 0, r = N + 1;
	while(r - l > 1){
		int c = (l + r) / 2;
		if(f(c)) r = c;
		else l = c;
	}
	cout << r << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main() {
    ll n;
    ll v[3];
    cin >> n;
    rep(i, 0, 3) cin >> v[i];
    ll sum = v[0] + v[1] + v[2];
    vector<string> t(n);
    rep(i, 0, n) cin >> t[i];
    vector<char> res;
    rep(i, 0, n) {
        string s = t[i];
        char s0 = s[0] - 'A';
        char s1 = s[1] - 'A';
        if(v[s0] == 0 && v[s1] == 0) {
            cout << "No" << endl;
            return 0;
        } else if (v[s0] == 0) {
            //cerr << "a1" << endl;
            v[s0]++;
            v[s1]--;
            res.push_back(s[0]);
        } else if (v[s1] == 0) {
            //cerr << "a2" << endl;
            v[s0]--;
            v[s1]++;
            res.push_back(s[1]);
        } else if (i == n-1) {
            //cerr << "a3" << endl;
            res.push_back(s[0]);
        } else {
            string next = t[i+1];
            if(v[next[0]-'A'] == 0) {
                //cerr << "a4" << endl;
                if(s[0] == next[1]){
                    v[s0]++;
                    v[s1]--;
                    res.push_back(s[0]);
                } else {
                    v[s0]--;
                    v[s1]++;
                    res.push_back(s[1]);
                }
            } else if (v[next[1]-'A'] == 0) {
                //cerr << "a5" << endl;
                if(s[0] == next[0]){
                    v[s0]++;
                    v[s1]--;
                    res.push_back(s[0]);
                } else {
                    v[s0]--;
                    v[s1]++;
                    res.push_back(s[1]);
                }
            } else {
                //cerr << "a6" << endl;
                if(v[s0] > v[s1]) {
                    v[s0]--;
                    v[s1]++;
                    res.push_back(s[1]);
                } else {
                    v[s0]++;
                    v[s1]--;
                    res.push_back(s[0]);
                }
            }
        }
    }
    cout << "Yes" << endl;
    for(auto e : res) cout << e << endl;
    return 0;
}

Measured memory_bytes: 6728
from sys  import stdin,stdout

import bisect

import math

def st():
    return list(stdin.readline().strip())

def inp():
    return int(stdin.readline())

def li():
    return list(map(int,stdin.readline().split()))

def mp():
    return map(int,stdin.readline().split())

def pr(n):
    stdout.write(str(n)+"\n")

def soe(limit):
    l=[1]*(limit+1)
    prime=[]
    for i in range(2,limit+1):
        if l[i]:
            for j in range(i*i,limit+1,i):
                l[j]=0

    for i in range(2,limit+1):
        if l[i]:
            prime.append(i)
    return prime

def segsoe(low,high):
    limit=int(high**0.5)+1
    prime=soe(limit)
    n=high-low+1
    l=[0]*(n+1)
    for i in range(len(prime)):
        lowlimit=(low//prime[i])*prime[i]
        if lowlimit<low:
            lowlimit+=prime[i]
        if lowlimit==prime[i]:
            lowlimit+=prime[i]
        for j in range(lowlimit,high+1,prime[i]):
            l[j-low]=1
    for i in range(low,high+1):
        if not l[i-low]:
            if i!=1:
                print(i)
                
def gcd(a,b):
    while b:
        a=a%b
        b,a=a,b
    return a

def power(a,n):
    r=1
    while n:
        if n&1:
            r=(r*a)
        a*=a
        n=n>>1
    return r
    
def solve():
    a=list(input())
    b=list(input())
    c=list(input())
    s=a
    while True:
        if len(s)==0:
            print(ans)
            break
                
        x=s.pop(0)
        if x=='a':
            s=a
            ans='A'
        elif x=='b':
            s=b
            ans='B'
        else:
            s=c
            ans='C'
        


for _ in range(1):
    solve()
    


Measured memory_bytes: 9268
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
len_c = len(c)
b = {k:v for k,v in c.items() if v > 1}
sum_b = sum(b.values())
if n == 3:
    print(1)
if (sum_b + len(b)) % 2 == 0:
    print(len_c)
else:
    print(len_c - 1)


Measured memory_bytes: 18656
n,m=map(int,input().split())
h=list(map(int,input().split()))
x=[1]*n
for i in range(m):
    a,b=map(int,input().split())
    if h[a-1]>=h[b-1]:
        x[b-1]=0
    if h[a-1]<=h[b-1]:
        x[a-1]=0
print(sum(x))

Measured memory_bytes: 20100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=998244353,MAX=1<<17;
const ll INF=1LL<<60;

int main(){
    
    int N,K;cin>>N>>K;
    if(N%2==1){
        if(K<=(N+1)/2){
            vector<int> A(N),B(N),C(N);
            for(int i=0;i<N;i++){
                C[i]=K+N+N+i;
            }
            for(int i=N/2;i>=0;i--){
                A[i]=K+(N/2)-i;
            }
            for(int i=N-1;i>N/2;i--){
                A[i]=K+(N+1)/2+N-1-i;
            }
            
            for(int i=0;i<=N/2;i++){
                B[i]=K+N+i*2;
            }
            for(int i=N/2+1;i<N;i++){
                B[i]=K+N+1+(i-N/2-1)*2;
            }
            
            for(int i=0;i<N;i++){
                cout<<A[i]<<" "<<B[i]<<" "<<C[i]<<endl;
            }
        }else cout<<-1<<endl;
    }else{
        if(K<=(N+1)/2){
            vector<int> A(N),B(N),C(N);
            for(int i=0;i<N;i++){
                C[i]=K+N+N+i;
            }
            for(int i=N/2-1;i>=0;i--){
                A[i]=K+(N/2-1)-i;
            }
            for(int i=N-1;i>=N/2;i--){
                A[i]=K+N/2+N-1-i;
            }
            
            for(int i=0;i<N/2;i++){
                B[i]=K+N+i*2;
            }
            for(int i=N/2;i<N;i++){
                B[i]=K+N+1+(i-N/2)*2;
            }
            
            for(int i=0;i<N;i++){
                cout<<A[i]<<" "<<B[i]<<" "<<C[i]<<endl;
            }
        }else cout<<-1<<endl;
    }
    
}




Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
long long int power(int a,int b)
{
    if(b==0)
        return 1;
    long long int k=power(a,b/2);
    if(b%2==0)
        return ((k%M)*(k%M))%M;
    else
        return ((k%M)*(k%M)*(a%M))%M;
}
long long int fact(long long int n)
{
    if(n==1 || n==0)
        return 1;
    else
        return ((n%M)*(fact(n-1)%M))%M;

}
int div(int n)
{  int c=0;
    for(int i=1;i<sqrt(n);i++)
    {
        if(n%i==0)
        {
          c++;
        }
    }
    c=c*2;
    if(pow(sqrt(n),2)==(sqrt(n)*sqrt(n)))
        c++;
    return  c;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
 
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 
   #endif
  int k;
  cin>>k;
  string str;
  cin>>str;
  int l=str.length();
  if(l<=k)
    cout<<str;
else
{
    for(int i=0;i<k;i++)
    {
        cout<<str[i];
    }
    cout<<"...";
}


 return 0;
}








Measured memory_bytes: 3544
#include<iostream>
using namespace std;
int a[1005];
int main(){
  int n,m;
  cin>>n>>m;
  int sum=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
  }
  int l=sum/(4*m);
  if(sum%(4*m)) l++;
  int t=0;
  for(int i=0;i<n;i++){
    if(a[i]>=l) t++;
  }
  if(t>=m) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair <int,int> PII;
typedef pair <ll, ll> PLL;
typedef pair <int,string> PIS;
typedef vector <int> vec;
typedef priority_queue<int> PQ;
#define endl '\n'
#define pi 3.141592653589793
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fori(z,n)  for(int i=z;i<n;i++)
#define fork(z,n)  for(int k=z;k<n;k++)
#define forii(z,n) for(int i=z;i<=n;i++)
#define forkk(z,n) for(int k=z;k<=n;k++)
int maxElement(int arr[],int n)
{
    int maxi=arr[0];
    for(int i=1;i<n;i++)
    {
        if(arr[i]>maxi)
            maxi=arr[i];
    }
    return maxi;
}
int minElement(int arr[],int n)
{
    int mini=arr[0];
    for(int i=1;i<n;i++)
    {
        if(arr[i]<mini)
            mini=arr[i];
    }
    return mini;
}
string trim(const string& str)
{
    size_t first = str.find_first_not_of(' ');
    if (string::npos == first)
    {
        return str;
    }
    int last = str.find_last_not_of(' ');
    return str.substr(first, (last - first + 1));
}
int main() 
{ 
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;cin>>n>>k;
    int arr[n+1];
    fori(1,n+1) cin>>arr[i];
    bool dp[k+1];
    memset(dp,false,sizeof(dp));
    // dp[i] - is true if the first player wins.
    forii(1,k)
    {
        for(int p=1;p<=n;p++)
        {
            if((i-arr[p])>=0 && !dp[i-arr[p]])
                dp[i]=true;
        }
    }
    dp[k]? cout<<"First":cout<<"Second";
    cout<<endl;
    cerr<<"Time elapsed"<<1.0*clock()/CLOCKS_PER_SEC<<"s\n";
    return 0;
}


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


int main(){
  int H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  cout << (H2 - H1) * 60 + (M2 - M1) - K << endl;
  return 0;
}


Measured memory_bytes: 3636
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<map>
#include<tuple>
using namespace std;
#define INF 1LL<<62
#define MAX 1100000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<pair<int,int>,int> p;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
//__builtin_popcount(S)

//https://kyopro-friends.hatenablog.com/entry/2019/01/12/231035

const int MAX_N=420000;

//セグメント木を持つグローバル配列
ll n;
ll dat[2*MAX_N-1];

//初期化
void init(ll n_){
    //簡単のために要素数を2のべき乗に
    n=1;
    while(n<n_) n*=2;

    //全ての値をINT_MAXに
    for(int i=0;i<2*n-1;i++) dat[i]=-1;
}

//k番目の値(0-indexed)をaに変更
void update(int k,ll a){
    //葉の節点
    k+=n-1;
    dat[k]=a;
    //登りながら更新
    while(k>0){
        k=(k-1)/2;
        dat[k]=max(dat[k*2+1],dat[k*2+2]);
    }
}

//[a,b)の最小値を求める
//後ろの方の引数は、計算の簡単のための引数
//ｋは接点の番号、l,rはその接点が[l,r)に対応づいていることを表す
//したがって、外からはquery(a,b,0,0,n)として呼ぶ
ll query(int a,int b,int k,int l,int r){
    //[a,b)と[l,r)が交差しなければ,INT_MAX
    if(r<=a || b<=l) return -1;

    //[a,b)が[l,r)を完全に含んでいれば、この節点の値
    if(a<=l && r<=b) return dat[k];
    else{
        //そうでなければ、２つの子の最小値
        ll vl=query(a,b,k*2+1,l,(l+r)/2);
        ll vr=query(a,b,k*2+2,(l+r)/2,r);
        return max(vl,vr);
    }
}

int main(){
    int N; cin>>N;
    int h[210000];
    ll a[210000];
    init(N);
    for(int i=0;i<N;i++){
        cin>>h[i]; h[i]--;
    } 
    for(int i=0;i<N;i++) cin>>a[i];

    for(int i=0;i<N;i++){
        ll x=query(0,h[i],0,0,n);
        //cout<<i<<" "<<x<<endl;
        if(x<0) x=0;
        update(h[i],x+a[i]);
    }
    cout<<query(0,N+1,0,0,n)<<endl;
}



Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    long long N,K,S;
    cin >> N >> K >> S;
    rep(i,K){
        cout << S << " ";
    }
    rep(i,N-K){
        if(S+1<=1000000000){
            cout << S+1 << " ";
        }else{
            cout << S-1 << " ";
        }
    }
    cout << endl;



}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll a,b,c,d,e,ans=0,n;
constexpr ll INF=99999999999999999;
int main(){
  
  string s;
cin>>s;
  a=0,b=0;
    for(int i=0;s[i]!='\0';i++){
        if(s[i]=='0')a++;
      if(s[i]=='1')b++;
    }

    cout<<2*fminl(a,b)<<endl;
}

Measured memory_bytes: 512
H,W = map(int,input().split())
A = [input() for i in range(H)]
MOD = 10**9+7
dp = [[0]*W for i in range(H)]
dp[0][0] = 1

for i in range(H):
    for j in range(W):
        if i < H-1 and A[i+1][j] == '.':
            dp[i+1][j] += dp[i][j]
            dp[i+1][j] %= MOD
        if j < W-1 and A[i][j+1] == '.':
            dp[i][j+1] += dp[i][j]
            dp[i][j+1] %= MOD
print(dp[-1][-1])

Measured memory_bytes: 43644
import sys
import math
import functools
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

h = ni()
c = 0
s = 1
while h > 1:
    h //= 2
    c += 1
    s += 2 ** c
print(s)


Measured memory_bytes: 3828
S = str(input())
a = [0] * 26

# 数値(1〜26)→アルファベット(A〜Z)
num2alpha = lambda c: chr(c+96)

#num2alpha(3) #==> C 
# アルファベット(A〜Z)→数値(1〜26)
alpha2num = lambda c: ord(c) - ord('a') + 1

#alpha2num('Y') #==> 25 

for i in range(len(S)):
  x = alpha2num(S[i])
  a[x - 1] += 1
  
if min(a) != 0:
  print("None")
else:
  ans = a.index(0)
  print(num2alpha(ans + 1))
  
  

Measured memory_bytes: 9064
#include <stdio.h>

#define black 1
#define white 0
#define gray 2
#define INF -1

void bfs(void);
int dequeue(void);
void enqueue(int);

int num;
int a[110][110];
int di[110];
int color[110];
int data[110];
int total;
int head;

int main(){
  int i,j;
  int elem,in,sum;

  scanf("%d",&num);
  for(i=1;i<=num;i++){
    for(j=1;j<=num;j++) a[i][j]=white; 
  }

  for(i=1;i<=num;i++){
    scanf("%d%d",&elem,&sum);
    for(j=1;j<=sum;j++){
      scanf("%d",&in);
      a[elem][in]=black;
    }
  }
  bfs();
  for(i=1;i<=num;i++) printf("%d %d\n",i,di[i]);
  
  return 0;
}

void bfs(void){
  int i,j,l;
  int k;
  
  for(i=1;i<=num;i++){
      color[i]=white;
      di[i]=INF;
  }
  color[1]=gray;
  di[1]=0;
  enqueue(1);
  
  while(head!=num){
    k=dequeue();
    for(j=1;j<=num;j++){
      if(a[k][j]==black){
	if(color[j]==white){
	  color[j]=gray;
	  di[j]=di[k]+1;
	  enqueue(j);
	}
      }
    }
    color[k]=black;
  }
}

void enqueue(int k){
  data[++total]=k;
}

int dequeue(void){
  return data[++head];
}



Measured memory_bytes: 2072
n,m = gets.chomp.split.map{|i|i = i.to_i}
a=[]
n.times do|i|
  arr = gets.chomp.split.map{|i|i = i.to_i}
	a << [arr[0],arr[1]]
end
#puts "n=#{n}, m=#{m}"
a.sort_by!{|i|i[0]}

#puts "a=#{a}"
drink_num=0
sum_money=0
while drink_num<m do
	if (m-drink_num) < a[0][1] then
		sum_money += (m - drink_num) * a[0][0]
		drink_num += (m - drink_num)
		break
	else
		drink_num += a[0][1]
		sum_money += a[0][1] * a[0][0]
		a.delete_at(0)
	end
	#puts "now a = #{a}, drink_num = #{drink_num}, sum_money = #{sum_money}"
end
#puts "final, drink_num=#{drink_num}, sum_money=#{sum_money}"
puts sum_money


Measured memory_bytes: 12664
#include<cstdio>
#include<cstring>
using namespace std;
#define MAXN 15
#define LL long long
char s[MAXN];
int digit[MAXN];
LL ans,N;
LL Pow(int x)
{
	LL res=1;
	while(x--)
		res*=10;
	return res;
}
int Abs(int x)
{
	if(x>0) return x;
		else return -x;
}
void dfs(int pos,LL sum,LL last)
{
	if(pos>N)
	{
		ans=ans+sum+last;
		return ;
	}
	dfs(pos+1,sum,last*10+digit[pos]);
	dfs(pos+1,sum+last,digit[pos]);
}
int main()
{
	scanf("%s",s+1);
	N=strlen(s+1);
	for(int i=1;i<=N;i++)
		digit[i]=s[i]-'0';
	dfs(2,0,digit[1]);
	//注意第一种情况确定，第一个数前面不能加'+'，第一位一定是第一个加数的第一位
	printf("%lld\n",ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define Fr(i,a,b) for(int i=(a);i<=(int)(b);++i)
#define Dr(i,a,b) for(int i=(a);i>=(int)(b);--i)
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
#define debug(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define bug(x) cout<<#x<<"="<<x<<" "
int n,d,a[15][15];
int main() {
	int cnt=0;
	cin>>n>>d;
	Fr(i,1,n)Fr(j,1,d)cin>>a[i][j];
	Fr(i,1,n){
		Fr(j,i+1,n){
			ll s=0;
			Fr(k,1,d)s+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
			if(s<0)continue;
			if((int)sqrt(s)*(int)sqrt(s)==s)cnt++;
		}
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <typeinfo>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll int,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell   	    1000000007
#define PI 			3.14159265358979323844
#define rep(i,a,b)  for (long long int i=a;i<b;i++)
#define repr(i,a,b) for (long long int i=a-1;i>=b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios         ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//primes for hashing 937,991,1013,1409,1741

using namespace std;
 
void solve() {
	string s;
	cin>>s;
	vi v;
	ll count;
	ll j;
	rep(i,0,s.length()){
		count=0;
		j=i;
		while(j<s.length() && s[i]==s[j]){count++;j++;}
		v.pb(count);
		i+=count-1;
	}
	ll sum=0;
	if (s[0]=='<'){
		if (v.size()%2){v.pb(0);};
		for (ll i=0;i<v.size();i+=2){
			if (v[i]>v[i+1]){
				sum+=(v[i]*(v[i]+1))/2;
				sum+=((v[i+1]-1)*v[i+1])/2;
			}
			else{
				sum+=(v[i+1]*(v[i+1]+1))/2;
				sum+=((v[i]-1)*v[i])/2;
			}
		}
	}
	else{
		sum+=(v[0]*(v[0]+1))/2;
		auto itr=v.begin();
		v.erase(itr);
		if (v.size()%2){v.pb(0);};
		for (ll i=0;i<v.size();i+=2){
			if (v[i]>v[i+1]){
				sum+=(v[i]*(v[i]+1))/2;
				sum+=((v[i+1]-1)*v[i+1])/2;
			}
			else{
				sum+=(v[i+1]*(v[i+1]+1))/2;
				sum+=((v[i]-1)*v[i])/2;
			}
		}
	}
	cout<<sum;
}
 
signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

Measured memory_bytes: 3352
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int i = 1;
    int cnt = 0;
    while (i < n) {
        if (a[i] == a[i-1]) {
            ++cnt;
            i += 2;
        } else {
            i += 1;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
n=int(input())
s=[]
t=[]
for i in range(n):
    li=input().split()
    s.append(li[0])
    y=int(li[1])
    t.append(y)
x=input()
flg=False
ans=0
for j in range(n):
    if flg:
        ans+=t[j]
    if s[j]==x:
        flg=True
print(ans)
        
    
    

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

using namespace std;

ifstream f("input.in");
ofstream g("output.out");

int main(int argc, char **argv)
{
    int n, a, b;
    string str;
    cin>>a>>b;
    cout<<fixed<<setprecision(10)<<(double)a/b<<endl;
    //cout.unsetf(ios::fixed);
    /*
    f>>n>>ws;

    for(int i = 0; i < n; ++i)
    {
        getline(f, str);


    }*/

    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

N, M = map(int, input().split(' '))
heights = (0, *map(int, input().split(' ')))

edges = defaultdict(set)

for _ in range(M):
    A, B = map(int, input().split(' '))
    edges[A].add(B)
    edges[B].add(A)

ans = 0
for i in range(1, N + 1):
    for j in edges[i]:
        if heights[i] <= heights[j]:
            break
    else:
        ans += 1

print(ans)


Measured memory_bytes: 51920
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main()
{
	int N;
	cin >> N;
	int temp = N, cnt = 0;
	while (temp > 0)
	{
		cnt += temp % 10;
		temp /= 10;
	}
	if (N % cnt == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int h,w,s;
int map[32][32];
int all;
pair<int,int> memo[32][32][33][33];

pair<int,int> rec(int y1,int x1,int y2,int x2,int sum){
  pair<int,int> res,hoge1,hoge2;
  int a=1,b=0;
  int tmp;
  bool flag = false;

  if(memo[y1][x1][y2][x2].first>=0)return memo[y1][x1][y2][x2];

  tmp = 0;
  for(int i=x1+1;i<x2;i++){

    for(int j=y1;j<y2;j++)tmp += map[j][i-1];

    if( all-tmp <= s && all-(sum-tmp) <= s){
      flag = true;
      hoge1 = rec(y1,x1,y2,i,tmp);
      hoge2 = rec(y1,i,y2,x2,sum-tmp);
      if(hoge1.first+hoge2.first > a){
	a = hoge1.first + hoge2.first;
	b = max(hoge1.second,hoge2.second);
      }else if(hoge1.first + hoge2.first == a && max(hoge1.second,hoge2.second) < b){
	b = max(hoge1.second,hoge2.second);
      }
    }
  }

  tmp = 0;
  for(int i=y1+1;i<y2;i++){

    for(int j=x1;j<x2;j++)tmp += map[i-1][j];

    if( all-tmp <= s && all-(sum-tmp) <= s){
      flag = true;
      hoge1 = rec(y1,x1,i,x2,tmp);
      hoge2 = rec(i,x1,y2,x2,sum-tmp);
      if(hoge1.first+hoge2.first > a){
	a = hoge1.first + hoge2.first;
	b = max(hoge1.second,hoge2.second);
      }else if(hoge1.first + hoge2.first == a && max(hoge1.second,hoge2.second) < b){
	b = max(hoge1.second,hoge2.second);
      }
    }
  }

  if(!flag){
    res.first = 1;
    res.second = all - sum;
  }else{
    res.first = a;
    res.second = b;
  }
  memo[y1][x1][y2][x2] = res;
  return res;
}


int main(){
  pair<int,int> ans;
  while(1){
    cin >> h >> w >> s;
    if(!h && !w && !s)break;

    all = 0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> map[i][j];
	all += map[i][j];
      }
    }
 
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	for(int k=0;k<=h;k++){
	  for(int l=0;l<=w;l++){
	    memo[i][j][k][l].first = -1;
	    memo[i][j][k][l].second = -1;
	  }
	}
      }
    }

    ans = rec(0,0,h,w,all);
    cout << ans.first << " " << s - ans.second << endl;
  }
}

Measured memory_bytes: 9584
#include <stdio.h>
#include <stdlib.h>
#define int long long

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

signed main(){
	int T, t, A, B, C, D, k, i;
	scanf("%lld", &T);
	for(t = 0; t < T; t++){
		scanf("%lld%lld%lld%lld", &A, &B, &C, &D);
		if(A < B || B > D){
			printf("No\n");
			continue;
		}
		if(C >= B){
			printf("Yes\n");
			continue;
		}
/*		int f = 0;
		for(i = 0; i < 2; i++){
			k = (A - C + B - 1) / B;
			A = A - k * B;
			a[i] = A;
			if(A < 0){
				printf("No\n");
				f = 1;
				break;
			}
			A += D;
		}
		if(f == 1){
			continue;
		}
		if(a[0] == a[1]){
			printf("Yes\n");
		}
		else if(a[0] < a[1]){

		}
		printf("Yes\n");
*/

		int g = GCD(B, D);
		int s1 = (A - B) / g + 1;
		int s2 = (A - C - 1) / g;
		if(s1 <= s2){
			printf("No\n");
		}
		else{
			printf("Yes\n");
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int ac = 0, wa = 0, tle = 0, re = 0;
  for (int i = 0; i < N; i ++) {
    string check = "";
    cin >> check;
    if (check == "AC") {
      ac++;
    }
    if (check == "WA") {
      wa++;
    }
    if (check == "TLE") {
      tle++;
    }
    if (check == "RE") {
      re++;
    }
  }
  
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
}

Measured memory_bytes: 3636
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    FOR(i,1,n+1){
        ll cnt=0;
        FOR(x,1,101){
            FOR(y,x,101){
                FOR(z,y,101){
                    if(x*x+y*y+z*z+x*y+y*z+z*x==i){
                        if(x==y&&y==z){
                        	cnt++;
                        }
                        else if(x==y||y==z||x==z){
                            cnt+=3;
                        }
                      	else{
                        	cnt+=6;
                      	}
                    }
                    if(x*x+y*y+z*z+x*y+y*z+z*x>=n){
                        break;
                    }
                }
            }
        }
        cout << cnt << '\n';
    }
}


Measured memory_bytes: 3612