akhauriyash/Code-Regression huggingface dataset:
N=1
for t in range(N):
    x, y, z = list(map(int, input().split()))
    if (x == y and y == z):
        print(0)
        continue
    cost = 0
    l = sorted([x, y, z])

    cost += (l[2] - l[1])

    a = l[0] + l[2] - l[1]

    if (l[2] - a)%2 == 0:
        cost += (l[2] - a)//2
    else:
        cost += ((l[2] - a)//2 + 2)

    print(cost)
    


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

const int mod = 1000000007;
struct mint {
    long long x;
    mint(long long x = 0) : x((x % mod + mod) % mod) {}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return (*this) *= a.inv(); }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

struct combination {
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i)
            fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
    mint operator()(int n) { return fact[n]; }
};

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

    mint sum = mint(10).pow(N);

    mint sum1 = mint(9).pow(N);
    mint sum2 = mint(9).pow(N);
    mint sum3 = mint(8).pow(N);

    sum = sum - (sum1 + sum2 - sum3);

    cout << sum.x << endl;

    return 0;
}

Measured memory_bytes: 3620
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::*;
use std::usize;
#[allow(unused_imports)]
use std::vec::Vec;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input!{
        n: usize,
        x: usize,
    }
    let mut lenb: Vec<usize> = Vec::new();
    let mut cntp: Vec<usize> = Vec::new();

    for i in 0..n + 1 {
        if i == 0 {
            lenb.push(1);
            cntp.push(1);
            continue;
        }
        let prevlen = lenb[i - 1];
        let prevcnt = cntp[i - 1];
        lenb.push(prevlen * 2 + 3);
        cntp.push(prevcnt * 2 + 1);
    }
    // eprintln!("{:?}", lenb);
    // eprintln!("{:?}", cntp);

    println!("{}", calcp(n, x, lenb, cntp));
}

