akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define dup(x, y) (((x) + (y)-1) / (y))
#define PI 3.14159265359
typedef long long LL;
typedef vector<vector<int>> Graph;
typedef vector<int> Vector;
const LL MOD = 1e9 + 7;
const LL LLINF = 1LL << 60;
const int INF = 1 << 30;
template <class T> inline void chmax(T &a, T b) {
    if(a < b) {
        a = b;
    }
}
template <class T> inline void chmin(T &a, T b) {
    if(a > b) {
        a = b;
    }
}
template <class T> inline T gcd(T x, T y) {
    if(y == 0) {
        return x;
    } else if(x == 0) {
        return y;
    }
    return gcd(y, x % y);
}
template <class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template <class T> inline void print_vector(vector<T> vec) {
    for(int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    cout << endl;
}
template <class T> inline T mpower(T x, T n) {
    if(n == 0) {
        return 1;
    } else if(n % 2 == 0) {
        return mpower(x * x % MOD, n / 2);
    } else {
        return x * mpower(x, n - 1) % MOD;
    }
}
LL mfrac(LL x) {
    LL res = 1;
    for(LL i = x; i >= 1; i--) {
        res *= i;
        res %= MOD;
    }
    return res;
}
LL mcomb(LL n, LL r) {

    if(n == 0 and r == 0) {
        return 1;
    } else if(n < r || n < 0) {
        return 0;
    }

    LL res = mfrac(n) * mpower(mfrac(r), MOD - 2) % MOD;
    res *= mpower(mfrac(n - r), MOD - 2) % MOD;

    return res;
}

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

    if(X < 100) {
        cout << 0 << endl;
        return 0;
    }

    int threshold = X / 100;
    int mod = X % 100;
    int need_num = dup(mod, 5);

    if(need_num > threshold) {
        cout << '0' << endl;
    } else {
        cout << '1' << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int l[250002];
int r[250002];
int count = 0;

void merge(int a[], int left, int mid, int right) {
  int n1, n2, i;
  n1 = mid - left;
  n2 = right - mid;
  for (i = 0; i < n1; i++)
    l[i] = a[left+i];
  for (i = 0; i < n2; i++)
    r[i] = a[mid+i];
  l[n1] = 2000000000;
  r[n2] = 2000000000;
  i = 0;
  int j = 0;
  int k;
  for (k = left; k < right; k++) {
    if (l[i] <= r[j]) {
      a[k] = l[i++];
    } else {
      a[k] = r[j++];
    }
    count++;
  }
}

void mergesort(int a[], int left, int right) {
  if (left+1 < right) {
    int mid = (left + right) / 2;
    mergesort(a, left, mid);
    mergesort(a, mid, right);
    merge(a, left, mid, right);
  }
}

int main(void)
{
  int n, i;
  int s[500000];
  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf("%d", &s[i]);
  mergesort(s, 0, n);
  printf("%d", s[0]);
  for (i = 1; i < n; i++)
    printf(" %d", s[i]);
  printf("\n");
  printf("%d\n", count);
  return 0;
}



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

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

	vector<int> p(n);

	for (int i = 0; i < n; i++)
	{
		cin >> p[i];
	}

	int tmp;

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

	int sum = 0;

	for (int i = 0; i < k; i++)
	{
		sum += p[i];
	}

	cout << sum << endl;

	return 0;
}

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

int  A[100000];

int main(){
	int N; cin>>N;
	int r = 0, n = 0;
	rep(i, N){ cin>>A[i]; n = max(n, A[i]); }
	int half = n/2;
	rep(i, N) if(abs(half - r) > abs(half - A[i])) r = A[i];
	cout<< n <<" "<< r <<endl;
}

Measured memory_bytes: 640
from bisect import bisect_right
N = int(input())
A = []
for i in range(N):
    A.append(-int(input()))
INF = float('inf')
D = [INF] * N
for i in range(len(A)):
  
    D[bisect_right(D, A[i])] = A[i]

print(N - D.count(INF))


Measured memory_bytes: 7840
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int K,A,B;
  cin >> K >> A >> B;
  bool ans = false;
  for(int i=0;i<1000;i++)
  {
    if(K*i>=A&&K*i<=B)
    {
      cout << "OK" << endl;
      ans = true;
      break;
    }
  }
  if (ans == false){
  cout << "NG" << endl;}
  return 0;
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int h[n+1],i,j;
  for(i=1;i<=n;i++)
    cin>>h[i];
  int dp[n+1];
  for(i=0;i<=n;i++)
    dp[i]=INT_MAX;
  dp[1]=0;
  for(i=1;i<n;i++)
  {
    for(j=1;j<=k && (i+j)<=n;j++)
    {
      dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
    }
  }
  cout<<dp[n]<<endl;
  return 0;
}


