akhauriyash/Code-Regression huggingface dataset:
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

using ll = long long;

template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

#define mp make_pair
#define mt make_tuple

/* ----------- debug ---------- */

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p);

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "(" << p.first << "," << p.second << ")";
}

/* ---------- Constants ---------- */

// const ll MOD = 1000000007;
// const ll MOD = 998244353;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */

template <typename T>
inline T sq(T a) { return a * a; }

template <typename T>
T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    return b == 0 ? a : gcd(b, a % b);
}

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b /* % MOD */;
    if (n % 2 == 0) {
        return mypow(b * b /* % MOD */, n / 2);
    } else {
        return mypow(b, n - 1) * b /* % MOD */;
    }
}

ll pcnt(ll b) {
    return __builtin_popcountll(b);
}

template <typename T>
T iceil(T n, T d) {
    return (n + d - 1) / d;
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

int main() {
    double t, x;
    cin >> t >> x;
    cout << fixed << setprecision(10) << t / x << endl;
    return 0;
}


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

char matrix[77][77];
string dp[77][77];

bool is_num(char c) {
    return c >= '0' && c <= '9';
}

void chmax(string& s1, string s2) {
    if (s1.size() > s2.size()) return;
    else if (s1.size() < s2.size()) s1 = s2;
    else {
        for (int i = 0; i < s1.size(); i++) {
            if (s1[i] > s2[i]) return;
            else if (s1[i] < s2[i]) {
                s1 = s2;
                return;
            }
        }
    }
}

void solve(int w, int h) {
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) cin >> matrix[i][j];
    }
    for (int i = 0; i <= h; i++) {
        for (int j = 0; j <= w; j++) {
            dp[i][j] = "0";
        }
    }
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            if (!is_num(matrix[i][j])) continue;
            string s1 = dp[i - 1][j] + matrix[i][j];
            string s2 = dp[i][j - 1] + matrix[i][j];
            chmax(dp[i][j], s1);
            chmax(dp[i][j], s2);
        }
    }
    string ans = "0";
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            if (dp[i][j] == "") continue;
            for (int k = 0; k < dp[i][j].size(); k++) {
                if (dp[i][j][k] == '0') continue;
                string now = dp[i][j].substr(k, dp[i][j].size() - k);
                chmax(ans, now);
            }
        }
    }
    cout << ans << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int W, H;
    while (true) {
        cin >> W >> H;
        if (W == 0 && H == 0) break;
        solve(W, H);
    }
    return 0;
}


Measured memory_bytes: 3368
#include<bits/stdc++.h>
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define ss st.st
#define sn st.nd 
/****************************/
using namespace std;
ll d,t,s,ans;
int main()
{
	cin>>d>>t>>s;
	ans=t*s;
	if(d>ans)
	{
		cout<<"No";
	 }
	 else
	 {
	 	cout<<"Yes";
	 }
	return 0;
}

Measured memory_bytes: 3632
#include"bits/stdc++.h"

using namespace std;

int main() {
	int N, X;
	cin >> N >> X;
	int sum = 0;
	int cnt = 0;
	vector<int>m(N);

	for (int i = 0; i < N; i++) {
		cin >> m[i];
		sum += m[i];
		cnt++;
	}
	sort(m.begin(), m.end());
	cout << ((X - sum) / m[0]) + N << endl;


	return 0;
}

Measured memory_bytes: 256
s = input()
l = 0
r = 0
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == "0":
            l += 1
        elif s[i] == "1":
            r += 1
    elif i % 2 == 1:
        if s[i] == "0":
            r += 1
        elif s[i] == "1":
            l += 1
print(min(r,l))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
const ll INF = 1LL << 60;

