akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
ll h,w;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>h>>w;
  ll white = 0;
  char c[55][55];
  rep(i,h)rep(j,w) {
    cin>>c[i][j];
    if(c[i][j] == '.') white++;
  }
  ll dx[4] = {1,0,-1,0};
  ll dy[4] = {0,1,0,-1};
  queue<PPI> que;
  que.push(PPI(P(0,0),0));
  ll ans = INF;
  c[0][0] = '#';
  while(!que.empty()){
    PPI p = que.front();
    que.pop();
    if(p.fi.fi == h-1 && p.fi.se == w-1) {
      if(p.se < ans ) ans = p.se;
    }
    rep(j,4) {
      ll y = dy[j] + p.fi.fi;
      ll x = dx[j] + p.fi.se;
      if(y<0||x<0||y>=h||x>=w) continue;
      if(c[y][x] == '#') continue;
      c[y][x] = '#';
      que.push(PPI(P(y,x),p.se+1));
    }
  }
  if(ans == INF) cout<<-1<<endl;
  else {
    cout<<white-ans-1<<endl;
  }

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


Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc123a()
}

fun abc123a() {
    val antenna = (1..5).map { readLine()!!.toInt() }
    val distantLimit = readLine()!!.toInt()

    val maxDistant = antenna[4] - antenna[0]

    if (maxDistant <= distantLimit) println("Yay!") else println(":(")
}


Measured memory_bytes: 33540
// "include" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>
// }}}
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int minv = INF;
	int maxv = -1;
	rep(i,n){
		int a;
		cin >> a;
		minv = min(minv,a);
		maxv = max(maxv,a);
	}
	cout << maxv - minv << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <string>
#include <queue>
#include <cmath>
#include <iterator>
#include <math.h>
#include <cstdio>
#include <map>

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

int main(void){
    string a;
    cin >> a;
    a[3] = '8';
    cout << a << endl;
}


Measured memory_bytes: 764
//AOJ ITP1_2_B

using System;

