akhauriyash/Code-Regression huggingface dataset:
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

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

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (b - a == c - b)
		print("YES");
	else
		print("NO");
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 384
using System;


namespace ConsoleApplication43
{
    class Program
    {
        static void Main(string[] args)
        {
            while(true)
            {
                string n = Console.ReadLine();
                
                if ("-" == n)
                {
                    break;
                }   
                int m = int.Parse(Console.ReadLine());
                string A = string.Empty;
                string B = string.Empty;
                //ans???????????\??????
                string Ans = string.Empty;
                for (int i = 0; i < m; i++)
                {
                    int ns = int.Parse(Console.ReadLine());
                    
                        A = n.Substring(0, ns);
                        B = n.Remove(0,ns);
                        Ans = B + A;
                        n = B + A;
                        //Console.WriteLine("x???" + m + "?????¨???");
                        //Console.WriteLine("A???" + A + "B???" + B);
                        //Console.WriteLine("Ans???" + Ans);    
                }
                Console.WriteLine(Ans); 
            }
        }
    }
}

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

const ll INF = 1001001001;
vector<int> dist;
bool ok;

void dfs(int v, int cost, const Graph &G){
    dist[v] = cost;
    for(auto p : G[v]){
        int nv = p.first, dis = p.second;
        if(dist[nv] != -INF){
            if(dist[v] + dis == dist[nv]) continue;
            ok = false;
            return;
        }
        else{
            dfs(nv, cost + dis, G);
        }
    }
}