int main(){
	int n, k; cin >> n >> k;
	int ans = 1;
	for(int i = 0; i < n; ++i){
		ans = min(ans*2, ans+k);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const N_MAX = 10e5 + 100;
ll const INF = 1LL << 60;
ll dp[N_MAX];
vector<vector<ll>> g;

ll dfs(int pos, ll score) {
  if (dp[pos] != -INF) {
    return dp[pos] + score;
  }
  ll cur_score = 0;
  for (int next_pos : g[pos]) {
    cur_score = max(cur_score, dfs(next_pos, 0) + 1);
  }
  dp[pos] = cur_score;
  return score + cur_score;
}

int main() {
  ll N, M;
  cin >> N >> M;
  g.resize(N);
  for (int i = 0; i < M; i++) {
    ll x, y;
    cin >> x >> y;
    x--;
    y--;
    g[x].push_back(y);
  }
  for (int i = 0; i < N_MAX; i++) {
    dp[i] = -INF;
  }
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    ans = max(ans, dfs(i, 0));
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int D;
  cin >> D;
  if(D==25) cout << "Christmas" << endl;
  else if(D==24) cout << "Christmas Eve" << endl;
  else if(D==23) cout << "Christmas Eve Eve" << endl;
  else cout << "Christmas Eve Eve Eve" << endl;
}

Measured memory_bytes: 256
from math import ceil
INF = 10 ** 10

D, G = map(int, input().split())
pairs = [map(int, input().split()) for _ in range(D)]
ps, cs = zip(*pairs)

minimumsolve = INF

for i in range(1 << D):
    solve = 0
    score = 0
    for j in range(D):
        if i & 1 << j:
            solve += ps[j]
            score += ps[j] * 100 * (j+1) + cs[j]
    if score < G:
        for j in range(D-1, -1, -1):
            if not i & 1 << j:
                neededsolve = ceil((G - score) / (100*(j+1)))
                if neededsolve >= ps[j]:
                    solve = INF
                    break
                else:
                    solve += neededsolve
                    #score doesn't have to be updated
                    break
    minimumsolve = min(minimumsolve, solve)

print(minimumsolve)



Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
long long moder = 1000000007;
long long fac[200005];
long long multi(long long a,long long b){
	if(b==0) return 1;
	if(b==1) return a;
	long long ret = multi(a,b/2);
	ret*=ret;
	ret%=moder;
	if(b%2){
		ret*=a;
		ret%=moder;
	}
	return ret;
}
long long combi(long long n,long long k){
	long long ret = 1;
	for(int i=0; i<k; i++){
		ret*=(n-i);
		ret%=moder;
	}
	return (ret*multi(fac[k],moder-2))%moder;
}
int main(){
	fac[0] = 1;
	for(int i=1; i<=200000; i++){
		fac[i] = fac[i-1]*i;
		fac[i]%=moder;
	}
	long long n,a,b;
	cin>>n>>a>>b;
	long long ret = multi(2,n);
	long long minus = (1+combi(n,a)+combi(n,b))%moder;
	ret-=minus;
	if(ret<0) ret+=moder;
	cout<<ret;
}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b && b==c){
    cout << 1 << endl;}
  else if(a!=b && b!=c && c!=a){
    cout << 3 << endl;}
  else{
    cout << 2 << endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll N, M, Q;
ll a[105], b[105], c[105], d[105];
ll ans;
vector<ll> v;

void dfs(int index) {
    if(index == N + 1) {
        ll now = 0;
        for(int i = 1; i <= Q; i++) {
            if(v[b[i]] - v[a[i]] == c[i]) now += d[i];
        }
        ans = max(ans, now);
        return;
    }
    for(int val = v[index-1]; val <= M; val++) {
        v.push_back(val);
        dfs(index + 1);
        v.pop_back();
    }
}

void input() {
    cin >> N >> M >> Q;
    for(int q = 1; q <= Q; q++) {
        cin >> a[q] >> b[q] >> c[q] >> d[q];
    }
}

void solve() {
    input();
    ans = 0;
    v = {1};
    dfs(1);
    cout << ans << endl;
    return;
}

int main() {
    solve();
    return 0;
}

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

#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define all(vec) vec.begin(), vec.end()
#define per(i,N) for (int i=(int)N-1; i>=0; i--)
//#define int long long
#define endl "\n"
typedef long long ll;

void trace(vector<char> v, int size) {
  rep(i, size) cout << v[i];
  cout << endl;
}

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

  int H, W; cin >> H >> W;

  rep(i, H) {
    vector<char> v;
    rep(j, W) {
      char c; cin >> c;
      v.push_back(c);
    }
    trace(v, W);trace(v, W);
  }

  return 0;
}

Measured memory_bytes: 256
from collections import deque

a, b, c = map(int, input().split())

def bfs(a, b, c):
    cnt = 0
    queue = deque([[a, b, c, cnt]])

    while queue:
        a, b, c, cnt = queue.popleft()
        if a == b and b == c:
            return cnt
        if a >= 60 or b >= 60 or c >= 60:
            return cnt

        if b > a and b > c:
            queue.append([a+1, b, c+1, cnt+1])
        elif a > b and a > c:
            queue.append([a, b+1, c+1, cnt+1])
        elif c > a and c > b:
            queue.append([a+1, b+1, c, cnt+1])
        elif a < b:
            queue.append([a+2, b, c, cnt+1])
        elif b < c:
            queue.append([a, b+2, c, cnt+1])
        elif c < a:
            queue.append([a, b, c+2, cnt+1])

print(bfs(a, b, c))


Measured memory_bytes: 3316
#include <stdio.h>
int min(int n,int m){
    if(n<m) return n;
    else return m;
}
int max(int n,int m){
    if(n>m) return n;
    else return m;
}
int main(void){
    int a,b;
    scanf("%d%d",&a,&b);
    for(int i=0;i<max(a,b);i++){
        printf("%d",min(a,b));
    }
    return 0;
}

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

using namespace std;


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

  int s = 0;
  for (int i = 1; i <= x; i++) {
    s += i;
    if (s >= x) {
      cout << i << '\n';
      return 0;
    }
  }

  return 0;
}


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

