akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<bitset>
#include<iomanip>
#include<cctype>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
const int inf = 1001001000;

void print(vector<vector<int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}
//UnionFind木のテンプレ.parentには根のindexが入っている.
//根には連結成分のサイズが入っている.nはノード数.
class UnionFind{
public:
	vector<int> parent;
	UnionFind(){}
	UnionFind(int n){
		this->parent = vector<int>(n,-1);
	}
	int root(int x){
		if (this->parent[x] < 0) return x;
		this->parent[x] = root(this->parent[x]);
		return this->parent[x];
	}
	int unite(int x, int y){
		int rx = this->root(x);
		int ry = this->root(y);
		if (rx == ry) return false;
		if (this->parent[rx] > this->parent[ry]) swap(rx, ry);
		this->parent[rx] += this->parent[ry];
		this->parent[ry] = rx;
		return true;
	}
	int same(int x, int y){
		int rx = this->root(x);
		int ry = this->root(y);
		return rx == ry;
	}
	int size(int x){
		return -this->parent[this->root(x)];
	}
};


//クラスカル法.UnionFindが必要.最小全域木の重みの総和を返す.
//nはノード数.queは(weight,from,to)の順に格納された順序付き待ち行列.
// int v, e; cin >> v >> e;
// 	priority_queue<vector<int>,vector<vector<int>>,greater<vector<int>>> que;
// 	for (int i = 0; i < e; i++){
// 		int s, t, w; cin >> s >> t >> w;
// 		que.push({w,s,t});
// 	}
int kruskal(int n, priority_queue<vector<int>,vector<vector<int>>,greater<vector<int>>> que){
	UnionFind uf(n);
	int weight = 0;
	while(!que.empty()){
		vector<int> now = que.top();
		que.pop();
		if (!uf.same(now[1],now[2])){
			uf.unite(now[1],now[2]);
			weight += now[0];
		}
	}
	return weight;
}
double kruskal(int n, priority_queue<tuple<double,int,int>,vector<tuple<double,int,int>>,greater<tuple<double,int,int>>> que){
	UnionFind uf(n);
	double weight = 0;
	while(!que.empty()){
		tuple<double, int, int> now = que.top();
		que.pop();
		if (!uf.same(get<1>(now),get<2>(now))){
			uf.unite(get<1>(now), get<2>(now));
			weight += get<0>(now);
		}
	}
	return weight;
}
double dist(vector<double> a,vector<double> b){
	return sqrt(pow((a[0] - b[0]), 2) + pow((a[1] - b[1]), 2) + pow((a[2] - b[2]), 2));
}

int main(){
	cout << fixed;
	while (true)
	{
		int n;
		cin >> n;
		if (n == 0)
			break;
		vector<vector<double>> cells(n, vector<double>(4, 0));
		rep(i, n){
			cin >> cells[i][0] >> cells[i][1] >> cells[i][2] >> cells[i][3];
		}
		priority_queue<tuple<double,int,int>,vector<tuple<double,int,int>>,greater<tuple<double,int,int>>> que;
		
		rep(i,n-1){
			rep2(j,i+1,n){
				double w = dist(cells[i], cells[j]) - cells[i][3] - cells[j][3];
				que.push(tuple<double, int, int>(w > 0 ? w : 0, i, j));
			}
		}
		cout << setprecision(3) << kruskal(n, que) << endl;
	}

	return 0;
}


Measured memory_bytes: 3412
#include <bits/stdc++.h>
#define mem(s,t) memset(s,t,sizeof(s))
#define pb(s) push_back(s)
#define inf 0x3f3f3f3f
#define mn 200010
typedef long long ll;
using namespace std;
const ll MOD=1e9+7;
char s[mn];
int a[mn];
int main()
{
	int n;
	scanf("%d",&n);
	scanf("%s",s);
	int cnt=0;
	bool ok=1;
	for(int i=0;i<2*n;++i){
		if(s[i]=='B'){
			if(cnt&1){
				a[i]=0;--cnt;
			}
			else {
				a[i]=1;++cnt;
			}
		}
		else {
			if(cnt&1){
				a[i]=1;++cnt;
			}
			else {
				a[i]=0;--cnt;
			}
		}
		if(cnt<0){ok=0;break;}
	}
	if(cnt)ok=0;
	ll ans=1;
	if(ok){
		ll lc=0;
		for(int i=0;i<2*n;++i){
			if(a[i])++lc;
			else {
				ans*=lc--;
				ans%=MOD;
			}
		}
		for(int i=1;i<=n;++i){
			ans=(ans*i)%MOD;
		}
	}
	else ans=0;
	printf("%lld\n",ans);

    return 0;
}



Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include<random>
using namespace std; typedef unsigned long long _ulong; typedef long long int lint; typedef pair<lint, lint> plint; typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define endk '\n'
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
const lint MOD = 1e9 + 7, INF = 1e18;
lint dx[8] = { 0, -1, 1, 0, 1, -1, 1, -1 }, dy[8] = { 1, 0, 0, -1, -1, -1, 1, 1 };
typedef pair<double, lint> Pa;
typedef pair<plint, lint> tlint;
struct edge {
	lint cost;
	lint u, v;
};

#include<atcoder/all>
using namespace atcoder;

string s;
int main() {
	cin >> s;
	lint ans = 1ll * SZ(s) * (SZ(s) + 1) / 2;
	auto sa = suffix_array(s);
	for (auto x : lcp_array(s, sa)) {
		ans -= x;
	}
	cout << ans << endk;
}