Measured memory_bytes: 4408
<?php
/*
    Problem URL : https://beta.atcoder.jp/contests/abc067/tasks/abc067_a

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

// define('DEBUG', true);
define('DEBUG', false);

ini_set('error_reporting', E_ALL & ~E_NOTICE);

fscanf(STDIN, "%d %d", $A, $B);

if ($A % 3 == 0 || $B % 3 == 0 || ($A + $B) % 3 == 0) {
    echo "Possible\n";
} else {
    echo "Impossible\n";
}


Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> A(N,0);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int ans = 0;
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  for (int i = 0; i < N; i++) {
    if (i%2 ==0) {
      ans += A[i];
    } else {
      ans -= A[i];
    }
  }
  cout << ans;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            var B = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);

            Array.Reverse(B);

            long[] A = new long[N];
            A[0] = B[0];
            A[N-1] = B[N - 2];

            for (int i = 1; i < N-1; i++)
            {
                if (B[i] > B[i - 1]){
                    A[i] = B[i - 1];
                }
                else
                {
                    A[i] = B[i];
                }

            }

            Console.WriteLine(A.Sum());
        

        }
    }
}


Measured memory_bytes: 13268
#include <stdio.h>

int main(){
  char c;
  
  scanf("%c", &c);
  
  if('a' == c || 'e' == c || 'i' == c || 'o' == c || 'u' == c){
    printf("vowel");
  }else{
    printf("consonant");
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using P = pair<int,int>;
const int INF = 1001001001;
int N, M;
vector<vector<int>> G;
vector<int> dist;
vector<int> parent;

int bfs(int s) {
    for(int i=0; i<N; ++i) dist[i] = INF;
    dist[s] = 0;
    queue<P> Q;
    Q.emplace(s, -1);
    while(!Q.empty()) {
        int cur = Q.front().first;
        int par = Q.front().second;
        Q.pop();
        for(int to : G[cur]) {
            if(to == s) {
                parent[to] = cur;
                return dist[cur] + 1;
            }
            if(dist[to] == INF) {
                parent[to] = cur;
                dist[to] = dist[cur] + 1;
                Q.emplace(to, cur);
            }
        }
    }
    return INF;
}

int main() {
    cin >> N >> M;
    G.resize(N); dist.resize(N); parent.resize(N);
    for(int i=0; i<M; ++i) {
        int a,b; cin >> a >> b;
        G[a - 1].push_back(b - 1);
    }

    int minlen = INF, v = -1;
    for(int i=0; i<N; ++i) {
        int len = bfs(i);
        if(len < minlen) {
            minlen = len;
            v = i;
        }
    }

    if(v == -1) {
        cout << -1 << endl;
    } else {
        cout << minlen << endl;
        bfs(v);
        stack<int> cycle;
        for(int i=0; i<minlen; ++i) {
            cycle.push(parent[v]);
            v = parent[v];
        }
        for(int i=0; i<minlen; ++i) {
            cout << cycle.top() + 1 << endl;
            cycle.pop();
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int N, Q;
    while (cin >> N >> Q, N | Q)
    {
        vector<int> date_dist(100, 0);
        for (int i = 0; i < N; ++i)
        {
            int M;
            cin >> M;
            for (int j = 0; j < M; ++j)
            {
                int date;
                cin >> date;
                ++date_dist[date];
            }
        }
        auto ans = max_element(date_dist.begin(), date_dist.end());
        if (*ans < Q)
        {
            cout << 0 << endl;
        }
        else
        {
            cout << distance(date_dist.begin(), ans) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1196
fn read() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().to_string()
}

fn main() {
    let n: usize = read().parse().unwrap();
    let mut cnt: Vec<usize> = vec![50_usize; 26];
    for _ in 0..n {
        let q: Vec<usize> = read().chars().map(|x| (x as u8 - b'a') as usize).collect();
        for i in 0..26 {
            let tmp = q.iter().filter(|&&x| x == i).count();
            cnt[i] = std::cmp::min(cnt[i], tmp);
        }
    }
    let ans: String = (0..26)
        .map(|x| {
            let s = (x + b'a') as char;
            (0..cnt[x as usize]).map(|_| s).collect::<String>()
        })
        .collect();
    println!("{}", ans);
}


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

int main(){
	int N;
	int A;
	int B;
	int yen;
	cin >> N;
	cin >> A;
	cin >> B;
	if(A * N <= B){
		yen = N * A;
	}else{
		yen = B;
	}
	cout << yen << endl;
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> P(N);
  vector<int> minP(N);
  cin >> P[0];
  minP[0] = P[0];
  for(int i = 1; i < N; i++){
    cin >> P[i];
    minP[i] = min(P[i], minP[i - 1]);
  }
  
  int cnt = 0;
  for(int i = 0; i < N; i++){
    if(minP[i] >= P[i]) cnt++;
  }
  
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<map>
#include<string.h>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<cstdlib>
#include<math.h>
#include<set>
#include<array>
using namespace std;

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



#define rep(n) for(int i=0;i<(n);i++)
typedef pair<int, int> pii;

typedef long long ll;
typedef pair<ll, ll>pll;
const int MOD = 1000000007;
const int INF = 1 << 29;




int main() {
	int n;
	cin >> n;
	vector<vector<int>> s(n);
	rep(n-1) {
		int a, b;
		
		cin >> a >> b;
		a--; b--;
		s[a].push_back(b);
		s[b].push_back(a);
	}
	queue<int> q;
	int cnt[2] = { 0,0 };
	vector<int> color(n, -1);
	color[0] = 0;
	color[n - 1] = 1;
	q.push(0); q.push(n - 1);
	while (!q.empty()) {
		int a = q.front();
		q.pop();
		for (int i = 0; i < s[a].size(); i++) {
			if (color[s[a][i]] == -1) {
				color[s[a][i]] = color[a];
				cnt[color[a]]++;
				q.push(s[a][i]);
			}
		}
	}
	if (cnt[0] > cnt[1])cout << "Fennec" << endl;
	else cout << "Snuke" << endl;
	return 0;
}

Measured memory_bytes: 6144
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <string.h>
using namespace std;


struct edge{int to, cap, rev;};
int level[300];
int iter[300];
int INF = 100000000;

void bfs(vector< vector<edge> > &G, int s){
  memset(level, -1, sizeof(level));
  queue<int> que;
  level[s] = 0;
  que.push(s);
  while(!que.empty()){
    int v = que.front();
    que.pop();
    for(int i = 0; i < G[v].size(); ++i){
      edge &e = G[v][i];
      if(e.cap > 0 && level[e.to] < 0){
        level[e.to] = level[v] + 1;
        que.push(e.to);
      }
    }
  }
}


int dfs(vector< vector<edge> > &G, int v, int t, int f){
  if(v == t) return f;
  for(int &i = iter[v]; i < G[v].size(); ++i){
    edge &e = G[v][i];
    if(e.cap > 0 && level[v] < level[e.to]){
      int d = dfs(G,e.to,t,min(f,e.cap));
      if(d > 0){
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

int max_flow(vector< vector<edge> > G, int s, int t){
  int flow = 0;
  for(;;){
    bfs(G,s);
    if(level[t] < 0) return flow;
    memset(iter,0,sizeof(iter));
    int f;
    while((f = dfs(G,s,t,INF)) > 0){
      flow += f;
    }
  }
}

int main(){
  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N), D(N);
  for(int i = 0; i < N; ++i) cin >> A[i] >> B[i];
  for(int i = 0; i < N; ++i) cin >> C[i] >> D[i];
  int V = 2*N + 2;
  vector< vector<edge> > G(V);
  for(int i = 0; i < N; ++i){
    G[2*N].push_back((edge){i,1,G[i].size()});
    G[i].push_back((edge){2*N,0,G[2*N].size()-1});
    G[N+i].push_back((edge){2*N+1,1,G[2*N+1].size()});
    G[2*N+1].push_back((edge){N+i,0,G[N+i].size()-1});
    for(int j = 0; j < N; ++j){
      if(A[i] < C[j] && B[i] < D[j]){
        G[i].push_back((edge){N+j,1,G[N+j].size()});
        G[N+j].push_back((edge){i,0,G[i].size()-1});
      }
    }
  }
  cout << max_flow(G,2*N,2*N+1) << endl;
  return 0;
}


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

const ll INF = 1000000000000000000;

int main() {
  ll N;
  cin >> N;
  ll ans = 1;

  vector<ll> A(N);
  rep(i, N) {
    ll a;
    cin >> a;
    A[i] = a;
    if (a == 0) {
      ans = 0;
    }
  }
  
  if (ans == 1) {
    for(int i = 0; i < N; i++) {
      if (A[i] <= INF / ans) {
        ans *= A[i];
      } else {
        ans = -1;
        break;
      }
    }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4036
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

const ll MOD = 1e9+7;
ll dp[61][3];
// uのiビット目以降を確定させたとき、(N>>i)-(v>>i)がjとなる場合の数

void add(ll &a, ll b) {
    a = (a + b) % MOD;
}

int nth_bit(ll n, int i){
    return (n >> i) & 1;
}

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

    dp[60][0] = 1;
    for (int i = 59; i >= 0; i--) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                int tmp = min(2, 2 * j + nth_bit(n, i) - k);
                if (tmp >= 0) add(dp[i][tmp], dp[i+1][j]);
            }
        }
    }

    cout << (dp[0][0] + dp[0][1] + dp[0][2]) % MOD << "\n";
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector <int> H(N);
  int prev;
  bool flag=true;
  for(int i=0;i<N;i++){
    cin >> H.at(i);
    if(i==0){
      prev=H.at(0);
      }else{
      if(prev<H.at(i)){
        H.at(i)--;
      }
      if(prev>H.at(i)){
        flag=false;
        break;
      }
      prev=H.at(i);
    }
  }
  if(flag){
    cout<<"Yes"<<endl;
    }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	static int n;
	static int m;
	static int c;
	static int d;
	static String A;
	static String B;
	static char[][] a;
	static char[][] b;
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		n = scan.nextInt();
		m = scan.nextInt();
		a = new char[n][n];
		b = new char[m][m];
		for (int i = 0; i < n; i++) {
			A = scan.next();
			for (int j = 0; j < n; j++) {
				a[i][j] = A.charAt(j);
			}
		}
		for (int i = 0; i < m; i++) {
			B = scan.next();
			for (int j = 0; j < m; j++) {
				b[i][j] = B.charAt(j);
			}
		}
		for (c = 0; c <= n-m; c++) {
			for (d = 0; d <= n-m; d++) {
				if (search()) {
					System.out.println("Yes");
					return;
				}
			}
		}
		System.out.println("No");
	}
	static boolean search() {
		for (int k = 0; k < m; k++) {
			for (int l = 0; l < m; l++) {
				if (a[c+k][d+l] != b[k][l]) {
					return false;
				}
			}
		}
		return true;
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

void dfs(int s, vector<vector<int> > &G, ll *tmp, int *seen) {
    seen[s] = 1;
    for (int i = 0; i < (int)G[s].size(); i++) {
        int v = G[s][i];
        if (seen[v])
            continue;
        tmp[v] += tmp[s];
        dfs(v, G, tmp, seen);
    }
}

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<vector<int> > G(N);
    for (int i = 0; i < N-1; i++) {
        int a, b;   cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

    ll *tmp = new ll[N];
    int *seen = new int[N];
    for (int i = 0; i < N; i++)
        tmp[i] = 0, seen[i] = 0;

    for (int i = 0; i < Q; i++) {
        int x, p;  cin >> p >> x;
        tmp[p-1] += x;
    }

    dfs(0, G, tmp, seen);

    for (int i = 0; i < N; i++)
        cout << tmp[i] << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 29132
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using bint = boost::multiprecision::cpp_int;

int main()
{
    int N;
    std::cin >> N;
    std::vector<int> as(N);
    std::vector<int> bs(N);
    std::vector<int> diffs(N);
    for (int i = 0; i < N; i++) {
        std::cin >> as.at(i);
    }
    for (int i = 0; i < N; i++) {
        std::cin >> bs.at(i);
    }
    for (int i = 0; i < N; i++) {
        diffs.at(i) = as.at(i) - bs.at(i);
    }
    bint sum_a = std::accumulate(as.begin(), as.end(), bint(0));
    bint sum_b = std::accumulate(bs.begin(), bs.end(), bint(0));
    if (sum_a < sum_b) {
        std::cout << "-1" << std::endl;
        return 0;
    }
    std::sort(diffs.begin(), diffs.end());
    int minus_num = 0;
    bint minus = 0;
    for (int i = 0; i < N; i++) {
        if (diffs.at(i) >= 0) {
            break;
        }
        minus += diffs.at(i);
        minus_num = i + 1;
    }
    int large_num = 0;
    for (int i = 0; i < N; i++) {
        if (minus >= 0) {
            break;
        }
        large_num = i + 1;
        minus += diffs.at(N - i - 1);
    }
    std::cout << large_num + minus_num << std::endl;
    return 0;
}

Measured memory_bytes: 1408
#include<cstdio>
#include<algorithm>

using namespace std;

bool era[1000001];
int pnum[1000001];

int main(){
	era[0]=era[1]=true;
	for(int i=0;i<=1000;i++){
		if(!era[i])	for(int j=i*i;j<=1000000;j+=i)	era[j]=true;
	}
	for(int i=1;i<=1000000;i++)	pnum[i]=pnum[i-1]+!era[i];

	for(int n;scanf("%d",&n),n;){
		int prz=-n;
		while(n--){
			int p,m;	scanf("%d%d",&p,&m);
			prz+=pnum[min(p+m,1000000)]-pnum[max(0,p-m-1)];
		}
		printf("%d\n",prz);
	}

	return 0;
}

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

int main() {
  int N, K;
  int b;
  cin >> N;
  cin >> K;
  int count = 0;

  for (int i = 0; i < N; i++) {
    cin >> b;
    if (b <= K - b) {
      count += 2 * b;
    }else {
      count += 2 * (K - b);
    }
  }
  cout << count << endl;

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n, m;
    cin >> n >> m;
    vll road(n, 0);
    REP(i, m) {
        ll a, b;
        cin >> a >> b;
        road.at(a-1)++;
        road.at(b-1)++;
    }
    for (auto elem : road) {
        cout << elem << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

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

	auto sum = 0;
	for (auto i = 1; i < N; ++i)
	{
		if (S[i] == 'E')
		{
			++sum;
		}
	}

	auto result = sum;
	for (auto i = 1; i <= N; ++i)
	{
		if (S[i] == 'E')
		{
			--sum;
		}
		if (S[i - 1] == 'W')
		{
			++sum;
		}
		result = min(result, sum);
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 900
from collections import deque

if __name__ == '__main__':
    n, k = map(int, input().split())
    sushis = [tuple(int(s) for s in input().split()) for _ in range(n)]
    sushis.sort(key=lambda t: t[1], reverse=True)

    used_set = set()
    replace_stack = deque()
    add_queue = deque()
    ans = 0
    for i in range(k):
        t, d = sushis[i]
        if t in used_set:
            replace_stack.appendleft(d)
        else:
            used_set.add(t)
        ans += d
    num = len(used_set)
    ans += num * num

    for i in range(k, n):
        t, d = sushis[i]
        if t not in used_set:
            add_queue.append(d)
            used_set.add(t)

    tmp = ans
    for x, r, a in zip(range(num, k + 1), replace_stack, add_queue):
        tmp = tmp + 2 * x + 1 - r + a
        ans = max(ans, tmp)

    print(ans)



Measured memory_bytes: 23708
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define rep(i, n)for(int i=0; i<n; i++)

int main(){
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];

  sort(a.begin(), a.end());

  int count = 1;
  if(a[0] != a[1])
    count++;
  if(a[1] != a[2])
    count++;

  cout << count << endl;
    
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define N 200005
int n,a[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=2;i<=n;++i) if(a[i]==a[i-1]) {puts("NO");return 0;}
	puts("YES");return 0;
}

Measured memory_bytes: 1024
use proconio::input;
use std::collections::HashSet;


fn main() {
    input! {
        n: usize,
        sn: [String; n],
    }
    
    let mut items: HashSet<String> = HashSet::new();

    for s in sn.into_iter() {
        items.insert(s);
    }

    println!("{}", items.len());

}


Measured memory_bytes: 24932
#include <iostream>
using namespace std;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)

int main() {
	int a, b; cin >> a >> b;
	rep(i, 0, 2000) {
		if (i * 8 / 100 == a && i / 10 == b) {
			cout << i;
			return 0;
		}
	}
	cout << -1;
	return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
int main(void){
  int a,b;
  scanf("%d %d", &a, &b);
  if(a < b)
  {
  printf("a < b\n");}
  if(a > b){
  printf("a > b\n");}
  	if(a == b)
  {
  printf("a == b\n");
  }
  return 0;
  }

Measured memory_bytes: 580
function partition(A, p, r) {
	var x = A[r];
	var i = p - 1;
	for (var j = p; j < r; j++) {
		if (A[j] <= x) {
			i++;
			var tmp = A[i];
			A[i] = A[j];
			A[j] = tmp;
		}
	}
	var tmp = A[i + 1];
	A[i + 1] = A[r];
	A[r] = tmp;

	return i + 1;
}

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');

var n = +lines.shift();
var A = lines.shift().split(' ').map(function(i){return +i;});

var idx = partition(A, 0, A.length - 1);
A[idx] = '[' + A[idx] + ']';
console.log(A.join(' '));

Measured memory_bytes: 21920
n, x = map(int, input().split())
*a, = map(int, input().split())

b = a[:]
if b[0] > x:
    b[0] = x

for i in range(n-1):
    if b[i]+b[i+1] > x:
        b[i+1] = abs(b[i]-x)

print(sum(map(lambda x: abs(x[0] - x[1]), zip(a, b))))


Measured memory_bytes: 14540
#include<iostream>
using namespace std;
int p[104730]={0},n,s,i,j;
int main(){
  p[1]=1;
  for(i=2;i*i<104730;i++)
    if(!p[i])
      for(j=2;i*j<104730;j++)
	p[i*j]=1;

  while(cin>>n,n) {
    for(i=2,s=0;n;i++)
      if(!p[i])
	s+=i,n--;
    cout<<s<<endl;
  }
}

Measured memory_bytes: 0
/**
*    created: 30.06.2020 14:00:18
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pcnt(bit) __builtin_popcountll(bit)
using namespace std;
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const int mod = 1000000007;
const long double pi = acos(-1.0);
const int inf = 1LL << 60;


// 素因数分解してmapに格納
map<int,int> mp;

void prime(int n) {
    if (n == 1) return;
    for (int i = 2; i*i<= n; i++) {
        if (n % i == 0) {
            prime(i);
            prime(n/i);
            return;
        }
    }
    mp[n]++;
    return;
}


signed main() {

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

    
    int n;
    cin >> n;
    rep2(i,1,n+1) {
        prime(i);
    }
    int ans = 1;
    for (auto p : mp) {
        int t = p.second + 1;
        t %= mod;
        ans *= t;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3672
# include <iostream>
# include <string>
# include <cctype>
# include <vector>
# include <cstdlib>
# include <cstring>
# include <algorithm>
# include <iomanip>
# include <cmath>

using namespace std ;

//const double pi=acos(-1.0) ;//也可以用cmath中的M_PI
int main()
{
    ios::sync_with_stdio(false) ;
    int n ;
    while(cin>>n)
    {
    	if (n<1200)
       	cout << "ABC" << endl ;
       	else if(n<2800)
       	cout << "ARC" << endl ;
       	else
       	cout << "AGC" << endl ;

	}
	return 0 ;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	char youbi[7][10]={"Wednesday","Thursday","Friday"
	,"Saturday","Sunday","Monday","Tuesday"};
	int days[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
	int month,day;
	int i,sum;
	
	while(1){
		scanf("%d %d",&month,&day);
		if(month==0){
			break;
		}
		
		sum=0;
		
		for(i=1;i<month;i++){
			sum+=days[i];
			sum%=7;
		}
		
		sum+=day;
		sum%=7;
		
		printf("%s\n",youbi[sum]);
		
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    long long A, B;
    cin >> A >> B;
    if((A + B) % 2 != 0) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    } else {
        cout << (A + B) / 2 << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

int main()
{
   FAST/**/
   
   ll h,w;
   cin>>h>>w;
   
   if(h == 1 || w == 1)
   {
       cout<<1;
       return 0;
   }
   
   cout<<(h*w+1)/2;
   
   return 0;        
}  
   

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

