akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

typedef pair<int,int>pi;
typedef vector<int>vi;

const int MAXN=100005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int K;cin>>K;
	string S;cin>>S;
	if ((int) S.length() <= K) {cout<<S; exit(0);}
	FOR(i,0,K-1) cout<<S[i];
	cout<<"...";
}


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

int main() {
    string n;
    cin >> n;
    if (n[0]=='7' || n[1]=='7' || n[2]=='7') {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3624
{-# OPTIONS_GHC -O3 #-}
{-# LANGUAGE ViewPatterns, ScopedTypeVariables #-}

import qualified Data.ByteString as B (getLine)
import qualified Data.ByteString.Char8 as C (readInt, words)
import qualified Data.Maybe as M (fromJust)

readInt = fst . M.fromJust . C.readInt

main = do
    (map readInt . C.words -> [n, k]) <- B.getLine
    putStrLn $ show $ if k > n then 0 else n - k


Measured memory_bytes: 380
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<ll, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, m;
ll a[5010];
ll b[5010][210];

ll sum[5010][5010];
ll d[5010];

template<typename T>
class SegmentTree {
private:
    int n;
    T dat[(1<<18)-1];
public:
    SegmentTree(int n_) {
	n = 1;
	while (n < n_) n *= 2;
	for (int i = 0; i < 2*n-1; i++) dat[i] = make_pair(0, 0);
    }

    void update(int k, T a) {
	k += n - 1;
	dat[k] = a;
	while (k > 0) {
	    k = (k - 1) / 2;
	    dat[k] = max(dat[k*2+1], dat[k*2+2]);
	}
    }
    
    // call query(a, b)
    T query(int a, int b) { return query(a, b, 0, 0, n); }
    T query(int a, int b, int k, int l, int r) {
	if (r <= a || b <= l) return make_pair(0, 0);

	if (a <= l && r <= b) return dat[k];
	else {
	    T vl = query(a, b, k*2+1, l, (l+r)/2);
	    T vr = query(a, b, k*2+2, (l+r)/2, r);
	    return max(vl, vr);
	}
    }
};

SegmentTree<P> st(5010);

void calc(int i, int j) {
    if (i >= j) return;
    P p = st.query(i, j);
    ll v = p.first;
    int u = p.second;
    sum[i][u] += v; sum[u+1][u] -= v;
    sum[i][j] -= v; sum[u+1][j] += v;
    calc(i, u);
    calc(u+1, j);
}

ll dist(int i, int j) {
    return d[j] - d[i];
}

ll solve() {
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) {
            st.update(j, make_pair(b[j][i], j));
        }
        calc(0, n);
    }

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++)
            sum[i][j+1] += sum[i][j];
    }
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++)
            sum[i+1][j] += sum[i][j];
    }

    for (int i = 0; i < n-1; i++) d[i+1] = d[i] + a[i];

    ll res = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i; j < n; j++) {
            res = max(res, sum[i][j] - dist(i, j));
        }
    }
    return res;
}

void input() {
    cin >> n >> m;
    for (int i = 0; i < n-1; i++) cin >> a[i];
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            cin >> b[i][j];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 208384
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            list.add(scanner.nextInt());
        }
        list.sort((val1, val2) -> val1 - val2);
        int b = list.get(0);
        for (int i = 1; i < list.size(); i++) {
            int a = list.get(i);
            int r = a % b;
            while (r != 0) {
                a = b;
                b = r;
                r = a % b;
            }
        }
        System.out.println(b);
    }
}

Measured memory_bytes: 61872
#include <stdio.h>

int main(void) {
	static const char isBoin[256] = {
		['a'] = 1, ['e'] = 1, ['i'] = 1, ['o'] = 1, ['u'] = 1
	};
	char c[4];
	if (scanf("%3s", c) != 1) return 1;
	puts(isBoin[(unsigned char)c[0]] ? "vowel" : "consonant");
	return 0;
}


Measured memory_bytes: 128
open System

let n, k =
    let l = Console.ReadLine().Split(' ')
    let n = l.[0] |> int
    let k = l.[1] |> Int64.Parse
    n, k

let a =
    Console.ReadLine().Split(' ')
    |> Array.map (fun x -> int(x) - 1)

let ans =
    let loopOrigin, path =
        let rec search (path: int list) (towns: Set<int>) =
            let tail =
                match path with
                | tail :: _ -> tail
                | _ -> -1
            let next = a.[tail]

            if towns.Contains next then
                let path = path |> List.rev
                let loopOrigin =
                    path |> List.findIndex (fun t -> t = next)
                loopOrigin, path
            else
                search (next :: path) (towns.Add next)

        search [0] (Set [])

    let ans =
        let idx =
            let loopOrigin = int64 loopOrigin
            let freq = int64 (List.length path) - loopOrigin
            if k < loopOrigin then
                k |> int
            else
                loopOrigin + (k - loopOrigin) % freq |> int
        path.[idx] + 1

    ans