Measured memory_bytes: 15600
S = input()
T = input()

S_list = list(S)
T_list = list(T)
answer = 1000

for i in range(len(S_list)-len(T_list)+1):
    count = 0
    for j in range(len(T_list)):
        if(S_list[i+j] != T_list[j]):
            count +=1
    answer = min(count, answer)
print(answer)

Measured memory_bytes: 9104
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
using namespace std;

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

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

	int a, b;
	cin >> a >> b;
	cout << (a*b%2==0 ?"Even":"Odd") << endl;
	return 0;
}


Measured memory_bytes: 504
#include <iostream>

// わからないから全部やる
// 全部といっても、pは100以下だけやれば絶対大丈夫(残りは小数の切り捨てに影響しない)。qはよくわからないから低めに見積もっておいてそれを+2くらいして調べきればいい。
// カッコ悪い解法で誠に申し訳ない。

using namespace std;

int x, y, s;
int p, q;

int main() {
  while (scanf("%d%d%d", &x, &y, &s) && x && y && s) {
    int max = 0;
    for (p=1; p<=100; p++) {
      int X = p * (100 + x) / 100;
      if (s - X > 0) {
	int qprime = 100 * (s-X) / (100 + x);
	for (q=qprime; q<=qprime+2; q++) {
	  int Y = q * (100 + x) / 100;
	  if (X + Y == s && p*(100+y)/100 + q*(100+y)/100 > max) {
	    max = p*(100+y)/100 + q*(100+y)/100; 
	  }
        }
      }
    }
  printf("%d\n", max);
  }
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
/*    #ifndef ONLINE_JUDGE
      // for getting input from input.txt
      freopen("input.txt", "r", stdin);
      // for writing output to output.txt
      freopen("output.txt", "w", stdout);
  #endif*/
fast();
//ll  t;cin>>t;while(t--)
{
  ll a,b,c,x=0;
  cin>>x>>a;
  //if(abs(x-a)<abs(x-b))
  {
    cout<<max(1ll*0,x-a);
  }
  //else
  {
    //cout<<"B"<<endl;
  }
  
  
  
  

}
return 0;
}


Measured memory_bytes: 256
package main
import (
  "fmt"
)
func main() {
  var r int
  fmt.Scan(&r)
  var result string
  if r < 1200 {
    result = "ABC"
  } else if r < 2800 {
    result = "ARC"
  } else {
    result = "AGC"
  }
  fmt.Println(result)
}

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