int main(){
  string s;
  cin >> s;
  bool ok = true;
  
  for(int i = 0; i < s.size(); i++){
    for(int j = i + 1; j < s.size(); j++){
      if(s[i] == s[j]){
        ok = false;
        break;
      }
    }
  }
  
  if(ok){
    cout << "yes" << endl;
  }
  
  else
    cout << "no" << endl;
}
        
        
  
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int dp[31][4] = {};
  dp[1][1] = 1;
  dp[2][1] = dp[2][2] = 1;
  dp[3][1] = 2;
  dp[3][2] = dp[3][3] = 1;
  for(int i=4;i<31;++i){
    for(int j=1;j<4;++j){
      dp[i][j] += dp[i-j][1] + dp[i-j][2] + dp[i-j][3]; 
    }
  }
  while(cin>>n, n){
    int ans=0;
    for(int i=1;i<4;++i)
      ans += dp[n][i];
    ans = (ans+9)/10;
    ans = (ans+364)/365;
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3064
input_list = raw_input().split(" ")
r = int(input_list[0])
c = int(input_list[1])

i = 0
array = []
while i < r:
  input_line = raw_input().split(" ")
  array.append(map(int, input_line))
  i += 1

# print array

for i in xrange(len(array)):
  sum = 0
  for j in xrange(len(array[i])):
    sum += array[i][j]
  array[i].append(sum)

# print array

list = []
for i in xrange(c + 1):
  sum = 0
  for j in xrange(r):
    sum += array[j][i]
  list.append(sum)
array.append(list)

for i in xrange(r + 1):
  output = ""
  for j in xrange(c + 1):
    output += " " + str(array[i][j])
  print output.strip()

Measured memory_bytes: 6564
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int n;
int arr[maxn];
int mxl[maxn],mxr[maxn];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&arr[i]);
    mxl[1]=arr[1]; mxr[n]=arr[n];
    for(int i=2;i<=n;i++)mxl[i]=max(mxl[i-1],arr[i]);
    for(int i=n-1;i>=1;i--)mxr[i]=max(mxr[i+1],arr[i]);
    for(int i=1;i<=n;i++){
        if(i!=1&&i!=n)
        printf("%d\n",max(mxl[i-1],mxr[i+1]));
        else if(i==1)printf("%d\n",mxr[i+1]);
        else if(i==n)printf("%d\n",mxl[i-1]);

    }
}


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

using namespace std;
const int N = 100010;
const int MOD = 1e9+7;
int _w;

int n, cnt[26];
char s[N];

int main() {
	_w = scanf( "%d", &n );
	_w = scanf( "%s", s+1 );
	for( int i = 1; i <= n; ++i )
		++cnt[s[i] - 'a'];
	int ans = 1;
	for( int i = 0; i < 26; ++i )
		ans = int(1LL * ans * (cnt[i] + 1) % MOD);
	ans = (ans - 1 + MOD) % MOD;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3752
#include <iostream>
#include <math.h>
#include <algorithm>
#define ll long long int
#define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n)

using namespace std;
bool a[1000000];
int main()
{
    ll n, m;
    cin >> n >> m;
    REP(i, m)
    {
        int x;
        cin >> x;
        a[x] = true;
    }
    ll dp[n + 1];
    dp[0] = 1;

    if (a[1])
        dp[1] = 0;
    else
        dp[1] = 1;
    FOR(i, 2, n + 1)
    {
        if (a[i])
            dp[i] = 0;
        else
            dp[i] = (dp[i - 1] + dp[i - 2]) % 1000000007;
    }
    cout << dp[n] << endl;
    return 0;
}


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

const ll mod=1e9+7;

ll modpow(ll a,ll n){
    if(n==0) return 1;
    else if(n==1) return a;
    else if(n%2) return a*modpow(a*a%mod,(n-1)/2)%mod;
    else return modpow(a*a%mod,n/2);
}

ll modfact(ll na,ll nz){
    if(na==nz) return 1;
    else return na*modfact(na-1,nz)%mod;
}

ll modcomb(ll n,ll k){
    return modfact(n,k)*modpow(modfact(n-k,0),mod-2)%mod;
}

int main(){
    ll n,k;
    cin>>n>>k;
    for(ll i=1;i<=k;i++){
        if(i>n-k+1) cout<<0<<endl;
        else cout<<modcomb(n-k+1,i)*modcomb(k-1,i-1)%mod<<endl;
    }
    return 0;
}

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back

using namespace std;

// #define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline void chmax(T& a,T const& b){a=max(a,b);}
template<class T> inline void chmin(T& a,T const& b){a=min(a,b);}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<29;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<59; 

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c; cin >> a >> b >> c ;
  if(b<c) swap(b,c);
  if(a<b) swap(a,b);
  cout << 10*a+b+c << endl;
  return 0;
}

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

#define INPUT1(n, a)                                                           \
    int n;                                                                     \
    std::cin >> n;                                                             \
    std::vector<int> a(n);                                                     \
    for(int i = 0; i < n; i++) {                                               \
        std::cin >> a[i];                                                      \
    }

#define INPUT2(x, y, field)                                                    \
    int x, y;                                                                  \
    std::cin >> x >> y;                                                        \
    std::vector<std::vector<int>> field(x, std::vector<int>(y));               \
    for(int i = 0; i < x; i++) {                                               \
        for(int j = 0; j < y; j++) {                                           \
            std::cin >> field[i][j];                                           \
        }                                                                      \
    }

void print() { std::cout << std::endl; }
template <class Head, class... Tail> void print(Head &&head, Tail &&... tail) {
    std::cout << head;
    if(sizeof...(tail) != 0)
        std::cout << " ";
    print(std::forward<Tail>(tail)...);
}
template <class T> void print(std::vector<T> &vec) {
    for(auto &a : vec) {
        std::cout << a;
        if(&a != &vec.back())
            std::cout << " ";
    }
    std::cout << std::endl;
}
template <class T> void print(std::vector<std::vector<T>> &df) {
    for(auto &vec : df) {
        print(vec);
    }
}