ans |> Console.WriteLine


Measured memory_bytes: 73492
#include "bits/stdc++.h"
using namespace std;

void solve() {
    int H, W;
    cin >> H >> W;
    vector<vector<int>> c(10, vector<int>(10));
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> c.at(i).at(j);
        }
    }
    for (int k = 0; k < 10; k++) {
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                c.at(i).at(j) = min(c.at(i).at(j), c.at(i).at(k) + c.at(k).at(j));
            }
        }
    }
    int ans = 0, A;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> A;
            if (A == -1) continue;
            ans += c.at(A).at(1);
        }
    }
    cout << ans << endl;
    return;
}

int main() {
    solve();
}

Measured memory_bytes: 256
import scala.io.StdIn

object Main {
  def main(args: Array[String]): Unit = {
    val inputs = Iterator.continually(StdIn.readLine()).takeWhile(_ != null)
    for{
      in <- inputs
      val Array(h, w, _*) = in.split(" ").map(_.toInt)
      }{
        if(h != 0 && w != 0){
          println((List.tabulate(h, w){(i, j) =>
            if(j == w-1) "#\n" else "#"
          }).flatten.mkString)
        }
      }
  }
}

Measured memory_bytes: 49840
#include <iostream>
#include <array>

int main (){

    //data_set : a and b
    std::array<int, 4> data_a;
    std::array<int, 4> data_b;

    while(std::cin >> data_a[0] >> data_a[1] >> data_a[2] >> data_a[3]){
        std::cin >> data_b[0] >> data_b[1] >> data_b[2] >> data_b[3];
        int hit = 0;
        int blow = 0;
        for(int i = 0; i < 4; ++i){
            //if same digit and same num
            if(data_b[i] == data_a[i]) {
                hit++;
            } else {
                //if different digit and same num
                for (int j = 0; j < 4; ++j) {
                    if (data_b[i] == data_a[j]) {
                        blow++;
                    }
                }
            }
        }
        std::cout << hit << " " << blow << std::endl;

    }
}

Measured memory_bytes: 2932
import itertools

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

comb = list(itertools.permutations(range(1, n+1)))

p_i = comb.index(p)
q_i = comb.index(q)

print(abs(p_i-q_i))

Measured memory_bytes: 8052
#include<iostream>
using namespace std;
int main(){
  int n, x=0;
  cin >> n;
  string s;
  cin >> s;

  int sum=0, ans=0;
  for(int i=0; i<n; i++){
    if(s[i] == 'I'){
      sum = sum + 1;
    }
    else if(s[i] == 'D'){
      sum = sum - 1;
    }
    else{
      sum = sum;
    }
    ans = max(ans, sum);
  }
    cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>
//#include<bits/stdc++.h>

using namespace std;
long long MOD = 1000000007LL;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

int main() {
	int N, M;
	cin >> N >> M;
	map<int, int> mp;
	map<int, bool> acMP;
	int lastAC = 0;
	int countWA = 0;
	int countAC = 0;
	for (int i = 0; i < M; ++i) {
		int j;
		string s;
		cin >> j >> s;
		if (acMP[j] == true)continue;
		else {
			if (s == "WA")++mp[j];
			else if (s == "AC") {
				countWA += mp[j];
				++countAC;
				acMP[j] = true;
			}
		}
	}

	cout << countAC << " " << countWA << endl;
	return 0;
}



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

typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	ll n, ans = 0;
	cin >> n;
	for (ll i = 2; i * i <= n; i++) {
		int cnt = 0, tmp = 1;
		while (n % i == 0) {
			n /= i;
			cnt++;
		}
		while (cnt >= tmp) {
			ans++;
			cnt -= tmp;
			tmp++;
		}
	}
	if (n > 1)
		ans++;
	return cout << ans << "\n", 0;
		
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; scanf("%lld", &x); return x;}
ld fin(){double x; scanf("%lf", &x); return x;}
char yuyushiki[1000010]; string stin(){scanf( "%s", yuyushiki ); return yuyushiki;}

// head