class sample
{
    public static void Main()
    {
        string[] str = Console.ReadLine().Split(' ');
        int a = int.Parse(str[0]);
        int b = int.Parse(str[1]);
        int c = int.Parse(str[2]);
        if(a < b && b < c)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 8988
#include<bits/stdc++.h>
using namespace std;
#define _ ios::sync_with_stdio(false);cin.tie(0);
#define ll long long int
#define eb emplace_back
#define F first
#define S second

set<pair<int,int>> se;
/*multiset<int> mtsex,mtsey;
vector<int> ansx,ansy;*/
map<int,set<int>> mpx,mpy;
map<int,int> ctx,cty;

int main(){_
	int n,m,k,a,b;
	while(cin>>n>>m>>k)
	{
		int maxx=0,maxy=0;
		while(k--)
		{
			cin>>a>>b;
			se.insert({a,b});
			/*mtsex.insert(a);
			mtsey.insert(b);*/
			ctx[a]++;
			cty[b]++;
			if(ctx[a]==1)
			{
				mpx[1].insert(a);
				maxx=max(maxx,1);
			}
			else
			{
				int tmp=ctx[a];
				mpx[tmp-1].erase(a);
				mpx[tmp].insert(a);
				maxx=max(maxx,tmp);
			}
			if(cty[b]==1)
			{
				mpy[1].insert(b);
				maxy=max(maxy,1);
			}
			else
			{
				int tmp=cty[b];
				mpy[tmp-1].erase(b);
				mpy[tmp].insert(b);
				maxy=max(maxy,tmp);
			}
		}
		/*
		for(int i=1;i<=n;i++)
		{
			if(mtsex.count(i)>maxx)
			{
				ansx.clear();
				ansx.eb(i);
				maxx=mtsex.count(i);
			}
			else if(mtsex.count(i)==maxx)
			{
				ansx.eb(i);
			}
		}
		for(int i=1;i<=m;i++)
		{
			if(mtsey.count(i)>maxy)
			{
				ansy.clear();
				ansy.eb(i);
				maxy=mtsey.count(i);
			}
			else if(mtsey.count(i)==maxy)
			{
				ansy.eb(i);
			}
		}
		*/
		int ans=0;
		/*
		for(int i:ansx)
		{
			for(int j:ansy)
			{
				int tmpx=mtsex.count(i);
				int tmpy=mtsey.count(j);
				//cout<<i<<" "<<j<<" "<<mtsex.count(i)<<" "<<mtsey.count(j)<<"*\n";
				int cur=tmpx+tmpy;
				if(se.count({i,j})) cur--;
				anss=max(anss,cur);
			}
		}
		*/
		bool minus=1;
		for(auto it=mpx[maxx].begin();it!=mpx[maxx].end();it++)
		{
			for(auto jt=mpy[maxy].begin();jt!=mpy[maxy].end();jt++)
			{
				if(se.count({*it,*jt})==0)
				{
					minus=0;
					break;
				}
			}
			if(!minus) break;
		}
		cout<<(minus?maxx+maxy-1:maxx+maxy)<<"\n";
	}

	return 0;
}

Measured memory_bytes: 73924
#[allow(unused_imports)]
use proconio::{input, marker::*};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

fn main() {
    input! {
        n: usize,
        s: [String;n],
    }

    macro_rules ! min { ( $ x : expr ) => ( $ x ) ; ( $ x : expr , $ ( $ z : expr ) ,+ ) => { { std :: cmp :: min ( $ x , min ! ( $ ( $ z ) ,* ) ) } } }
    let s = s
        .into_iter()
        .map(|e| {
            let mut low = 0isize;
            let mut pos = 0isize;
            for c in e.chars() {
                if c == '(' {
                    pos += 1;
                } else {
                    pos -= 1;
                }
                low = min!(low, pos);
            }
            (low, pos)
        })
        .collect::<Vec<_>>();

    let mut pos = s
        .clone()
        .into_iter()
        .filter(|e| e.1 >= 0)
        .collect::<Vec<_>>();
    let mut neg = s.into_iter().filter(|e| e.1 < 0).collect::<Vec<_>>();

    pos.sort_by_key(|e| -e.0);
    neg.sort_by_key(|e| e.0 - e.1);

    let mut current = 0;
    for (low, cur) in pos.into_iter().chain(neg.into_iter()) {
        if current + low < 0 {
            println!("No");
            return;
        }
        current += cur;
        if current < 0 {
            println!("No");
            return;
        }
    }
    if current == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 74412
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ll;


using Graph=vector<vector<int>>;//グラフ型
void dfs(const Graph &G,int v/*根*/,vector<bool> &seen){
    seen[v]=true;  //vを訪問済にする
    for(auto next_v:G[v]){ //訪問済にしたvとつながっている場所を順番に探す
        if(seen[next_v]) continue; //もし探索済みならスルー
        dfs(G,next_v,seen); //再帰的に探索
    }
}

void bfs(const Graph &G,queue<int> &que/*発見したが訪問はしていない*/,vector<int> &dist/*開始地点からの距離*/,int s/*スタート地点*/){
    
    while(!que.empty()){
        int v=que.front();//queのうち先頭のものからスタート
        que.pop();//先頭を削除
        for(int nv :G[v]){//vとつながっている点を列挙
            if(dist[nv]!=-1) continue;//発見済(=距離が格納されている)であればスルー
            dist[nv]=dist[v]+1;//vとつながっている点に距離の情報を追加
            que.push(nv);//vとつながっている点を発見済にする
        }
    }
}

unsigned int to_int(char c){
    return c-48;
}

vector<int> a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main(void){
    int k;
    cin>>k;
    cout<<a[k-1];
}


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

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int64 cnt(int64 N, int64 X, vector<int64>& all, vector<int64>& p) {
  if (N == 0) return 1;
  if (X <= 1) return 0;
  if (X <= 1 + all[N - 1]) return cnt(N - 1, X - 1, all, p);
  if (X == 2 + all[N - 1]) return p[N - 1] + 1;
  if (X <= all[N - 1] * 2 + 2)
    return p[N - 1] + 1 + cnt(N - 1, X - all[N - 1] - 2, all, p);
  return p[N - 1] * 2 + 1;
}

int main() {
  int64 N, X;
  cin >> N >> X;
  vector<int64> all(51);
  vector<int64> p(51);
  all[0] = 1;
  p[0] = 1;
  for (int i = 1; i < N; i++) {
    all[i] = all[i - 1] * 2 + 3;
    p[i] = p[i - 1] * 2 + 1;
  }
  debug(all, p);
  int64 ans = cnt(N, X, all, p);
  cout << ans << endl;
  return 0;
}


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

int main () {
    int n, a[80];
    long long m = 1000, kabu = 0;
    cin >> n;
    cin >> a[0];
    for (int i = 1; i < n; i++) {
        cin >> a[i];
        if (a[i] > a[i-1]) {
            kabu += m/a[i-1];
            m = m%a[i-1];
        } else if (a[i] < a[i-1]) {
            m += kabu * a[i-1];
            kabu = 0;
        }
    }
    m += kabu * a[n-1];
    cout << m << endl;
}

Measured memory_bytes: 3144
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//long long int countt[200003];
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set, multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds; //necessary for the GNU based Policy based data structures.
typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define int long long
#define endl "\n"



signed main()
{
    FAST;
    int t;
    t=1;
    while(t--)
    {
        int i=0,j=0,k=0,n=0,m=0,count=0,temp=0;
        int temp1=0,temp2=0,temp3=0,x=0,l=0,y=0,sum=0;
        int left=0,up=0,down=0,start=0,end=0,r=0,q=0,total=0;
        int maxx=0,minn=0,curr=0,ans=0,places=0,zeroes=0,low=0,high=0;
        int prev=0,mid=0,z=0,d=0,val=0,pos=0,shift=0,h=0,right=0,var=0;
        
        cin>>n;
        string a;
        while(n>0)
        {
            temp = n%26;
            if(temp==0) temp=26;
            temp1='a';
            a += (temp1+temp-1);
            n=n/26;
            if(temp==26)
            {
                n--;
            }
        }
        reverse(a.begin() , a.end());
        cout<<a<<endl;
        
        
        
        
    }
        
    
    
    
    
}

Measured memory_bytes: 3664
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <complex>
#include <numeric>
using namespace std;

typedef long long LL; typedef pair<LL, LL> PLL; typedef vector<LL> VLL;
#define REP(i,n) for(int (i)=0; (i)<(n) ;++(i))
#define REPN(i,a,n) FOR((i),(a),(a)+(n))
#define FOR(i,a,b) for(int (i)=(a); (i)<(b) ;++(i))
#define PB push_back
#define MP make_pair
#define OUT(a) cout<<(a)<<endl;

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

    int n,m,num[100010],pos[100010]={1},x[100010],y[100010];
    fill(num,num+100010,1);
    cin >> n >> m;
    REP(i,m){
        cin >> x[i] >> y[i];
        x[i]--;
        y[i]--;
    }
    REP(i,m){
        --num[x[i]];
        ++num[y[i]];
        if(pos[x[i]]>0){
            pos[y[i]]=1;
        }
        if(num[x[i]]==0){
            pos[x[i]]=0;
        }
    }

    cout << accumulate(pos,pos+n,0)<<endl;

    return 0;
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

void F(int x,map<int,int>&mp){
  if(x <= 1)return;
  if(x == 2){
    mp[x]++;
    return;
  }
  if((x&1)==0){
    F(2,mp);F(x>>1,mp);
    return;
  }
  for(int i = 3; i*i <= x; i+=2){
    if(x % i == 0){
      F(i,mp);F(x/i,mp);
      return;
    }
  }
  mp[x]++;
}

int Cnt(int x){
  int cnt = 0;
  while(x%2 == 0){
    x /= 2;
    cnt++;
  }
  return cnt;
}

void M(map<int,int>&a,map<int,int>&b){
  for(auto&e:b){
    ChangeMax(a[e.first],e.second);
  }
}

int Pow(int a,int b){
  if(b == 0) return 1;
  if(b == 1) return a;
  if((b&1) == 1) return Pow(Pow(a,b>>1),2)*a;
  if(b == 2) return a*a;
  return Pow(Pow(a,b>>1),2);
}

int main(){
  int n,m; cin >> n >> m;
  vector<int> v(n); cin >> v;
  {
    int pre = 0;
    for(int i = 0; i < n; ++i){
      if(i == 0)pre = Cnt(v[i]);
      else if(pre != Cnt(v[i])){
	cout << 0 << endl;
	return 0;
      }
    }
  }  
  map<int,int> mp;
  for(auto e:v){
    map<int,int> nw;
    F(e,nw);
    M(mp,nw);
  }
  ll base = 1;
  for(auto e:mp){
    base *= Pow(e.first,e.second);
  }
  int ans = 2*m/base;
  ans = (ans+1)/2;
  cout << ans << endl;
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int M = 1e6 + 10;
const int INF = 0x3f3f3f3f;
char s[M];
vector <pair <int, int> > a, b, c;
bool cmp1(pair<int, int> a, pair<int, int> b) {
    return a.first > b.first;
}
bool cmp2(pair<int, int> a, pair<int, int> b) {
    return a.second + b.first > b.second + a.first;
}
int main(){
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
        scanf("%s", s);
        int len = strlen(s), cnt = 0, mn = INF;
        for(int i = 0; i < len; i++) {
            if(s[i] == '(') cnt++;
            else cnt--;
            mn = min(mn, cnt);
        }
        //printf("mn = %d cnt = %d\n", mn, cnt);
        if(cnt > 0) a.pb(make_pair(mn, cnt));
        else if(cnt == 0) b.pb(make_pair(mn, cnt));
        else c.pb(make_pair(mn, cnt));
	}
	sort(a.begin(), a.end(), cmp1);
	sort(c.begin(), c.end(), cmp2);
	int tot = 0;
	//printf("test 1\n");
	for(int i = 0; i < a.size(); i++) {
        //printf("%d %d\n", a[i].first, a[i].second);
        if(tot + a[i].first < 0) {
            printf("No\n");
            return 0;
        }
        else tot += a[i].second;
	}
	//printf("test 2\n");
	for(int i = 0; i < b.size(); i++) {
	    //printf("%d %d\n", b[i].first, b[i].second);
        if(tot + b[i].first < 0) {
            printf("No\n");
            return 0;
        }
	}
	//printf("test 3\n");
	for(int i = 0; i < c.size(); i++) {
	    //printf("%d %d\n", c[i].first, c[i].second);
        if(tot + c[i].first < 0) {
            printf("No\n");
            return 0;
        }
        else tot += c[i].second;
	}
	if(tot == 0) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 11188
// This file is a "Hello, world!" in Java language by OpenJDK for wandbox.

import java.util.*;

class Main
{
    public static void main(String[] args) 
    {
        Scanner scan = new Scanner(System.in);
        int n=scan.nextInt();
        ArrayList<Integer> v = new ArrayList<>(n);
        for (int i=0;i<n;i++){
            v.add(new Integer(scan.nextInt()));
            //v[i]=scan.nextInt();
        }
        ArrayList<Integer> w = new ArrayList<>(v);
        Collections.sort(v);        
        int med1=v.get(n/2);
        int med2=v.get(n/2-1);
        for(int i=0;i<n;i++){
            if (w.get(i)<med1){
                System.out.println(med1);
            }else{
                System.out.println(med2);
            }
        }
    }
}

// OpenJDK reference:
//   http://openjdk.java.net/

// Java language references:
//   http://docs.oracle.com/javase


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

using namespace std;

int main(){
    int n;cin >> n;
    vector<int> a(n+1);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    a[n] = 1e6;
    sort(a.begin(),a.end());
    int count = 0;
    int odd = 0;
    int even = 0;
    for(int i=0;i<n;i++){
        count ++;
        if(a[i] != a[i+1]){
            if(count %2 == 1){
                odd++;
                count = 0;
            }
            else{
                even ++;
                count = 0;
            }
        }
    }
    int ans = 0;
    if(even % 2 == 0){
        ans = odd + even;
    }
    else{
        ans = odd + even-1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];


int gC(char ch){
  if(ch == 'A') return 1;
  else if(ch == 'C') return 2;
   else if(ch == 'G') return 3;
   else if(ch == 'T') return 4;
   else return 0;
}


long long gK(char str[]){
  long long sum =0,p=1,i;
  for(i=0;i<strlen(str);i++){
    sum += p*(gC(str[i]));
    p *= 5;
  }
  return sum;
}


int h1(int k){
  return k%M;
}


int h2(int k){
  return 1+(k%(M-1));
}


int find(char str[]){
  long long k,i,h;
  k = gK(str);
  for(i=0;;i++){
    h=(h1(k)+i*h2(k))%M;
    if(strcmp(H[h],str)==0) return 1;
    else if(strlen(H[h])==0) return 0;
  }
  return 0;
}


int ins(char str[]){
  long long k,i,h;
  k=gK(str);
  for(i=0;;i++){
    h=(h1(k)+i*h2(k))%M;
    if(strcmp(H[h],str)==0) return 1;
    else if(strlen(H[h])==0) {
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}


int main(){
  int i,n,h;
  char str[L],com[9];
  for(i=0;i<M;i++) H[i][0]='\0';
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %s",com,str);

    if(com[0]=='i'){
      ins(str);
    }
      else{
        if(find(str)){
          printf("yes\n");
        }
        else{
          printf("no\n");
        }
      }
  }
  return 0;
}



Measured memory_bytes: 16048
#include<stdio.h> 
int main()
{
	int a,b,c,d,area1,area2;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	area1=a*b;
	area2=c*d;
	if(area1>=area2)
	printf("%d",area1);
	else
	printf("%d",area2);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int n;
int A[50];

int solve(int i, int m)
{
    if (m == 0)
    {
        return 1;
    }
    if (i >= n)
    {
        return 0;
    }

    int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
    return res;
}

int main()
{
    int q;
    int m;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> A[i];
    }
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        cin >> m;
        int res = solve(0, m);
        if (res)
        {
            cout << "yes" << endl;
        }
        else
        {
            cout << "no" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3088
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100;

int n;
vector<int> adj[MAXN];

int mxdeg[MAXN],mxdep;

void go(int at,int par,int dep) {
	mxdep=max(dep,mxdep);
	int deg=SZ(adj[at])-(par==-1?0:1);
	mxdeg[dep]=max(mxdeg[dep],deg);
	REPSZ(i,adj[at]) {
		int to=adj[at][i]; if(to==par) continue;
		go(to,at,dep+1);
	}
}

pair<int,ll> calc(int a,int b) {
	//printf("solve(%d",a+1); if(b!=-1) printf(",%d",b+1); printf("):"); REPE(i,mxdep) printf(" %d",mxdeg[i]); puts("");
	ll nleaf=b==-1?1:2; REP(i,mxdep) nleaf*=mxdeg[i];
	return MP(mxdep+1,nleaf);
}

pair<int,ll> solve(int a) {
	mxdep=0; memset(mxdeg,0,sizeof(mxdeg));
	go(a,-1,0);
	return calc(a,-1);
}

pair<int,ll> solve(int a,int b) {
	mxdep=0; memset(mxdeg,0,sizeof(mxdeg));
	go(a,b,0);
	go(b,a,0);
	return calc(a,b);
}

void run() {
	scanf("%d",&n); REP(i,n-1) { int a,b; scanf("%d%d",&a,&b); --a,--b; adj[a].PB(b); adj[b].PB(a); }

	pair<int,ll> ans=MP(INT_MAX,LLONG_MAX);
	REP(i,n) ans=min(ans,solve(i));
	REP(i,n) REPSZ(j,adj[i]) { int k=adj[i][j]; if(i<k) ans=min(ans,solve(i,k)); }
	printf("%d %lld\n",ans.first,ans.second);

}

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


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


typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define size1(a) int(a.size())
#define FOR(n) for(int i= 0;i<n;i++)
#define FORR(n) for(ll i= 0;i<n;i++)



// adjacency list graph input

// vector<vector<int> > adj(n, vector<int>());
// for (size_t i = 0; i < m; i++) {
// 	int x, y;
// 	cin >> x >> y;
// 	adj[x - 1].push_back(y - 1);

//}

int main() {
	fastio;




	int  n ;
	cin >> n;

	vi h(n , 0 );
	for (int i = 0 ; i < n ; i++) {
		cin >> h[i];
	}
	int dp1 = 0 , dp2 = abs(h[1] - h[0]) ;
	if (n == 2) { cout << dp2 ; return 0 ; }
	for (int i = 2 ; i < n ; i ++) {
		int temp = min(dp2 + abs(h[i] - h[i - 1]) , dp1 + abs(h[i] - h[i - 2])) ;
		dp1 = dp2 ;
		dp2 = temp ;
	}
	cout << dp2;
	return 0;


}


Measured memory_bytes: 3696
#include <iostream>
#include <stdlib.h>

using namespace std;

int main(int argc, char **argv)
{
	int n, t, tmp, st;
	cin >> t;
	
	for(int i = 0, up = 0, down = 0; i < t; i++, up = 0, down = 0){
		cin >> n;
		cin >> st;
		for(int j = 1; j < n; j++){
			cin >> tmp;
			st -= tmp;
			
			if(st < 0 && up > st){
				up = st;
			} else if(down < st){
				down = st;
			}
			
			st = tmp;
		}
		
		cout << (-up) << " " << down << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {

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



	int MAX = 100000;
	public void run() {
		Scanner sc = new Scanner(System.in);
		boolean prime[] = new boolean[MAX+1];
		for(int i=2; i<=MAX; i++)prime[i]=true;
		for(int i=2; i*i<=MAX; i++) {
			if(prime[i]) {
				for(int j=i+i; j<=MAX; j+=i) {
					prime[j]=false;
				}
			}
		}
		int c[] = new int[MAX+1];
		c[0]=c[1]=0;
		for(int i=2; i<=MAX; i++) {
			if(prime[i] && prime[(i+1)/2]) {
				c[i]++;
			}
		}
		for(int i=0; i<MAX; i++) {
			c[i+1]+=c[i];
		}

		int q=sc.nextInt();
		for(int i=0; i<q; i++) {
			int l=sc.nextInt();
			int r=sc.nextInt();
			System.out.println(c[r]-c[l-1]);
		}


		sc.close();
	}
}


Measured memory_bytes: 64848
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        OutputStream outputStream = System.out;
    	PrintWriter out = new PrintWriter(outputStream);

        int i, n, m, c, k;

		String str = br.readLine();    
        
      	int count = 0;
      String ch1=""+str.charAt(0);
      String ch2="";
      for(i=1;i<str.length();i++)
      {
        ch2+=str.charAt(i);
        while(i+1<str.length() && ch2.equals(ch1))
        {
          i++;
          ch2+=str.charAt(i);
        }
        if(!ch2.equals(ch1))
        	count++;
        ch1=ch2;
        ch2="";
      }
      out.print(count+1);
	
	out.flush();
	out.close();
	}
}

Measured memory_bytes: 42332
#pragma once
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

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

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string& S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
// mod 1000000007 の世界で a += b する関数
int n;
int bit[100010];
void add(int v, int x) {

	while (v <= n)
	{
		bit[v] += x;
		v += v & -v;
	}
}

ll sum(int v) {
	ll r = 0;
	while (v > 0)
	{
		r += bit[v];
		v -= v & -v;
	}
	return r;
}
void put(string v) {
	cout << "a" << v<< "b" << endl;
}
void solv() {

	while (true)
	{
		int a, b;
		char c;
		cin >> a >> c >> b;
		if (c == '?')break;
		switch (c)
		{
		case '+':
			cout << a + b << endl;
			break;
		case '-':
			cout << a - b << endl;
			break;
		case '*':
			cout << a * b << endl;
			break;
		case '/':
			cout << a / b << endl;
			break;
		default:
			break;
		}
	}
}


int main() {
	//	COMinit();
	solv();

	return 0;
}



Measured memory_bytes: 3108
import sys

import numpy as np
import itertools

N, M = list(map(int, sys.stdin.readline().split()))
A = np.array([list(sys.stdin.readline().rstrip()) for _ in range(N)]) == "#"
B = np.array([list(sys.stdin.readline().rstrip()) for _ in range(M)]) == "#"

ok = False
for i, j in itertools.product(range(len(A) - len(B) + 1), repeat=2):
    ok |= (A[i: i + len(B), j: j + len(B)] == B).all()

if ok:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 12388
#include <bits/stdc++.h>
using namespace std;
int GCD(int a,int b);

int main(void){
    int n,a,now;
    cin >> n;
    cin >> now;
    for(int i=0;i<n-1;i++){
        cin >> a;
        if(a > now){
            now=GCD(a,now);
        }else{
            now=GCD(now,a);
        }
        //cout << now << endl;
    }
    cout << now << endl;
    return 0;
}

int GCD(int a, int b){
    int r;
    r=a%b;
    while(true){

        if(a%b==0) break;
        r=a%b;
        a=b;
        b=r;
    }
    return b;
}

Measured memory_bytes: 384
n = input().split()
N = int(n[0])
K = int(n[1])
a = input().split()
sum = 0.0
max = 0.0
for j in range(0, N):
  sum += float(a[j])
  if j > K - 1:
    sum -= float(a[j - K])
  if max < sum:
    max = sum
print ((max + K) / 2)

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

using namespace std;

//????°???¬?????°
unsigned int comp_GCD(unsigned int a, unsigned int b){
	while(1){
		unsigned int r;
		r = a % b;
		a = b;
		b = r;
		if(b == 0){
			return a;
		}
	}
	return 0;
}

//?????????
int main() {
	unsigned int a, b;
	vector<unsigned int> result_gcd;
	vector<unsigned int> result_lcm;
	while(cin >> a >> b){
		unsigned int gcd = comp_GCD(a, b);
		result_gcd.push_back(gcd);
		result_lcm.push_back(a * (b / gcd));
	}
	for(unsigned int i = 0; i < result_gcd.size(); i++){
		cout << result_gcd[i] << " " << result_lcm[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
const long long INF = 1e12;

int main() {
string s,t;
cin >> s >> t;
for (ll i = 0; i < s.size();i++){
    if(s[i]!=t[i]){
        cout << "No" << endl;
        return 0;
    }
}
cout << "Yes" << endl;
}

Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>

using namespace std;

int a[26]; string w;
int main(){
    
    cin >> w;
    for (size_t i = 0; i < w.size(); i++)
    {
        a[w[i]-'A']++;
    }

    int counter = 0;
    for (size_t i = 0; i < 26; i++)
    {
        if(a[i] == 2){
            counter ++;
        }
    }
    if(counter == 2) cout << "Yes"<<endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
r = 0
for i in range(2000):
    if N == i*(i-1) // 2:
        r = i
        
if r == 0:
    print("No")
else:
    print("Yes")
    res_list = [["0"]*(r-1) for _ in range(r)]
    ind_list = [0]*r
    k = 0
    for i in range(r):
        for j in range(i+1, r):
            k += 1
            res_list[i][ind_list[i]] = str(k)
            res_list[j][ind_list[j]] = str(k)
            ind_list[i] += 1
            ind_list[j] += 1
    print(r)
    for i in range(r):
        print(" ".join([str(r-1)] + res_list[i]))

Measured memory_bytes: 16884
# -*- coding: utf-8 -*-

A,B,C,X,Y = list(map(int, input().rstrip().split()))
#----------
remain_X=X
remain_Y=Y
num_AB=0
cost=0

if (C*2) < (A+B):
    num_AB += min(X,Y) * 2
    remain_X -= num_AB / 2
    remain_Y -= num_AB / 2

if (C*2) < A and A > B and remain_X > 0:
    num_AB += remain_X * 2
    remain_X = 0
    remain_Y -= num_AB / 2
    
    if remain_Y < 0:
        remain_Y = 0

if (C*2) < B and A < B and remain_Y > 0:
    num_AB += remain_Y * 2
    remain_X -= num_AB / 2
    remain_Y = 0
    
    if remain_X < 0:
        remain_X = 0
###
if (C*2) < A and remain_X > 0:
    num_AB += remain_X * 2
    remain_X = 0
    remain_Y -= num_AB / 2
    
    if remain_Y < 0:
        remain_Y = 0
        
if (C*2) < B and remain_Y > 0:
    num_AB += remain_Y * 2
    remain_X -= num_AB / 2
    remain_Y = 0
    
    if remain_X < 0:
        remain_X = 0


cost = (remain_X * A) + (remain_Y * B) + (num_AB * C)
print(int(cost))


Measured memory_bytes: 3064
from collections import Counter
c = Counter(input())
labels = ['a', 'b', 'c']
min_cnt = min(c[label] for label in labels)
cnt = [c[label] - min_cnt for label in labels]
for x in cnt:
    if x in (0, 1):
        continue
    print('NO')
    break
else:
    print('YES')


Measured memory_bytes: 9444
#include <bits/stdc++.h>
using namespace std;
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

const int N = 55;
ivec graph[N];
bool used_v[N],used_e[N][N];
int ord[N],lowlink[N];
int k;

void dfs(int v){
  used_v[v]=true;
  ord[v]=lowlink[v]=k++;

  for (int i = 0; i < graph[v].size(); i++) {
    if(!used_v[graph[v][i]])
      {
        used_e[v][graph[v][i]]=true;
        dfs(graph[v][i]);
        lowlink[v]=min(lowlink[v],lowlink[graph[v][i]]);
      }
    else if(!used_e[graph[v][i]][v])
      //then,e(v,graph[v][i]) is backward edge
      {
	lowlink[v]=min(lowlink[v],ord[graph[v][i]]);
      }
  }
  return;
}

int main(int argc, char *argv[])
{
  int n,m;
  int u,v;
  scanf("%d %d",&n,&m);
  for (int i = 0; i < m; i++) {
    scanf("%d %d",&u,&v);
    graph[u].push_back(v);
    graph[v].push_back(u);
  }

  int res = 0;
  dfs(1);
  
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < graph[i].size(); j++) {
      if(ord[i]<lowlink[graph[i][j]]) res++;
    }
  }
  printf("%d\n",res);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int W,H,x,y,r;

    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

    if(0<=(x-r) && (x+r)<=W && 0<=(y-r) && (y+r)<=H){
    printf("Yes\n");
    }

    else{
    printf("No\n");
    }

 return 0;
}


Measured memory_bytes: 2112
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

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


		StringBuilder sb = new StringBuilder();
		while (true) {
			String line = sc.nextLine();

			if ("-".equals(line)) {
				break;
			}

			ArrayList<String> cards = new ArrayList<String>( Arrays.asList(line.split("")) );

			int shuffleCount = Integer.parseInt(sc.nextLine());
			for (int i = 0; i < shuffleCount; i++) {

				int maisu = Integer.parseInt(sc.nextLine());


				for (int j = 0; j < maisu; j++) {

					String card = cards.remove(0);	// remove first element
					cards.add(card); // add first element

				}

			}
			sb.append(String.join("", cards));sb.append("\n");
		}

		System.out.print(sb.toString());
	}
}


Measured memory_bytes: 26392
#include<iostream>

using namespace std;

int main(void){
    int h,w;
    cin >> h >> w;
    while(h != 0 || w != 0){
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(i == 0 || j == 0 || i == h-1 || j == w-1){
                    cout << "#";
                } else {
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
        cin >> h >> w;
    }
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    long long a[n], b[n], dif = 0, sum = 0, ans = 0;
    vector<long long> v;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    for(int i = 0; i < n; i++){
        cin >> b[i];
        dif += b[i]-a[i];
        if(a[i] < b[i]){
            sum += b[i]-a[i];
            ans++;
        }
        else v.push_back(a[i]-b[i]);
    }
    if(dif > 0){
        cout << -1 << endl;
        return 0;
    }
    sort(v.rbegin(), v.rend());
    long long tmp = 0;
    int p = 0;
    while(tmp < sum){
        ans++;
        tmp += v[p++];
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
 
  string S;
  cin >> S;
  
  bool sub1 = S.at(0) != S.at(1);
  bool sub2 = S.at(1) != S.at(2);
  bool sub3 = S.at(2) != S.at(3);
  if (sub1 && sub2 && sub3) cout << "Good";
  else cout << "Bad";
  cout << endl;  
}

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

int main(){
    string S;
    cin >> S;
    int len = S.size();
    int left_count = 0;
    int right_count = 0;
    vector<char> tile(len);
    rep(i,len){
        tile[i] = S[i];
    }
    rep(i,len - 1){
        if (tile[i] == tile[i + 1]){
            if (tile[i] == '0'){
                tile[i + 1] = '1';
                left_count++;
                //cout << left_count << endl;
            }
            else if(tile[i] == '1'){
                tile[i + 1] = '0';
                left_count++;
                //cout << left_count << endl;
            }
        }
    }
    rep(i,len){
        tile[i] = S[i];
    }
    repr(i,len - 2){
        if (tile[i + 1] == tile[i]){
            if (tile[i + 1] == '0'){
                tile[i] = '1';
                right_count++;
                //cout << right_count << endl;
            }
            else if(tile[i + 1] == '1'){
                tile[i] = '0';
                right_count++;
                //cout << right_count << endl;
            }
        }
    }
    cout << min(left_count, right_count) << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int main() {
    for(;;){
        string str;
        cin >> str;
        if(str=="0") break;
        vector<vector<int> > dp(str.length()+1,vector<int>(11,0));
        for(int i=0; i< str.length();i++){
            int now = str[i] - '0';
            if(now!=0) dp[i+1][now]++;
            for(int j=0; j<11; j++){
                dp[i+1][(j*10+now)%11] += dp[i][j];
            }
        }
        int ans=0;
        for(int i=0; i<= str.length(); i++){
            ans +=dp[i][0];
        }
        cout << ans << endl;
    }
    return 0;
}



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

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef string S;

int main(){
    S s;
    cin >> s;
    bool p[s.size()];
    p[s.size()-1]=false;
    ll sum=0;
    rp(bit,(1<<(s.size()-1))){
        rp(i,s.size()-1){
            if(bit&(1<<i)){
                p[i]=true;
            }else{
                p[i]=false;
            }
        }
        int q=0;
        rp(j,s.size()){
            if(p[s.size()-j-1]){
                q=j;
            }
            sum += (s.at(s.size()-j-1)-'0')*pow(10,j-q);
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 384
class UnionFind:
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rank = [0]*(n+1)

    # ノードxのrootノードを見つける
    def findRoot(self, x):
        if(self.root[x] < 0): # 根
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.findRoot(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.findRoot(x)
        y = self.findRoot(y)
        # すでに同じ木に属していた場合
        if x == y:
            return 
        # 違う木に属していた場合rankを見てくっつける方を決める
        if self.rank[x] > self.rank[y]:
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.findRoot(x) == self.findRoot(y)

    # ノードxが属する木のサイズを返す
    def count(self, x):
        return -self.root[self.findRoot(x)]

n,m = map(int,input().split())
t = UnionFind(n)
for _ in range(m):
    a,b = map(int,input().split())
    t.unite(a,b)

#root要素の数-1本の道を加えることで、すべての要素が連結になる
print(len([a for a in t.root[1::] if a < 0])-1)


Measured memory_bytes: 12412
//   __                    .__              ________ .________ ________   ______  
//  |  | __  ____    ______|  |__   __ __  /  _____/ |   ____//   __   \ /  __  \ 
//  |  |/ /_/ __ \  /  ___/|  |  \ |  |  \/   __  \  |____  \ \____    / >      < 
//  |    < \  ___/  \___ \ |   Y  \|  |  /\  |__\  \ /       \   /    / /   --   \
//  |__|_ \ \___  >/____  >|___|  /|____/  \_____  //______  /  /____/  \______  /
//       \/     \/      \/      \/               \/        \/                  \/ 

#include<bits/stdc++.h>
#define range 100005
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

int b[200];
int a[200];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("test.txt","r",stdin);
	int n;
	cin>>n;
	for(int i=0;i+1<n;i++)cin>>b[i];
		a[0] = b[0];
	a[n-1] = b[n-2];
	for(int i=1;i+1<n;i++){
		a[i] = min(b[i-1],b[i]);
	}
	int output = 0 ;
	for(int i=0;i<n;i++){
		output+=a[i];
	}
	cout<<output;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
L = [list(map(int,input().split())) for i in range(N)]

dp = [[0,0,0] for i in range(N+1)]
for i in range(N) :
    for j in range(3) :
        for k in range(3) :
            if j == k :
                continue
            dp[i+1][k] = max(dp[i+1][k], dp[i][j] + L[i][k])
print(max(dp[-1]))


Measured memory_bytes: 47328
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>

using namespace std;

int main(int argc, char const *argv[])
{
    string s;
    int q;
    cin >> s >> q;

    int head = 0;
    for (int i = 0; i < q; i++)
    {
        int t;
        cin >> t;

        if (t == 1)
        {
            if (head == 0)
            {
                head = s.size() - 1;
            }
            else if (head == s.size() - 1)
            {
                head = 0;
            }
        }

        else if (t == 2)
        {
            int f;
            string c;
            cin >> f >> c;
            if (f == 1)
            {
                if (head == 0)
                {

                    s.insert(0, c);
                }
                else if (head == s.size() - 1)
                {
                    s += c;
                    head = s.size()-1;
                }
            }

            else if (f == 2)
            {
                if (head == s.size() - 1)
                {
                    s.insert(0, c);
                    head = s.size()-1;
                    
                }
                else if (head == 0)
                {
                    s += c;
                }
            }
        }
    }

    if (head == 0)
        cout << s << endl;
    else if (head == s.size()-1){
        reverse(s.begin(), s.end());
        cout << s << endl;
    }

        return 0;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int Y, M, D;
	char l;
	cin >> Y >> l >> M >> l >> D;
	if (M <= 4)
		cout << "Heisei" << endl;
	else
		cout << "TBD" << endl;
	return;
}

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

	int stop;
	cin >> stop;

	return 0;
}

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

class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		List<int> dp = Enumerable.Repeat(N, N + 1).ToList();
		dp[0] = 0;
		List<int> num = new List<int>();
		num.Add(1);

		for (int i = 6; i <= N; i *= 6)
		{
			num.Add(i);
		}
		for (int i = 9; i <= N; i *= 9)
		{
			num.Add(i);
		}

		num.Sort();
		int numcnt = num.Count();
		for (int j = 0; j <= N; j++)
		{
			for (int z = 0; z < numcnt; z++)
			{
				if (j + num[z] <= N)
				{
					dp[j + num[z]] = Math.Min(dp[j + num[z]], dp[j] + 1);
				}
			}
		}
		Console.WriteLine(dp[N]);
	}

	/// <summary>
	/// アナグラム
	/// </summary>
	/// <param name="word1"></param>
	/// <param name="word2"></param>
	/// <returns></returns>
	static bool IsAnagramOf(string word1, string word2)
	{
		return word1.OrderBy(x => x).SequenceEqual(word2.OrderBy(x => x));
	}
	/// <summary>
	/// 最小公倍数
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	public static long Lcm(long a, long b)
	{
		return a * b / Gcd(a, b);
	}

	/// <summary>
	/// 最大公約数
	/// </summary>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <returns></returns>
	public static long Gcd(long a, long b)
	{
		if (a < b)
			// 引数を入替えて自分を呼び出す
			return Gcd(b, a);
		while (b != 0)
		{
			var remainder = a % b;
			a = b;
			b = remainder;
		}
		return a;
	}
}




//string s = Console.ReadLine();
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];
//int N = int.Parse(Console.ReadLine());
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());
//Boolean ok = false;

//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.ReadKey();
//Console.WriteLine(cnt);

//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];


Measured memory_bytes: 28624
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define all(x) (x).begin() , (x).end()
#define f first
#define s second
#define pr(x) cout<<x<<endl;
#define pr2(x,y) cout<<x<<" "<<y<<endl;
#define pr3(x,y,z) cout<<x<<" "<<y<<endl;
#define prv(v) for(auto x:v) cout<<x<<" ";
#define ffs fflush(stdout);
using namespace std;
 
const ll N =(2e5+5);
const ll MOD = 998244353;
const ll INF = LLONG_MAX;
const ll LOG = 29;
 
long long binpow(long long a, long long b) {
    // a%=MOD;    
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a);
        a = (a * a) ;
 
        
        b >>= 1;
    }
    //res;
    return res;
} 

void solve(){
    string s;
    cin>>s;
    ll n = s.size();
    ll x = 0,y=0,w=0,z=0;
    for(int i=  0;i<n;i++){
        if(s[i]=='E')x++;
        if(s[i]=='W')y++;
        if(s[i]=='N')z++;
        if(s[i]=='S')w++;
    }        
    if((x&&!y) || (!x && y) || (z && !w) || (!z && w)){
        cout<<"No\n";
        return;
    }
    

    else
        cout<<"Yes\n";
}
 
 
 
 
int main(){
    ios_base::sync_with_stdio(0);
     cin.tie(NULL);
     
    ll t=1;
    while(t--){
        solve();
    }
     
 
 
    return 0;     
    
        
}


Measured memory_bytes: 256