int dist(vector<int> p1, vector<int> p2) {
    int size = p1.size();
    int sum = 0;
    for(int i = 0; i < size; i++) {
        sum += pow(abs(p1[i] - p2[i]), 2);
    }
    if(floor(sqrt(sum)) == ceil(sqrt(sum))) {
        return true;
    }
    return false;
}

int main() {
    INPUT2(n, d, x);

    int count = 0;
    for(int i = 0; i < x.size() - 1; i++) {
        for(int j = i + 1; j < x.size(); j++) {
            if(dist(x[i], x[j])) {
                count++;
            }
        }
    }
    print(count);

    return 0;
}

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

#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define REP(i, n) FOR(i, 0, n)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 2e9;
const ll MOD = 1e9+7;
//const ll MOD 998244353;

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

	string s;
	cin >> s;

	int ans = 1;
	REP(i, n){
		if(!i) continue;
		if(s[i] != s[i-1]) ans++;
	}

	co(ans);

	return 0;
}


Measured memory_bytes: 512
package main

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

var nextString func() string

func init() {
	nextString = newReadString(os.Stdin)
}

func main() {
	N := nextInt()
	ans := 0
	A := make([]int, N)
	B := make([]int, N)

	for i := 0; i < N; i++ {
		A[i] = nextInt()
		B[i] = nextInt()
	}

	for i := N - 1; i >= 0; i-- {
		A[i] += ans
		if A[i]%B[i] != 0 {
			ans += abs((A[i] % B[i]) - B[i])
		}
	}
	fmt.Println(ans)
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func nextInt() (result int) {
	result, _ = strconv.Atoi(nextString())
	return
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
		}
		return r.Text()
	}
}


Measured memory_bytes: 5504
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
	int g[12] = {	0, 2, 0, 1, 0,
					1, 0, 0, 1, 0,
					1, 0};

	int x, y;
	cin >> x >> y;

	string ret;
	if(g[x-1] == g[y-1])
		ret = "Yes";
	else
		ret = "No";

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(void){
 
  int i;
 
  /* 文字 */
  char moji;
 
  /* 文字を入力 */
  scanf("%c", &moji);
 
  /* アルファベットの小文字か大文字かを判定 */
  if((moji>= 'a') && (moji<='z')){
    printf("a\n");
  }
  else{
  	printf("A");
  }
    
}

Measured memory_bytes: 1596
#include <iterator>
#include <list>
#include <algorithm>
#include <iostream>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <sstream>
#include <iomanip>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
using namespace std;

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

  vector<int> apple(N);
  for (int i = 1; i <= N; i++) {
    apple[i-1] = L + i - 1;
  }

  int sum = accumulate(apple.begin(), apple.end(), 0);

  int ans = 1e9;
  int sm;
  for (int i = 0; i < N; i++) {
    int v = sum - apple[i];
    int d = abs(abs(sum) - abs(v));
    if (d < ans) {
      ans = d;
      sm = v;
    }
  }

  cout << sm << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define DB double
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000001
#define NUM 200010