int main(){

  ll n = in();
  bool ok = false;
  REP(i, n){
    ll a = in();
    if(a % 2 == 1){
      ok = true;
    }
  }

  if(ok){
    puts("first");
  } else {
    puts("second");
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
ll gcd(ll a,ll b){
  if(!b) return a;
  return gcd(b,a%b);
}
vec Era(int n){
    vec is_prime(n+1,0),Q;
    for(int i=2;i<=n;i++){
        if(!is_prime[i]){
            for(int j=i;j<=n;j+=i) is_prime[j]=i;
            Q.push_back(i);
        }
    }
    return is_prime;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vec A(n);
    rep(i,n) cin>>A[i];
    ll a=A[0];
    rep(i,n) a=gcd(a,A[i]);
    if(a!=1){
        cout<<"not coprime";
        return 0;
    }
    vec B=Era(1000000);
    map<int,int> D;
    rep(i,n){
        set<ll> C;
        while(A[i]!=1) C.insert(B[A[i]]),A[i]/=B[A[i]];
        for(auto itr=C.begin();itr!=C.end();itr++){
            if(D[*itr]){
                cout<<"setwise coprime";
                return 0;
            }
            D[*itr]++;
        }
    }
    cout<<"pairwise coprime";
}

Measured memory_bytes: 19780
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define debugArray(x, n)                                      \
  cerr << __LINE__ << ": " << #x << " = {";                   \
  for (long long hoge = 0; (hoge) < (long long)(n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];                   \
  cerr << "}" << '\n'
#define debugMatrix(x, h, w)                                         \
  cerr << __LINE__ << ": " << #x << " =\n";                          \
  for (long long hoge = 0; (hoge) < (long long)(h); ++(hoge)) {      \
    cerr << ((hoge ? " {" : "{{"));                                  \
    for (long long fuga = 0; (fuga) < (long long)(w); ++(fuga))      \
      cerr << ((fuga ? ", " : "")) << x[hoge][fuga];                 \
    cerr << "}" << (hoge + 1 == (long long)(h) ? "}" : ",") << '\n'; \
  }
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#define debugMatrix(x, h, w) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int N, M;
  cin >> N >> M;
  int X[N];
  for (int i = 0; i < N; i++) cin >> X[i];
  sort(X, X + N);
  int cnt[M], same[M];
  fill(cnt, cnt + M, 0);
  fill(same, same + M, 0);
  for (int i = 0; i < N; i++) {
    int j = i + 1;
    while (j < N && X[i] == X[j]) j++;
    cnt[X[i] % M] += j - i;
    same[X[i] % M] += (j - i) / 2;
    i = j - 1;
  }
  int ans = 0;
  for (int i = 1; 2 * i < M; i++) {
    int a = i, b = M - i;
    int sa = cnt[a], sb = cnt[b];
    if (sa > sb) swap(sa, sb), swap(a, b);
    ans += sa;
    ans += min((sb - sa) / 2, same[b]);
  }
  ans += cnt[0] / 2;
  if (M % 2 == 0) ans += cnt[M / 2] / 2;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 4736
import java.util.Scanner;

/**
 * @author ??\???
 *
 */
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		scanner.close();
		
		int ans = 0;
		for (int i = a; i <= b; i++) {
			ans = (c % i == 0) ? ans + 1: ans;
		}
		
		System.out.println(ans);
	}

}

Measured memory_bytes: 26196
#include<bits/stdc++.h>
using namespace std;
long long f(int n,vector<long long>& h,vector<long long>& m){
	if(n>=h.size()){
		return 1000000000;
	}
	if(n==h.size()-1){
	  return 0;	
	}
	if(m[n]!=-1){
		return m[n];
	}
	m[n]=min(f(n+1,h,m)+abs(h[n]-h[n+1]),f(n+2,h,m)+abs(h[n]-h[n+2]));
	return m[n];
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int n;
	cin>>n;
	vector<long long> h(n);
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	vector<long long> m(n);
	for(int i=0;i<n;i++){
		m[i]=-1;
	}
	cout<<f(0,h,m);
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define ll long long int
#define F(i,j,k,in) for(int i=j;i<k;i+=in)
#define DF(i,j,k,in) for(int i=j;i>=k;i-=in)
#define feach(it,l) for (auto it = l.begin(); it != l.end(); ++it)
#define fitr(it,it1,itr2) for(auto it=itr1;it!=itr2;++it)
#define fall(a) a.begin(),a.end()
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define eq equal_range
#define fs first
#define ss second
#define ins insert
#define mkp make_pair
#define PI 3.1415926535897932384626433832795
#define endl "\n"
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vin;
typedef vector<char> vch;
typedef vector<string> vst;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll,ll>> vpll;
typedef set<ll> sll;
typedef set<int> sint;
typedef set<char> sch;
typedef set<string> sst;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef map<ll,ll> mll;
typedef pair<ll,ll> pll;
const ll MOD=1000000007;
ll pwr(ll b,ll p){ll res=1;while(p){if(p&1) {res*=b; p--;}else{b*=b; p>>=1;}}return res;}

int main()
{
  ios_base::sync_with_stdio(false) , cin.tie(NULL) , cout.tie(NULL);
  ll n,m;
  cin>>n>>m;
  if (m<=n) {
    cout<<m/2<<endl;
  }
  else {
    cout<<n+(m-2*n)/4<<endl;
  }

return 0;
}




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

using namespace std;

int s[1005][1005]={};

int main(){
	int h,w,a,b; cin >> h >> w >> a >> b;
	a=w-a;
	b=h-b;
	for(int i=0;i<b;i++){
		for(int j=0;j<a;j++){
			s[i][j]=1;
		}
	}
	
	for(int i=b;i<h;i++){
		for(int j=a;j<w;j++){
			s[i][j]=1;
		}
	}
	
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cout << s[i][j];
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int N;
  cin >> N;
  VEC<int> P(N);
  REP(i, 0, N) cin >> P[i];
  VEC<int> mi(N, 0);
  mi[0] = P[0];
  REP(i, 1, N) { mi[i] = min(P[i], mi[i - 1]); }
  // DUMP(mi);
  int cnt = 1;
  REP(i, 1, N) {
    if (P[i] < mi[i - 1]) {
      cnt++;
    }
  }
  cout<<cnt<<endl;

  return 0;
}


Measured memory_bytes: 1920
#include <iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	double sum = 0;
	for (int i = 0; i < n; i++) {
		double r;
		cin >> r;
		sum += 1.0 / r;
	}
	
	cout << (1.0/sum) << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
	Scanner sc=new Scanner(System.in);
	int n=sc.nextInt();
	char []s=sc.nextLine().toCharArray();
	int west=0;
	for(char c:s)
		if(c=='W')
			west++;
	
	int east=n-west;
	
	int west_left=0;
	int ans=n;
	for(int i=0;i<n;i++)
	{
		int east_left=i-west_left;
	
		int east_right=east-east_left;
		
		if(s[i]=='E')
			east_right--;
		ans=Math.min(ans, west_left+east_right);
		
		
		if(s[i]=='W')
			west_left++;
				
	}
	System.out.println(ans);
	
		
		
	

	}
	static class Scanner
	{
		BufferedReader br;
		StringTokenizer st;
		public Scanner(InputStream s)
		{
			br=new BufferedReader(new InputStreamReader(s));
		}
		public Scanner(String s) throws FileNotFoundException
		{
			br=new BufferedReader(new FileReader(s));
		}
	
		public String nextLine() throws IOException
		{
			return br.readLine();
		}
		public String next() throws IOException
		{
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws IOException
		{
			return Integer.parseInt(next());
			
		}
		public double nextDouble() throws IOException
		{
			return Double.parseDouble(next());
		}
		public boolean ready() throws IOException
		{
			return br.ready();
		}
		public long nextLong() throws IOException
		{
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 26492
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        String a = scanner.next();
        String[] num = new String[3];
        num = a.split("");

        if (num[0].equals(num[2])) {
        	System.out.println("Yes");
        }else {
        	System.out.println("No");
        }

    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

Measured memory_bytes: 23124
import sys
input = sys.stdin.readline

S = list(reversed(input().strip()))
P = [list(reversed(v)) for v in ["dream", "dreamer", "erase", "eraser"]]

n = 0
while n < len(S):
    if S[n:n+5] == P[0] or S[n:n+5] == P[2]:
        n += 5
    elif S[n:n+7] == P[1]:
        n += 7
    elif S[n:n+6] == P[3]:
        n += 6
    else:
        print("NO")
        exit()
        
print("YES")

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define pb(v) push_back(v)
#define mp(x, y) make_pair(x, y)
#define fi first
#define se second
#define print(var)  do{ cout << #var << " : "; view(var); } while(0)
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using P = pair<int ,int>;
using Graph = vector<vector<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;

int memo[50];

int fib(int x) {
    if (x==0 || x==1) return 1;
    int ret1, ret2;
    ret1 = (memo[x-1]==-1) ? (fib(x-1)) : memo[x-1];
    ret2 = (memo[x-2]==-1) ? (fib(x-2)) : memo[x-2];
    memo[x-1] = ret1;
    memo[x-2] = ret2;
    return ret1+ret2;
}

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

    int n; cin >> n;
    rep(i, 50) memo[i] = -1;
    cout << fib(n) << endl;
}


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

int main() {
    int n, m, x; cin >> n >> m >> x;
    vector<bool> ns(n+1); 
    for (int i=0; i<m; i++) {
        int a; cin >> a;
        ns[a] = true;
    }
    int n_cnt = 0;
    for (int i=x; i<n+1; i++) {
        if (ns[i]) {
            n_cnt += 1;
        }
    }
    int zero_cnt = 0;
    for (int i=x; i>0; i--) {
        if (ns[i]) {
            zero_cnt += 1;
        }
    }
    cout << min(n_cnt, zero_cnt) << endl;
} 


Measured memory_bytes: 256
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     setbits(x)  __builtin_popcountll(x)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=305;
const int mod=1e9+7;

int n,t[4];
db dp[N][N][N];
db rec(int a,int b,int c){
    if(a+b+c==0) return 0;
    db &cache=dp[a][b][c];
    if(cache>-0.5) return cache;
    db ext=n*1.0/(a+b+c);
    cache=0;
    if(a){
        cache+=(rec(a-1,b,c)+ext)*a*1.0/(a+b+c);
    }
    if(b){
        cache+=(rec(a+1,b-1,c)+ext)*b*1.0/(a+b+c);
    }
    if(c){
        cache+=(rec(a,b+1,c-1)+ext)*c*1.0/(a+b+c);
    }
    return cache;
}
signed main(){
    FastIO;
    cin>>n;
    rep(i,1,n){
        int x;
        cin>>x;
        t[x]++;
    }
    memset(dp,-1,sizeof dp);
    cout<<fix<<rec(t[1],t[2],t[3]);
    return 0;
}


Measured memory_bytes: 221952
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL n,a[100010],ma=0,half;
int main(){
	LL i,j,k;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
		ma=max(ma,a[i]);
	}
	half=ma/2;
	for(i=0;i<n;i++)if(a[i]==ma)break;
	while(i<n-1){
		swap(a[i],a[i+1]);
		i++;
	}
	for(i=0,j=a[0],k=1e9;i<n-1;i++){
		if(k>abs(half-a[i])){
			j=a[i];
			k=abs(half-a[i]);
		}
	}
	cout<<ma<<" "<<j<<endl;
	return 0;
}

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

int main() {
  int N,A,x;

  // 変数aで入力を受け取る
  cin >> N >> A;
  x = N % 500;
  if(x <= A ) {
     cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let (a, b, c) = get!(i32, i32, i32);
    let rest = a - b;
    let ans = if rest <= c { c - rest } else { 0 };
    println!("{}", ans);
}


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

typedef pair<int, int> P;

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}


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

    vector<pair<ll, ll>> p = prime_factorize(n);
    ll ans = 0;

    rep(i,p.size()){
        //cout << p[i].first << " " << p[i].second << endl;
        int count = 0;
        int index = 1;
        while (p[i].second >= index){
            count++;
            index = (count+1)*(count+2)/2;
        }
        ans += count;
    }

    cout << ans << endl;

}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long
#define lfl long double

lin n;
string s;
lin q;

void solve(lin k)
{
    queue<lin> d;
    queue<lin> m;
    lin ad = 0;
    lin res = 0;

    rep(i, s.length())
    {
        if(d.size() > 0)
        {
            if(i - d.front() >= k)
            {
                d.pop();
                ad -= m.size();

                if(d.size() > 0)
                {
                    while(m.size() > 0 && d.front() > m.front())
                    {
                        m.pop();
                    }
                }
                else
                {
                    while(m.size() > 0)
                    {
                        m.pop();
                    }                    
                }
            } 
        }

        if(s[i] == 'D')
        {
            d.push(i);
        }
        else if(s[i] == 'M')
        {
            if(d.size() > 0)
            {
                m.push(i);
                ad += d.size();
            }
        }
        else if(s[i] == 'C')
        {
            res += ad;
        }
    }

    cout << res << endl;
}

int main(void)
{
    lin k[76];

    cin >> n >> s >> q;
    rep(i, q)
    {
        cin >> k[i];
        solve(k[i]);
    }

    return 0;
}


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

int main(){
  int n; cin >> n;
  vector<int> x(n);	rep(i,n) cin >> x[i];
  int ans = (int)1e9;
  int sum;
  rep(i,100){
    sum = 0;
    rep(j,n) sum+=(x[j]-i-1)*(x[j]-i-1);
    ans = min(ans, sum);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include <ext/rope>

#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define rep(i, n) for (int i=0; i<(n); i++)
#define rep1(i, n) for (int i=1; i<=(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl "\n"

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned uint;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
template<typename _def> using ordered_set=tree<_def, null_type, less<_def>, rb_tree_tag, tree_order_statistics_node_update>;
typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;

ll f(ll n) {return vll{n, 1, n+1, 0}[n&3];}

int32_t main() {
    fastio;
    ll a, b; cin>>a>>b; cout<<(f(a-1)^f(b))<<endl;
}


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

int main(){
  int N; string S; cin >> N >> S;
  int count[26]={};
  for(int i=0; i<N; i++){
    count[(int)(S[i]-'a')]++;
  }
  long long result=1;
  for(int i=0; i<26; i++){
    if(count[i]>0){
      result=(result*(count[i]+1))%1000000007;
    }
  }
  cout << result-1 << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define newl "\n"
using namespace std;
using lli = long long int;
using vvint = vector <vector <int>>;
using pii = pair <int,int>;
const int mod = 1e9 + 7;

const int N = 2e5 + 1;

int h,w;
pair <int,int> s,d;
vector <string> a;
vector <vector <pair <int,int>>> adj;
vector <int> dist;

void bfs01(int src){
	vector <bool> vis(h * w,0);
	dist[src] = 0;
	deque <int> q;
	q.push_back(src);
	while(q.size() > 0){
		int u = q.front();
		q.pop_front();
		if(vis[u]) continue;
		vis[u] = 1;
		for(auto vv : adj[u]){
			int v = vv.first;
			int d = vv.second;
			if(d > 0) q.push_back(v);
			else q.push_front(v);
			if(dist[u] + d < dist[v]) dist[v] = dist[u] + d;
		}
	}
	return;
}

void solve(){
	cin >> h >> w;
	cin >> s.first >> s.second;
	cin >> d.first >> d.second;
	--s.first,--s.second,--d.first,--d.second;
	
	dist = vector <int>(h * w,mod);
	a = vector <string>(h);
	adj = vector <vector <pair<int,int>>>(h * w);
	
	for(int i = 0;i < h;++i) cin >> a[i];
	for(int i = 0;i < h;++i){
		for(int j = 0;j < w;++j){
			if(a[i][j]!='#'){
				if(i - 1 >= 0 and a[i - 1][j] == '.') adj[i * w + j].push_back({(i - 1) * w + (j),0});
				if(i + 1 < h and a[i + 1][j] == '.') adj[i * w + j].push_back({(i + 1) * w + (j),0});
				if(j - 1 >= 0 and a[i][j - 1] == '.') adj[i * w + j].push_back({(i ) * w + (j - 1),0});
				if(j + 1 < w and a[i][j + 1] == '.') adj[i * w + j].push_back({(i ) * w + (j + 1),0});
				for(int i1 = -2;i1 <= 2;++i1){
					for(int j1 = -2;j1 <= 2;++j1){
						if(i1 == 0 and j1 == 0) continue;
						if(i - i1 >= 0 and i - i1 < h and j - j1 >= 0 and j - j1 < w and a[i - i1][j - j1] == '.') adj[i * w + j].push_back({(i - i1) * w + j - j1,1});
					}
				}
			}
		}
	}
	bfs01(s.first * w + s.second);
	if(dist[d.first * w + d.second]==mod) cout << -1 << newl;
	else cout << dist[d.first * w + d.second] << newl;
	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(10);
	#ifdef EXECUTE_LOCALLY
		   freopen("in.txt","r",stdin);
		   freopen("out.txt","w",stdout);
	#endif
	int t = 1;
	//cin >> t;
	while(t--) solve();
	#ifdef EXECUTE_LOCALLY
    	cout << setprecision(3) << "program time: " << (double)clock() / CLOCKS_PER_SEC << newl;
	#endif
	return 0;
}


Measured memory_bytes: 114232
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    for(int i=1;i<s.size();i++){
        if(s[i]==s[i-1]){
            cout<<i<<" "<<i+1;
            return 0;
        }
    }
    for(int i=2;i<s.size();i++){
        if(s[i]==s[i-2]){
            cout<<i-1<<" "<<i+1;
            return 0;
        }
    }
    cout<<"-1 -1";
}

Measured memory_bytes: 512
/*input
3 3
abc


*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
typedef long long int ll;
#define ld long double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define sz(_a) (ll)(_a.size())
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;

ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int n;
    cin>>n;
    int sum=0;
    int b[n-1],a[n];
    REP(i,n-1){
    	cin>>b[i];
    }
  
    a[0]=b[0];
    b[n-1]=INF;
    for(int i=1;i<n;i++){
    	int ans=0;
    	REP(j,1e5+1){
    		if(max(j,a[i-1])<=b[i-1] and j<=b[i]){
    			ans=j;
    		}
    		else break;
    	}
    	a[i]=ans;
    }
    REP(i,n){
    	sum+=a[i];
    }
    cout<<sum;
}

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

typedef long long ll;
const int MOD = 1e9 + 7;
const int MAX = 1e5 + 10;

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

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

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int N, K; cin >> N >> K;
    vector<ll> A(N); for (int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end());
    ll max = 0;
    ll min = 0;
    COMinit();
    for (int i = 0; i < N; i++) {
        if (i + K - 1 <= N - 1) {
            min = (min + (A[i] * COM(N - i - 1, K - 1)) % MOD) % MOD;
        }
        if (i - K + 1 >= 0) {
            max = (max + (A[i] * COM(i, K - 1)) % MOD) % MOD;
        }
    }
    cout << (MOD + max - min) % MOD << endl;
}

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

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  bool ans=false;
  for(int i=0;i<n;i++){
    if(a[i]%2==1){
      ans=true;
    }
  }
  cout << (ans?"first":"second") << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <cstdint>
#include <iomanip>
#include <set>
#include <map>
#include <unordered_map>
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

int main(){
    int n, k; std::cin >> n >> k;
    std::vector<int> p(n,0);
    for(int i=0; i<n; i++){
        std::cin >> p[i];
    }

    std::sort(p.begin(),p.end());

    std::cout << std::accumulate(p.begin(), p.begin()+k, 0) << "\n";
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

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

#define MAX_N 1000
#define MAX_M 100

const long long INF = 1LL << 60;

//境界値に注意！！！

// DP テーブル
ll dp[100010];

int main() {
    ll n;
    cin >> n;
    ll h[100010];
    for (ll i=0;i<n;++i)cin >> h[i];
    for (ll i=0;i<n;++i)dp[i]=INF;
    dp[0]=0;
    for (ll i=1;i<n;++i){
        chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
        if(i>1){
            chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1792
n=int(input())
l=[int(input()) for i in range(n)]
ct=0
for i in range(n):
  ct+=l[i]//2
  l[i]%=2
  if i!=n-1 and l[i]==1 and l[i+1]!=0:
    ct+=1
    l[i]-=1
    l[i+1]-=1
print(ct)

Measured memory_bytes: 7072
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,n;
    cin>>a>>n;
    int h[100010];
    int sum=0;
    for(int i=1;i<=n;++i){
        cin>>h[i];
        sum+=h[i];
    }
    if(sum>=a)puts("Yes");
    else puts("No");
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();

            if (H == 0 && W == 0) break;

            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if ((i % 2 == 0 && j % 2 == 0) || (i % 2 == 1 && j % 2 == 1)) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 34668
#include<bits/stdc++.h>
using namespace std;
char a[4][4];
int main()
{
	for (int i=1;i<=3;i++)
	    for (int j=1;j<=3;j++)
	        cin >>a[i][j];
	cout <<a[1][1] <<a[2][2] <<a[3][3];
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
typedef struct fes{
  char cl[16];
  int in[2];
}fes;

main(){
  int i,ans,sum;
  fes f[10];
  for(i=0;i<9;i++){
    scanf("%s %d %d",f[i].cl,&f[i].in[0],&f[i].in[1]);
  }
  for(i=0;i<9;i++){
    sum=f[i].in[0]+f[i].in[1];
    ans=f[i].in[0]*200 + f[i].in[1]*300;
    printf("%s %d %d\n",f[i].cl,sum,ans);
  }
  return 0;
}

Measured memory_bytes: 0
n = int(input())
a = list(map(int, input().split()))
q = int(input())

m = {}
for i in a:
    if i in m.keys():
        m[i] = m[i] + 1
    else:
        m[i] = 1

ans = 0
for k in m:
    ans += m[k] * k

for i in range(q):
    b, c = map(int,input().split())
    if b in m.keys():
        t = 0
        if c in m.keys():
            t = m[c] * c
            m[c] = m[c] + m[b]
        else:
            m[c] = m[b]
        ans += m[c] * c - m[b] * b - t
        m.pop(b)
    print(ans)


Measured memory_bytes: 20848
# A - Bichrome Cells

# N * N のマス目がある。
# このマス目の各マスを白色または黒色に塗ることにしました (すべてのマスをどちらか片方の色に塗ります)
# ちょうど  A マスを白色に塗るとき、黒色に塗ることになるマスはいくつあるでしょうか。

# 黒色に塗ることになるマスの個数を出力

# 標準入力 N
N = int(input())

# 標準入力 A
A = int(input())
# print(N, A)

# マス数を計算
square_num = N * N
# print(square_num)

# 黒色に塗るマスの量を計算
answer = square_num - A

# 結果を出力
print(answer)


Measured memory_bytes: 9088
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
typedef long long ll;
using namespace std;
int main(void){
 int k;
 cin>>k;
 int a,b;
 a=(k+1)/2;
 b=k/2;
 cout<<a*b<<endl;   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;
typedef long long int lli;
typedef pair<int, int> ii;

int main() {
    string s;
    int K;
    cin >> s;
    cin >> K;

    set<string> ss;
    for (int i = 0; s[i] != '\0'; i++) {
        for (int j = 0; s[i + j] != '\0' && j <= K; j++) {
            string ps = s.substr(i, j + 1);
            ss.insert(ps);
            if (ss.size() > K) ss.erase(--ss.end());
        }
    }

    cout << *(--ss.end()) << endl;
}


Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.bigint;
import std.bitmanip;
import std.conv;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

// 差の絶対値
@nogc @safe pure T diff(T)(const ref T a, const ref T b) { return a > b ? a - b : b - a; }

// 切り上げ除算
@nogc @safe pure T divCeil(T)(const ref T a, const ref T b) {
    return (a+b-1)/b;
}

T[] readToArray(T)() {
    return readln.split.to!(T[]);
}

void readInto(T...)(ref T ts) {
    auto ss = readln.split;
    foreach(ref t; ts) {
        t = ss.front.to!(typeof(t));
        ss.popFront;
    }
}

// 冪乗をmod取りつつ計算
@nogc @safe pure ulong modPow(ulong a, ulong n, ulong m) {
    ulong r = 1;
    while (n > 0) {
        if(n % 2 != 0) r = r * a % m;
        a = a * a % m;
        n /= 2;
    }
    return r;
}

// フェルマーの小定理から乗法逆元を計算
// 定理の要請により法は素数
@nogc @safe pure ulong modInv(ulong a, ulong m) {
    return modPow(a, m-2, m);
}

// mod取りつつ順列を計算
@nogc @safe pure ulong modPerm(ulong n, ulong k, ulong m) {
    if (n < k) return 0;

    ulong r = 1;
    for (ulong i = n-k+1; i <= n; i++) {
        r *= i;
        r %= m;
    }
    return r;
}

// mod取りつつ順列を計算
@nogc @safe pure ulong modFact(ulong n, ulong m) {
    return modPerm(n, n, m);
}

// mod取りつつ組み合わせを計算
// modInvを使っているので法は素数
@nogc @safe pure ulong modComb(ulong n, ulong r, ulong m) {
    return modPerm(n, r, m)*modInv(modFact(r, m), m) % m;
}

immutable ulong MOD = 1000000007;

void main() {
    ulong n;
    readInto(n);
    ulong[] as = readToArray!(ulong);
    auto ret = n;
    double s = 0;
    foreach(ulong a ; as) {
        s += 1.0/a;
    }
    writefln("%.10f", 1/s);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fi first
#define se second
#define vi_a vector<int>a;
#define p_b push_back
#define ll long long
#define ull unsigned long long
#define ld long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define m_p make_pair
#define fast_io cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
#define all(x) x.begin(),x.end()
#define sqr(x) (x)*(x)
#define pw(x) (1ll << x)
#define sz(x) (int)x.size()
#define endl "\n"
using namespace std;
signed main()
{
    ll n;
    cin>>n;
    vector<ll>a(n);
    bool ok=1;
    unordered_map<ll,bool>mp;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        if(mp[a[i]]){
            ok=0;
        }
        mp[a[i]]=1;
    }
    if(ok){
        cout<<"YES";
    }
    else{
        cout<<"NO";
    }
}


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

int main(void)
{
  int k, x;
  scanf("%d %d", &k, &x);

  for(int i = 0; i < 2 * k - 1; i++){
    printf("%d ", x - k + 1 + i);
  }
  printf("\n");

  return 0;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> image(n, vector<int>(n)), figure(m, vector<int>(m));
    rep(i, n) {
        string str;
        cin >> str;
        rep(j, n) {
            if(str.at(j) == '#') image.at(i).at(j) = 1;
            else image.at(i).at(j) = 0;
        }
    }
    rep(i, m) {
        string str;
        cin >> str;
        rep(j, m) {
            if(str.at(j) == '#') figure.at(i).at(j) = 1;
            else figure.at(i).at(j) = 0;
        }
    }
    bool ans = false;
    rep(i, n - m + 1) {
        rep(j, n - m + 1) {
            bool flag = true;
            rep(k, m) {
                rep(l, m) {
                    if(image.at(k + i).at(l + j) != figure.at(k).at(l)) flag = false;
                }
            }
            if(flag) ans = true;
        }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

unsigned long long Kaijo(int n) {
	if (n == 1)return 1;
	else return Kaijo(n - 1)*n;
}

int main() {
	int N;
	unsigned long long ans;
	scanf("%d", &N);
	ans = Kaijo(N);
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 2024