fn calcp(l: usize, x: usize, lenb: Vec<usize>, cntp: Vec<usize>) -> usize {
    // eprintln!("{} {}", l, x);
    if l == 0 {
        if x > 0 {
            return 1;
        } else {
            return 0;
        }
    } else if lenb[l] <= x {
        return cntp[l];
    } else if lenb[l] / 2 < x {
        return calcp(l - 1, x - lenb[l - 1] - 2, lenb, cntp.clone()) + 1 + cntp[l - 1];
    } else if lenb[l] / 2 == x {
        return cntp[l - 1];
    } else if l < x {
        return calcp(l - 1, x - 1, lenb, cntp);
    } else {
        return 0;
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+18
#define MOD 1000000007
using namespace std;



int main(){
    int N;
    string A,B,C;
    cin >> N >> A >> B >> C;
    
    int ans=0;
    for(int i=0; i<N; i++){
        char a=A[i],b=B[i],c=C[i];
        
        if(a==b && b==c){
            ans+=0;
        }else{
            if((a==b && b!=c)||(b==c && c!=a)||(c==a && b!=a)){
                ans+=1;
            }else{
                ans+=2;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>

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

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = acos(-1);
const ll mod = 1000000007;

// aとbの最大公約数を求める関数
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

    int ans = 0;
    for (int a = 1; a <= k; a++) {
        for (int b = 1; b <= k; b++) {
            for (int c = 1; c <= k; c++) {
                int tmp = gcd(a, b);
                ans += gcd(tmp, c);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 1e9 + 7
#define pb push_back
#define all(v) v.begin(),v.end()
#define rall(v) v.begin(), v.end(), greater<ll>()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;
using namespace std;
int main() {
    ll n, m, quan, price;
    cin >> n >> m;
    vector<pair<ll, ll>> moni(n);
    for(ll i = 0; i < n; ++i) {
        cin >> price >> quan;
        moni[i] = {price, quan};
    }
    sort(moni.begin(), moni.end());
    ll ans = 0;
    price = 0;
    for(auto mon: moni) {
        if((ans + mon.second) <= m) {
            ans += mon.second;
            price += (mon.first * mon.second);
        }
        else {
            ll diff = m - ans;
            price += (mon.first * diff);
            break;
        }
    }
    cout << price;
}


Measured memory_bytes: 1792
N=int(input())
lp=[int(e) for e in input().split(' ')]

c=0
for i,p in enumerate(lp):
    if i>=1 and i<= N-2:
        if (lp[i-1]<p<=lp[i+1]) or (lp[i+1]<p<=lp[i-1]):
            c+=1
print(c)

Measured memory_bytes: 2940
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        List<Point> students = new ArrayList<Point>();
        List<Point> checkPoints = new ArrayList<Point>();
        for(int i = 0; i < n; i++){
            students.add(new Point(sc.nextInt(), sc.nextInt()));
        }
        for(int i = 0; i < m; i++){
            checkPoints.add(new Point(sc.nextInt(), sc.nextInt()));
        }
        for(Point s : students){
            int minDist = Integer.MAX_VALUE;
            int ans = 0;
            for(int i = 0; i < m; i++){
                int tmp = Math.abs(s.x - checkPoints.get(i).x) + Math.abs(s.y - checkPoints.get(i).y);
                if(minDist > tmp){
                    minDist = tmp;
                    ans = i+1;
                }
            }
            System.out.println(ans);
        }
    }
}

class Point{
    int x, y;
    public Point(int x, int y){
        this.x = x;
        this.y = y;
    }
}


Measured memory_bytes: 21972
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<stack>
#include<cstdlib> 
#include<fstream> 
using namespace std;
int ct[30];
int cc[4];//cc[1]-->1,cc[2]-->2,cc[3]-->4;
int h,w;
char a[105][105]; 
int main(){
	memset(ct,0,sizeof(ct));
	memset(cc,0,sizeof(cc));
	cin>>h>>w;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin>>a[i][j];
			ct[a[i][j]-'a'+1]++;
		}
	}
	if((h%2==0)&&(w%2==0)){
		for(int i=1;i<=26;i++){
			if(ct[i]%4!=0){
				cout<<"No"<<endl;
				return 0;
			}
		}
	}else if(w%2==0){
		for(int i=1;i<=26;i++){
			if(ct[i]%2==0&&ct[i]%4!=0){
				cc[2]++;
			}else if(ct[i]%2!=0){
				cout<<"No"<<endl;
				return 0;
			}
		}
		if(cc[2]>w/2){
			cout<<"No"<<endl;
			return 0;
		}
	}else if(h%2==0){
		for(int i=1;i<=26;i++){
			if(ct[i]%2==0&&ct[i]%4!=0){
				cc[2]++;
			}else if(ct[i]%2!=0){
				cout<<"No"<<endl;
				return 0;
			}
		}
		if(cc[2]>h/2){
			cout<<"No"<<endl;
			return 0;
		}
	}else{
		for(int i=1;i<=26;i++){
			if(ct[i]%4==1){
				cc[1]++;
				if(cc[1]>1){
					cout<<"No"<<endl;
				    return 0;
				}
			}else if(ct[i]%4==3){
				cc[1]++;
				if(cc[1]>1){
					cout<<"No"<<endl;
				    return 0;
				}
				cc[2]++;
			}else if(ct[i]%2==0&&ct[i]%4!=0){
				cc[2]++;
			}else if(ct[i]%2!=0){
				cout<<"No"<<endl;
				return 0;
			}
		}
		if(cc[2]>h/2+w/2){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            int N = scanner.nextInt();
            int K = scanner.nextInt();
            long[] heights = new long[N];
            for (int i = 0; i < N; i++) {
                heights[i] = scanner.nextLong();
            }
            Arrays.sort(heights);
            long min = Long.MAX_VALUE;
            for (int i = 0; i + K - 1 < N; i++) {
                long diff = heights[i + K - 1] - heights[i];
                min = Math.min(diff, min);
            }
            System.out.println(min);
        }
    }

    static class Pair {
        final int kind;
        final long point;

        Pair(int kind, long point) {
            this.kind = kind;
            this.point = point;
        }
    }

}


Measured memory_bytes: 50092
#include<iostream>
using namespace std;
int main()
{
    string str;
    cin>>str;
    int len=str.size();
    for(int i=0;i<len;i++)
    {
        if(str[i]=='1') str[i]='9';
        else if(str[i]=='9') str[i]='1';
    }
    cout<<str<<endl;
    return 0;
}

Measured memory_bytes: 256
/* This code is written by Nemlit */
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define re register
#define debug printf("Now is Line : %d\n",__LINE__)
#define file(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define rep(i, a, b) for(re int i = (a); i <= (b); ++ i)
#define drep(i, a, b) for(re int i = (b); i >= (a); -- i)
#define Next(i, u) for(re int i = head[u]; i; i = e[i].next)
#define mem(k, p) memset(k, p, sizeof(k))
#define int long long
#define D double
#define inf 1023456789
#define mod 1000000007
#define lb(x) (x)&(-(x))
il int read() {
    re int x = 0, f = 1; re char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
    return x * f;
}
il int Mul(int a, int b) { return 1ll * a * b % mod; }
il int Inc(int a, int b) { return (a += b) >= mod ? a - mod : a; }
il int Dec(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
il int qpow(int a, int b) { int r = 1; while(b) { if(b & 1) r = Mul(r, a); a = Mul(a, a), b >>= 1; } return r; }
#define ls k * 2
#define rs k * 2 + 1
#define maxn 3005
namespace Graph {
	int head[maxn], cnt;
	struct edge { int v, next; }e[maxn << 1];
	il void add(int u, int v) { e[++ cnt] = (edge){v, head[u]}, head[u] = cnt; }
}
using namespace Graph;
int n, m, dp[maxn], a[maxn];
il void dfs(int u, int fr) {
	Next(i, u) {
		int v = e[i].v;
		if(v == fr) continue;
		dfs(v, u);
		dp[u] |= ((!dp[v]) && (a[u] > a[v]));
	}
}
signed main() {
	n = read();
	rep(i, 1, n) a[i] = read();
	rep(i, 2, n) {
		int u = read(), v = read();
		add(u, v), add(v, u);
	}
	rep(i, 1, n) {
		mem(dp, 0), dfs(i, 0);
		if(dp[i]) printf("%d ", i);
	}
	return 0;
}


Measured memory_bytes: 4076
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < (N); i++)
#define swap(a, b) (a += b, b = a - b, a -= b)
using namespace std;
int main()
{
    long long L, R, m = 2018;
    cin >> L >> R;
    for (long long i = L; i < R + 1; i++)
    {

        for (long long j = i + 1; j < R + 1; j++)
        {
            if (i * j % 2019 == 0)
            {
                cout << 0 << endl;
                return 0;
            }
            else
            {
                m = min(m, (i * j) % (long long)2019);
            }
        }
    }
    cout << m << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int i,j,k,n,x,max,c;
    max=0;
    c=0;
    while(true){
        max=0;
        cin>>n>>x;
        if(n==0 && x==0){
            break;
        }
        for(i=1;i<=n;i++){
            for(j=i+1;j<=n;j++){
                for(k=j+1;k<=n;k++){
                    if(x==i+j+k){
                        max=max+1;
                    }
                }
            }
        }
        cout<<max<<endl;
    }
    return 0;
}

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

#define ll long long
#define pb push_back
#define F first
#define S second

using namespace std;

const int N = 100005;

int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int a, b;
    cin >> a >> b;
    int res = b;
    if (a <= 5) res = 0;
    else if (a <= 12) res /= 2;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a.at(i);
    ll ans=1;
    sort(a.begin(),a.end());
    if(a.at(0)==0) cout << 0 << endl;
    else{
        rep(i,n){
            if(1000000000000000000/ans<a.at(i)){
                ans=-1;
                break;
            }
            else{
                ans*=a.at(i);
            }
        } 
        cout << ans << endl;       
    }
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int main(){
  int n,x;
  cin >> n >> x;
  int now=0,ans=1,l;
  rep(i,n){
    cin >> l;
    now+=l;
    if(now<=x) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int N;
    cin >> N;
    int mod=N%10;
    if(mod==2||mod==4||mod==5||mod==7||mod==9){
        cout << "hon" << endl;
    }else if(mod==3){
        cout << "bon" << endl;
    }else{
        cout << "pon" << endl;
    }
}


Measured memory_bytes: 3636
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>


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

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;
#define int long long


int N;
//here begins your code
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> N;

  for(int i = sqrt(N); i >= 1; i--){
  	if(N % i == 0){
  		cout << i + (N / i) - 2<< endl;
  		return 0;
  	}
  }
  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

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

int main() {

	string s;
	cin >> s;
	int a, b;
	int n = s.size();
	for (int i = 0; i<n; i++) {
		if (s[i] == 'A') {
			a = i;
			break;
		}
	}

	for (int i =0; i<n; i++) {
		if (s[i] == 'Z') {
			b = i;
		}
	}

	cout << b - a + 1 << endl;

	return 0;
}

Measured memory_bytes: 640
n=input().split()
a=input().split()
s=0
b=0
x=[0]
for i in range(int(n[0])):
    s+=int(a[i])
    x.append(s)
for i in range(len(x)):
    if x[i]<=int(n[1]):
        b+=1
print(b)

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
//#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 300000;
const int K = 19;
int mod = 1e9 + 7;
int b[N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (int i = 1; i <= n; i++){
        if (s[i - 1] == '.') b[i] = b[i - 1] + 1; else b[i] = b[i - 1];
    }
    int ans = n;
    for (int i = 0; i <= n; i++){
        int x = i - b[i];
        int y = b[n] -  b[i];
        if (i == n) y = 0;
        ans = min(ans, x + y);
    }
    cout << ans;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

int A, B, K;

signed main()
{
    cin >> A >> B >> K;
    bool t_turn = true;
    REP(k, K) {
        if(t_turn) {
            if(A % 2 != 0) { A--; }
            B += A / 2;
            A /= 2;
            t_turn = false;
        } else {
            if(B % 2 != 0) { B--; }
            A += B / 2;
            B /= 2;
            t_turn = true;
        }
    }
    printf("%lld %lld\n", A, B);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    int r = 0;
    vector<char> stone(n);
    for(int i = 0; i< n; i++){
        cin >> stone[i];
        if(stone[i] == 'R') r++;
    }
    int res = r;
    for(int i = 0; i< res; i++){
        if(stone[i] == 'R') r--;
    }
    cout << r << endl;
    return 0;
}

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

using ll = long long int;
using P = pair<ll, ll>;
using P3 = pair<double,P>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9) + 7;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};
constexpr double EPS = 1e-8;

void chmin(ll &a, ll b){
    a = min(a,b);
}

int solve(){
    ll n, T;
    cin >> n >> T;
    vector<P3> v;
    vector<ll> cnst = {0};
    for(int i=0;i<n;i++){
        ll a, b;
        cin >> a >> b;
        if(a > 0) v.push_back(P3(double(a)/(b+1),P(a,b)));
        else cnst.push_back(b);
    }
    sort(v.rbegin(), v.rend());
    sort(cnst.begin(), cnst.end());
    for(int i=0;i<int(cnst.size())-1;i++){
        cnst[i+1] += cnst[i]+1;
    }
    int m = v.size();
    vector<vector<ll> > dp(m+1, vector<ll>(36, T+1));
    dp[0][0] = 0;
    for(int i=0;i<m;i++){
        for(int j=0;j<35;j++){
            if(dp[i][j] > T) continue;
            ll a = v[i].second.first, b = v[i].second.second;
            chmin(dp[i+1][j], dp[i][j]);
            chmin(dp[i+1][j+1], min(dp[i][j]+1+a*(dp[i][j]+1)+b, T+1));
        }
    }
    int ans = 0;
    for(int i=0;i<=35;i++){
        if(dp[m][i] > T) break;
        ans = max(ans, i+int(upper_bound(cnst.begin(),cnst.end(),T-dp[m][i])-cnst.begin())-1);
    }
    cout << ans << endl;
    return 0;
}

int main(){
    solve();
    // while(solve()==0);
    // int t; cin >> t; for(;t>0;t--) solve();
    return 0;
}

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

int main(){
    int five = 2;
    int seven = 1;

    for(int i=0;i<3;++i){
        int in;cin >> in;
        if(in == 5){
            five--;
        } else if(in == 7){
            seven--;
        } else{
            cout << "NO" << endl;
            return 0;
        }
    }
    if(five < 0 || seven < 0){
        cout << "NO" << endl;
    } else{
        cout << "YES" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%lld",x)
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
#define re register
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define per(i,n,m) for(int i=m;i>=n;i--)
#define rrep(i,m,n) for(register int i=m;i<=n;i++)
#define rper(i,n,m) for(register int i=m;i>=n;i--)
const int N = 3e3 + 10;
const ll mod = 1e9 + 7;

signed main(){
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,x,t;
    cin>>n>>x>>t;
    int num=n/x;
    if(n%x!=0)num++;
    cout<<num*t;
   return 0;
}

Measured memory_bytes: 3608
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): pass
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

n = I()
H = LI()
dp = [0] * n
dp[1] = abs(H[1] - H[0])
for i in range(2, n):
    dp[i] = min(dp[i-1] + abs(H[i] - H[i-1]), dp[i-2] + abs(H[i] - H[i-2]))

print(dp[-1])

Measured memory_bytes: 97256
import numpy as np

def solve(n, A):
    res = 0
    while A:
        i = np.argmax(A)
        res += A[i] if (len(A) + n) % 2 == 0 else -A[i]
        A.pop(i)
    return res

_n = int(input())
_A = list(map(int, input().split()))
print(solve(_n, _A))

Measured memory_bytes: 12424
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]

    if n==0:
        print(0)
        return

    digit = []
    while n:
        r = abs(n)%2
        digit.append(r)
        n = (n-r)//(-2)

    for i in digit[::-1]:
        print(i, end = '')

solve()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
  ll H, W, K;
  cin>>H>>W>>K;
  vector<vector<char>> C(H, vector<char>(W));
  rep(i, H){
    rep(j, W){
      cin>>C[i][j];
    }
  }
  ll Ans=0;
  for(ll i=0; i<(1<<H); ++i){
    for(ll j=0; j<(1<<W); ++j){
      ll cnt=0;
      for(ll k=0; k<H; k++){
        for(ll l=0; l<W; l++){
          if(i&(1<<k)&&j&(1<<l)){
            if(C[k][l]=='#')cnt++;
          }
        }
      }
      if(cnt==K)Ans++;
    }
  }
  cout<<Ans<<endl;
} 

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
int main() {
	int N , L , R;
	int ans = 2020;
    cin >> L >> R;
	N = R - L;
	for(int i = L; i < L + min(2019 , N); i++){
		for(int j = i + 1; j <= min(R , i + 2019); j++){
			ans = min(((i % 2019) * (j % 2019)) % 2019 , ans);
		}
	}
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    int n;cin>>n;
    int a[n];
    for(int i = 0;i<n;i++) cin>>a[i];
    long g= 0;
    for(int i = 0;i<n;i++){
     g+=a[i]-1;
    }
    cout<<g;
    return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(i, v) for(auto i =  v.begin(); i !=  v.end(); ++i)
#define RFOR(i, v) for(auto i = v.rbegin(); i != v.rend(); ++i)

template<typename T> bool setmin(T & a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T & a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T> ostream & operator<<(ostream & os, const vector<T> & v) {
	os << "[";
	FOR(it, v) {
		if(it != v.begin()) { os << ", "; }
		os << *it;
	}
	os << "]";
	return os;
}
template<typename F, typename S> ostream & operator<<(ostream & os, const pair<F, S> & p) {
	os << "<" << p.FI << ", " << p.SE << ">";
	return os;
}

// ---- ----

int n, k, a[100000];
LL psum[100001];
LL msum[100001];

int main() {
	cin >> n >> k;
	inc(i, n) { cin >> a[i]; }
	
	inc(i, n) {
		psum[i + 1] = psum[i] + max(0, a[i]);
		msum[i + 1] = msum[i] + min(0, a[i]);
	}
	
	LL b = -1e15, w = 1e15;
	inc(i, n - (k - 1)) {
		setmax(b, msum[i + k] - msum[i]);
		setmin(w, psum[i + k] - psum[i]);
	}
	
	LL sum = 0;
	inc(i, n) { sum += max(0, a[i]); }
	
	cout << sum + max(b, -w) << endl;
	
	return 0;
}


Measured memory_bytes: 2304
#include <cstdio>
#include <cctype>
#include <utility>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;
	while (isspace(c)) {c = gcu();}
	if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	for (int t; (t = in());) {
		for (int n = in(); n; n--) {
			int s = in();
			t -= in() - s;
		}
		if (t > 0)
			outl(t);
		else
			outl("OK");
	}
}


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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    int f = 0;
    int x = n;
    while (x > 0) {
        f += x % 10;
        x /= 10;
    }
    cout << (n % f == 0 ? "Yes" : "No") << endl;
}


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

int main() {
  int n,cnt=0;
  string s;
  cin >> n >> s;
  for (int i=0;i<n-2;i++){
    if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') cnt++;
  }
  cout << cnt << endl;
}


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

int main(){
	int num[1000010];
	int num2[1000010];
	vector<int> v;
	for(int i=0; i< 100000; i++){
		int m = i*(i+1)*(i+2)/6;
		if(1000000 <= m) break;
		v.push_back(m);
	}
	for(int i=0; i< 1000010; i++) num[i] = 10e8;
	for(int i=0; i< 1000010; i++) num2[i] = 10e8;
	num[0] = 0;
	num2[0] = 0;
	for(int j=0; j< 1000010; j++){
		for(int i=0; i < v.size(); i++){
			int m = i*(i+1)*(i+2)/6;
			if(1000010 <= m+j) continue;
			num[j+m] = min(num[j]+1, num[j+m]);

			if(m == 0) continue;
			if(m%2 == 0) continue;
			num2[j+m] = min(num2[j]+1, num2[j+m]);
		}
	}
	int n;
	while(cin >> n, n){
		cout << num[n] << " " << num2[n] << endl;
	}
}

Measured memory_bytes: 9028
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <climits>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main() {
#ifdef RUN_LOCAL
  ifstream in("../input.txt");
  cin.rdbuf(in.rdbuf());
#endif

  cin.tie(0);
  ios::sync_with_stdio(false);

  int a, b;
  cin >> a >> b;
  for (int x = 0; x < 100000; ++x) {
    int A = (int)(0.08 * x);
    int B = (int)(0.1 * x);
    if (A == a && B == b) {
      cout << x << endl;
      return 0;
    }
  }
  cout << -1 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#include <string.h>


int main() {
	int S, W;
	scanf("%d %d", &S, &W);
	if (W >= S) {
		printf("unsafe");
	}
	else {
		printf("safe");
	
	}
	return 0;
}


Measured memory_bytes: 1680
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int32_t main()
{
	int n=in();
	
	
	if(n>=400 and n<=599)puts("8");
	if(n>=600 and n<=799)puts("7");
	if(n>=800 and n<=999)puts("6");
	if(n>=1000 and n<=1199)puts("5");
	if(n>=1200 and n<=1399)puts("4");
	if(n>=1400 and n<=1599)puts("3");
	if(n>=1600 and n<=1799)puts("2");
	if(n>=1800 and n<=1999)puts("1");
	
}

Measured memory_bytes: 3760
#include<complex>
#include<stdio.h>
#define F(a,b,c) acos((b*b+c*c-a*a)/2/b/c)
int main(){typedef double D;int n;D d,e,f,g,h,i;for(scanf("%d",&n);n--;){scanf("%lf%lf%lf%lf%lf%lf",&d,&g,&e,&h,&f,&i);std::complex<D> a(d,g),b(e,h),c(f,i);D A=abs(b-c),B=abs(c-a),C=abs(a-b),L=F(A,B,C),s=sin(2*L),t=sin(2*F(B,C,A)),u=sin(2*F(C,A,B)),v=s+t+u;printf("%.3f %.3f %.3f\n",(d*s+e*t+f*u)/v,(g*s+h*t+i*u)/v,A/sin(L)/2);}}

Measured memory_bytes: 0
package main

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

var s = bufio.NewScanner(os.Stdin)

func Scan() string {
	s.Scan()
	return s.Text()
}

func main() {
	fmt.Println(p())
}

func ScanInt() int {
	a, err := strconv.Atoi(Scan())
	if err != nil {
		return 0
	}
	return a
}

func test(n int) string {
	for i := 9; i > 0; i-- {
		if n%i == 0 {
			a := n / i
			if a < 10 {
				return "Yes"
			}
			return "No"
		}
	}
	return "No"
}

func p() string {
	a := ScanInt()
	if a == 0 || a > 81 {
		return "No"
	}
	return test(a)
}


Measured memory_bytes: 640
n = int(input())
s = input()
 
W_csum = [0] * (n+1)
E_csum = [0] * (n+1)
for i in range(n):
    if s[i] == 'W':
        W_csum[i+1] = W_csum[i] + 1
        E_csum[i+1] = E_csum[i]
    else:
        W_csum[i+1] = W_csum[i]
        E_csum[i+1] = E_csum[i] + 1
E_csum.append(E_csum[-1])

ans = float('inf')
for i in range(1,n+1):
    count = 0
    count += W_csum[i-1]
    count += E_csum[-1] - E_csum[i]
    if count < ans:
        ans = count
print(ans)

Measured memory_bytes: 17612
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace procon
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            string[] input = Console.ReadLine().Split(' ');
            int[] a = new int[n];

            for(int i = 0;i<n;i++)
            {
                a[i] = int.Parse(input[i]);
            }

            int min = a.Min();
            int max = a.Max();

            int? difmin = null;

            for(int j = min; j<=max; j++)
            {
                int dif = 0;

                foreach(int tmp in a)
                {
                    dif = dif + (tmp - j) * (tmp - j);
                }

                if(difmin == null || difmin > dif)
                {
                    difmin = dif;
                }
            }

            Console.WriteLine(difmin);
        }
    }
}


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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
const int MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
struct edge { int i, v; };

int main() {
	int N; cin >> N;
	vector<vector<ll> > a(N, vector<ll>(N));
	rep(u, N) rep(v, N) scanf("%lld", &a[u][v]);
	vector<vector<ll> > a0 = a;
	rep(k, N) rep(u, N) rep(v, N) a[u][v] = min(a[u][v], a[u][k] + a[k][v]);
	rep(u, N) rep(v, N) if (a[u][v] < a0[u][v]) {
		cout << -1 << endl;
		return 0;
	}
	vector<vector<ll> > d(N, vector<ll>(N));
	rep(u, N) rep(v, N) if (a[u][v]) d[u][v] = a[u][v] * INT_MAX - 1;
	vector<vector<ll> > d0 = d;
	rep(k, N) rep(u, N) rep(v, N) d[u][v] = min(d[u][v], d[u][k] + d[k][v]);
	ll ans = 0;
	rep(u, N) rep(v, N) if (d[u][v] == d0[u][v]) ans += a0[u][v];
	cout << ans / 2 << endl;
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
vector<vector<int> > adjlist;
#define max(x,y) (x>y)?x:y
#define min(x,y) (x>y)?y:x
#define sfor(n) for(int i=0;i<n;i++)
#define mod 1000000007
#define pb push_back
#define in insert
#define mp make_pair
#define inf mod
#define bg begin()
#define ed end()
#define vi vector<int>
#define map map<int,int>
#define smap map<string,int>
#define set set<int>
typedef long double ld;
typedef long long int ll;
int main()
{
    ll k,x;
    cin>>k>>x;
    for (ll i = x-k+1; i <=x+k-1 ; ++i) {
        cout<<i<<" ";
    }
    return 0;
}

Measured memory_bytes: 256
n, k = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)
placeOne = 0
for i in 0..(n-1) do
  if a[i] == 1
    placeOne = i
  end
end

count = placeOne / (k-1)
if placeOne % (k-1) != 0
  count += 1
  placeOne = count * (k-1)
end

rest = n - placeOne - 1
count += (rest / (k-1))
if rest % (k-1) != 0
  count += 1
end

p count

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


int main() {

    string s;
    cin >> s;
    cout << s[0];
    cout << to_string(s.size()-2);
    cout << s[s.size()-1] << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            int[] wt = new int[N + 2];
            int[] et = new int[N + 2];

            int w = 0;
            int e = 0;
            for (int i = 0; i < N; i++)
            {
                if (s[i] == 'W')
                {
                    w++;
                }
                else
                {
                    e++;
                }

                wt[i + 1] = w;
                et[i + 1] = e;
            }

            wt[N + 1] = wt[N];
            et[N + 1] = et[N];


            int ans = int.MaxValue;

            for (int i = 1; i < N + 1; i++)
            {
                ans = Math.Min(ans, wt[i - 1] + e - et[i]);
            }

            Console.WriteLine(ans);
        }
    }
}