void swap(LL* a,LL* b){LL tmp=*a;*a=*b;*b=tmp;}
LL lpow(LL a,LL n){LL ans=pow(a,n)*10;if(ans%10<5)return ans/10;return ans/10+1;}
LL dup(LL a,LL d){if(a%d==0)return a/d;else return a/d+1;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(&m,&d);x-=k*y;swap(&x,&y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}

typedef struct{LL X,H;}P;
int cmp(const void* a,const void* b){return ((P*)a)->X-((P*)b)->X;}

int main(){
  LL N,D,A,i,dam=0,n=0,m=0,ans=0;
  scanf("%lld%lld%lld",&N,&D,&A);
  LL da[N],d[N];
  P p[N];
  D*=2;
  FOR(i,0,N)scanf("%lld%lld",&p[i].X,&p[i].H);
  FOR(i,0,N)p[i].H=dup(p[i].H,A),da[i]=-1,d[i]=-1;
  qsort(p,N,sizeof(P),cmp);
  //printf("%lld %lld\n",p[0].X,p[0].H);
  FOR(i,0,N){
    if(d[m]!=-1&&m<N)while(p[i].X>d[m]){
      if(d[m]==-1||m>=N)break;
      dam-=da[m++];
    }
    //printf("%lld %lld %lld\n",dam,m,d[m]);
    if(p[i].H<=dam)continue;
    ans+=p[i].H-dam,da[n]=p[i].H-dam,dam+=p[i].H-dam,d[n++]=p[i].X+D;
  }

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


Measured memory_bytes: 9596
N = gets.to_i
K = gets.to_i

ans = 1 # 整数１以下はない

N.times do ## N 回繰り返す
  if K <= ans  # 結果がkより大きい,同じ
    ans += K
  else      
    ans *= 2  ## ans = ans * 2 と同じ
  end
end

puts ans

Measured memory_bytes: 3836
MOD = 10**9+7
N, M = map(int, input().split())
broken = {int(input()) for _ in range(M)}

dp = [0 for _ in range(N+2)]
dp[N+1] = 0
dp[N] = 1

for i in reversed(range(N)):
    if i not in broken:
        dp[i] = dp[i+1] + dp[i+2]
        dp[i] %= MOD

print(dp[0])


Measured memory_bytes: 11884
m, f, r = map(int, input().split())
while m != -1 or f != -1 or r != -1:
    if m == -1 or f == -1:
        g = "F"
    elif m + f >= 80:
        g = "A"
    elif m + f >= 65:
        g = "B"
    elif m + f >= 50:
        g = "C"
    elif m + f >= 30:
        if r >= 50:
            g = "C"
        else:
            g = "D"
    else:
        g = "F"
    print(g)
    m, f, r = map(int, input().split())


Measured memory_bytes: 5592
from collections import Counter

def factorize(n: int):
    d = Counter()
    m= 2
    
    while m*m <= n:
        while n%m == 0:
            n //= m
            d[m] += 1
            
        m += 1
        
    if n > 1:
        d[n] += 1
        
    return d

MOD = 10**9+7
n = int(input())

fac = Counter()
for i in range(2,n+1):
    fac += factorize(i)
    
ans = 1
for k,v in fac.items():
    ans *= (v+1)
    ans %= MOD
    
print(ans)

Measured memory_bytes: 3572
import collections

s= input()
slist = list(s)

flag =0

c = collections.Counter(slist)
values,counts = zip(*c.most_common())

if len(values)==2:
    for i in range(len(counts)):
        counts[i] ==2
        flag =1

if flag ==0:
    print("No")
else:
    print("Yes")





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

using namespace std;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int a, b;
	cin >> a >> b;
	cout << ((a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) ? "Possible" : "Impossible");
}

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

using namespace std;

#define allof(x) (x).begin(), (x).end()

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 2005;

int N, K, Q;
int arr[MAXN];

pii sorted[MAXN];

struct BIT {
    int data[MAXN];
    void update(int pos, int val){
        while(pos < MAXN){
            data[pos] += val;
            pos += pos & -pos;
        }
    }

    int query(int pos){
        int ans = 0;
        while(pos){
            ans += data[pos];
            pos -= pos & -pos;
        }
        return ans;
    }
}ds;

int solve(int lowv){
    memset(ds.data, 0, sizeof ds.data);

    for(int a = 1; a <= N; a++){
        ds.update(a, 1);
    }

    set<int> illegal;
    illegal.insert(0);
    illegal.insert(N + 1);

    int used = 0;

    for(int a = 1; a <= N; a++){
        if(sorted[a].first < lowv){
            illegal.insert(sorted[a].second);
            ds.update(sorted[a].second, -1);
        } else {
            auto iter = illegal.lower_bound(sorted[a].second);
            int lft = *prev(iter);
            int rht = *iter;
            if(ds.query(rht) - ds.query(lft) >= K){
                //good
                used++;
                if(used == Q) {
                    return sorted[a].first - lowv;
                }
            } else {
                illegal.insert(sorted[a].second);
            }
            ds.update(sorted[a].second, -1);
        }
    }
    return 1e9;
}

int main(){
    cin.tie(0);
    cin.sync_with_stdio(0);

    cin >> N >> K >> Q;
    for(int a = 1; a <= N; a++){
        cin >> arr[a];
        sorted[a] = pii(arr[a], a);
    }

    sort(sorted + 1, sorted + N + 1);

    int ans = 1e9;
    for(int a = 1; a <= N; a++){
        ans = min(ans, solve(arr[a]));
    }
    cout << ans;
}


Measured memory_bytes: 512
def isPrime(n):
    # nの素数判定
    if n == 1:
        return False
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


p = [False]*(10**5+1)
c = [0]*(10**5+1)

for i in range(2, len(p)):
    p[i] = isPrime(i)
    c[i] = c[i-1]
    if i % 2 == 1 and p[i] and p[i//2+1]:
        c[i] += 1

Q = int(input())
for q in range(Q):
    l, r = map(int, input().split())
    print(c[r]-c[l-1])


Measured memory_bytes: 74816
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,ra,re) for((i)=ra;(i)<(re);(i)++)
#define rep_(i,ra,re) for((i)=ra;(i)<=(re);(i)++)
#define _rep(i,ra,re) for((i)=ra;(i)>(re);(i)--)
#define _rep_(i,ra,re) for((i)=ra;(i)>=(re);(i)--)
#define pu(n) cout << n; 
#define put(n) cout << n << " "; 
#define puts(n) cout << n << endl;
bool a[2000][2000];
int l[2000][2000],r[2000][2000],u[2000][2000],d[2000][2000];
int ui,di,lj,rj,k;
int i,j;
int maxs=-1;
int main(void){
	int h,w;
	cin >> h >> w;
	rep(i,0,h){
		rep(j,0,w){
			char s;
				cin >> s;
			a[i][j]=(s=='#'?true:false);
		}
	}
		
	rep(i,0,h){
		int lx=-1,rx=w;
		rep(k,0,w){
			lj=k;rj=w-k-1;
				if(a[i][lj])
					lx=lj;
				else
					l[i][lj]=lj-lx-1;
			
				if(a[i][rj])
					rx=rj;
				else
					r[i][rj]=rx-rj-1;
			}
		}
		
	rep(j,0,w){
		int ux=-1,dx=h;
			rep(k,0,h){
				ui=k;di=h-k-1;
				if(a[ui][j])
					ux=ui;
				else
					u[ui][j]=ui-ux-1;
				
				if(a[di][j])
					dx=di;
				else
					d[di][j]=dx-di-1;
			}
		}
		rep(i,0,h){
			rep(j,0,w){
				if(!a[i][j])
					maxs=max(maxs,r[i][j]+l[i][j]+u[i][j]+d[i][j]);
			}
		}
		puts(maxs+1);
		return 0;
}


Measured memory_bytes: 66688
from collections import defaultdict,deque
n,m = map(int,input().strip().split())
graph = defaultdict(list)
for _ in range(m):
    u,v = map(int,input().strip().split())
    graph[u].append(v)
    graph[v].append(u)

queue = deque()
queue.append(1)

mini_passage = defaultdict(list)
visited = defaultdict(int)
level = 0
while queue:
    temp = []
    while queue:
        x = queue.pop()
        visited[x] = 1
        for neighbour in graph[x]:
                #if not visited[neighbour]:
                if neighbour in mini_passage:
                    if level<mini_passage[neighbour][1]:
                        mini_passage[neighbour] = [x,level]
                        temp.append(neighbour)
                else:
                    mini_passage[neighbour] = [x, level]
                    temp.append(neighbour)
    queue = temp.copy()
    level += 1
#print(mini_passage)
if len(mini_passage)<n-1:
    print("No")
else:
    print("Yes")
    for key in range(2,n+1):
        print(mini_passage[key][0])

Measured memory_bytes: 64184
#include <stdio.h>
#include <bits/stdc++.h>
#define pb push_back
#define pp pop_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
typedef long long ll;

using namespace std;

const int N = 3e5 + 111, inf = 1e9, mod = 1e9 + 7, C = 2000;
const double pi = acos(-1.0), eps = 1e-9;
const ll INF = 1e18;

int n, a[N], L;

int main(){
	srand(time(NULL));
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	cout << setprecision(10) << fixed;

	cin >> n >> L;

	for(int i = 1; i <= n; ++i)
		cin >> a[i];

	for(int i = 1; i < n; ++i){
		if(a[i] + a[i + 1] >= L){
			cout << "Possible\n";
			for(int j = 1; j < i; ++j)
				cout << j << endl;
			for(int j = n - 1; j >= i + 1; --j)
				cout << j << endl;
			cout << i << endl;	
			return 0;
		}
	}

	cout << "Impossible";

	//cout << (clock() + 0.0) / CLOCKS_PER_SEC;
	return 0;
}

Measured memory_bytes: 1280
r=input().split()
N=int(r[0])
K=int(r[1])
d=[input().split() for i in range(2*K)]
d_2=[]
d_ans=[0]*N
for i in range(2*K):
    d_pre=[int(s) for s in d[i]]
    d_2.append(d_pre)
for i in range(2*K):
    if i%2==0:
        for j in range(d_2[i][0]):
            d_ans[d_2[i+1][j]-1]=1
print(d_ans.count(0))

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(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;
}

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

  ll ans = 0;
  string S;
  cin >> S;
  ll cntB = 0;
  for(int i = 0; i < S.length(); i++){
    if(S[i] == 'B'){
      cntB++;
      ans += S.length()-i-1;
    }
  }

  ans -= (cntB-1) * cntB / 2;

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 720
#include<stdio.h>
int main()
{
    int A,B,c;
    scanf("%d %d %d",&A,&B,&c);
    if(A==B && A!=c || A==c && A!=B || B==c && A!=B)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}


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

using namespace std;

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

Measured memory_bytes: 512
package main

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

// 文字列変換
func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	str := sc.Text()
	sc.Scan()
	q, _ := strconv.Atoi(sc.Text())
	s := ""
	for i := 0; i < q; i++ {
		sc.Scan()
		ary := strings.Split(sc.Text(), " ")
		a, _ := strconv.Atoi(ary[1])
		b, _ := strconv.Atoi(ary[2])
		switch ary[0] {
		case "replace":
			str = str[:a] + ary[3] + str[b+1:]
		case "reverse":
			str = str[:a] + reverse(str[a:b+1]) + str[b+1:]
		case "print":
			s += str[a:b+1] + "\n"
		}
	}
	fmt.Print(s)
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}



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

