akhauriyash/Code-Regression huggingface dataset:
H, W = map(int, input().split())
x = [list(map(str, list(input()))) for l in range(H)]

#両端にドットを追加
for i in range(len(x)):
    x[i].insert(0, ".")
    x[i].append(".")
#最上部と最下部の行にドットを追加
x.insert(0, ["."]*(W+2))
x.append(["."]*(W+2))

#3*3→5*5 from[1][1] to[3][3] to[H][W]
tmp = 0
for i in range(1, H+1):
    for j in range(1, W+1):
        if x[i][j] == "#":
            x[i][j] = "#"
            continue
        if x[i-1][j-1] == "#":
            tmp += 1
        if x[i-1][j] == "#":
            tmp += 1
        if x[i-1][j+1] == "#":
            tmp += 1
        if x[i][j-1] == "#":
            tmp += 1
        if x[i][j+1] == "#":
            tmp += 1
        if x[i+1][j-1] == "#":
            tmp += 1
        if x[i+1][j] == "#":
            tmp += 1
        if x[i+1][j+1] == "#":
            tmp += 1
        x[i][j] = str(tmp)
        tmp = 0
#最上部と最下部の行のドットを削除
del x[0]
del x[-1]
#両端のドットを削除
for i in range(len(x)):
    del x[i][0]
    del x[i][-1]

for i in range(len(x)):
    print(''.join(x[i]))

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

using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int, int> pii;

const int INF = 1 << 29;
const double EPS = 1e-10;

double zero(double d) {
    return d < EPS ? 0.0 : d;
}

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &a) {
    os << '[';
    rep(i, a.size()) os << (i ? " " : "") << a[i];
    return os << ']';
}

// to avoid error on mingw
string toString(int i) {
    stringstream ss;
    ss << i;
    return ss.str();
}

const int MOD = 1000000007;
// a^k
ll fpow(ll a, ll k, int M) {
    ll res = 1ll;
    ll x = a;
    while (k != 0) {
        if ((k & 1) == 1)
            res = (res * x) % M;
        x = (x * x) % M;
        k >>= 1;
    }
    return res;
}

int main() {
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(8);
    ios_base::sync_with_stdio(false);

    const int MAX_N = 1000000;
    bool sieve[MAX_N];
    fill(sieve, sieve+MAX_N, true);
    sieve[1] = false;

    for(int i=2; i*i <= MAX_N; ++i) {
        for(int j=i*i; j < MAX_N; j += i) {
            sieve[j] = false;
        }
    }

    vi prime_num(MAX_N, 0);
    REP(i, 1, MAX_N){
        prime_num[i] = prime_num[i-1];
        if(sieve[i])
            prime_num[i]++;
    }

    int n;
    while(cin >> n) {
        cout << prime_num[n] << endl;
    }

    return 0;
}

Measured memory_bytes: 5948
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
class Program
{    
    public void slove()
    {
        string str = Console.ReadLine();
        List<int>[] charIndex = 
            Enumerable.Range(0, 26)
            .Select(x => new List<int>())
            .ToArray();
        foreach(var item in str.Select((c, i) => new {Char = (int)(c - 'a'), Index = i}))
        {
            charIndex[item.Char].Add(item.Index);
        }
        foreach(var c in charIndex)
        {
            foreach(int i in c.Skip(1).Select((x, i) => i))
            {
                if(c[i + 1] - c[i] < 3)
                {
                    System.Console.WriteLine($"{c[i] + 1} {c[i + 1] + 1}");
                    return;
                }
            }
        }
        System.Console.WriteLine("-1 -1");
    }
    
    static void Main(string[] args)
    {
        new Program().slove();
    }
}


Measured memory_bytes: 16992
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <set>
#include <algorithm>
#include<cmath>

#define F first
#define S second
#define rep(i, a, b) for (int i=a; i <b; i++)

using namespace std;

typedef long long ll;
typedef vector< int > vi;