Measured memory_bytes: 14432
N = int(input())
count=0

for i in range(1,N+1):
    if i < 10:
        count+=1
    elif i<100:
        count+=0
    elif i<1000:
        count+=1
    elif i<10000:
        count+=0
    elif i<100000:
        count+=1

print(count)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
int main(){
    int h,w;cin >> h >> w;
    vector<string> grid(h);
    for(int i=0;i<h;i++) cin >> grid[i];
    int mx=0;
    vector<pair<char,int>> yoko[h];
    vector<vector<int>> yoko_score(h,vector<int>(w));
    for(int i=0;i<h;i++){
        char st=grid[i][0];
        int cnt=1;
        for(int j=1;j<w;j++){
            if(st!=grid[i][j]){
                yoko[i].push_back({st,cnt});
                cnt=1;
                st=grid[i][j];
            }
            else cnt++;
        }
        yoko[i].push_back({st,cnt});
    }
    for(int i=0;i<h;i++){
        int stn=0;
        for(auto p: yoko[i]){
            if(p.first=='#'){
                for(int j=stn;j<stn+p.second;j++){
                    yoko_score[i][j]=0;
                }
            }
            else{
                for(int j=stn;j<stn+p.second;j++){
                    yoko_score[i][j]=p.second;
                }
            }
            stn+=p.second;
        }
    }
    vector<pair<char,int>> tate[w];
    vector<vector<int>> tate_score(h,vector<int>(w));
    for(int i=0;i<w;i++){
        char st=grid[0][i];
        int cnt=1;
        for(int j=1;j<h;j++){
            if(st!=grid[j][i]){
                tate[i].push_back({st,cnt});
                cnt=1;
                st=grid[j][i];
            }
            else cnt++;
        }
        tate[i].push_back({st,cnt});
    }
    for(int i=0;i<w;i++){
        int stn=0;
        for(auto p: tate[i]){
            if(p.first=='#'){
                for(int j=stn;j<stn+p.second;j++){
                    tate_score[j][i]=0;
                }
            }
            else{
                for(int j=stn;j<stn+p.second;j++){
                    tate_score[j][i]=p.second;
                }
            }
            stn+=p.second;
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            mx=max(yoko_score[i][j]+tate_score[i][j]-1,mx);
        }
    }
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 67968
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    ga,sa,ba = map(int,ipt().split())
    gb,sb,bb = map(int,ipt().split())

    dp = [0]*(5005)
    for i in range(n+1):
        dp[i] = dp[i-1]
        if i >= ga and dp[i] < (gb-ga)+dp[i-ga]:
            dp[i] = gb-ga+dp[i-ga]
        if i >= sa and dp[i] < (sb-sa)+dp[i-sa]:
            dp[i] = sb-sa+dp[i-sa]
        if i >= ba and dp[i] < (bb-ba)+dp[i-ba]:
            dp[i] = bb-ba+dp[i-ba]
    ni = n+dp[n]

    dp = [0]*max(5005,ni+5)
    for i in range(ni+1):
        dp[i] = dp[i-1]
        if i >= gb and dp[i] < (ga-gb)+dp[i-gb]:
            dp[i] = ga-gb+dp[i-gb]
        if i >= sb and dp[i] < (sa-sb)+dp[i-sb]:
            dp[i] = sa-sb+dp[i-sb]
        if i >= bb and dp[i] < (ba-bb)+dp[i-bb]:
            dp[i] = ba-bb+dp[i-bb]
    print(ni+dp[ni])

    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 270612
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
#include <utility>

using namespace std;

int main()
{
	char c;
	cin >> c;
	vector<char> vowels{'a', 'e', 'i', 'u', 'o'};

	auto itr = find(vowels.begin(), vowels.end(), c);
	if (itr != vowels.end())
	{
		cout << "vowel" << endl;
	}
	else
	{
		cout << "consonant" << endl;
	}
}

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

typedef long long ll;
const int maxn = 1e6 + 10, mod = 1e9 + 7;
int n, p[maxn], l, r, f[maxn];

inline int add(int a, int b){
	return (ll(a) + b) % mod;
}

inline int sub(int a, int b){
	return (ll(a) - b + mod) % mod;
}

inline int mult(int a, int b){
	return (ll(a) * b) % mod;
}

inline int pot(int a, int b){
	int r = 1, p = a;
	for(int i = 0; i < 31; i++){
		if(b & (1 << i)){
			r = mult(r, p);
		}
		p = mult(p, p);
	}
	return r;
}

inline int inv(int a){
	return pot(a, mod - 2);
}

inline int pov(int a, int b){
	if(b == 0)
		return 1;

	if(b > a)
		return 0;

	return mult(f[a], inv(mult(f[b], f[a - b])));
}

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

	f[0] = 1;
	for(int i = 1; i < maxn; i++){
		f[i] = mult(f[i - 1], i);
	}

	cin >> n;

	for(int i = 1; i <= n + 1; i++){
		int x;
		cin >> x;

		if(p[x]){
			l = p[x] - 1;
			r = n + 1 - i;
		}

		p[x] = i;
	}

	for(int i = 1; i <= n + 1; i++){
		cout << sub(pov(n + 1, i), pov(l + r, i - 1)) << '\n';
	}
}


Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);


int main() {
    cin>>N;
    vec c(26), s(26), last(26, 0);
    rep(i,26) cin>>c[i];
    reps(day, 1, N + 1){
        rep(i, 26) {
            cin>>s[i];
            s[i] += c[i] * (day - last[i]);
        }
        auto ite = max_element(ALL(s));
        cout<<(ite - s.begin()) + 1<<endl;
        last[ite - s.begin()] = day;
    }
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int a, b;
    string s;
    cin >> a >> b >> s;
    if (s[a] != '-') {
        cout << "No" << endl;
        return 0;
    } else {
        for(int i = 0; i < a; i++)
        if (s[i] == '-') {
            cout << "No" << endl;
            return 0;
        }
        for(int i = a+1; i < s.size(); i++)
        if (s[i] == '-') {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 256