int main(){
	int n,m;
	cin>>n>>m;
	priority_queue<int,vector<int>,less<int> >pq;
	while(n--){
		int a;
		cin>>a;
		pq.push(a);
	}
	while(m--){
		int curr = pq.top();
		pq.pop();
		curr/=2;
		pq.push(curr);
	}
	long long ret = 0;
	while(pq.size()){
		ret+=pq.top();
		pq.pop();
	}
	cout<<ret;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using Pair = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;

/*
*ios::sync_with_stdio(false);
*cin.tie(0);
*/
int main(){
   string s,t;
   cin >> s >> t;
   ll cnt = 0;
   for(int i=0;i<s.size();i++){
       if(s[i] != t[i]) cnt++;
   }
   cout << cnt << endl;
}

Measured memory_bytes: 3916
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1ll << 60
     
using namespace std;
typedef long long ll;
typedef pair<int, int> pp;
     
int main(void) {
    int num, i;
    ll k = 1, ans = 0;
    cin >> num;
    num++;
    vector<ll> d(num), f(num);
    for(i = 0; i < num; i++)
        cin >> d[i];
    f = d;
    for (i = num - 2; i >= 0; i--)
        f[i] += f[i + 1];
    for(i = 0; i < num; i++) {
        if (k < d[i]) {
            ans = -1;
            break;
        }
        ans += min(k, f[i]);
        k -= d[i];
        k <<= 1;
        if (k > INF)
            k = INF;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4800
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, A: int, B: int, S: str):

    b = [1 if S[i]=='b' else 0 for i in range(N)]
    lb = [0] * (N+1)
    for i in range(N):
        lb[i+1] = lb[i] + b[i]


    cnt = 0
    for i in range(N):
        if S[i] == 'c':
            print(NO)
        
        elif cnt < A+B:
            if S[i] == 'a':
                print(YES)
                cnt += 1
        
            elif S[i] == 'b' and lb[i] < B:
                print(YES)
                cnt += 1
        
            else:
                print(NO)

        else:
            print(NO)
        

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, A, B, S)

if __name__ == '__main__':
    main()


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

int main()
{
    int w, n;
    cin >> n;
    cin >> w;
    int T[31];
    for (int i = 1; i <= n; i++)
    {
        T[i] = i;
    }
    for (int i = 0; i < w; i++) {
        int a, b;
        char c;
        cin >> a >> c >> b;
        swap(T[a], T[b]);
    }
    for (int i = 1; i <= n; i++)
        cout << T[i] << endl;
    return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <math.h>
using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7; //1000000007                                                   

//a^n                                                                                  
ll pow(ll a, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res *= a;
    a *= a;
    n >>= 1;
  }
  return res;
}

//a^n % mod                                                                            
ll mod_pow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

//a^(-1) % mod (only if : a % p != 0)                                                  
ll mod_inv(ll a, ll mod) {
  return mod_pow(a, mod - 2, mod);
}

//nCk % mod                                                                            
ll mod_nCk(int n, int k, int mod) {
  if (n == 0 || k == 0) return 1;
  ll p = 1, q = 1;
  for (int i = n - k + 1; i <= n; i++)
    p = (p * i) % MOD;
  for (int i = 2; i <= k; i++)
    q = (q * i) % MOD;
  q = mod_inv(q, MOD);
  return (p * q) % MOD;
}

int main() {
  int n, k; cin >> n >> k;
  cout << mod_nCk(k, n, MOD) << endl;
}




Measured memory_bytes: 3132
#include <stdio.h>

int main (){
    int dif = 0;
    int maior = 0 , menor = 1e9;
    int n;

    scanf("%d",&n );

    int V[112];

    for (int i = 0; i < n ; i++)
        scanf("%d",&V[i] );

    for(int i = 0 ; i < n ; ++i ){
        if (V[i] > maior){
            maior = V[i];
        }
        if (V[i] < menor){
            menor = V[i];
        }
    }

    printf("%d\n",maior - menor );


return 0;
}


Measured memory_bytes: 128
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N, M, K;
ll arr[100005], arr1[100005];
string S = "";
std::vector<ll> V;
set<ll> s1;
queue<ll> q;
stack<ll> st;


int main() {
	scanf("%lld %lld %lld", &N, &M, &K);
	V.push_back(N);
	V.push_back(M);
	V.push_back(K);
	sort(V.begin(), V.end());
	if(V[0] == V[1] && V[1] != V[2]) {
		printf("Yes\n");
	}
	else if(V[0] != V[1] && V[1] == V[2]) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

██╗    ██╗██████╗ ██╗████████╗████████╗███████╗███╗   ██╗    ██████╗ ██╗   ██╗
██║    ██║██╔══██╗██║╚══██╔══╝╚══██╔══╝██╔════╝████╗  ██║    ██╔══██╗╚██╗ ██╔╝
██║ █╗ ██║██████╔╝██║   ██║      ██║   █████╗  ██╔██╗ ██║    ██████╔╝ ╚████╔╝
██║███╗██║██╔══██╗██║   ██║      ██║   ██╔══╝  ██║╚██╗██║    ██╔══██╗  ╚██╔╝
╚███╔███╔╝██║  ██║██║   ██║      ██║   ███████╗██║ ╚████║    ██████╔╝   ██║
 ╚══╝╚══╝ ╚═╝  ╚═╝╚═╝   ╚═╝      ╚═╝   ╚══════╝╚═╝  ╚═══╝    ╚═════╝    ╚═╝

     ███╗   ███╗   ██╗██████╗ ██████╗  █████╗ ██╗  ██╗██╗███╗   ███╗
     ████╗ ████║   ██║██╔══██╗██╔══██╗██╔══██╗██║  ██║██║████╗ ████║
     ██╔████╔██║   ██║██████╔╝██████╔╝███████║███████║██║██╔████╔██║
     ██║╚██╔╝██║   ██║██╔══██╗██╔══██╗██╔══██║██╔══██║██║██║╚██╔╝██║
     ██║ ╚═╝ ██║██╗██║██████╔╝██║  ██║██║  ██║██║  ██║██║██║ ╚═╝ ██║
     ╚═╝     ╚═╝╚═╝╚═╝╚═════╝ ╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚═╝╚═╝     ╚═╝
*/
#define speed  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FOR(n) for(int i=0;i<n;i++)
#define For(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define E "\n"
#define all(e) e.begin(),e.end()
#define F first
#define S second
#define pi (acos(-1))
#define rad(x) ((x*pi)/(ld)(180))
#define perc(x) fixed<<setprecision(x)
/*****
#define cross(a, b) ((conj(a) * (b)).Y)
#define dot(a, b) ((conj(a) * (b)).X)
#define vec(a,b) ((b) - (a))
#define rot(p,angle) (p)*polar((double)(1),angle)
#define rot2(p,angle,a) ((p)-(a)) *(polar((ld)(1),angle)+ (a))
#define x real()
#define y imag()
*****/
typedef long long int ll; typedef unsigned long long ull; typedef long double ld;typedef complex<ld> point; typedef tuple<double,double,double> line;
ll gcd(ll x,ll y){if(!y)return x; return gcd(y,x%y);};   ll lcm(ll x,ll y){return (x*y)/__gcd(x,y);}

int dp[1005][1005],n,m;
char arr[1005][1005];

ll solve(int i,int j)
{

}
int mod=1e9+7;
int main(){ speed;
memset(dp,0,sizeof dp);
cin>>n>>m;

for(int i=0;i<n;i++)for(int j=0;j<m;j++)cin>>arr[i][j];

dp[0][0]=1;
for(int i=0 ; i<n; i++)
{
    for(int j=0; j<m ; j++)
    {
        if(arr[i][j]=='#')continue;

        if(i)
        dp[i][j] = (dp[i][j] + dp[i-1][j])% mod;
        if(j)
        dp[i][j] = (dp[i][j] + dp[i][j-1]) % mod;

    }
}

cout<< dp[n-1][m-1];

return 0;}


Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<string> s(n);
  for(int i=0;i<n;i++)
  {
  	cin>>s[i];
  }

  int n1=0,n2=0,n3=0,n4=0;
  for(int i=0;i<s.size();i++)
  {
    if(s[i]=="AC") n1++;
    if(s[i]=="WA") n2++;
    if(s[i]=="TLE") n3++;
    if(s[i]=="RE") n4++;
  }
  cout<<"AC x "<<n1<<endl;
  cout<<"WA x "<<n2<<endl;
  cout<<"TLE x "<<n3<<endl;
  cout<<"RE x "<<n4<<endl;

  
  return 0;
}

Measured memory_bytes: 6424
#include<iostream>
#include<cmath>
using namespace std;
int gcd(int x,int y){
  if(y>x){
    int t=x;
    x=y;
    y=t;
  }
  while(true){
    int t=y;
    y=x%y;
    x=t;
  
    if(y==0){return x;}
  }
}

int lcm(int x,int y){
  return (double)x/gcd(x,y)*y;//オーバーフロー防止

}


int main(){
  int n,m;
  while(cin>>n>>m){
    cout<<gcd(n,m)<<' '<<lcm(n,m)<<endl;
  }
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<iterator>
#include<stack>
#include<queue>
#include<utility>
#include<functional>
#include<bitset>
#include<numeric>
#include<cstring>
#include<tuple>
using namespace std;

int n, m, price;
long long ans = 0;
multiset< int > s;

int main( void )
{
	ios :: sync_with_stdio( 0 );
	cin.tie( 0 );
	
	cin >> n >> m;
	for( int i = 1; i <= n; ++i )
	{
		cin >> price;
		s.insert( price );		
	}
	for( int i = 1; i <= m; ++i )
	{
		price = *s.rbegin();
		s.erase( s.find( price ) );
		s.insert( ( price >> 1 ) );
	}
	for( int price : s )
	{
		ans += price;
	}
	cout << ans << "\n";	
	return 0;
}

Measured memory_bytes: 4992
a, b = map(int, input().split())

bd = []
for i in range(32):
    bd.append(['#' for _ in range(64)])
for i in range(32):
    bd.append(['.' for _ in range(64)])

for i in range(a - 1):
    bd[(i // 32) * 2][(i % 32) * 2] = '.'

for i in range(b - 1):
    bd[63 - (i // 32) * 2][63 - (i % 32) * 2] = '#'

print("64 64")
for i in range(64):
    print(''.join(bd[i]))

Measured memory_bytes: 39152
#include <bits/stdc++.h>
#define ll long long int
#include<list>
#include<algorithm>
#define ld long double
#define pb push_back
#define FF first
#define SS second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repr for(i=n-1;i>=0;i--)
#define PLL pair<ll, ll>
#define inf 100000001
#define mod 1000000007
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define PQ priority_queue
#define rep1 for(i=1;i<=n;i++)
#define VLL vector<ll>
#define EF else if
const double pie  =3.141592653589793238463;
#define all(x) (x).begin(), (x).end()
#define SORT(A) sort(A.begin(), A.end());
#define REVERSE(A) reverse(A.begin(), A.end());
#define UMP unordered_map
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll myXOR(unsigned long long int x, unsigned long long int y)
{
    return (x|y)&(~x|~y);   
}
ll powerLL(ll x, ll n) 
{ 
    ll result = 1; 
    while (n) { 
        if (n & 1) 
            result = result * x % mod; 
        n = n / 2; 
        x = x * x % mod; 
    }
    return result; 
} 
int main()
{
    fastio
    ll a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r, t,u,w,x,y,z;
    string str, ss, str1;
    
    cin>>k>>str;
    if(str.length()<=k)
        cout<<str;
    else
    {
        cout<<str.substr(0, k) + "...";
    }
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  bool is_poor = false;
  if (a == b && b != c) is_poor = true;
  if (b == c && c != a) is_poor = true;
  if (c == a && a != b) is_poor = true;
  
  if (is_poor)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int a, p;
  cin >> a >> p;
  cout << (a*3+p)/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdlib.h>
#include<string.h>
#define ll long long
#define ull unsigned long long int
#define T int test; scanf("%d",&test); while(test--)
#define pb push_back
#define in insert
#define PI acos(-1)
#define sc(n) scanf("%d",&n)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define lsc(n) scanf("%lld",&n)
#define lsc2(a,b) scanf("%lld%lld",&a,&b)
#define rep(i,n) for(i=0;i<n;i++)
#define fr(i,a,b) for(i=a;i<b;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/__gcd(a,b)
using namespace std;



int main()
{
	string s;
	cin >> s;
	int i;
	rep(i,3)
	{
		if(s[i]=='7')
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3600
from scipy.special import comb
s=int(input())
mod = 1000000007
if s in [0,1,2]:
    print(0)
else:
    n = s//3
    a = 0
    for i in range(n):
        i +=1
        c = s - 3*i
        a += comb((c+i-1),(i-1),exact=True)
        a = a%mod
    print(a%mod)

Measured memory_bytes: 42180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int n,K,i,j;
ll a[N],b[N];
int main(){
	scanf("%d%d",&n,&K);
	bool fl=1;
	for(i=1;i<=n;++i)scanf("%lld",a+i);
	for(j=1;j<=K;++j){
		memset(b+1,0,n+1<<3);
		for(i=1;i<=n;++i)++b[max(1ll,i-a[i])],--b[min(n+1ll,i+a[i]+1)];
		for(i=1;i<=n+1;++i)b[i]+=b[i-1];
		memcpy(a+1,b+1,n<<3);
		bool bb=1;for(i=1;i<=n;++i)bb&=a[i]==n;if(bb)break;
	}
	for(i=1;i<=n;++i)printf("%lld%c",a[i],i==n?'\n':' ');
}

Measured memory_bytes: 6944
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii, std.numeric, std.random;
import std.typecons, std.functional, std.traits,std.concurrency;
import std.algorithm, std.container;
import core.bitop, core.time, core.memory;
import std.bitmanip;
import std.regex;

enum INF = long.max/3;
enum MOD = 10L^^9+7;

//辞書順順列はiota(1,N),nextPermituionを使う


void end(T)(T v)
if(isIntegral!T||isSomeString!T||isSomeChar!T)
{
    import core.stdc.stdlib;
    writeln(v);
    exit(0);
}

T[] scanArray(T = long)()
{
    static char[] scanBuf;
    readln(scanBuf);
    return scanBuf.split.to!(T[]);
}

dchar scanChar()
{
    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    return cast(dchar)c;
}

T scanElem(T = long)()
{
    import core.stdc.stdlib;
    static auto scanBuf = appender!(char[])([]);

    scanBuf.clear;

    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    while (!isWhite(c) && c != -1)
    {
        scanBuf ~= cast(char) c;
        c = getchar;
    }
    return scanBuf.data.to!T;
}

dchar[] scanString(){
    return scanElem!(dchar[]);
}


void main()
{
    auto A = scanElem;
    auto B = scanElem;
  	writeln((A+B+1)/2);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int N, M;
	int road[1001],weather[1001];
	cin >> N >> M;
	for (int i = 1; i <= N; ++i) {
		cin >> road[i];
	}
	for (int i = 1; i <= M; ++i) {
		cin >> weather[i];
	}
	int *map[1001];
	map[0] = new int[M - N + 2]{0};
	for (int i = 1; i <= N; ++i) {
		map[i] = new int[M - N + 2];
		map[i][0] = 2000000000;
		for (int j = 1; j <= M - N + 1; ++j) {
			map[i][j] = min(map[i][j - 1], road[i] * weather[i + j - 1] + map[i - 1][j]);
		}
	}
	cout << map[N][M - N + 1] << endl;
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    int cnt = 0;
    for (int i = 0; i < s.size()-1; i++){
        if(s[i]!=s[i+1]) cnt++;
    }
    cout << cnt << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 512
program main

    ! <module>s to import
    use, intrinsic :: iso_fortran_env

    ! require all variables to be explicitly declared
    implicit none

    ! variables for this <program>
    logical,        allocatable :: status_snack(:,:)
    integer(INT16)              :: num_people
    integer(INT16)              :: num_snack
    integer(INT16)              :: num_victims
    integer(INT16)              :: bffr_num_snack
    integer(INT16), allocatable :: bffr_id(:)

    ! support variables for this <program>
    integer(INT16) :: itr_id, itr_snack


    read(unit= INPUT_UNIT, fmt= *) num_people, num_snack

    allocate( status_snack(1:num_snack, 1:num_people) )
    allocate( bffr_id(1:num_people) )

    do itr_snack = 1_INT16, num_snack, 1_INT16

        read(unit= INPUT_UNIT, fmt= *) bffr_num_snack
        read(unit= INPUT_UNIT, fmt= *) bffr_id(1:bffr_num_snack)

        do itr_id = 1_INT16, bffr_num_snack, 1_INT16
            status_snack( itr_snack, bffr_id(itr_id) ) = .true.
        end do

    end do

    num_victims = num_people

    loop_id    : do itr_id    = 1_INT16, num_people, 1_INT16
    loop_snack : do itr_snack = 1_INT16, num_snack,  1_INT16
        if ( status_snack(itr_snack, itr_id) ) then
            num_victims = num_victims - 1_INT16
            exit loop_snack
        end if
    end do loop_snack
    end do loop_id

    deallocate( status_snack )
    deallocate( bffr_id )

    write(unit= OUTPUT_UNIT, fmt='(I0)') num_victims

end program main

Measured memory_bytes: 2932
import sys
N=int(input())
T=[int(i) for i in input().split()]
A=[int(i) for i in input().split()]

if T[-1] != A[0]:
    print(0)
    sys.exit()

max_=T[-1]
MAX_T=[max_ for _ in range(N)]
MIN_T=[1 for _ in range(N)]
MAX_A=[max_ for _ in range(N)]
MIN_A=[1 for _ in range(N)]

MAX_T[0] = T[0]
MIN_T[0] = T[0]
for i in range(1,N):
    MAX_T[i] = T[i]
    if T[i] > T[i-1]:
        MIN_T[i] = T[i]
    else:
        MIN_T[i] = 1 

#print(MAX_T)
#print(MIN_T)   
        
MAX_A[-1] = A[-1]
MIN_A[-1] = A[-1]
for i in range(0,N-1)[::-1]:
    MAX_A[i] = min(MAX_A[i],A[i])
    if A[i] > A[i+1]:
        MIN_A[i] = min(MAX_A[i],A[i])
    else:
        MIN_A[i] = max(1,MIN_A[i])
        
#print(MAX_A)
#print(MIN_A)

sum_= 1
lim = 10**9 + 7
for i in range(N):
    if (MAX_T[i] < MIN_A[i]) or (MAX_A[i] < MIN_T[i]):
        print(0)
        sys.exit()
    else:
        sum_ = (sum_ * (min(MAX_T[i],MAX_A[i]) - max(MIN_T[i],MIN_A[i]) +1 )) % lim
print(sum_)

Measured memory_bytes: 89700
N = int(input())
L = list(map(int, input().split()))
res = 0
tmp = [0 for _ in range(N)]

while True:
    #res += 1
    flag = False
    co = 0
    for i in range(N):
        if L[i] != tmp[i] and flag == True:
            tmp[i] += 1
        elif L[i] != tmp[i] and flag == False:
            tmp[i] += 1
            flag = True
            res += 1
        elif L[i] == tmp[i]:
            flag = False
            
    for i in range(N):
        if L[i] == tmp[i]:
            co += 1
            
    if co == N:
        break
        
print(res)

Measured memory_bytes: 3064
import java.util.*;
import java.util.Arrays;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int [] l = new int[200001];
        int N = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        int ans = 0;
        for(int i = 0; i < N; i++)
            l[Integer.parseInt(sc.next())]++;
            Arrays.sort(l);
        for(int i = 0; i < 200001-K; i++)
            ans += l[i];
        System.out.println(ans);
    }
}


Measured memory_bytes: 59572
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    L = int(input())

    m = []
    while L > 1:
        if L % 2 == 0:
            m.append(0)
            L //= 2
        else:
            m.append(1)
            L -= 1

    ans = []
    last = 1
    l = 1
    for x in m[::-1]:
        if x == 0:
            for i in range(len(ans)):
                ans[i][2] *= 2

            ans.append([last, last + 1, 0])
            ans.append([last, last + 1, 1])
            last += 1
            l *= 2
        else:
            ans.append([1, last, l])
            l += 1

    print(last, len(ans))
    for x in ans:
        print(*x)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4468
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#include <math.h>
#include <iomanip>
#include <set>
using namespace std;
int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int a[n],b[n];
    long long asum,bsum;
    asum=0;bsum=0;
    bool hata=0;
    long long at,bt;
    at=0;bt=0;
    for(int i=0;i<n;++i){cin>>a[i];asum+=a[i];}
    for(int i=0;i<n;++i){cin>>b[i];bsum+=b[i];if(a[i]!=b[i]){hata=1;}
        if(a[i]>b[i]){bt=bt+a[i]-b[i];}
        if(a[i]<b[i]){at=at+(b[i]-a[i])/2;}
    }
    //if(asum>bsum){cout<<"No"<<endl;return 0;}
    //if(hata==0){cout<<"Yes"<<endl;return 0;}
    if(at>=bt){cout<<"Yes"<<endl;return 0;}else{
        cout<<"No"<<endl;return 0;
    }
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Vec = vector<int>;
using Graph = vector<Vec>;

int		main(void)
{
	ld w, h, x ,y;
	cin >> w >> h >> x >> y;
	ld ans = w * h / 2;
	cout << ans;
	if (w / 2 == x && h / 2 == y)
		cout << " 1" << endl;
	else
		cout << " 0" << endl;
}


Measured memory_bytes: 256
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    a = int(input())

    if a ==1:
        print("Hello World")
    else:
        b =int(input())
        c = int(input())
        print(b+c)

Measured memory_bytes: 3952
N = int(input())
v_i = list(map(int, input().split()))

A = 0
B = 0

while len(v_i) != 1:
    A = min(v_i)
    del v_i[v_i.index(A)]
    B = min(v_i)
    del v_i[v_i.index(B)]
    v_i.append((A + B) / 2)

print(v_i[0])


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

void InsertSort(int x[], int N);

int main(){
    int N, i;
    string buf;

    cin >> buf;
    N = stoi(buf);

    int x[N];

    for(i = 0; i < N; i++){
        cin >> buf;
        x[i] = stoi(buf);
    }
    InsertSort(x, N);

    return 0;
}

void InsertSort(int x[], int N){
    int tmp, j, k;

    for(int i = 1; i < N; i++){
        for(k = 0; k < N - 1; k++){
            cout << x[k] << " ";
        }
        cout << x[k] << endl;
        tmp = x[i];
        j = i - 1;
        while(j >= 0 && x[j] > tmp){
            x[j+1] = x[j];
            j--;
        }
        x[j+1] = tmp;

    }
    for(k = 0; k < N - 1; k++){
        cout << x[k] << " ";
    }
    cout << x[k] << endl;
}

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

int main(){
    int n,x,y; cin >> n >> x >> y;
    --x; --y;
    map<int,int> mp;
    rep(i,n){
        for(int j=i+1;j<n;++j){
            int d = min(abs(i-j),abs(i-x)+1+abs(y-j));
            d = min(d,abs(j-x)+1+abs(i-y));
            mp[d]++;
        }
    }
    for(int d=1;d<=n-1;++d) cout << mp[d] << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll x;
	cin>>x;
	ll val = 100,count=0;
	while(val<x){
		ll in = val/100;
		val+=in;
		count++;
	}
	cout<<count;
	
	return 0;
}

Measured memory_bytes: 3648
#include<cstdio>
#define neko 3010
#define cmin(a,b) ((a)<(b)?(a):(b))
#define f(i,a,b) for(register int i=(a);i<=(b);i=-(~(i)))
#define travel(i,u,v) for(register int i=head[u],v=e[i].v;i;i=e[i].nex,v=e[i].v)
struct node
{int u,v,nex;}e[neko<<1];
int dep[neko],head[neko],t,n,k,cnt,ans=2e9;
void dfs(int u,int fa,int deep)
{
	dep[u]=deep;
	travel(i,u,v)if(v^fa)dfs(v,u,deep+1);
}
void add(int x,int y)
{
	e[++t].v=y,e[t].u=x,e[t].nex=head[x],head[x]=t;
	e[++t].v=x,e[t].u=y,e[t].nex=head[y],head[y]=t;
}
int main()
{
	int x,y;
	scanf("%d%d",&n,&k);
	f(i,1,n-1)scanf("%d%d",&x,&y),add(x,y);
	if(k&1)
	{
		f(i,1,n)
		{
			dfs(e[i].u,e[i].v,0);
			dfs(e[i].v,e[i].u,0);
			f(j,1,n)if(dep[j]>(k-1)/2)++cnt;
			ans=cmin(ans,cnt),cnt=0;
		}
	}
	else
	{
		f(i,1,n)
		{
			dfs(i,0,0);
			f(j,1,n)if(dep[j]>k/2)++cnt;
			ans=cmin(ans,cnt),cnt=0;
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 384
k = int(input())
n = 3
cnt = [0] * (k + 1)

for i in range(k, 0, -1):
    cnt[i] = (k // i) ** n
    for j in range(i * 2, k + 1, i):
        cnt[i] -= cnt[j]

print(sum((i* cnt[i] for i in range(1, k + 1))))


Measured memory_bytes: 9172
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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








int main(){
    int N; std::cin >> N;
    long long cnt(0);
    std::vector<int> L(N);
    for(int i(0); i < N; ++i) std::cin >> L[i];
    std::sort(std::begin(L), std::end(L));
    for(int mid(1), mid_len(N-1); mid < mid_len; ++mid){
        for(int high(mid+1); high < N; ++high){
            int lowlow(L[high] - L[mid] + 1);
            cnt += std::max(0L, std::distance(std::lower_bound(std::begin(L), std::end(L), lowlow), std::begin(L) + mid));
        }
    }
    std::cout << cnt << std::endl;
    return 0;
}


Measured memory_bytes: 3580
while(True):
	stack1=[]
	flag=-1
	st=raw_input()
	#print st,"!"


	if st==".":
		break
	for s in st:
		if s=="(":
			stack1.append(s)
		elif s=="[":
			stack1.append(s)
		elif s==")":
			if len(stack1)==0:
				flag=0
				break
			if stack1[len(stack1)-1]!="(":
				flag=0
				break

			stack1.pop()
		elif s=="]":
			if len(stack1)==0:
				flag=0
				break
			if stack1[len(stack1)-1]!="[":
				flag=0
				break
			stack1.pop()


	if flag!=0 and len(stack1)==0:
		print "yes"
		continue
	print "no"
	continue

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

namespace AtCoder
{
    class Program
    {
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }

        static long[] ReadLongs()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        static double ReadDouble()
        {
            return double.Parse(Console.ReadLine());
        }

        static double[] ReadDoubles()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }

        static string ReadString()
        {
            return Console.ReadLine();
        }

        static string[] ReadStringSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        static void A()
        {
            var AB = ReadLongs();
            var A = AB[0];
            var B = AB[1];
            Console.WriteLine(Math.Max(A - (2 * B), 0));
        }

        static void B()
        {
            var N = ReadLong();
            var ds = ReadLongs();
            long ans = 0;
            foreach (var x in Enumerable.Range(0, (int)N))
            {
                foreach (var y in Enumerable.Range(x, (int)N - x))
                {
                    if (x == y)
                    {
                        continue;
                    }
                    ans += ds[x] * ds[y];
                }
            }
            Console.WriteLine(ans);
        }

        static void C()
        {
            var N = ReadLong();
            var S = ReadString();
            char prev = '0';
            long ans = 0;
            foreach (var x in S)
            {
                if (x == prev)
                {
                    continue;
                }

                prev = x;
                ans++;
            }
            Console.WriteLine(ans);
        }

        static void D()
        {

        }

        static void Main(string[] args)
        {
            //A();
            //B();
            C();
            //D();
        }
    }
}


Measured memory_bytes: 27920
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    S=ST()
    
    left_d = {"E":0, "W":0}
    right_d = Counter(S[:])
    ans = inf
    for i in range(N):
        right_d[S[i]]-=1
        cost = left_d["W"] + right_d["E"]
        ans = min(ans,cost)
        left_d[S[i]]+=1
    print(ans)
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 67436
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")
 
#include <bits/stdc++.h>
#include<fcntl.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
 
#define X first
#define Y second
 
//#include <boost/unordered_map.hpp>
//using namespace boost;
 
/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/
 
using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
//using i128 = __int128_t;
//using u128 = __uint128_t;
//using i128 = i64;
//using u128 = u64;
 
ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}
 
ll exgcd(ll a, ll b, ll &x, ll &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll px, py;
	ll d = exgcd(b, a%b, px, py);
	x = py;
	y = px-a/b*py;
	return d;
}
 
template<class T>
inline void freshmin(T &a, const T &b)
{
	if (a > b) a = b;
}
 
template<class T>
inline void freshmax(T &a, const T &b)
{
	if (a < b) a = b;
}

template<class T>
void print(const T &a)
{
	for (auto x : a) printf("%d ", x); puts("");
}

const int MAXN = 100010;
const int MAXM = 26;
//const i64 INF = 1000000000000000000LL;
const int INF = 1000000000;
//const int MOD = 998244353;
const int MOD = 998244853;
const int INV2 = (MOD+1)/2;
const ld pi = 3.1415926535897932384626433;

int n;
int a[MAXN];

void solve()
{
	string a, b;
	cin >> a >> b;
	int ans = 0;
	for (int i = 0; i < 3; ++ i) ans += a[i] == b[i];
	cout << ans << endl;
}

int main()
{
	/*
	int T;
	scanf("%d", &T);
	while (T --)*/
		solve();
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#define MN 200000
#define mpair(a,b) std::make_pair(a,b)
int n,m,c,q[MN+5],ans;
std::set<std::pair<int,int>> s;
bool ck(int x,int y){
	if(x>n||y>m) return false;
	return s.find(mpair(x,y))==s.end();
}
bool down(int &x,int y){
	if(!ck(x+1,y)) return false;
	x++; return true;
}
int main(){
	scanf("%d%d%d",&n,&m,&c);
	for(int i=1;i<=c;i++){
		static int x,y;
		scanf("%d%d",&x,&y);
		s.insert(mpair(x,y));
	}
	int x=1;
	for(int y=1;y<=m;y++){
		q[y]=x;
		if(!down(x,y)) break;
		while(!ck(x,y+1)) if(!down(x,y)) break;
		if(!ck(x,y+1)) break;
	}
	ans=n;
	for(auto it=s.begin();it!=s.end();it++){
		if(q[it->second]!=0&&it->first>q[it->second])
			ans=std::min(ans,it->first-1);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 10112
unittest
{
	assert( [ "5 1 5 2 4" ].parse.expand.solve == "YES" );
	assert( [ "4 7 6 4 5" ].parse.expand.solve == "NO" );
	assert( [ "48792 105960835 681218449 90629745 90632170" ].parse.expand.solve == "NO" );
	assert( [ "491995 412925347 825318103 59999126 59999339" ].parse.expand.solve == "YES" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nabcd = input.front.split.to!( long[] );
	return tuple( nabcd[ 0 ], nabcd[ 1 ], nabcd[ 2 ], nabcd[ 3 ], nabcd[ 4 ] );
}

auto solve( long n, long a, long b, long c, long d )
{
	n--;
	for( auto i = 0L; i <= n; i++ )
	{
		auto l = a - ( d * i ) + ( c * ( n - i ) );
		auto r = a - ( c * i ) + ( d * ( n - i ) );
		if( l <= b && b <= r ) return "YES";
	}
	return "NO";
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
int n;
char s[20],t[20];
int main()
{
	scanf("%s%s",s+1,t+1); n=strlen(s+1);
	for (int i=1;i<=n;i++) if (s[i]!=t[i]) {printf("No\n"); return 0;}
	printf("Yes\n");
return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, h, w;
    cin >> n >> h >> w;
    int ans = 0;
    rep(i, n) rep(j, n) {
        int x = i + h - 1;
        int y = j + w - 1;
        if (x<n && y<n) ans++;
    }
    
    pr(ans);
    return 0;
}


Measured memory_bytes: 3572
n=int(input())
x=int(n**0.5)+1
l=[]
for i in range(1,x):
  if n%i==0:
    l.append(i)
l=list(set(l))
L=[]
for i in range(len(l)):
  L.append(l[i]+n//l[i]-2)
print(min(L))

Measured memory_bytes: 3316
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
  char c;
  cin >> c;
  
  if(c=='A'){
	cout << "T" << endl;
    return 0;
  }else if(c=='T'){
	cout << "A" << endl;
    return 0;
  }else if(c=='G'){
	cout << "C" << endl;
    return 0;
  }else if(c=='C'){
	cout << "G" << endl;
    return 0;
  }
  return 0;
}

Measured memory_bytes: 256
import itertools
 
N = int(input())
L = list(map(int,(input().split())))
L.sort()
Combi = list(itertools.combinations(L, 3))
count = 0
 
for i in Combi:
    a = int(i[0])
    b = int(i[1])
    c = int(i[2])
    if((a+b)> c and a!=b != c and  a<b <c ):
        count+=1
 
print(count)

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

int main() {
    int h, w, n, c[100][100], x, y;
    cin >> h >> w >> n;
    x = y = 0;
    for(int i=1;i<=n;i++){
        int a;
        cin >> a;
        while((a--)>0){
            c[x][y] = i;
            if(x%2==0){
                if(y<w-1)y++;
                else x++;
            }else{
                if(y>0)y--;
                else x++;
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout << c[i][j] << " ";
        }
        cout << endl;
    }
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
    int main(){
        int N;cin>>N;
     vector<int> a(N);

     for(int i=0;i<N;i++)cin>>a[i];

     sort(a.begin(),a.end());
    if(a[N/2]!=a[N/2-1])cout<<a[N/2]-a[N/2-1]<<endl;
    else cout<<0<<endl;


    }










Measured memory_bytes: 640
#include <iostream>

using namespace std;

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

    int a,b;
    cin >> a >> b;
    if(a%3 == 0 || b%3 == 0 || (a+b)%3 == 0) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    return 0;
}


Measured memory_bytes: 384