int main(){
    int n, m; cin >> n >> m;
    Graph G(n);
    dist.resize(n, -INF);
    for(int i = 0; i < m; i++){
        int l, r, d; cin >> l >> r >> d;
        --l; --r;
        G[l].push_back({r, d});
        G[r].push_back({l, -d});
    }
    ok = true;
    for(int i = 0; i < n; i++){
        if(dist[i] == -INF){
            dfs(i, 0, G);
        }
        if(!ok) break;
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 15024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

const ll INF = 1e18;
int main() {
  ll H, W;
  cin >> H >> W;
  vector<vector<ll>> A(H, vector<ll>(W, 0)), B(H, vector<ll>(W, 0)),
      C(H, vector<ll>(W, 0));

  REP(i, H) REP(j, W) { cin >> A[i][j]; }
  REP(i, H) REP(j, W) { cin >> B[i][j]; }
  REP(i, H) REP(j, W) { C[i][j] = abs(A[i][j] - B[i][j]); }

  ll x = 80;
  ll M = (H + W) * x;
  vector<vector<vector<bool>>> dp(
      H + 1, vector<vector<bool>>(W + 1, vector<bool>(M + 1, false)));
  // dp[i][j][k] = (i,j)で|red-blue|=kとできるか
  ll t = C[0][0];
  dp[0][0][t] = true;

  REP(i, H) REP(j, W) {
    REP(k, M + 1) {
      if ((i - 1 >= 0 && dp[i - 1][j][k]) || (j - 1 >= 0 && dp[i][j - 1][k])) {
        vector<ll> nxt = {k + C[i][j], abs(k - C[i][j])};
        REP(l, 2) {
          ll t = nxt[l];
          if (0 <= t && t <= M) {
            dp[i][j][t] = true;
          }
        }
      }
    }
  }

  ll ans = 1e18;
  REP(k, M + 1) {
    if (dp[H - 1][W - 1][k]) {
      ans = min(ans, k);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 13184
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<pair<ll,ll>> p(n);
  for (auto &i : p) cin >> i.second >> i.first;
  sort(p.begin(), p.end());
  ll ans = 0;
  for (auto i : p) {
    ans += i.second;
    if (ans > i.first) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>

int main(void)
{
  int i,r,D,X;
    int x[10]={0};
  
  scanf("%d %d %d",&r,&D,&x[0]);
  
  for(i=0;i<10;i++)
  {
    x[i+1]=r*x[i]-D;
    printf("%d",x[i+1]); 
    if(i!=9)
    {
      printf("\n");
    }
  }
  
  return 0;
    
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i, n)  for(ll i = 0; i < (n); ++i)
#define rep1(i,n)  for(ll i = 1;i <= (n); ++i)
#define pb push_back
#define M 1000000007
unordered_map<ll,ll>mp;

int main()
{
    fastIO
	string st;
  cin>>st;
  int rem=0;
  for(ll i=0;i<(ll)st.length();i++)
  {
    rem+=(st[i]-'0');
      rem=rem%9;
  }
  if(rem==0)
    cout<<"Yes";
  else
    cout<<"No";
	return 0;
}


Measured memory_bytes: 3728
K = int(input())
h = [0]*10
h[0] = {1,2,3,4,5,6,7,8,9}

def digit_lunlun(x):
    if x == 0:
        return h[0]
    G = digit_lunlun(x-1)
    a = set()
    for g in G:
        b = g%10
        for i in set([max(0,b-1),b,min(b+1,9)]):
            a.add(g*10+i)
    h[x] = a
    return a

digit_lunlun(9)
for i in range(10):
    le = len(h[i])
    if le < K:
        K -= le
    else:
        for g in sorted(h[i]):
            if K == 1:
                print(g)
                exit()
            else:
                K -= 1




Measured memory_bytes: 51796
fn main() {
    let a: i32 = read();
    let b: i32 = read();
    let sum = a + b;

    if a % 3 == 0 || b % 3 == 0 || sum % 3 == 0 {
        println!("Possible");
    } else {
        println!("Impossible")
    }
}



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 toparse token")
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
int main(){
    int n,q;
    cin>>n>>q;

    UnionFind uf(n);

    rep(i,q){
        int query;
        cin>>query;
        int x,y;
        cin>>x>>y;
        if(!query){
            uf.unite(x,y);
        }
        else{
            if(uf.same(x,y)){
                cout<<'1'<<'\n';
            }
            else{
                cout<<'0'<<'\n';
            }
        }
    }
    return 0;

}
/*


*/



Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin >> a >> b;
  char vec[a][b];
  for(int i = 0;i < a;i++){
    for(int j = 0;j < b;j++){
      cin >> vec[i][j];
    }
  }
  int count = 0;
  
  for(int i = 0;i < a;i++){
    for(int j = 0;j < b;j++){
      if(vec[i][j] == '#' && vec[i][j-1] == '.' && vec[i][j+1] == '.' && vec[i-1][j] == '.' && vec[i+1][j] == '.'){
        count++;
      }
    }
  }
  
  if(count == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {
    int arr[26];// = {5000};
    //cout << arr[0] << endl;
    //memset(arr, 5000, sizeof(arr));
    for(int i=0; i<26; i++) arr[i] = 5001;
    int n ;cin>> n;
    string s;
    for(int i=0; i<n; i++){
        cin >> s;
        int new_arr[26];
        memset(new_arr, 0, sizeof(new_arr));
        for(int ii=0; ii<s.length(); ii++){
            new_arr[s[ii]-'a'] += 1;
        }
        //for(int l = 0; l<26; l++) cout << new_arr[l]<< " ";
        //cout << endl;
        for(int ii=0; ii<26; ii++){
            arr[ii] = min(arr[ii], new_arr[ii]);
            //cout << arr[ii] << " ";
        }
        //cout << endl;
    }
    //for(int i=0;i<26; i++) cout << arr[i]  <<" ";
    //cout << endl;
    string ans = "";
    for(int i=0; i<26; i++){
        if(arr[i] == 5000) continue;
        for(int j=0; j<arr[i]; j++){
            ans += 'a'+i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int L;
ll dp[5];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> L;
    register ll A;

    for(int i = 0; i < L; ++i){
        cin >> A;
        ll mn = dp[0];
        dp[0] += A;
        mn = min(mn, dp[1]), dp[1] = mn + (A == 0 ? 2 : A % 2);
        mn = min(mn, dp[2]), dp[2] = mn + (A + 1) % 2;
        mn = min(mn, dp[3]), dp[3] = mn + (A == 0 ? 2 : A % 2);
        mn = min(mn, dp[4]), dp[4] = mn + A;
    }
    cout << min({dp[0], dp[1], dp[2], dp[3], dp[4]}) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
string s;
int main(){
	cin>>s;
	int x=0,y=0;
	for(int i=0;i<s.size();i++){
		if(i%2==0){
			if(s[i]!='0')x++;
		}
		else if(i%2!=0) {
			if(s[i]!='1')x++;
		}
	}
	for(int i=0;i<s.size();i++){
		if(i%2==0){
			if(s[i]!='1')y++;
		}
		else {
			if(s[i]!='0')y++;
		}
	}
	if(x>y)cout<<y;
	else cout<<x;
} 

Measured memory_bytes: 512
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define chmax(x,y) x = max(x,y)

 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
typedef vector<LL> VL;
typedef vector<vector<long long>> VVLL;
typedef vector<set<int>> VSI;
const int MOD = 1e9+7;
const int INF = 1e9;
const LL LINF = 1e18;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}
struct UnionFind {
    VI d;
    UnionFind(int n = 0): d(n,-1) {}
    int find(int x) {
        if(d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x,int y) {
        x = find(x); y = find(y);
        if(x == y) return false;
        if(d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x,int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};
int deg[100005];
VI to[100005];

struct mint {
  LL x; // typedef long long ll;
  mint(LL x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(LL t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(MOD-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(int n) {
    if(n == 0) return 1;
    mint x = f(n/2);
    x *= x;
    if(n%2 == 1) x *= 2;
    return x;
}

mint choose(int n,int a) {
    mint x = 1, y = 1;
    rep(i,a) {
        x *= n-i;
        y *= i+1;
    }
    return x/y;
}

int main() {
  int k;
  cin >> k;
  LL ans = 0;
  FOR(i,1,k+1) {
    FOR(j,1,k+1) {
      FOR(u,1,k+1) {
        int tmp = gcd(i,j);
        int tmp2 = gcd(tmp,u);
        ans += tmp2;
      }
    }
  }
  cout << ans << endl;
    
}


Measured memory_bytes: 5936
#include <iostream>
#include<vector>
#include<string>
#include<bits/stdc++.h>
#include<algorithm>
#include<stdio.h>
#include<bits/stdc++.h>
#define ll  long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

using namespace std;

/*ll ma=998244353;
ll power(ll v,ll ti){
if(ti==1)
    return v;
ll x=power(v,ti/2);
x=(x*x)%ma;
if(ti%2==1)
    x=(x*v)%ma;
return x;

}
struct t{
int a,b;
};
vector<vector<t > >g;
vector<int> v;


ll n;


void dfs(int i,int sum){
v[i]=1;


for(int j=0;j<go[i].size();j++){
    int x=go[i][j].a;
    int y=go[i][j].b;
    if(v[x]==0){
        dfs(x,min(y,sum));

    }

}

}*/



 int main(){
ll n;
cin>>n;
ll ans=0;
for(ll i=1;i*i<n;i++){
    if(n%i==0 && n/i-1>i){
        ans+=(n/i-1);
    }

}
cout<<ans<<endl;
 }


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct List{
	int key; //真ん中の値
	List* head; //前の値のポインタ
	List* ass; //後ろの値のポインタ
};

List *porn; //番兵設置

void init(){  //初期化
	porn = (List *)malloc(sizeof(List));
	porn->ass = porn;
	porn ->head = porn;
}

void insert(int key){//リスト末尾にkeyを入れる
	List *added = (List *)malloc(sizeof(List));//メモリ確保
	added->key = key;//真ん中の値にkeyを入れる
	added->ass = porn->ass;//番兵の直後に要素追加
	porn->ass->head=added;
	porn->ass=added;
	added->head=porn;
}

List* listSearch(int key){
	List *now = porn->ass;//番兵にきて現在地をを取得、要素を探索していく
	while(now != porn && now->key != key){
		now = now->ass;
	}
	return now;//要素を見つけたらそのポインタを返す。
}

void deleteList(List *node){
	if(node == porn) return;//nodeが番兵ならすぐ戻る
	node->head->ass = node->ass;
	node->ass->head = node->head;
	free(node);
}

void deleteFirst(){//deleteListに後ろの引数を与える。
	deleteList(porn->ass);
}

void deleteLast(){//deleteListに前の引数を与える。
	deleteList(porn->head);
}

void deletekey(int key){//問題文におけるdelete、値を直接指定して消す。
	deleteList(listSearch(key));
}

void printer(){//Listを表示
	List *now = porn->ass;
	int isf = 0;
	while(1){
		if(now==porn)break;
		if(isf++>0)printf(" ");
		printf("%d",now->key);
		now = now->ass;	
	}
	printf("\n");
}

int main(){
	int key,n,i;
	int size=0;
	char com[20];//命令を読み取る
	int np= 0,nd=0;
	scanf("%d",&n);
	init();//初期化
	for(i=0;i<n;i++){
		scanf("%s",com);//"%s %d"に半角スペースを入れないと数字が認識されない
		//com[0]=='i'であればinsertが使われている。
		if(com[0]=='i'){scanf("%d",&key);insert(key);np++;size++;}
		else if(com[0]=='d'){
			if(strlen(com)>6){
				if(com[6]=='F'){deleteFirst();}
				else if(com[6]=='L'){deleteLast();}
			}else{
				scanf("%d",&key);
				deletekey(key);nd++;	
			}
			size--;
		}	
	}
	printer();
	return 0;
}


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

int main(){
int N,B,C=0,K,d;
cin >> N >> K;
vector<int> A(N);

for(int i = 0;i < N; i++){
	A.at(i) = 0;
}

for(int i = 0;i < K; i++){
	cin >> d;
	for(int j = 0;j < d; j++){
		cin >> B;
		A.at(B-1)++;
	}
}
for(int i = 0;i < N; i++){
	if(A.at(i)==0) C++;
}
cout << C << endl;
}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
#define MAX 100000

int parent(int i) {
	return i / 2;
}
int left(int i) {
	return 2 * i;
}
int right(int i) {
	return 2 * i + 1;
}

int main() {
	int H, i, A[MAX + 1];
	cin >> H;
	for (i = 1; i <= H; i++) {
		cin >> A[i];
	}
	for (i = 1; i <= H; i++) {
		cout << "node " << i << ": key = " << A[i] << ", ";
		if (parent(i) >= 1)cout << "parent key = " << A[parent(i)] << ", ";
		if (left(i) <= H)cout << "left key = " << A[left(i)] << ", ";
		if (right(i) <= H)cout << "right key = " << A[right(i)] << ", ";
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

// chmax, chmin
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail {
template <typename T, std::size_t NDIMS>
struct vector_builder {
  using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
    if (!dims.empty()) dims.pop_back();
    return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
  }
};

template <typename T>
struct vector_builder<T, 1> {
  using type = std::vector<T>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    return type(dims.empty() ? 0 : dims.back(), v);
  }
};
}  // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T& v, SIZE_T... dims) {
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T& data, vector<int>& iter) {
  cout << data << " ";
}
template <typename T>
void dump(const vector<T>& data, vector<int>& iter) {
  for (auto elem : data) dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>>& data, vector<int>& iter) {
  for (auto elem : iter) {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++) {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T>& data, int dummy) {
  for (int i = 0; i < data.size(); i++) {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T& data) {  // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

int main() {
  int N;
  cin >> N;
  vector<int> input(N);
  for (int i = 0; i < N; i++) cin >> input[i];
  vector<int> pos(N);
  for (int i = 0; i < N; i++) pos[input[i] - 1] = i;

  int cur = 0;
  int maxim = 0;
  for (int i = 0; i < N - 1; i++) {
    if (pos[i] < pos[i + 1]) {
      cur++;

      maxim = max(maxim, cur);
    } else {
      cur = 0;
    }
  }
  maxim++;
  cout << N - maxim << endl;

  return 0;
}

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

int main()
{
	string s,t;
	cin>>s>>t;
	
	bool f=0;
	for(int i=0;i<s.size();i++){
		int trans=s[0]; 
		for(int j=0;j<s.size()-1;j++){
			s[j]=s[j+1];
		}
		s[s.size()-1]=trans;
		if(s==t) f=1;
	}
	
	if(f==1) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}


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

#define fren bigounce
#define speedup ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define endl "\n"
#define mt make_tuple
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define usaco(in,out) ifstream cin(in); ofstream cout(out)
#define all(X) (X).begin(), (X).end()
#define sz(X) ((int)X.size())
#define erase_dupes(X) sort(all(X)); (X).resize(distance((X).begin(), unique(all(X))));
#define decimal(X) cout << fixed << setprecision(X)
#define mst(X,Y) memset(X,Y,sizeof(X));

typedef long long LL;
typedef double DBL;
typedef pair<int,int> PII; 
typedef pair<LL,LL> PLL;
typedef pair<string, int> PSI;
typedef pair<int,string> PIS;
typedef vector<PSI> VPSI;
typedef vector<PIS> VPIS;
typedef pair<char,int> PCI;
typedef pair<int,char> PIC;
typedef vector<PCI> VPCI;
typedef vector<PIC> VPIC;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<LL> VLL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long double LD;
typedef pair<LD,LD> PLD;
typedef vector<LD> VLD;
typedef vector<PLD> VPLD;

template<class TH> void _dbg(const char *sdbg, TH h) { 
	cerr<<sdbg<<" = "<<h<<endl;
}

template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',') cerr<<*sdbg++;
  cerr<<" = "<<h<<", "; _dbg(sdbg+1, a...);
}

#define LOCAL
#define SEPERATOR cout << "-----------------------------------------" << endl;

#ifdef LOCAL
	#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
	#define dbg(...)
	#define cerr if(0)cout
#endif

const int maxn = 1e5+7;
const int inf = 1e9+7;
const LL LLinf = ((LL)1e18)+7LL;
const LD eps = 1e-9;

// **************************************** NICE **************************************** //
// ~/~/~/~/~/~/~/~/~/~/~/~/~/~/ A PRO_GEMR Special... Enjoy! \~\~\~\~\~\~\~\~\~\~\~\~\~\~ //

LL n, k, a[maxn], dp[maxn];

int main() {
	speedup
	
	cin >> n >> k;
	for (int i = 0; i < n; ++i) {cin >> a[i];}
	
	mst(dp,inf);
	dp[0] = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = i+1; j <= i+k; ++j) {
			if (j < n) {
				dp[j] = min(dp[j],dp[i]+abs(a[i]-a[j]));
			}
		}
	}
	cout << dp[n-1];
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

int main()
{
  int n;
  cin >> n;
  // S=> 0, H=> 1, C=> 2, D=> 3
  bool c[4][13];
  for (int i = 0; i < 4; i++)
  {
    for (int j = 0; j < 13; j++)
    {
      c[i][j] = false;
    }
  }

  for (int i = 0; i < n; i++)
  {
    string mark;
    int num;
    cin >> mark >> num;
    num--;
    if (mark == "S")
      c[0][num] = true;
    else if (mark == "H")
      c[1][num] = true;
    else if (mark == "C")
      c[2][num] = true;
    else
      c[3][num] = true;
  }

  vector<pair<int, int>> m;
  for (int i = 0; i < 4; i++)
  {
    for (int j = 0; j < 13; j++)
    {
      if (!c[i][j])
        m.push_back(make_pair(i, j));
    }
  }

  for (int i = 0; i < m.size(); i++)
  {
    if (m[i].first == 0)
      cout << "S " << m[i].second + 1 << endl;
    else if (m[i].first == 1)
      cout << "H " << m[i].second + 1 << endl;
    else if (m[i].first == 2)
      cout << "C " << m[i].second + 1 << endl;
    else
      cout << "D " << m[i].second + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3084
// inputに入力データ全体が入る
function Main(input) {
  input = input.split(" ");
  area = (input[0] * input[1]) /2

	//出力
	console.log(area);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import itertools
n,k=map(int,input().split())
mod=10**9+7
ans=0
d=[i for i in range(n+1)]
d=list(itertools.accumulate(d))
for i in range(k,n+1):
  d_min=d[i-1]-d[0]
  d_max=d[n]-d[n-i]
  ans+=(d_max-d_min+1)
print((ans+1)%mod)

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

const int MOD = 2019;
int L, R;

int solve(int x, int y) {
	int min_v = MOD + 1;
	for (int i = x; i < y; ++i) {
		for (int j = i + 1; j <= y; ++j) {
			int val = (i * j) % MOD;
			min_v = min(val, min_v);
		}
	}
	return min_v;
}

int main(void) {
	cin >> L >> R;

	int ld = L / MOD;
	int rd = R / MOD;
	int ans = 0;
	if ((ld == rd) && (L % MOD != 0) && (R % MOD != 0))
		ans = solve(L % MOD, R % MOD);

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
def yo():
    l,r = map(int,input().split())

    a = l*r%2019
    for i in range(l,r) :
        for j in range(i+1,r+1):
            ij = i*j%2019
            
            if (a > ij) :
                a = ij

            if(a==0) :
                return a

    return a



print(yo())

Measured memory_bytes: 3060
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

a,b = MAP()
ans = 0
for i in range(1, 10): #1桁目
    for j in range(0, 10): #2桁目
        for k in range(0, 10): #3桁目
            s = str(i) + str(j) + str(k) + str(j) + str(i)
            s = int(s)
            if a <= s <= b:
                ans += 1
print(ans)

Measured memory_bytes: 5144
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define rg register
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
using namespace std;
const int Maxn = 2e5 + 5;
typedef long long ll;
typedef int arr[Maxn];
//ll Add(ll x, ll y) { return (x += y) >= Mod ? x - Mod : (x < 0 ? x + Mod : x); }
ll min(ll x, ll y) { return x < y ? x : y; }
ll max(ll x, ll y) { return x > y ? x : y; }
inline ll read()
{
	rg ll res = 0, sign = 1;
	rg char ch = getchar();
	while (!isdigit(ch))
	{
		if (ch == '-')
			sign = -1;
		ch = getchar();
	}
	do
	{
		res = (res << 3) + (res << 1) + (ch ^ 48);
		ch = getchar();
	} while (isdigit(ch));
	return res * sign;
}
int n, cnt;
arr fir, Max, Max2, fa, son, ans, sum;
struct
{
	int to, last;
} e[Maxn << 1];
void con(int u, int v)
{
	e[++cnt].to = v;
	e[cnt].last = fir[u];
	fir[u] = cnt;
}
void DFS(int x)
{
	if (Max[x] == fa[x])
		Max2[x] = x;
	else
		Max2[x] = max(Max2[fa[x]], x);
	if (x < Max[x])
	{
		if (Max[Max[x]] > Max2[x])
			sum[Max[x]]++;
		else
			sum[son[Max[x]]]++;
	}
	else
		sum[x]++;
	ans[x]--;
	for (int next = fir[x], nx; next; next = e[next].last)
	{
		nx = e[next].to;
		if (nx == fa[x])
			continue;
		fa[nx] = x;
		Max[nx] = max(Max[x], x);
		son[x] = nx;
		DFS(nx);
	}
}
void Cal(int x, int s)
{
	ans[x] += s;
	for (int next = fir[x], nx; next; next = e[next].last)
	{
		nx = e[next].to;
		if (nx == fa[x])
			continue;
		Cal(nx, s + sum[nx]);
	}
}
int main()
{
	rg int a, b, tmp;
	cin >> n;
	for (int i = 1; i < n; i++)
	{
		a = read();
		b = read();
		con(a, b);
		con(b, a);
	}
	cnt = 0;
	DFS(1);
	Cal(1, sum[1]);
	for (int i = 2; i <= n; i++)
		cout << ans[i] << ' ';
	putchar('\n');
	return 0;
}


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

int main() {
  string s,t;
  int count = 0;
  cin >> s >> t;

  for(int i = 0; i<s.size();++i) if(s[i] != t[i]) count++;
  cout << count << endl;
  return 0;
}

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

int main(void){
    int R;
    cin>>R;
    if(R>=0&&R<1200)
        cout<<"ABC"<<endl;
    else if(R>=1200&&R<2800)
        cout<<"ARC"<<endl;

    else if(R>=2800&&R<=4208)
        cout<<"AGC"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
using namespace	std;
int a[128]={1,1,2},n;
int main()
{
  for(int i=3;i<31;i++)
    a[i]=a[i-1]+a[i-2]+a[i-3];
  while(cin >> n, n)
    cout << a[n]/10/365+1 << endl;
}

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

int main() {
    stack<char> s;
    string S,ans="";
    cin >> S;
    rep(i,S.size()){
        if(S[i]=='B'&&ans.size()!=0){
            ans.erase(ans.end()-1);
        } else if(S[i]!='B'){
            ans += S[i];
        }
    }
    cout << ans << endl;
}

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

typedef vector<char> vec;
typedef vector<vec> mat;
mat A( 2 , vec(0) );

void  pr(){
  for(int i=0;i<(int)A.size();i++){
    for(int j=0;j<(int)A[i].size();j++){
      printf("%c",A[i][j]);
    }
    printf("\n");
  }
  fflush(stdout);
}

int N;

bool check(){

  if( (int) A[0].size() > N )return false;
  
  char str[100];
  pr();
  scanf("%s",str);
  if(str[0]=='T')return true;
  else return false;
}

string strx="..##";
string stry=".#.#";



int main(){

  bool bk=true;
  

  scanf("%d",&N);
  while(1){
    bool flag=false;
    for(int i=0;i<4;i++){
      mat tmp=A;
      if(bk){
        A[0].push_back( strx[i] );
        A[1].push_back( stry[i] );
        if( check() ){
          flag=true;
          break;
        }
      }else{
        A[0].insert(A[0].begin(), strx[i] );
        A[1].insert(A[1].begin(), stry[i] );
        if( check() ){
          flag=true;
          break;
        }
      }
      A=tmp;
    }
    if(!flag){
      if(bk)bk=false;
      else break;
    }
  }
  pr();
  return 0;
}


Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end());
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
void dout(double d){printf("%.12f\n",d);}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int n;
int ml, s;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n){
    int l;
    cin >> l;
    maxs(ml, l);
    s += l;
  }
  cout << ((s-ml > ml) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        string line;
        for (; (line = Console.ReadLine()) != null;)
        {
            string[] w = line.Trim().Split(' ');
            var a = long.Parse(w[0]);
            var b = long.Parse(w[1]);
            Console.WriteLine("{0} {1}",Gcd(a,b) , Lcm(a,b));
        }
    }
    public static long Lcm(long a, long b)
    {
        if (a < b) return Lcm(b, a);
        var ab = a * b;
        while (b != 0)
        {
            var wk = a % b;
            a = b;
            b = wk;
        }
        return ab / a;
    }
    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;
    }
}


Measured memory_bytes: 9088
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int[] l = new int[n];
    for (int i = 0; i < n; i++) {
      l[i] = sc.nextInt();
    }
    Arrays.sort(l);
    int res = 0;
    for (int i = l.length - 1; i >= 2; i--) {
      for (int j = i - 1; j >= 1; j--) {
        for (int k = j - 1; k >= 0; k--) {
          if (l[i] < l[j] + l[k]) {
            res++;
          }
        }
      }
    }
    System.out.println(res);
  }
}


Measured memory_bytes: 27392
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.function.Consumer;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");
		int h = Integer.parseInt(str[0]);
		int w = Integer.parseInt(str[1]);

		boolean flag[][] = new boolean[h][w];

		for (int i = 0; i < h; i++) {
			str = br.readLine().split("");
			for (int j = 0; j < w; j++) {
				if (str[j].equals("#")) {
					flag[i][j] = true;
				}
			}
		}

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (flag[i][j]) {
					if ((i > 0 && flag[i - 1][j]) || (i < h - 1 && flag[i + 1][j]) || (j > 0 && flag[i][j - 1])
							|| (j < w - 1 && flag[i][j + 1])) {
						continue;
					}
					System.out.println("No");
					return;
				}
			}
		}

		System.out.println("Yes");
	}
}


Measured memory_bytes: 21460
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

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

    vector<int> v(n);
    iota(v.begin(), v.end(), 0);

    int a, b;
    int cnt = 0;
    do{
        cnt++;
        if(v == p) a = cnt;
        if(v == q) b = cnt;
    }while(next_permutation(v.begin(), v.end()));

    cout << abs(a - b) << endl;

    return 0;
}


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

#define FOR(i,a,b) for(i=a;i<=b;i++)
#define FOD(i,b,a) for(i=a;i>=b;i--)
#define pa pair<int,int>
#define fi first
#define se second
#define task "x"

typedef long long ll;
const ll M=1e6+1;
const ll N=1e4+1;
using namespace std;

string s;
ll i, j, ans =0;
bool kt;

void input()
{
    cin >> s;
}

void solve()
{
    FOR(i,0,s.size()-1)
    {
     ans +=s[i]-'0';
    }
    if(ans%9 == 0) cout<<"Yes";
    else cout<<"No";
}

int main()
{
  	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	if(fopen(task".inp","r"))
        {
 	  freopen(task".inp","r",stdin);
 	  freopen(task".out","w",stdout);
	}
	input();
	solve();

   return 0;
}


Measured memory_bytes: 3736
import sys
from collections import deque
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = deque(input())

Q = int(input())
TURN = False

for _ in range(Q):
    q = input()
    if q[0] == '1':
        TURN = not TURN
        continue

    _, f, c = q.split()

    FIRST = True if f == '1' else False

    if (FIRST and (not TURN)) or ((not FIRST) and TURN):
        S.appendleft(c)
    else:
        S.append(c)


if TURN:
    S.reverse()

print(''.join(S))


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

int main(){
  string ss;
  cin>>ss;
  int n=0;
  int s=0;
  int e=0;
  int w=0;
  for(int i=0; i<ss.size(); ++i){
    if(ss[i]=='N') n++;
    if(ss[i]=='S') s++;
    if(ss[i]=='E') e++;
    if(ss[i]=='W') w++;
  }
  if(n>0 && s==0){
    cout<<"No"<<endl;
  } else if(n==0 && s>0){
    cout<<"No"<<endl;
  } else if(e>0 && w==0){
    cout<<"No"<<endl;
  } else if(e==0 && w>0){
    cout<<"No"<<endl;
  } else {
    cout<<"Yes"<<endl;
  }
  return 0;
}


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

int main(){
  int n,k; cin >> n >> k;
  vector<char> s(n);
  for(int i=0; i<n; i++){
    cin >> s[i];
  }if(s[k-1] == 'A'){
    s[k-1] = 'a';
  }if(s[k-1] == 'B'){
    s[k-1] = 'b';
  }if(s[k-1] == 'C'){
    s[k-1] = 'c';
  }
  for(int i=0; i<n; i++){
    cout << s[i];
  }
}


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

void solve() {
	int N; cin >> N;
	vector<long long> A(N);
	int res = 0;
	rep(i, N) {
		scanf("%d", &A[i]);
		while (A[i] % 2 == 0) {
			A[i] /= 2;
			res++;
		}
	}
	cout << res << endl;
}

int main(void) {
	solve();

	return 0;
}

Measured memory_bytes: 384
h,w = list(map(int,input().split()))
h_ch = [0]*h
w_ch = [0]*w
inp = []
for i in range(h):
  inp.append(input())
  for j in range(w):
    h_ch[i] += 1 if inp[-1][j]=="#" else 0
    w_ch[j] += 1 if inp[-1][j]=="#" else 0
    
for i in range(h):
  if h_ch[i] > 0:
    out = ""
    for j in range(w):
      if w_ch[j] > 0:
        out += inp[i][j]
    print(out)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

long long pow_mod(long long n,long long k,long long m){
    if (k == 0){
        return 1;
    } else if (k % 2 == 1){
        return pow_mod(n,k-1,m)*n % m;
    } else {
        long long t = pow_mod(n,k/2,m);
        return t*t % m;
    }
}

const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_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 || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int par[100010],dep[100010];
void init(int N){
    for(int i = 0; i < N; i++){
        par[i] = i;
        dep[i] = 0;
    }
}

int find(int x){
    if (x == par[x]) return x;
    return par[x] = find(par[x]);
}

void merge(int a,int b){
    a = find(a);
    b = find(b);
    if (dep[a] > dep[b]){
        par[b] = a;
        dep[a] += b;
    } else {
        par[a] = b;
        dep[b] += a;
    }
}


int main(){
    string s; cin >> s;
    int a[3] = {0};
    for(int i = 0; i < s.size(); i++){
        a[s[i] - 'a']++;
    }
    if (abs( max(a[0],max(a[1],a[2])) - min(a[0],min(a[1],a[2])) ) < 2){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


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

int main(int argc, const char * argv[]) {
    string S;
    int counts[26] = {0};
    
    cin >> S;
    for (int i = 0; i < S.length(); i++) {
        counts[S[i] - 'a']++;
    }
    
    char a = ' ';
    for (int i = 0; i < 26; i++) {
        if (counts[i] == 0) {
            a = 'a' + i;
            break;
        }
    }
    
    if (a == ' ') cout << "None" << endl;
    else cout << a << endl;
    
    return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, m, a[100000], s[100000], v, w;

void p() {
	inc(i, m) { cout << s[i] << " "; } cout << endl;
}

int main() {
	cin >> n >> m;
	inc(i, n) { cin >> a[i]; a[i]--; }
	
	inc(i, n - 1) {
		int d = (m + a[i + 1] - a[i]) % m;
		if(d < 2) { continue; }
		int x = (a[i + 0] + 2) % m;
		int y = (a[i + 1] + 1) % m;
		int z = (a[i + 1] + 2) % m;
		
		s[x] += 1;
		s[y] -= d;
		s[z] += d - 1;
		
		if(x > a[i + 1]) { v += m - x + 1; w++; }
		else if(x == 0) { v++; w++; }
		if(y == 0) { w -= (d - 1); }
	}
	
	// p();
	
	s[0] = w;
	inc(i, m - 1) { s[i + 1] += s[i]; }
	// p();
	s[0] = v;
	inc(i, m - 1) { s[i + 1] += s[i]; }
	// p();
	
	LL ans = 0;
	inc(i, n - 1) { ans += (a[i] < a[i + 1] ? a[i + 1] - a[i] : m - a[i] + a[i + 1]); }
	
	LL ma = 0;
	inc(i, n) { setmax(ma, s[ a[i] ]); }
	ans -= ma;
	
	cout << ans << endl;
	
	return 0;
}


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

using namespace std;

// built-in function version
int main() {
    int K;
    cin >> K;

    int sum = 0;
    for (int a = 1; a <= K; a++) {
        for (int b = 1; b <= K; b++) {
            for (int c = 1; c <= K; c++) {
                sum += gcd(gcd(a, b), c);
            }
        }
    }

    cout << sum << endl;

    return 0;
}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'

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


using vvll = vector< vector<ll> >;
using vll = vector<ll> ;

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;


void pre(){


}



void solve(){

    ll n;
    cin >> n;
    ll a[n+1];
    ll b[n+1];
    for(ll i=1;i<=n;i++)
        cin >> a[i] >> b[i];
    sort(a+1,a+n+1);
    sort(b+1,b+n+1);
    ll x,y;
    if(n%2){
        ll ind = (n+1)/2;
        x = a[ind];
        y = b[ind];
    }else{
        ll ind = (n+1)/2;
        x = a[ind] + a[ind+1];
        y = b[ind] + b[ind+1];
    }
    cout << y -  x  + 1;

}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 6772