using namespace std;

void dfs(int now,int N,vector<bool> &v,vector<vector<int>> &g){
	for(int i=0;i<N;i++){
		if(now==i)continue;
		if(g[now][i]==1 && v[i]==0){
			v[i] = 1;
			dfs(i,N,v,g);
		}
	}
}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,M,ans = 0;
	cin >> N >> M;
	vector<int> a(M),b(M);
	rep(i,M){
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
	}
	for(int i=0;i<M;i++){
		//i番目の辺を除いた状態で各頂点から全ての頂点にいけるかどうかを調べる
		vector<vector<int>> g(N,vector<int>(N,-1));
		vector<bool> v(N);
		rep(j,M){
			if(i==j)continue;
			g[a[j]][b[j]]=1;
			g[b[j]][a[j]]=1;
		}
		v[0] = 1;
		dfs(0,N,v,g);
		bool ok = 0;
		for(int i=0;i<N;i++){
			if(v[i]==0)ok = 1;
		}
		if(ok)ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int H,W,i,j;
    while(1){
        scanf("%d %d",&H,&W);
        if(H==0&&W==0){
            break;
         }
         for(i=0;i<H;i++){
            for(j=0;j<W;j++){
                if(H==1&&W==1){
                    printf("#\n");
                }else if((i+j)%2==0){
                    printf("#");
                        if(j==W-1) printf("\n");
                }else if((i+j)%2==1){
                    printf(".");
                        if(j==W-1) printf("\n");
                  }
            }
         }
         printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1808
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

int main() {
	int A; int B; int C;
	while (~scanf("%d%d%d", &A, &B, &C)) {
		int ans = 0;
		if (A % 2 == 0 && A == B && B == C) {
			ans = -1;
		} else {
			while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
				++ ans;
				int nA = (B + C) / 2;
				int nB = (A + C) / 2;
				int nC = (A + B) / 2;
				A = nA;
				B = nB;
				C = nC;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}


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

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

    if (N == 1) {
        cout << "Hello World" << endl;
    } else {
        int A, B;
        cin >> A >> B;
        cout << A + B << endl;
    }
    
    return 0;
}


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

using namespace std;

int main(){
	int h,w,n;
	cin >> h >> w >> n;
	vector<vector<int> > list(h,vector<int>(w,0));
	int c=0;
	for(int i=0;i<n;i++){
		int t;
		cin >> t;
		for(int j=0;j<t;j++){
			list[c/w][c%w]=i+1;
			c++;
			//cout << i+1 << " ";
		}
		//cout << endl;
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(i%2==0){
				cout << list[i][j];
			}
			else{
				cout << list[i][w-j-1];
			}
			if(j!=w-1)cout << " ";
		}
		cout << endl;
	}
			

	return 0;
}



Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>

int main(){
	int i,j,n;
	int kane = 100000;
	double money;

	scanf("%d",&n);

	if(n<0 || n>100){
		return 0;
	}

	for(i=0;i<n;i++){
		kane += kane * 0.05;

		money = ceil((double)kane / 1000);
		
		kane = money * 1000;
	}
	
	printf("%d\n",kane);
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x,n) for(ll i=(ll) x;i<(ll) n;i++)
ll i,j;
const ll mod=1000000000+7;

int main(){
    ll N;
    cin>>N;
    vector<ll> L(N);
    ll cnt=0;
    rep(i,0,N)cin>>L.at(i);
    sort(L.begin(),L.end());
    rep(i,0,N-2){
        rep(j,i+1,N-1){
            ll en=N-1;
            ll st=j+1;
            
            while(en-st!=0){
                ll half=(en+st)/2;
                if(L.at(i)+L.at(j)>L.at(half)){
                    st=half+1;
                }
                else{
                    en=half;
                }
            }
            if(L.at(i)+L.at(j)>L.at(en))cnt+=en-j;
            else cnt+=en-j-1;
        }
        
    }
    cout<<cnt<<endl;



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second

using namespace std;

typedef long long ll;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, m; cin >> n >> m;
    priority_queue <ll> nums;
    for(int i=0; i<n; i++){
        ll tmp; cin >> tmp;
        nums.push(tmp);
    }
    while(m--){
        ll tmp = nums.top();
        nums.pop();
        nums.push(tmp/2);
    }
    ll ans = 0;
    while(!nums.empty()){
        ans += nums.top();
        nums.pop();
    }
    cout << ans << '\n';
    return 0;
}


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

using namespace std;


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


Measured memory_bytes: 256
# A-Grouping(ABC062)
A=[[1,3,5,7,8,10,12],[4,6,9,11],[2]]
x,y=map(int,input().split())
for i in range(2):
    if x in A[i]  and y in A[i]:
        print("Yes")
        break
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

bool comp2r(P a, P b) {
    if (a.second != b.second)
        return a.second > b.second;
    return a.first > b.first;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    vector<P> p(m);
    for (int i = 0; i < m; i++) {
        int b, c;
        cin >> b >> c;
        p[i] = make_pair(b, c);
    }
    
    sort(a.begin(), a.end());
    sort(p.begin(), p.end(), comp2r);
    
    vector<ll> s(n+1);
    s[0] = 0;
    for (int i = 0; i < n; i++)
        s[i+1] = s[i] + a[i];
    ll total = s[n];
    int mi = a[0];
    int del = 0;
    bool endflag = false;
    for (int i = 0; i < m && !endflag; i++) {
        int b = p[i].first, c = p[i].second;
        auto it = lower_bound(a.begin(), a.end(), c);
        int pos = it - a.begin();
        if (del + b > pos)
            b = pos - del;
        if (del + b >= n) {
            b = n - del;
            endflag = true;
        }
        if (mi < c) {
            total -= s[b + del] - s[del];
            total += (ll)c * b;
            del += b;
            mi = a[del];
        }
        else
            endflag = true;
    }
    
    cout << total << endl;
    
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
//using mint = modint1000000007;
using mint = modint998244353;



int main(){
  int N;
  cin >> N;
  map<int,int> m;
  rep(i,2*N){
    int a;
    cin >> a;
    m[a]++;
  }
  vector<int> v;
  FOR(it,m){
    v.push_back(it->second);
  }

  vector<mint> fact(2*N+5);
  vector<mint> inv_fact(2*N+5);
  vector<mint> fact2(2*N+5);
  {
    fact[0] = 1;
    rep(i,fact.size()-1) fact[i+1] = fact[i] * (i+1);
  }
  {
    inv_fact[fact.size()-1] = 1/fact[fact.size()-1];
    for(int i=fact.size()-1; i>0; i--) inv_fact[i-1] = inv_fact[i] * i;
  }
  {
    fact2[0] = fact2[1] = 1;
    REP(i,2,fact2.size()) fact2[i] = fact2[i-2] * i;
  }
  
  vector<vector<mint>> w;
  rep(i,v.size()){
    int max_num_edge = v[i] / 2;
    vector<mint> tmp;
    rep(j,max_num_edge+1){
      mint x = fact[v[i]] * inv_fact[2*j] * inv_fact[v[i]-2*j];
      if(2*j-1>=0) x *= fact2[2*j-1];
      tmp.push_back(x);
    }
    w.push_back(tmp);
  }

  while(w.size()>1){
    vector<vector<mint>> ww;
    swap(ww,w);

    for(int i=0; i<ww.size(); i+=2){
      if(i+1 >= ww.size()){
        w.push_back(ww[i]);
      }else{
        w.push_back(convolution(ww[i], ww[i+1]));
      }
    }
  }

  mint ret = fact2[2*N-1];
  REP(i,1,w[0].size()){
    mint d = w[0][i];
    if(2*N-2*i-1>=0) d *= fact2[2*N-2*i-1];

    if(i%2==1) ret -= d;
    else ret += d;
  }
  cout << ret.val() << endl;
  
  return 0;
}



Measured memory_bytes: 17784
n, d = map(int,input().split())
x = list(range(n))
for i in range(n):
  x[i] = list(map(int, input().split()))

a = []
for i in range(200):
  a.append(i**2)

ans = 0
for i in range(n-1):
  for j in range(i+1, n):
    dis = 0
    for k in range(d):
      dis = dis + (x[i][k]-x[j][k])**2
    if dis in a:
      ans += 1
print(ans)

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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    string S; cin >> S;
    string T; cin >> T;
    REP(i, S.size()){
        if (S[i]!=T[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3616
n, k = gets.chomp.split.map(&:to_i)
r, s, p = gets.chomp.split.map(&:to_i)
t = gets.chomp

po = {r: p, s: r, p: s}

point = 0
memo = Array.new(n, true)

n.times do |i|
  if (i - k >= 0) && t[i] == t[i - k] && memo[i - k]
    memo[i] = false
    next
  end

  point += po[t[i].to_sym]
end
puts point


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

#define ll long long 

bool cmp (pair<int, int> a, pair<int, int> b) {
    return a.first * b.second > a.second * b.first; 
}

bool cmp2 (pair<int, int> a, pair<int, int> b) {
    return a.second < b.second; 
}

bool cmp3 (pair<int, int> a, pair<int, int> b) {
    return a.first > b.first; 
}

int main() {
    ios::sync_with_stdio(0); 

    int h, n; 
    cin >> h >> n; 
    vector<pair<int, int>> spells(n);
    vector<pair<int, int>> spells2(n);
    
    for (int i = 0; i < n; i++) {
        int a, b; 
        cin >> a >> b;
        spells[i] = {a, b};
        spells2[i] = spells[i]; 
    }

    sort(spells.begin(), spells.end(), cmp); 
    sort(spells2.begin(), spells2.end(), cmp3);


    //cout << endl << endl;
    //for (auto x : spells) {
        //cout << x.first << " " << x.second << "\n";
    //}


    //auto melhor = spells[0]; 
    //long long cost = 0;
    //while (h - melhor.first > spells2[0].first) {
        //h = h - melhor.first;  // damage
        //cost += melhor.second; 
    //}
    // o mais forte mata
    vector<ll> dp(h+1, 1000000000LL); 
    //cout << "HP: " << h << endl;
    //cout << "custo: " << cost << endl;
    dp[h] = 0;  

    for (int hp = h; hp >= 0; hp--) {
        for (int j = 0; j < n; j++) {
            int idx = hp-spells[j].first; 
            if (idx < 0) idx = 0; 
            dp[idx] = min(dp[idx], dp[hp] + spells[j].second); 

        }
    }

    //vector<pair<int, int>> matam;
    //for (auto x : spells) {
        //if (x.first >= h) matam.push_back(x); 
    //}

    //sort(matam.begin(), matam.end(), cmp2);
    //cost += matam[0].second; 

    cout << dp[0] << endl; 

    //cout << cost << endl; 

    return 0; 
}



Measured memory_bytes: 384
n,m = map(int,input().split())
a = list(map(int,input().split()))
a_sum = sum(a)

list.sort(a,reverse=True)
judge = 1

for i in range(m):
    if a[i]< a_sum*1/(m*4):
        judge = 0
        break

if judge == 0:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3064
N = int(input())
a = list(map(int, input().split()))
Alice = 0
Bob = 0
for i in range(N):
    if i % 2 == 0:
        A = max(a)
        Alice = Alice + A
        a.remove(A)
    else:
        A =max(a)
        Bob = Bob + A
        a.remove(A)
print(Alice - Bob)

Measured memory_bytes: 9176
N=int(input().strip())
S=input().strip()
x=[0]
lc=0
rc=0
for i in range(len(S)):
    if S[i]=='(':
        lc+=1
    elif S[i]==')':
        rc+=1
    x.append(lc-rc)

xn=min(x)
d=lc-rc

ans='('*(-xn)+S+')'*(d-xn)

print(ans)

Measured memory_bytes: 3064
N=int(input())
length=len(str(N))
if(length == 1):
    print(N)
elif(length == 2):
    print(9)
elif(length == 3):
    print(9 + len(range(100,N+1)))
elif(length == 4):
    print(909)
elif(length == 5):
    print(909 + len(range(10000,N+1)))
else:
    print(90909)

Measured memory_bytes: 3060
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random,resource

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    x,y = LI()
    if y % 2 == 1 or x*2 > y or x*4 < y:
        return 'No'

    return 'Yes'


print(main())




Measured memory_bytes: 10860
#include<bits/stdc++.h>
#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define one 1.0
#define inf 1000000000000000000
#define ret return
#define all(vl) vl.begin(),vl.end()
#define sor sort 
#define cl clear
#define m_p make_pair 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;
typedef map<string,ll> mapstl;
int main()
{
	ll a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	if(a == 0)cout<<1<<endl;
	else if(b == 0)cout<<2<<endl;
	else if(c == 0)cout<<3<<endl;
	else if(d == 0)cout<<4<<endl;
	else if(e == 0)cout<<5<<endl; 
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    vector<int> A(N), diff(N);
    REP(i, 0, N) cin >> A[i];
    REP(i, 0, N) {
        int b; cin >> b;
        diff[i] = A[i] - b;
    }

    sort(ALL(diff));
    int ans = 0;
    ll negative = 0;
    REP(i, 0, N) {
        if (diff[i] >= 0) break;
        negative += diff[i];
        ans++;
    }

    for (int i = diff.size() - 1; i >= 0; i--) {
        if (negative >= 0 || diff[i] <= 0) break;
        negative += diff[i];
        ans++;
    }

    if (negative < 0) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
    int n,i,N;
    char p[3],P;/*カードの種類用*/
    int S[13],H[13],C[13],D[13];

    for(i=1;i<14;i++){
        S[i]=i, H[i]=i, C[i]=i, D[i]=i;
    }
    scanf("%d",&n);    

    i=0; 
    while(scanf("%c ",&P)==1){
        if(i==n+1) break;
        while(scanf("%d",&N)==1){
        switch(P){
            case 'S':{
                S[N]=100; break;
            }
             case 'H':{
                H[N]=100; break;
            }
             case 'C':{
                C[N]=100; break;
            }
             case 'D':{
                D[N]=100; break;

            }
     
        }
        if(i==n) break;
        i++;
        } 
        /*if(i==n) break;
        i++;*/
        
    }
    for(i=1;i<14;i++){
        if(S[i]!=100) printf("S %d\n",S[i]);
    }
        for(i=1;i<14;i++){
        if(H[i]!=100) printf("H %d\n",H[i]);
        }
            for(i=1;i<14;i++){
        if(C[i]!=100) printf("C %d\n",C[i]);
            }
                for(i=1;i<14;i++){
        if(D[i]!=100) printf("D %d\n",D[i]);
                }
    
    return 0;
}


Measured memory_bytes: 2108
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        boolean isPrime[] = new boolean[100001];
        for (int i = 0; i <= 100000; i++) {
            isPrime[i] = true;
        }
        isPrime[0] = false;
        isPrime[1] = false;
        for (long i = 2; i <= 100000; i++) {
            for (long j = i * 2; j <= 100000; j += i) {
                isPrime[(int) j] = false;
            }
        }

        boolean isLike2017[] = new boolean[100001];
        for (int i = 0; i <= 100000; i++) {
            isLike2017[i] = isPrime[i] && isPrime[(i + 1) / 2];
        }
        int sum[] = new int[100002];
        sum[0] = 0;
        for (int i = 0; i <= 100000; i++) {
            sum[i + 1] = sum[i];
            if (isLike2017[i]) {
                sum[i + 1]++;
            }
        }
        int n = in.nextInt();
        for (int i = 0; i < n; i++) {
            int l = in.nextInt();
            int r = in.nextInt();
            System.out.println(sum[r + 1] - sum[l]);
        }
    }
}


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

const int MAX = 500;

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n;
	while (cin >> n, n) {
		vector<vector<int>> dp(MAX + 1, vector<int>(n + 1, -1));
		dp[0][0] = 0;
		for (int i = 0; i < n; i++) {
			int p;
			cin >> p;
			for (int j = MAX; j >= 0; j--) {
				for (int k = n; k >= 0; k--) if (dp[j][k] != -1) {
					int val = (p + 999) / 1000;
					if (p % 1000 != 0 && p % 1000 <= 500) {
						dp[j + val][k + 1] = max(dp[j + val][k + 1], dp[j][k] + val * 1000 - p - 500);
					}
					else {
						dp[j + val][k] = max(dp[j + val][k], dp[j][k] + val * 1000 - p);
						if (val * 1000 - p + dp[j][k] >= 500) {
							dp[j + val][k + 1] = max(dp[j + val][k + 1], dp[j][k] + val * 1000 - p - 500);
						}
					}
				}
			}
		}
		int cnt = 0, sum = 0;
		for (int i = 0; i <= MAX; i++) {
			for (int j = 0; j <= n; j++) if (dp[i][j] != -1) {
				if (j > cnt) {
					cnt = j;
					sum = i * 1000 - j * 500 - dp[i][j];
				}
				else if (j == cnt) {
					sum = min(sum, i * 1000 - j * 500 - dp[i][j]);
				}
			}
		}
		cout << cnt << ' ' << sum << endl;
	}
	return 0;
}



Measured memory_bytes: 3228