int main() {
	int a,b;
	cin>>a>>b;
	if(a<b){
		cout<<"a < b"<<endl;
	}if(a>b){
		cout<<"a > b"<<endl;
	}if(a==b){
		cout<<"a == b"<<endl;
	}
}




Measured memory_bytes: 3076
from collections import Counter
def c_nb(i):
  b = Counter(v[i::2]).most_common()+[(0,0)]
  return b
def c_rpl(a,x,y):
  r = a-o[x][1]-e[y][1]
  return r
n = int(input())
v = list(map(int,input().split()))
o = c_nb(0)
e = c_nb(1)
if o[0][0]!=e[0][0]:
  ans = c_rpl(n,0,0)
else:
  ans = min(c_rpl(n,0,1),c_rpl(n,1,0))
print(ans)

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

int main(){
    int n; cin>>n;
    vector<pair<int,int>> p(n);
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        p[i]=make_pair(b,a);
    }
    sort(p.begin(),p.end());

    int sum=0;
    for(int i=0;i<n;i++){
        sum+=p[i].second;
        if(sum>p[i].first){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
struct edge{int u,v,typ;}a[maxn+3];
int fa[maxn+3];
int n,q,c; 
long long m;
int find(int u){return fa[u]==u?u:fa[u]=find(fa[u]);}
int main()
{
    scanf("%d%lld%d",&n,&m,&q);
    for(int i=1;i<=n;i++)fa[i]=i;
    for(int i=1;i<=q;i++)
    {
        scanf("%d%d%d",&a[i].u,&a[i].v,&a[i].typ);
		a[i].u++,a[i].v++;
        if(a[i].typ==0)
        {
            int u=find(a[i].u),v=find(a[i].v);
            if(u!=v)fa[u]=v;
        }
    }
    int flag=0;c=0;
    for(int i=1;i<=n;i++)if(i==find(i))c++;
    for(int i=1;i<=q;i++)
    if(a[i].typ==1)
    {
        flag=1;
        int u=find(a[i].u),v=find(a[i].v);
        if(u==v){puts("No");return 0;}
    }
    long long l=flag?max(3,c):c-1,r=c*1LL*(c-1ll)/2ll;
    if(m-(n-c)>=l&&m-(n-c)<=r)puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 1792
def solve():

    N, M = map(int, input().split())
    Alist = list(map(int, input().split()))

    Alist.sort(reverse=True)

    needRatio = 1/(4*M)
    total = sum(Alist)

    for i in range(M):
        ratio = Alist[i] / total
        if ratio < needRatio:
            print("No")
            exit()

    print("Yes")


if __name__ == "__main__":
    solve()


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

int main() {
   int a, b, c, d;
   cin >> a >> b >> c >> d;

   if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) {
       cout << "Yes" << endl;
   } else {
       cout << "No" << endl;
   }
}

Measured memory_bytes: 256
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); ++i)
#define ROF(i,a,b) for (int i = (b); i >= (a); --i)
#define debug() cout << 1 << endl
#define fi first
#define se second
#define pii pair<int, int>
#define mp make_pair
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define ins insert
#define lb lower_bound
#define ub upper_bound
const long long mod = 1e9 + 7;
const double PI = acos(-1);
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
const int MAXN = 1e5 + 10;
#define LOCAL
template<class I>
inline void read(I &x) {
    x = 0; I f = 1; char c = getchar();
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar(); }
    while(c >= '0' && c <= '9') {x = x * 10 + c - '0'; c = getchar(); }
    x *= f;
}
int qpow(int a, int b){int res=1;while(b>0){if(b&1)res=res*a%mod;b=b>>1;a=a*a%mod;}return res % mod;}
ll gcd(ll a,ll b) { return b ? gcd(b, a % b) : a;}