int main() {
    int n; 
    cin >> n;
    int sn = 2 * ((int)sqrt((double)n) + 10);
    vector<long long int> sum(sn, 0);

    for(int i = 1; i < sn-1; i++) { sum[i] = sum[i-1] + i; }
    int k = 0;  
    for(int i = 1; i < sn-1; i++) { 
        if(sum[i] == n) { k = (i+1);} 
    }
    //printf("candidate: %d\n", sum[sn-2]);
    
    if (k == 0) { 
        printf("No\n"); 
    } else {
        printf("Yes\n");
        printf("%d\n", k);
        int index = 1;
        vector< vector<long long int> > st;
        st.resize(k+1); rep(i, 0, k) { st[i].resize(k+1); }
        rep(i, 0, k) {
            int l = k - i -1;
            rep(j, 0, l) {
                st[i][j+i] = index;
                st[i+j+1][i] = index;
                index++;
            }
        }

        rep(i, 0, k) {
            printf("%d ", k-1);
            rep(j, 0, k-1) {
                printf("%d ", st[i][j]);
            }
            printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 2944
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <stack>
#include <queue>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
using ld = long double;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

char maze[1001][1001]; // 迷路を表す文字列の配列
ll N, M;
ll sx, sy; // スタートの座標
ll gx, gy; // ゴールの座標
ll d[1001][1001]; // 各点までの最短距離の配列
ll dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1}; // 移動4方向のベクトル

// 幅優先探索('#'は壁)
// 辿り着けないとINF
// スタートからゴールまでの最短距離を返す
ll bfs(){
    queue<pair<ll,ll>> que;
    // 全ての点をINFで初期化
    for(ll i=0; i<N; i++){
        for(ll j=0; j<M; j++){
            d[i][j] = INF;
        }
    }
    // スタート地点をキューに入れ、その点の距離を0にする
    que.push(pair<ll,ll> (sx,sy));
    d[sx][sy] = 0;

    // キューが空になるまでループ
    while(que.size()){
        // キューの先頭を取り出す
        pair<ll,ll> p = que.front();
        que.pop();
        // 取り出してきた状態がゴールなら探索をやめる
        if(p.first == gx && p.second == gy) break;
        // 移動4方向をループ
        for(ll i=0; i<4; i++){
            // 移動した後の点を(nx,ny)とする
            ll nx = p.first + dx[i];
            ll ny = p.second + dy[i];

            // 移動が可能かの判定とすでに訪れたことがあるかの判定(d[nx][ny]!=INFなら訪れたことがある
            if(0<=nx && nx<N && 0<=ny && ny<M && maze[nx][ny]!='#' && d[nx][ny]==INF){
                // 移動できるならキューに入れ、その点の距離をpからの距離+1で確定する
                que.push(pair<ll,ll> (nx, ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }

    return d[gx][gy];
}

int main(void)
{
    cin >> N >> M;
    ll a, ans=0;

    for(ll i=0; i<N; i++){
        for(ll j=0; j<M; j++){
            cin >> maze[i][j];
        }
    }

    for(sx=0; sx<N; sx++){
        for(sy=0; sy<M; sy++){
            for(gx=0; gx<N; gx++){
                for(gy=0; gy<N; gy++){
                    if(maze[sx][sy]=='.' && maze[gx][gy]=='.'){
                        a = bfs();
                        chmax(ans, a);
                    }
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main()
{
  string s;
  int cnt = 0;
  cin >> s;
  for (int i = 0; i < 3; i++)
  {
    if(s.at(i) == '1') cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		 Scanner sc = new Scanner(System.in);

	        for(int i = 0 ; i < 10000 ; i++){
	            int a = sc.nextInt();
	            if( a == 0){
	                break;
	            }
	            System.out.println("Case " + (i+1) +": " + a);
	        }
	}

}


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


def main():
    w = input().strip()
    d = {}
    for c in w:
        if c in d:
            d[c] += 1
        else:
            d[c] = 1
    if all(v % 2 == 0 for v in d.values()):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define ll_MAX LONG_LONG_MAX
#define ll_MIN LONG_LONG_MIN
#define pi pair<int,int>
#define endl "\n"
#define MAXN 100005
using namespace std;

void solve()
{
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    solve();
    string s,t;
    ll ans = 0;
    cin>>s>>t;
    for(ll i=0; i<s.size(); i++)
    {
        if(s[i]!=t[i])
        {
            ans++;
        }
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
const int mod7=1e9+7;
const int mod9=1e9+9;
const int inf=1<<30;
const ll INF=1LL<<60;
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):abs(a);}
template<typename T> T lcm(T a,T b){return a/gcd(a,b)*b;}
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
template<typename A,size_t N,typename T> void Fill(A (&array)[N],const T &val){fill((T*)array,(T*)(array+N),val);}

int main(){
    string s;cin>>s;
    ll dp[s.size()+1];
    fill(dp,dp+s.size()+1,0);
    ll r=0;
    rep(i,s.size())
    {
        if(s[i]=='<')r++;
        else r=0;
        chmax(dp[i+1],r);
    }
    rep(i,s.size()+1)cerr<<dp[i]<<" "<<flush;
    cerr<<endl;
    reverse(all(s));
    reverse(dp,dp+s.size()+1);
    r=0;
    rep(i,s.size())
    {
        if(s[i]=='>')r++;
        else r=0;
        chmax(dp[i+1],r);
    }
    ll ans=0;
    rep(i,s.size()+1)ans+=dp[i];
    reverse(dp,dp+s.size()+1);
    rep(i,s.size()+1)cerr<<dp[i]<<" "<<flush;
    cerr<<endl;
    cout<<ans<<endl;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
bool LTE(double a,double b) { return equals(a,b) || a < b; }
bool LT(double a,double b) { return !equals(a,b) && a < b; }

void compute() {

}

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  ll ans = LLONG_MAX;
  ll sum = 0;
  rep(i,n) {
    sum += a[i];
  }
  ll cur=0;
  rep(i,n) {
    cur += a[i];
    if( cur * 2LL == sum ) {
      ans = 0;
    } else if( cur * 2LL < sum ) {
      ll target = sum - cur - cur;
      ans = min(ans,target);
    } else {
      ll target = sum - cur;
      target = cur - target;
      ans = min(ans,target);
    }
  }
  cout << ans << endl;
  compute();
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(a,b) for (int (a) = 0; (a) < (b); (a)++)
signed main() {
    int n; cin >> n;
    int a[n]; for (int i = 0; i< n; i++) {cin >> a[i];}
    int b[n]; b[0] = a[0]; for (int i = 1; i< n; i++) b[i] = b[i-1] + a[i];
    map<int,int> cnt;
    cnt[0]++;
    for (int i = 0; i < n; i++) {
        cnt[b[i]]++;
    }
    int ans = 0;
    for (auto&& A : cnt) {
        ans += A.second * (A.second - 1) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    int N;
    cin >> N;
    vector<lli> x(N), y(N), h(N);
    lli H = 0;
    REP(i, 0, N) {
        cin >> x[i] >> y[i] >> h[i];
        H = max(H, h[i]);
    }
    REP(CX, 0, 101) {
        REP(CY, 0, 101) {
            REP(CH, H, H + 210) {
                bool ok = true;
                REP(i, 0, N) {
                    lli height = max(0LL, CH - abs(CX - x[i]) - abs(CY - y[i]));
                    if (height != h[i]) {
                        ok = false;
                        break;
                    }
                }
                if (ok) {
                    cout << CX << ' ' << CY << ' ' << CH << endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int i,j,work;
	int Mt[10];
		for(i=0;i<10;i++){
		scanf("%d",&Mt[i]);
	}
	for(i=0;i<10;i++){
		for(j=i+1;j<10;j++){
			if(Mt[i]<Mt[j]){
				work = Mt[j];
				Mt[j] = Mt[i];
				Mt[i] = work;
			}
		}
	}
	printf("%d\n",Mt[0]);
	printf("%d\n",Mt[1]);
	printf("%d\n",Mt[2]);
	return 0;
}

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

int main() {
  int N,T,A;
  cin >> N >> T >> A;
  vector<double> vecH(N);
  
  for(int i = 0; i < N; i++){//平均温度の配列作成
    int H;
    cin >> H;
    vecH[i] = (T*1000 - H*6);
  }
  
  int d = abs(vecH[0] - A*1000);
  vector<double> vecd(1);
  vecd[0] = d;
  for(int i = 1; i < N; i++){//温度差の配列作成
    vecd.push_back(abs(vecH[i] - A*1000));
  }
    
  for(int i = 1; i < N; i++){//最小のdを見つける
    if(d> abs(vecH[i] - A*1000)){
      d = abs(vecH[i] - A*1000);
    }
   }

  int c = 0;
    for(int i = 0; i < N; i++){//温度差配列の中からdと同じものの添え字番号を求める
    if(d == vecd[i]){
      c = i+1;
      break;
    }
   }
         cout << c << endl;     
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    map<long long,long long> L;
    
    long long ans = 0;
    for(int i = 1; i <= N; i++) {
        int H;
        cin >> H;
        ans += L[i-H];
        L[i+H]++;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 26248
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    int k, n; cin >> k >> n;
    vector<int> vec(n);
    rep(i, n) cin >> vec[i];

    int ans = INF;
    rep(i, n) {
        int tmp = 0;
        int start = i;
        int end = i-1;
        if (end < 0) {
            end = n-1;
            tmp = vec[end]-vec[start];
        } else {
            tmp = (k-vec[start]) + vec[end];
        }
        ans = min(ans, tmp);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	long long m;
	cin >> m;
	vector<long long> d(m);
	vector<long long> c(m);
	for(long long i=0;i<m;i++)
		cin >> d[i] >> c[i];
	long long cnt=0;
	long long now=0;
	for(long long i=0;i<m;i++)
	{
		//cnt+=(now+d[i]*c[i])/10;
		now+=(d[i]*c[i]);
		long long allcnt=0;
		while(now>9)
		{
			long long tmpcnt=now/10;
			allcnt+=tmpcnt;
			now%=10;
			now+=tmpcnt;
		}
		cnt+=allcnt;
	}
	long long ans=0;
	for(long long i=0;i<m;i++)
		ans+=c[i];
	ans-=1;
	ans+=cnt;
	cout << ans << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
//ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
//ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  int x; cin>>x;
  YesNo(x>=30);  
}

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


Measured memory_bytes: 3624
function Main(input){
  input = input.split("\n");
  inputStr = input[0].split(" ");
  const N = Number.parseInt(inputStr[0]);
  //パラメータ値Nを3乗した値を出力
  console.log(Math.pow(N,3));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn dfs(cn: usize, map: &Vec<Vec<usize>>, cnt: &mut usize, is_done: &mut Vec<bool>) {
    if is_done[cn] {
        return;
    }

    is_done[cn] = true;
    if is_done.iter().all(|&x| x == true) {
        *cnt += 1;
    }
    for i in &map[cn] {
        if is_done[*i] == true {
            continue;
        }
        let mut copy_done = is_done.clone();
        dfs(*i, map, cnt, &mut copy_done);
    }
}

fn main() {
    let n: usize = read();
    let m: usize = read();
    let mut map: Vec<Vec<usize>> = vec![vec![]; n + 1];

    for _ in 0..m {
        let a: usize = read();
        let b: usize = read();
        map[a].push(b);
        map[b].push(a);
    }
    let mut ans = 0;
    let mut is_done = vec![false; n + 1];
    is_done[0] = true;

    dfs(1, &map, &mut ans, &mut is_done);
    println!("{}", ans);
}


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

int main()
{
    long long int a,b;
    cin >> a >> b;
    long long int x = a * b;

    if (a < b)
        swap(a,b);

    int r = a % b;

    while(r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    cout << x/b << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    string st;
    cin >> st;
    int n = 0, w = 0, s = 0, e = 0;
    repi(i, st){
        if(*i == 'E'){
            ++e;
        }else if(*i == 'W'){
            ++w;
        }else if(*i == 'N'){
            ++n;
        }else if(*i == 'S'){
            ++s;
        }
    }
    bool ans = true;
    if(w == 0 && e != 0){
        ans = false;
    }else if(w != 0 && e == 0){
        ans = false;
    }else if(s == 0 && n != 0){
        ans = false;
    }else if(n == 0 && s != 0){
        ans = false;
    }
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define inf 1000000000000000
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
int main(){
IOS;
lli n,i,j;
cin>>n;
lli a[n];
for(i=0;i<n;i++){
    cin>>a[i];
}
lli dp[n][n];
for(i=0;i<n;i++){
    if(n%2){
        dp[i][i]=a[i];
    }
    else{
        dp[i][i]=-a[i];
    }
}
for(i=n-1;i>=0;i--){
    for(j=i+1;j<n;j++){
        if(n%2){
            if((j-i+1)%2==0){
                lli mini=inf;
                mini=min(dp[i+1][j]-a[i],mini);
                mini=min(dp[i][j-1]-a[j],mini);
                dp[i][j]=mini;
            }
            else{
                lli maxi=-inf;
                maxi=max(dp[i+1][j]+a[i],maxi);
                maxi=max(dp[i][j-1]+a[j],maxi);
                dp[i][j]=maxi;
            }
        }
        else{
            if((j-i+1)%2==0){
                lli maxi=-inf;
                maxi=max(dp[i+1][j]+a[i],maxi);
                maxi=max(dp[i][j-1]+a[j],maxi);
                dp[i][j]=maxi;
            }
            else{
                lli mini=inf;
                mini=min(dp[i+1][j]-a[i],mini);
                mini=min(dp[i][j-1]-a[j],mini);
                dp[i][j]=mini;
            }
        }
    }
}
cout<<dp[0][n-1]<<endl;
}


Measured memory_bytes: 70400
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int t,N,c;
  cin >> N;
  t = N;
  c = 0;
  while(t > 0)
  {
    c += t % 10;
    t /= 10;
  }
  if(N % c == 0)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
struct data {int a, b;};
typedef long long LL;
typedef vector<data> vec;
const LL INF = 1e10;
const int N = 131100;

int n, fa[N]; vec g[N], f[N]; LL ans = INF, mid, aid[N];

inline bool cmpa(data x, data y) {return x.a < y.a;}
inline bool cmpb(data x, data y) {return x.b < y.b;}
inline int read() {
	int x = 0, f = 1; char ch = getchar();
	for (; ch<'0' || ch>'9';) {if (ch=='-') f=-1; ch = getchar();}
	for (; ch>='0' && ch<='9';) x = x*10 + ch-'0', ch = getchar();
	return x;
}

inline void work(vec &o, vec &ls, vec &rs) {
	if (ls.size() > rs.size()) swap(ls, rs);
	int el = ls.size(), er = rs.size();

	sort(ls.begin(), ls.end(), cmpb);
	sort(rs.begin(), rs.end(), cmpa);
	aid[0] = rs[0].b;
	for (int i = 1; i < er; ++i)
		aid[i] = min(aid[i - 1], rs[i].b);
	for (int i = 0, j = er - 1; i < el; ++i) {
		for (; ~j && ls[i].b + rs[j].a > mid;) --j;
		if (~j) o.pb((data){ls[i].a, aid[j]});
	}

	sort(ls.begin(), ls.end(), cmpa);
	sort(rs.begin(), rs.end(), cmpb);
	aid[0] = rs[0].a;
	for (int i = 1; i < er; ++i)
		aid[i] = min(aid[i - 1], rs[i].a);
	for (int i = 0, j = er - 1; i < el; ++i) {
		for (;~j && ls[i].a + rs[j].b > mid;) --j;
		if (~j) o.pb((data){aid[j], ls[i].b});
	}
}

inline void dfs(int u) {
	if (!f[u].empty()) f[u].clear();
	if (g[u].empty()) {f[u].pb((data){0, 0}); return;}
	for (int i = 0; i < g[u].size(); ++i) dfs(g[u][i].a);

	vec &ls = f[g[u][0].a];
	for (int i = 0, e = ls.size(), c = g[u][0].b; i < e; ++i)
		ls[i].a += c, ls[i].b += c;
	vec &rs = f[g[u][1].a];
	for (int i = 0, e = rs.size(), c = g[u][1].b; i < e; ++i)
		rs[i].a += c, rs[i].b += c;

	work(f[u], ls, rs);
	ls.clear();
	rs.clear();
}

int main() {
	int w; n = read();
	for (int i = 2; i <= n; ++i) {
		fa[i] = read();
		g[fa[i]].pb((data){i, read()});
	}

	for (LL l = 0, r = INF; l <= r;) {
		mid = l + r >> 1;
		dfs(1);
		if (f[1].empty()) l = mid + 1;
		else r = (ans = mid) - 1;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 22776
N = int(input())
A = list(map(int,input().split()))
count = 0

if N % 2 ==0:
    for i in range((N+2)//2 - 1):
        if A[2*i ] % 2 == 1:
            count += 1
else:
    for i in range((N+2)//2):
        if A[2*i ] % 2 == 1:
            count += 1

print(count)

Measured memory_bytes: 9056
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a =sc.nextInt();
		int b =sc.nextInt();
		int c =sc.nextInt();
		if(a == b && b == c) {
			System.out.println("No");
		}
		else if(a == b || b == c || c == a) {
			System.out.println("Yes");
	}
		else
			System.out.println("No");

}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
#define cout(x) cout<<x<<endl
#define all(v) v.begin(), v.end()
using namespace std;
//型エイリアス
using vi = vector<int>;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
const ll inf = 1e18;
const int N = 2e5 + 10;


int main(){
    ll a,b,v,w,t;
    cin >> a >> v >> b >> w >> t;

    bool can = false;
    ll dif = abs(a - b);
    ll dist = (v-w)*t;
    if(dif <= dist) can = true;

    if(can) cout("YES");
    else cout("NO");
    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>

int main(void){
	
	int r;
	scanf("%d",&r);
	if(r<1200){
		printf("ABC");
	}
	else if(r>=1200&&r<2800){
		printf("ARC");
	}
	else{
		printf("AGC");
	}
	return(0);
}

Measured memory_bytes: 128
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
#include <sstream>

using namespace std;
typedef pair<int,int> P;
vector<string> split(const string &s, char delim) {
    vector<string> elems;
    stringstream ss(s);
    string item;
    while (getline(ss, item, delim)) {
    if (!item.empty()) {
            elems.push_back(item);
        }
    }
    return elems;
}

int main(){
  int w,n;
  cin>>w;
  cin>>n;
  int ami[40];
  P bou[40];
  for(int i=0;i<n;i++){
    int x=0,y=0;
    scanf("%d,%d",&x,&y);
    bou[i]=P(x,y);
  }
  for (int i=0;i<w;i++){
    int start=i+1;
    for(int j=0;j<n;j++){
      if(bou[j].first==start){start=bou[j].second;}
      else if(bou[j].second==start){start=bou[j].first;}
    }
    ami[start]=i+1;
  }
  for(int i=1;i<=w;i++)cout<<ami[i]<<endl;






}



Measured memory_bytes: 3156
fun main(args: Array<String>) {
    var N = readLine()!!.toInt()

    var dp = Array(110000) {N}
    dp[0] = 0

    for (i in 1..N) {
        var pow6 = 1
        while (pow6 <= i && pow6 <= N) {
            dp[i] = Math.min(dp[i], 1 + dp[i - pow6])
            pow6 *= 6
        }

        var pow9 = 1
        while (pow9 <= i && pow9 <= N) {
            dp[i] = Math.min(dp[i], 1 + dp[i - pow9])
            pow9 *= 9
        }
    }

    println(dp[N])
}

Measured memory_bytes: 33604
S_list = [(input()) for i in range(2)]
n,m = map(int,S_list[0].split())
S_list_1 = list(map(int,S_list[1].split()))
sum_homework = sum(S_list_1)
if  sum_homework > n:
    result = -1
else:
    result = n - sum_homework
print(result)

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

int num[110],p[110],n,m;

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

ll f[32][310];

inline ll work()
{
	memset(f,0,sizeof(f));
	f[0][num[n]*n]=1;
	for (int i=0;i<m;i++) for (int j=1;j<n;j++) for (int k=0;k<(1<<(n-1));k++) if (!((k>>(j-1))&1))
	{
		for (int l=i*n+j;l<=n*m;l++) f[k|(1<<(j-1))][min(n*m,max(l,i*n+j+num[p[j]]*n))]+=f[k][l];
	}
	return f[(1<<(n-1))-1][n*m];
}

int main()
{
	n=rd();m=rd();
	for (int i=1;i<=n;i++) num[i]=rd();
	sort(num+1,num+n+1);
	for (int i=1;i<n;i++) p[i]=i;
	ll ans=0;
	do
	{
		ans+=work();
	}while (next_permutation(p+1,p+n));
	ll res=1;
	for (int i=1;i<n;i++) res=res*i*m;
	printf("%.15lf\n",(double)ans/res);
	return 0;
}

Measured memory_bytes: 3844
# coding: utf-8
# Your code here!
N=int(input())
A=[0]*N
for i in range(N):
    A[i]=int(input())
m=sorted(A)[N-1]
m_=A.index(m)
m2=sorted(A)[N-2]
m2_=A.index(m2)
for i in range(N):
    if i!=m_:
        print(m)
    else:
        print(m2)

Measured memory_bytes: 14660
#include <stdio.h>
#include <stdbool.h>
int balls[10];
int left[10],right[10],l=0,r=0,det;
void solve();
void dfs(int depth);
bool check();
int main(void){
	int times;
	scanf("%d",&times);
	for(int i=0;i<times;i++){
		for(int j=0;j<10;j++)
			scanf("%d",&balls[j]);
		solve();
	}
	return 0; 
}

void solve(){
	det=0;
	dfs(0);
	if(det)	puts("YES");
	else	puts("NO");
}

void dfs(int depth){
	if(det)	return;
	if(depth==10){
		if(check())	det=1;
		return;
	}
	left[l++]=balls[depth++];
	dfs(depth);
	l--;depth--;
	right[r++]=balls[depth++];
	dfs(depth);
	r--;depth--;
}

bool check(){
	bool m=1,n=1;
	for(int i=0;i<l-1;i++)
		if(left[i]>left[i+1]){
			m=0;
			break;
		}
	for(int i=0;i<r-1;i++)
		if(right[i]>right[i+1]){
			n=0;
			break;
		}
	return m&&n;
}

Measured memory_bytes: 1008
object Main {
  def main(args: Array[String]): Unit = {
    var acute, right, obtuse = 0

    for(line <- io.Source.stdin.getLines()) {
      val edges = line.split(" ").map(_.toInt).toList.sorted
      val squared = edges.map(x => x * x)
      val isTryangle = (edges(0) < edges(1) + edges(2)) && (edges(1) < edges(0) + edges(2)) && (edges(2) < edges(0) + edges(1))

      if(isTryangle) {
        if(squared(2) < squared(0) + squared(1)) acute += 1
        if(squared(2) == squared(0) + squared(1)) right += 1
        if(squared(2) > squared(0) + squared(1)) obtuse += 1
      } else {
        println(s"${acute + right + obtuse} ${right} ${acute} ${obtuse}")
        System.exit(0)
      }
    }
  }
}


Measured memory_bytes: 44192
S=input()
if S[0]=='A' and S.count('C')==1 and 'C' in S[2:-1]:
    for c in S[1:len(S)]:
        if not (c.islower() or c=='C'):
            print("WA")
            break
    else:
        print("AC")
else:
    print("WA")


Measured memory_bytes: 9096
#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 = 1e11;
const int MAX_V = 300;

int V;

ll c[MAX_V][MAX_V];
bool enabled[MAX_V][MAX_V];

void wf() {
  rep(i, V) rep(j, V) rep(k, V) {
    if (i == j || j == k || i == k) continue;
    // if (i == 0 && j == 2 && k == 1)
    if (c[i][k] + c[k][j] < c[i][j]) {
      cout << -1 << endl;
      exit(0);
    }
    if (c[i][k] + c[k][j] == c[i][j]) {
      enabled[i][j] = true;
    }
  }
}

int main() {
  cin >> V;
  rep(i, V) rep(j, V) {
    int a;
    cin >> a;
    c[i][j] = a;
  }
  wf();
  ll ans = 0;
  rep(i, V) {
    for (int j = i; j < V; j++) {
      if (!enabled[i][j]) ans += c[i][j];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;

// int prime[1000001];
// vector<ll> primes;

// void soe() {
//     int i,j;
//     for(i=2;i<1000001;i++) prime[i] = 1;
//     for(i=2;i<=sqrt(1000001);i++) {
//         if(prime[i] == 1) {
//             for(j=i*i;j<1000001;j+=i) {
//                 prime[j] = 0;
//             }
//         }
//     }
//     for(i=2;i<1000001;i++) {
//         if(prime[i]) primes.pb(i);
//     }
// }

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

    ll n,i,req = 1;
    cin >> n;
    ll a[n];
    for(i=0;i<n;i++) {
        cin >> a[i];
        if(a[i] == req) {
            req++;
        }
    }
    if(req != 1) cout << n-req+1;
    else cout << -1;
    cout << "\n";
    return 0;
}




Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,n,b=0,r=0;
	char c;
	scanf("%d",&n);
	getchar();
	for(i=0;i<n;i++)
	{
		scanf("%c",&c);
		if(c=='R')
			r++;
		else
			b++;
	}
	if(r>b)
		printf("Yes");
	else 
		printf("No");
	return 0;
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             INT_MAX
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(x)			x.begin(),x.end() 
#define FIO				ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)


int nCr(int n , int r ) {
	int p = 1, k = 1;

	if (n - r < r ) {
		r = n - r;
	}
	if (r != 0) {
		while (r != 0) {
			p *= n ;
			k *= r ;
			int m = __gcd(p, k);
			p /= m;
			k /= m;
			n--;
			r--;
		}
	}
	else {
		p = 1;
	}
	return p ;
}

int lcm(int x , int y){
	return (x * y) / __gcd(x, y);
}

int modPower(int x, int y , int p) {
	//Used to calculate (x^y)%p
	int res = 1;
	if (y == 0) {
		return 1;
	}

	x = x % p;
	if (x == 0) {
		return 0  ;
	}

	while (y > 0) {
		if (y & 1) {
			res = (res * x) % p;
		}

		y >>= 1;
		x = (x * x) % p;
	}
	return res ;

}

void aryan_p() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	return;
}

int factorial(int n){
	if(n==0){
		return 1;
	}

	return n * factorial(n - 1);
}


int32_t main() {
	//aryan_p();
	FIO;

	int n;
	cin >> n;

	vector<int> a(n);
	vector<int> b(n);

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



	int count =0 ; 
	if(a<b){
		while(a!=b){
			next_permutation(all(a));
			count++;
		}
	}
	else{
		while(a!=b){
			next_permutation(all(b));
			count++;
		}
	}
	cout << count;

	return 0;
}


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

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int> vec(n,0);
    for (int i = 0; i < n; i++)
    {
        cin>>vec[i];
    }
    sort(vec.begin(),vec.end());
    int mid1=(n/2)-1;
    int mid2=(n/2);
    int count=vec[mid2]-vec[mid1];
    cout<<count<<endl;    
    
    return 0;
}

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

int main(){
	long N, S=0, n;
	cin >> N;
	n = N;
	while(n>0){
		S += n%10;
		n /= 10;
	}
	cout << (N%S ? "No" : "Yes") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
//
int main(){
  int N;
  cin>>N;
  cout<<N*32<<endl;
  return 0;
}


Measured memory_bytes: 3068
#include <iostream>
#include <string>
#include <vector>
#include <queue>

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define MP make_pair
#define X first
#define Y second

using namespace std;

typedef pair<int, int> P;

const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};

struct Matrix{
	int n;
	vector<vector<int> > dat;
	Matrix(int n):n(n){
		dat.resize(n);
		rep(i, n) dat[i].resize(n, 0);
	}

	void rotate(int r, int c, int size, int angle){
		int cnt = angle/90;
		Matrix sub = subMatrix(c, r, size);
		rep(i, cnt) sub.rotate();
		paste(sub, c, r);
	}

	void rotate(){
		Matrix m = (*this);
		rep(i, n) rep(j, n){
			dat[i][j] = m.dat[n-j-1][i];
		}
	}

	void Lshift(int r){
		int x = dat[r][0];
		rep(i, n-1) dat[r][i] = dat[r][i+1];
		dat[r][n-1] = x;
	}

	void Rshift(int r){
		int x = dat[r][n-1];
		for(int i = n-1; i > 0; i--) dat[r][i] = dat[r][i-1];
		dat[r][0] = x;
	}

	void reversal(int r, int c, int size){
		Matrix sub = subMatrix(c, r, size);
		rep(i, sub.n) rep(j, sub.n) {
			sub.dat[i][j] = !sub.dat[i][j];
		}
		paste(sub, c, r);
	}

	void IslandReversal(int x, int y){
		int val = dat[y][x];
		vector<P> v;
		queue<P> q;
		q.push(MP(x, y));
		vector<vector<int> > visit(n, vector<int>(n, 0));
		while(!q.empty()){
			P p = q.front();
			q.pop();
			if(visit[p.Y][p.X]) continue;
			visit[p.Y][p.X] = 1;
			v.push_back(MP(p.X, p.Y));

			rep(i, 4){
				int nx = p.X + dx[i], ny = p.Y + dy[i];
				if(nx < 0 || nx >= n || ny < 0 || ny >= n) continue;
				if(dat[ny][nx] != val) continue;
				q.push(MP(nx, ny));
			}
		}
		val = !val;
		rep(i, v.size()){
			dat[v[i].Y][v[i].X] = val;
		}
	}

	void print(){
		rep(i, n){
			rep(j, n) cout << (j?" ":"") << dat[i][j];
			cout << endl;
		}
	}

	Matrix subMatrix(int x, int y, int size){
		Matrix sub(size);
		rep(i, size) rep(j, size){
			sub.dat[i][j] = dat[y+i][x+j];
		}
		return sub;
	}

	void paste(const Matrix &mat, int x, int y){
		rep(i, mat.n) rep(j, mat.n){
			dat[y+i][x+j] = mat.dat[i][j];
		}
	}
};

int main(){
	int n, m;
	cin >> n >> m;
	Matrix mat(n);
	rep(i, n) rep(j, n){
		cin >> mat.dat[i][j];
	}
	rep(i, m){
		int op;
		cin >> op;
		if(op == 0){
			int r, c, size, angle;
			cin >> r >> c >> size >> angle;
			mat.rotate(r-1, c-1, size, angle);
		}else if(op == 1){
			int r, c, size;
			cin >> r >> c >> size;
			mat.reversal(r-1, c-1, size);
		}else if(op == 2){
			int r;
			cin >> r;
			mat.Lshift(r-1);
		}else if(op == 3){
			int r;
			cin >> r;
			mat.Rshift(r-1);
		}else if(op == 4){
			int r, c;
			cin >> r >> c;
			mat.IslandReversal(c-1, r-1);
		}
	}
	mat.print();

	return 0;
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;cin>>n>>m;
  int l=0,r=n;
  for(int i=0;i<m;i++){
    int a,b;cin>>a>>b;
    l=max(a,l);
    r=min(b,r);
  }
  if(r>=l)cout<<r-l+1<<endl;
  else cout<<0<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> A(n), B(n);
  rep(i, n) cin >> A[i] >> B[i];
  sort(all(A));
  sort(all(B));
  if(n%2) {
    cout << B[n/2]-A[n/2]+1 << "\n";
  } else {
    cout << B[n/2-1]+B[n/2]-(A[n/2-1]+A[n/2])+1 << "\n";
  }
  return 0;
}


Measured memory_bytes: 6332
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

N = int(input())
counter = 0
for i in range(1,N+1,2):
    if(len(make_divisors(i)) == 8):
        counter+=1
print(counter)

Measured memory_bytes: 9080
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){
	
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n;
	ll fl[3][3]={0},ar[3][3];
	for(i=0;i<3;i++){
		for(j=0;j<3;j++){
			cin>>ar[i][j];
		}
	}
	cin>>n;
	ll br[n+1];
	for(i=1;i<=n;i++){
		cin>>br[i];
		for(j=0;j<3;j++){
			for(k=0;k<3;k++){
				if(ar[j][k]==br[i]){
					fl[j][k]=1;
					break;
				}
			}
		}
	}

	int an=0;
	for(i=0;i<3;i++){
		ll c=0;
		for(j=0;j<3;j++){
			if(fl[i][j]==1) c++;
		}
		if(c==3){
			an=1; break;
		}
	}
	for(i=0;i<3;i++){
		ll c=0;
		for(j=0;j<3;j++){
			if(fl[j][i]==1) c++;
		}
		if(c==3){
			an=1; break;
		}
	}

	if(fl[0][0]+fl[1][1]+fl[2][2]==3){
		an=1;
	}
	if(fl[1][1]+fl[2][0]+fl[0][2]==3){
		an=1;
	}
	if(an){
		cout<<"Yes";
	}
	else cout<<"No";
	return 0;
}

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

int MOD=1000000007;
struct edge {
    int to, cost;
};

int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}

int gyaku(int n){
    return modpow(n,MOD-2);
}

auto factor(int n){
  map<int,int>res;
  for(int i=2;i*i<=n;i++){
      for(; n%i==0;n/=i) res[i]++;
  }
  if(n>1)res[n]++;
  return res;
}
////////////////////////////////////////////////////////////
signed main() {
  int n,m;
  cin>>n>>m;
  int ans;
  if(n==1&&m==1) ans=1;
  else if(n==1||m==1) ans=n*m-2;
  else ans=n*m-(2*(n+m-2));
  cout<<ans<<endl;
}


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

    using namespace std;
    typedef long long ll;
    # define M_PI  3.14159265358979323846

    void solve(){
        ll n,m,k;
        cin>>n>>m>>k;
        vector<ll>a(n);
        vector<ll>b(m);
        for(int i=0;i<n;i++)
            cin>>a[i];
        for(int i=0;i<m;i++)
            cin>>b[i];
        vector<ll>sumA(n+1);
        vector<ll>sumB(m+1);
        for(int i=0;i<n;i++)
            sumA[i+1]=sumA[i]+a[i];
        for(int i=0;i<m;i++)
            sumB[i+1]=sumB[i]+b[i];
        int total=0;
        for(int i=0;i<=n;i++){
            ll other=k-sumA[i];
            if(other<0)
                continue;
            int l=lower_bound(sumB.begin(),sumB.end(),other)-sumB.begin();
            if(l>m || sumB[l]>other)
                --l;
//            cout<<other<<" "<<l<<" "<<i<<" "<<"\n";
            total=max(total,i+l);
        }
        cout<<total;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
        int t=1;
//        cin>>t;
        for(int i=1;i<=t;i++){
            solve();
        }
        return 0;
    }


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

using namespace std;

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

  int n;
  cin >> n;
  vector<vector<int>> A(2, vector<int>(n)), sum(2, vector<int>(n,0));
  for (int i = 0; i < 2; ++i)
    for (int j = 0; j < n; ++j) {
      cin >> A[i][j];
    }
  sum[0][0] = A[0][0];
  for (int i = 1; i < n; ++i) {
    sum[0][i] = A[0][i]+sum[0][i-1];
  }
  sum[1][n-1] = A[1][n-1];
  for (int i = n-2; i >= 0; --i) {
    sum[1][i] = A[1][i]+sum[1][i+1];
  }
  int res = 0;
  for (int i = 0; i < n; ++i) {
    res = max(res, sum[0][i]+sum[1][i]);
  }
  cout << res << endl;

  return 0;
}



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

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

    string s;
    cin >> s;

    int n = s.size();

    if(n == 1){
        cout << 0 << endl;
        return 0;
    }
    /*
    if(s[0] != 'x' and s[n - 1] != 'x' and n > 2){
        cout << -1 << endl;
        return 0;
    }
    */

    int l = 0, r = n - 1, cnt = 0;
    while(l <= r){
        if(l == r) break;
        if(s[l] == s[r]){
            l++;
            r--;
        }else if(s[l] == 'x'){
            l++;
            cnt++;
        }else if(s[r] == 'x'){
            r--;
            cnt++;
        }else{
            cout << -1 << endl;
            return 0;
        }
    }

    cout << cnt << endl;

    return 0;
}

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

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

    vector<int> p(n);
    rep(i, n) cin >> p[i];

    for (int i = 0; i < 100; ++i)
    {
        bool exist = true;
        for (int l : p)
            if (x - i == l)
                exist = false;

        if (exist)
        {
            cout << x - i << endl;
            exit(0);
        }

        for (int l : p)
            if (x + i == l)
                exist = true;

        if (!exist)
        {
            cout << x + i << endl;
            exit(0);
        }
    }
}

Measured memory_bytes: 3636
class Unionfind():
    def __init__(self, size):
        self.table = [-1 for _ in range(size)]

    def find(self, x):
        while(self.table[x] >= 0):
            x = self.table[x]
        return x

    def union(self, x, y):
        xp = self.find(x)
        yp = self.find(y)
        if xp != yp:
            if self.table[xp] < self.table[yp]:
                self.table[xp] += self.table[yp]
                self.table[yp] = xp
            else:
                self.table[yp] += self.table[xp]
                self.table[xp] = yp

n, m = map(int, input().split())
edge = [tuple(map(int, input().split())) for _ in range(m)]
ret = 0
for i in range(m):
    uni = Unionfind(n)
    for j in range(m):
        if j != i:
            uni.union(edge[j][0] - 1, edge[j][1] - 1)
    for j in range(n):
        if uni.table[j] < 0 and -(uni.table[j]) != n:
            ret += 1
            break
print(ret)

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

int main()
{
	int D;
	cin >> D;
	string e = "Eve";
	string c = "Christmas";
		if(D == 22)cout << c <<' '<< e << ' ' << e << ' ' << e << endl;
		if (D == 23)cout << c << ' ' << e << ' ' << e <<endl;
		if (D == 24)cout << c << ' ' << e <<endl;
		if (D == 25)cout << c << endl;

		return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 r;
  std::cin >> r;
  std::cout << r * r << std::endl;
  return 0;
}

Measured memory_bytes: 256