int main() 
{
	ios::sync_with_stdio(false);
	cout.tie(0), cin.tie(0);
	// #ifdef LOCAL
	// freopen("data.in", "r", stdin);
	
	// #endif
	int t;
	string s;
	cin >> s;
	int maxx = -1;
	int cnt = 0;
	FOR(i, 0, 2) {
		if (s[i] == 'R') {
			cnt++;
			
		}
		else cnt = 0;
		maxx = max(maxx, cnt);
	}
	cout << maxx << endl;
    return 0;
}

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

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }


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

  vector<int> left(N + 1);
  vector<int> right(N + 1);
  int n = 0;
  for(int i = 1; i <= N; i++) {
    if(S[i - 1] == 'W') { n++; left[i] = n; } 
    else { left[i] = n; }
  }
  n = 0;
  for(int i = N - 1; i >= 0; i--) {
    if(S[i] == 'E') { n++; right[i] = n; }
    else { right[i] = n; }
  }
  int ans = 400000;
  for(int i = 0; i < N; i++) {
    if(ans > left[i] + right[i + 1]) ans = left[i] + right[i + 1];
  }
  
  cout << ans;
  return 0;
}

Measured memory_bytes: 2948
import java.util.*;
import java.util.function.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt(); //参考書の種類
        int M = sc.nextInt(); //アルゴリズムの種類
        int X = sc.nextInt(); //理解度の目標数値
        int[][] figure = new int[N][M+1]; //0: 購入価格, 1~: アルゴリズむの理解度
        for(int i = 0; i < N; i++){
          figure[i][0] = Integer.parseInt(sc.next());
          for(int j = 1; j <= M; j++){
            figure[i][j] = Integer.parseInt(sc.next());
          }
        }

        int min = Integer.MAX_VALUE;
        boolean judge = true;
        IntBinaryOperator smallNumber =
          (num1, num2) -> num1 <= num2 ? num1 : num2;
        for(int i = 0; i < Math.pow(2, N); i++){
          int[] rikaido = new int[M];
          int total = 0;
          Arrays.fill(rikaido, 0);
          for(int j = 0; j < N; j++){
            if((1&i>>j) == 1){
              total += figure[j][0];
              for(int k = 0; k < M; k++){
                rikaido[k] += figure[j][k+1];
              }
            }
          }
          OptionalInt o = Arrays.stream(rikaido).reduce(smallNumber);
          if(X <= o.getAsInt()){
            min = smallNumber.applyAsInt(min, total);
          }
        }

        if(min == Integer.MAX_VALUE)
          System.out.println(-1);
        else
          System.out.println(min);
    }
}


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

using namespace std;

int main() {
    int a, b;
    string s;
    cin >> a >> b;
    cin >> s;
    bool ok = true;
    if (s[a] == '-') {
        for (int i = 0; i < s.size(); i++) {
            if (i != a) {
                if (s[i] == '0' || s[i] == '1' || s[i] == '2' || s[i] == '3' ||
                    s[i] == '4' || s[i] == '5' || s[i] == '6' || s[i] == '7' ||
                    s[i] == '8' || s[i] == '9') {
                } else {
                    ok = false;
                }
            }
        }
    } else {
        ok = false;
    }
    if (ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    int x = a - b;
    if (k % 2)
        cout << -x << endl;
    else
        cout << x << endl;
}

Measured memory_bytes: 256
import Data.List
import Control.Monad

main :: IO ()
main = do
    n <- readLn :: IO Int
    ss <- sort . map sort <$> replicateM n getLine :: IO [String]
    print (sum $ map (s . length) $ group ss)

s :: Integral a => a -> a
s n = div (n * (n - 1)) 2

Measured memory_bytes: 114044
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
    if (a%10 == a/100){
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 23124
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>

using namespace std;

int main() {
    int X;
    cin >> X;
    int ans = (X / 500) * 1000;
    X %= 500;
    ans += (X / 5) * 5;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include<random>
using namespace std;
#define N (1000000000+7)
#define M 998244353
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
 
ll A(ll x){
    if(x>=0)return x;
    else return -x;
}
 
ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}

char board[30][30];

int main(void){
	ll n;
	cin>>n;
	ll ans = 0;
	ll tmp=0;
	for(ll i=1;i<=n;i++){
		ans+=n*(n+1)/2-tmp;
		tmp+=(n-i+1);
	}
	for(int i=0;i<n-1;i++){
		ll u,v;
		cin>>u>>v;
		ll L = min(u,v);
		ll R = max(u,v);
		ans-=L*(n-R+1);
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3620
"use strict"
function main(arg) {
    var N = arg.trim().split("\n")[0].split(" ").map(Number)[0]
    var Ai = arg.trim().split("\n")[1].split(" ").map(Number)
    var ans = N - sum(Ai)
    if (ans < 0) {
        ans = -1
    }
    console.log(ans)
}

function sum(arr) {
    return arr.reduce(function(prev, current, i, arr) {
        return prev+current;
    });
};
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

#define f first
#define s second
#define p pair<int,int>
#define P pair<ll,ll>
#define pb push_back
#define ll long long
#define db double
#define zero(a) memset(a,0,sizeof(a))
#define inff(a,n) fill(a,a+n+1,inf)
#define all(a) a.begin(),a.end()
#define sz(a) int((a).size())
#define read(x) scanf("%lld",&x)
#define read2(x,y) scanf("%lld%lld",&x,&y)
#define write(x) printf("%lld\n",x)

const int maxn=2e5+5;
const ll inf=1e9;

char s[300000];
ll a[40];
int main()
{
    scanf(" %s",s);
    ll n=strlen(s);
    for(int i=0; i<n; i++)
    {
        a[s[i]-'a']++;
    }
    ll ans=n*(n-1)/2+1;
    for(int i=0; i<26; i++)
    {
        ans-=(a[i])*(a[i]-1)/2;
    }
    write(ans);
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define INF 100000005
#define MAX 100000001
#define dmp make_pair
#define dpb push_back
#define fi first
#define se second
using namespace std;
//__gcd(a,b), __builtin_popcount(a);

int a[201], b[201][3];
pair<int,int> dp[201][2];
int main(){
	int d, n, ans = 0;
	scanf("%d%d", &d, &n);
	rrep(i,d)scanf("%d", &a[i]);
	rrep(i,n)scanf("%d%d%d", &b[i][0], &b[i][1], &b[i][2]);
	int t1, t2, x, y;
	for(int i = 1;i <= d;i++){
		t1 = INF;t2 = 0;
		for(int j = 1;j <= n;j++){
			if(b[j][0] <= a[i] && a[i] <= b[j][1]){
				t1 = min(t1, b[j][2]);
				t2 = max(t2, b[j][2]);
			}
		}
		dp[i][0].se = t1;
		dp[i][1].se = t2;
		x = dp[i-1][0].se;
		y = dp[i-1][1].se;
		dp[i][0].fi = max(dp[i-1][1].fi + abs(y-t1), dp[i-1][0].fi + abs(x-t1));
		dp[i][1].fi = max(dp[i-1][0].fi + abs(x-t2), dp[i-1][1].fi + abs(y-t2));
		if(i == 1){
			dp[i][0].fi = 0;
			dp[i][1].fi = 0;
		}
	}
	t1 = dp[d][0].fi;
	t2 = dp[d][1].fi;
	printf("%d\n", max(t1, t2));
	return 0;
}

Measured memory_bytes: 3196