akhauriyash/Code-Regression huggingface dataset:
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

int main() {
    string s, t;
    cin >> s >> t;
    ll a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if (s == u) {
        a--;
    } else {
        b--;
    }
    cout << a << " " << b << endl;
}


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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()

using ll = std::int64_t;
using vint = std::vector<int>;
using pint = std::pair<int, int>;

constexpr std::int32_t INF = 1001001001;

void Main() {
    int m, d;
    cin >> m >> d;
    int ans = 0;
    for (int i = 1; i <= m; ++i) {
        for (int j = 1; j <= d; ++j) {
            if (j / 10 >= 2 && j % 10 >= 2 && (j / 10) * (j % 10) == i) {
                ++ans;
            }
        }
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
const ll MAX = 1e15 + 1;
int main() {
  int N;
  cin >> N;
  int r = N % 1000;
  if(r == 0){
    cout << 0 << endl;
  }
  else{
    cout << 1000-r << endl;
  }
  return 0;
}



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

#define rep(i, n) for (int i = 0; i < (int) (n); i++)
typedef long long ll;


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

    int a, b;

    cin >> a;
    cin >> b;

    if (a - 2 * b >= 0) { cout << a - 2 * b << endl; }
    else { cout << "0" << endl; }

    return 0;
}


Measured memory_bytes: 256
#50b
#n　問題数
n = int(input())
#t 時間
t = [int(i) for i in input().split()]
#m ドリンクの種類
m = int(input())
ans = []

for i in range(m):
    a,b = map(int,input().split())
    temp = sum(t) - t[a-1] + b
    ans.append(temp)

for i in range(m):
    print(ans[i])

Measured memory_bytes: 3064
//#include "stdc++.h"
#include<bits/stdc++.h>
#include<iostream>
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))
#define sz(x) (int)(x.size())
#define ff first
#define ss second
#define endl "\n"
#define int long long int
inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p*p)%m;if(n%2) return (p*a)%m;else return p;}
const ll MOD = 1000000007;
const ll MOD1=1000000009;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
/*
 shuffle(x,x+n,rng) // shuffling elements of x in random order
 */

int32_t main()
{
    IOS;
    int n;
    cin>>n;
    int ans=n*n;
    ans=ans*n;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int gen[1001][1001];

int main(void)
{
	int n,m,i,j,hiro,min,x,y,gou;
	int c[1001],d[1001];
	min=2100000000;
	scanf("%d %d",&n,&m);
	for(i=0;i<=m;i++){
		for(j=0;j<=n;j++){
			gen[i][j]=2100000000;
		}
	}
	for(i=0;i<n;i++){
		scanf("%d",&d[i]);
	}
	for(i=0;i<m;i++){
		scanf("%d",&c[i]);
	}
	gen[0][0]=0;
	for(i=0;i<m;i++){
		for(j=0;j<=n;j++){
			hiro=c[i]*d[j];
			if(gen[i+1][j]>gen[i][j]){
				gen[i+1][j]=gen[i][j];
			}
			if(gen[i+1][j+1]>gen[i][j]+hiro && j<n){
				gen[i+1][j+1]=gen[i][j]+hiro;
			}
		}
	}
	/*for(i=0;i<=m;i++)	{
		for(j=0;j<=n;j++)	{
			printf("%8d ",gen[i][j]);
		}
		printf("\n");
	}*/
	printf("%d\n",gen[m][n]);
	return 0;
}

Measured memory_bytes: 4944
#include <iostream>
#include <sstream>
#include <cmath>

int main()
{
  unsigned int a, b;
  std::cin >> a >> b;
  std::stringstream ss;
  ss << a << b;
  unsigned int x2 = std::stoi(ss.str());
  float x_f = std::sqrt(x2);
  unsigned int x_i = (unsigned) x_f;
  std::cout << ((x_i*x_i == x2) ? "Yes" : "No") << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<int,int> P;
const int INF=1e9;
int main(){
    int n,now=1,ans=0;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    for(int i=0;i<n;i++){
        if(a[i]==now){
            now++;
        }
        else ans++;
    }
    if(ans==n) cout<<"-1";
    else cout<<ans;
}

Measured memory_bytes: 4020
#include <bits/stdc++.h>
#define ff(i, a, b) for(int i = (a), _b = (b); i <= _b; i++)
#define fb(i, a, b) for(int i = (a), _b = (b); i >= _b; i--)
#define pb push_back

typedef long long ll;
using namespace std;
typedef vector <int> vi;

int N;
int a[100005], b[100005];

int main(void) {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N;
    ff(i, 1, N) cin >> a[i] >> b[i], a[i] %= b[i];
    ff(i, 1, N) if (a[i]) a[i] = b[i] - a[i];
    ll need = a[N];
    fb(i, N - 1, 1) need = (need - a[i] + b[i] - 1) / b[i] * b[i] + a[i];
    cout << need << endl;
    return 0;
}


Measured memory_bytes: 1024
N = int(input())
P = list(map(int, input().split()))

count = 0
for i, p in enumerate(P):

    # if i == 0:
    #     continue
    if i+1 != P[i]:
        count += 1

    if count > 2:
        break

if count > 2:
    print('NO')

else:
    print('YES')


Measured memory_bytes: 2940
a = [True for i in range(1000000)]
i = 3
while i * i < 1000000:
    for j in range(3 * i, 1000000, 2 * i): a[j] = False
    i += 2

while True:
    try:
        n = int(input())
    except:
        break

    count = int(n >= 2) + sum(a[i] for i in range(3, n + 1, 2))
    print(count)

Measured memory_bytes: 14528
#include<stdio.h>

int main(){
    int N,M;
    int a[100+1] = {0};
    int all=0;
    int i,j,tmp;

    scanf("%d %d", &N, &M);

    for( i = 1; i <= N; i++ ){
        scanf("%d", &a[i]);
        all += a[i];
    }

    for( i = 1; i <= N-1; i++ ){
        for( j = i+1; j <= N; j++ ){
            if( a[i] < a[j] ){
                tmp = a[i];
                a[i] = a[j];
                a[j] = tmp;
            }
        }
    }

/*    for(i=1;i<=N;i++){
        printf("%d ", a[i]);
    }
    printf("\n");
*/

    if( a[M]*4*M >= all ) printf("Yes\n");
    else printf("No\n");

    return 0;
}




Measured memory_bytes: 256
use std::io;
use std::io::prelude::*;

fn main() {
    let stdin = io::stdin();
    let mut vec = Vec::new();
    for line in stdin.lock().lines() {
        vec.push(line.unwrap())
    }

    let n: usize = vec[0].parse().unwrap();
    let s = &vec[1];

    if n % 2 != 0 {
        println!("No");
        return
    }

    let m = n / 2;

    let former = &s[..m];
    let latter = &s[m..];
        
    if former == latter {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <cstdio>
#include <algorithm>
#define inf 0x7fffffff
using namespace std;
int n, k, ans;
int main() {
	scanf("%d%d", &n, &k);
	ans = 1;
	for(int i = 1; i <= n; i++) {
		if(ans * 2 > ans + k) ans +=k;
		else ans *= 2;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 128
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}


fn f(d1: &Vec<i32>, d2:&Vec<i32>) -> bool{

    for i in 0..d1.len() {
        
    }


    return true;
}

use std::iter::Iterator;
use std::cmp;


fn main() {
    input! {
        n: usize,
        d: usize,
        x: [[i64; d]; n],
    }

    let  mut cnt  = 0;
    for i in 0..n {
        for j in 0..n {
            if i != j {
                let mut sum   = 0;
                for k in  0..d {
                    sum+=(x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
                }
                if f64::sqrt(sum as f64) == f64::sqrt(sum as f64) as i64 as f64{
                    cnt+=1;
                }
            }
        }
    }
    println!("{}", cnt / 2);

}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
using namespace std;
 
int main()
{
    const int N = 1000000;
    vector<bool> vec(N, true);
    int limit = 1000;
    for (int i = 2; i < limit; i++){
        for (int j = 2; i * j < N; j++){
            vec[i * j] = false;
        }
    }
    int n, cnt = 0;
    while (cin >> n){
        for (int i = 2; i <= n; i++){
            if (vec[i])cnt++;
        }
        cout << cnt << endl;
        cnt = 0;
    }
}

Measured memory_bytes: 1316
#include<bits/stdc++.h>
using namespace std;
using Int = signed;
using ll = long long;
signed main(){  
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  Int n,m;
  cin>>n>>m;

  m++;
  vector<Int> a(m),b(m);
  for(Int i=0;i<m;i++) cin>>a[i];
  for(Int i=1;i<m;i++) cin>>b[i];

  vector<ll> hs;
  function<void(Int, Int)> predfs=[&](Int l,Int r){
    Int x=lower_bound(a.begin(),a.end(),r)-a.begin();
    if(a[x-1]<=l&&r<=a[x]) return;
    
    hs.emplace_back(((ll)l<<31)|r);
    Int m=(l+r)>>1;
    predfs(l,m);
    predfs(m,r);
  };

  predfs(0,(1<<n));
  sort(hs.begin(),hs.end());
  hs.erase(unique(hs.begin(),hs.end()),hs.end());
  map<ll, Int> idx;
  for(Int i=0;i<(Int)hs.size();i++) idx[hs[i]]=i;
  //cout<<hs.size()<<endl;
  
  vector<vector<Int> > dp(n+1,vector<Int>(hs.size(),-1));
  
  function<Int(Int, Int, Int, Int)> dfs=[&](Int l,Int r,Int d,Int k)->Int{
    //cout<<l<<" "<<r<<" "<<d<<" "<<k<<endl;
    Int x=lower_bound(a.begin(),a.end(),r)-a.begin();
    if(a[x-1]<=l&&r<=a[x]){
      Int v=b[x],tmp=0;
      tmp+=(k==v);
      tmp+=(r-l)>>(n-v+1);
      return tmp;
    }

    if(~dp[k][idx[((ll)l<<31)|r]]) return dp[k][idx[((ll)l<<31)|r]];
    Int &res=(dp[k][idx[((ll)l<<31)|r]]=0);
    
    Int m=(l+r)>>1;
    res=max(res,dfs(l,m,d+1,d)+dfs(m,r,d+1,k));
    res=max(res,dfs(l,m,d+1,k)+dfs(m,r,d+1,d));
    return res;
  };
  
  cout<<(1<<n)-dfs(0,1<<n,1,0)<<endl;
  return 0;
}



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

map<int, int> counter(const vector<int>& xs)
{
    map<int, int> counts;
    for (const int x : xs)
        counts[x]++;
    return counts;
}

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

    vector<int> a(N+1);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        a[N] ^= a[i];
    }

    vector<int> b(N+1);
    for (int i = 0; i < N; i++)
    {
        cin >> b[i];
        b[N] ^= b[i];
    }

    if (counter(a) != counter(b))
    {
        cout << -1 << endl;
        return 0;
    }

    int edges = 0;
    map<int, vector<int>> out_neighbors;
    for (int i = 0; i <= N; i++)
    {
        if (i < N && a[i] == b[i]) continue;
        edges++;
        out_neighbors[a[i]].push_back(b[i]);
    }

    set<int> seen;
    const function<void(int)> dfs = [&](const int v)
    {
        seen.insert(v);
        for (const int w : out_neighbors[v])
            if (!seen.count(w))
                dfs(w);
    };

    int components = 0;
    for (const auto kv : out_neighbors)
    {
        if (seen.count(kv.first)) continue;
        else components++;
        dfs(kv.first);
    }

    cout << edges + components - 2 << endl;
}


Measured memory_bytes: 24448
n,l=map(int,input().split())
ringo=[0]*n
ringoz=[0]*n
min=1000000000000000
mini=0
for i in range(n):
    ringo[i]+=i+l
    if ringo[i]<0:
        ringoz[i]=-ringo[i]
    else:
        ringoz[i]=ringo[i]
    if ringoz[i]<min:
        min=ringoz[i]
        mini=i
ringo.pop(mini)

print(sum(ringo))


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long int ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

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

void Main() {
  Cin(int, n);
  Cins(int, n, a);

  if (n <= 2) {
    cout << 1 << endl;
    return;
  }

  int ans = 1;
  bool up = a[0] < a[1];
  bool dn = a[0] > a[1];
  for (int i = 2; i < n; ++i) {
    if (a[i - 1] < a[i]) up = true;
    if (a[i - 1] > a[i]) dn = true;
    if (up && dn) {
      up = dn = false;
      ans++;
    }
  }
  cout << ans << endl;
}

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

int main()
{
    int n, l, ar[100];

    scanf("%d %d", &n, &l);

    for(int i=0; i<n; i++)
    {
        scanf("%d", &ar[i]);
    }

    sort(ar, ar+n);

    int sum = 0;

    for(int i=n-1; i>=(n-l); i--)
    {
        sum = sum + ar[i];
    }

    printf("%d\n", sum);

    return 0;
}

Measured memory_bytes: 3700
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int xmap[16005][4005];
int ymap[16005][4005];

int main() {
  string S;
  cin>>S;
  int N = S.size();
  int X, Y;
  cin>>X>>Y;
  X += 8000;
  Y += 8000;
  bool nowx = true;
  int go = 0;
  vector<int> xarr, yarr;
  for(int i=0;i<S.size();++i) {
    if(S[i]=='F') {
      go++;
    }
    else {
      if(nowx) {
        xarr.push_back(go);
        go = 0;
      }
      else {
        yarr.push_back(go);
        go = 0;
      }
      nowx ^= 1;
    }
  }
  if(go>0) {
    if(nowx) xarr.push_back(go);
    else yarr.push_back(go);
  }
  vector<int> sumx, sumy;
  for(int i=0;i<xarr.size();++i) {
    sumx.push_back(xarr[i]);
  }
  for(int i=0;i<yarr.size();++i) {
    sumy.push_back(yarr[i]);
  }
  for(int i=xarr.size()-2;i>=0;--i) {
    sumx[i] += sumx[i+1];
  }
  for(int i=yarr.size()-2;i>=0;--i) {
    sumy[i] += sumy[i+1];
  }
  sumx.push_back(0);
  sumy.push_back(0);
  if(xarr.size()==0) xmap[8000][0] = 1;
  else {
    xmap[xarr[0]+8000][0] = 1;
    for(int i=0;i<xarr.size()-1;++i) {
      for(int j=0;j<16005;++j) {
        if(xmap[j][i]==0) continue;
        if(abs(X-(j+xarr[i+1]))<=sumx[i+2]) {
          xmap[j+xarr[i+1]][i+1]++;
        }
        if(abs(X-(j-xarr[i+1]))<=sumx[i+2]) {
          xmap[j-xarr[i+1]][i+1]++;
        }
      }
    }
  }
  if(yarr.size()==0) ymap[8000][0] = 1;
  else {
    ymap[yarr[0]+8000][0] = 1;
    ymap[-yarr[0]+8000][0] = 1;
    for(int i=0;i<yarr.size()-1;++i) {
      for(int j=0;j<16005;++j) {
        if(ymap[j][i]==0) continue;
        if(abs(Y-(j+yarr[i+1]))<=sumy[i+2]) {
          ymap[j+yarr[i+1]][i+1]++;
        }
        if(abs(Y-(j-yarr[i+1]))<=sumy[i+2]) {
          ymap[j-yarr[i+1]][i+1]++;
        }
      }
    }
  }
  /**
  for(int i=7950;i<=8050;++i) {
    for(int j=0;j<xarr.size();++j) {
      cout<<xmap[i][j]<<" ";
    }
    cout<<endl;
  }
  **/
  if(xarr.size()==0) xarr.push_back(0);
  if(yarr.size()==0) yarr.push_back(0);
  if(xmap[X][xarr.size()-1]>0 && ymap[Y][yarr.size()-1]>0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

int main()
{
	string c1,c2;
	cin>>c1>>c2;
	
	if(c1[0]==c2[2]&&c1[1]==c2[1]&&c1[2]==c2[0]) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
    
    int N; string S; cin >> N >> S;
	ll ans = 0;
	vi R,G,B;
	rep(i,S.size()) {
		if(S[i] == 'R') R.pb(i);
		else if (S[i] == 'G') G.pb(i);
		else B.pb(i);
	}

	ans += R.size() * G.size() * B.size();
	rep(i,S.size()) {
		repk(j,i+1,S.size()) {
			if(2*j-i<S.size() and S[i] != S[j] and S[2*j-i] != S[i] and S[2*j-i] != S[j]) ans--;
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 3664
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <string.h>
using namespace std;

#define ISEQ(c) (c).begin(), (c).end()
typedef long long ll;

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) break;
    vector<int> v(n);
    for (int i = 0; i < n; i++)
      cin >> v[i];
    sort(v.begin(), v.end());
    int sum = 0;
    for (int i = 1; i < n-1; i++)
      sum += v[i];
    cout << sum/(n-2) << endl;
  }
}

Measured memory_bytes: 1212
n = gets.to_i
arr = %w[3 5 7]

arr.each do |e|
  arr << e + '3'
  arr << e + '5'
  arr << e + '7'
  break if e.size == 10
end

arr.reject! { |e| e.index('3').nil? || e.index('5').nil? || e.index('7').nil? }
arr.map!(&:to_i)

puts arr.bsearch_index { |e| n < e }

Measured memory_bytes: 11260
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=110,size=1<<20;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

char s[N][N];
int f[N][N],n,m;

int main() {
	qr(n); qr(m); memset(f,63,sizeof f);
	for(int i=1;i<=n;i++) scanf("%s",s[i]+1);
	f[1][1]=(s[1][1]=='#');
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=m;j++)
			f[i+1][j]=min(f[i+1][j],f[i][j]+(s[i][j]!=s[i+1][j])),
			f[i][j+1]=min(f[i][j+1],f[i][j]+(s[i][j]!=s[i][j+1]));
	}
	pr2(f[n][m]+1>>1);
	return 0;
}


Measured memory_bytes: 256
from sys import stdin
n = int(stdin.readline())
ans = [0] * (n+2)
a = [0] + map(int,stdin.readline().split())
b = []
for i in xrange(1,n+1):
    b.append((a[i],i))
b.sort()
b.reverse()
first = {}
co = {}
for x,y in b:
    if x not in first:
        first[x] = y
    else:
        first[x] = min(first[x],y)
first[0] = 0        
m = set(a)
for i in a:
    co[i] = co.get(i,0) + 1
m = list(m)
m.sort()
m.reverse()
l = len(m)
for i in xrange(l-1):
    cur = m[i]
    fir = co[cur]
    mi = first[cur]
    sec = m[i+1]
    ans[mi]+=(m[i]-m[i+1])*fir
    co[sec] += fir
    first[sec] = min(first[sec],first[cur])
for i in xrange(1,n+1):
    print ans[i]

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

N = int(input().rstrip())

town = []
for i in range(N):
    x,y = map(int, input().split())
    town.append(tuple([i,x,y]))


#1. x,y順にソートしてx→x+1, y→y+1の辺を追加する
edges = []
for xy in [1,2]:
    town.sort(key=lambda x: x[xy])
    
    for i in range(N-1):
        edges.append(tuple([town[i+1][xy] - town[i][xy],town[i+1][0], town[i][0]]))
        
#2. edgesをコスト順にソート
edges.sort(key=lambda x: x[0])

#3. N-1本の辺で全点がつながるまでuniteする
par = [i for i in range(N)]
rank = [0 for i in range(N)]

def find(x:int) -> int:
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
    
def unite(x:int, y:int) -> bool:
    # 同じ木に属しているならスルーする
    if find(x) == find(y):
        return False
    
    rootx = find(x)
    rooty = find(y)
    
    if rank[rootx] < rank[rooty]:
        par[rootx] = rooty
        
    else:
        par[rooty] = rootx
        if rank[rootx] == rank[rooty]:
            rank[rootx] += 1

    return True    
    
rem = N
ans = 0

for cost,nex,prev in edges:
    if find(nex) != find(prev):
        unite(nex,prev)
        ans += cost
        rem -= 1
        
    if rem == 1:
        break
    
print(ans)

Measured memory_bytes: 47712
#include<bits/stdc++.h>
#define int long long int  //comment for large arrays
#define pll pair<int,int>
#define dbl long double
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define eps 0.00000001
#define INF 10000000000000001
#define all(x) (x).begin(),(x).end()
#define LB(v,x) (lower_bound(all(v),x) - v.begin()) 
#define UB(v,x) (upper_bound(all(v),x) - v.begin())
#define size(x) (int)(x).size()
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define popb() pop_back()
#define popf() pop_front()
#define mp(x,y) make_pair((x),(y))
#define vec(dt) vector<dt>
#define vv(dt) vector<vector<dt>>
#define fastio(x) ios_base::sync_with_stdio(x); cin.tie(NULL)
#define init(v,s) memset(v,s,sizeof(v)) 
#define bug(x) cerr<<"LINE: "<<__LINE__<<" || click to see test details "<<#x<<" = "<<x<<endl
#define loop(i,s,n) for(int i=s;i<n;i++)
#define print(v) for(auto it:v) cout<<it<<" "; cout<<endl 
using namespace std;


int n,seg_tree[4*200001+1]; // using 1 based indexing

void build(int node,int tl,int tr,int dp[])
{
	if(tl==tr) seg_tree[node] = dp[tl];
	else
	{
		int tm = (tl + tr)>>1;
		build(2*node,tl,tm,dp);
		build(2*node + 1,tm+1,tr,dp);
		seg_tree[node] = max(seg_tree[2*node], seg_tree[2*node + 1]);
	}	
}

void update(int node,int tl,int tr,int pos,int value)
{
	if(tl==tr) seg_tree[node] = value;
	else 
	{
		int tm = (tl + tr)>>1;
		if(pos <= tm) update(2*node,tl,tm,pos,value);
		else update(2*node + 1,tm+1,tr,pos,value);
		seg_tree[node] = max(seg_tree[2*node], seg_tree[2*node + 1]);
	}
}

int query(int node,int tl,int tr,int l,int r)
{
	if(l>r) return 0;
	if(tl==l && tr==r) return seg_tree[node];
	int tm = (tl + tr)>>1;
	return max(query(2*node,tl,tm,l,min(r,tm)), query(2*node + 1,tm+1,tr,max(l,tm+1),r));
}



signed main()
{
	fastio(0);
	cin>>n;
	int h[n+1],a[n+1],dp[n+1];
	loop(i,1,n+1) cin>>h[i];
	loop(i,1,n+1) cin>>a[i];
	init(dp,0);
	build(1,1,n,dp);
	loop(i,1,n+1)
	{
		dp[h[i]] = query(1,1,n,1,h[i]-1) + a[i];
		update(1,1,n,h[i],dp[h[i]]);
	}
	cout<<seg_tree[1]<<endl;
	return 0;		
}

Measured memory_bytes: 11136
s = input()
l = len(s)
n = int(s)
ans = 0
for i in range(1,l+1):
  if i == l and i % 2 == 1:
    ans += n - (10**(i-1)) + 1
  elif i % 2 == 1:
    ans += ((10**i) - 1) - (10**(i-1)) + 1
print(ans)

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

int main(){
  int N,D,X;
  cin >> N >> D >> X;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  int64_t ans=X;
  for(int i=0;i<N;i++){
    for(int j=0;;j++){
      if(j*A.at(i)+1<=D){
        ans++;
      }else{
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<queue>
#include<stack>
#include<utility>
#include<vector>
using namespace std;

typedef long long lint;

int main(){
    int a, b;
    cin >> a >> b;
    if(max(a, b) > 8){
        cout << ":(" << endl;
    }else{
        cout << "Yay!" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int H,W;
char S[2002][2002];
int L[2002][2002];
int R[2002][2002];
int U[2002][2002];
int D[2002][2002];

int main(){
    cin>>H>>W;
    repn(i,H) repn(j,W) cin>>S[i][j];

    repn(i,H){
        repn(j,W){
            if(S[i][j]=='#') L[i][j]=0;
            else L[i][j]=L[i][j-1]+1;

            if(S[i][W-j+1]=='#') R[i][W-j+1]=0;
            else R[i][W-j+1]=R[i][W-j+2]+1;

            if(S[i][j]=='#') U[i][j]=0;
            else U[i][j]=U[i-1][j]+1;

            if(S[H-i+1][j]=='#') D[H-i+1][j]=0;
            else D[H-i+1][j]=D[H-i+2][j]+1;
        }
    }

    int ans=0;
    repn(i,H){
        repn(j,W){
            ans=max(ans,L[i][j]+R[i][j]+U[i][j]+D[i][j]-3); 
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 66816
/* be name khoda */

// #define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <vector>
#include <fstream>
#include <set>
#include <map>
using namespace std;

#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;

#define forifrom(i, s, n) for (ll i = s; i < n; ++i)
#define forirto(i, n, e) for (ll i = (n) - 1; i >= e; --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define debug(x) cout << #x << " -> " << (x) << endl
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl

const ll MOD = 1000000007;
const ll INF = 2000000000;
const long long BIG = 1446803456761533460LL;

#define XL (x << 1)
#define XR (XL | 1)
#define MD ((l + r) >> 1)
#define Add(a, b) a = ((a) + (b)) % MOD
#define Mul(a, b) a = (1LL * (a) * (b)) % MOD

// -----------------------------------------------------------------------

const ll maxn = 100010;

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    // ifstream cin(".in");

    ll n; cin >> n;
    cout << (1000 - (n % 1000)) % 1000 << '\n';

}


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

using namespace std;

int main(int argc, char const *argv[]) {
  string s;
  cin >> s;
  int ans = 0;
  for (size_t i = 1; i < s.size(); i++) {
    if (s[i-1]!=s[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm> // sort
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <set>
#include <utility>

using namespace std;

typedef long long int lli;
typedef pair<lli,lli> p_ii;

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define debug(x) cout << #x ": " << x << endl
int bug = 1;

vector<lli> arr;
vector<lli> pre;

int main(){
	IOS
	lli i;
	lli n, x;
	
	cin >> n >> x;
	arr.resize(n);
	pre.resize(n);
	for(i = 0; i < n; i++){
		cin >> arr[i];
	}

	pre[0] = arr[0];
	for(i = 1; i < n; i++){
		pre[i] = pre[i-1] + arr[i];
	}

	i = 0;
	lli di = 0, jump = 0;
	/*while(di <= x && i < n){
		jump++;
		di = di + arr[i];
		i++;
	}*/

	for(i = 0; i < n; i++){
		if(pre[i] > x){
			break;
		}
	}
	i--;
	
	jump = i+2;
	cout << jump << endl;

	return 0;
}


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

#define llong long long
#define inf 999999999
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef pair<P, int> PP;
typedef pair<PP, int> PPP;
typedef struct data{
	int now;
	int cost;
}data;
int nh[4] = {1, 0, -1, 0};
int nw[4] = {0, 1, 0, -1};





int main(){
	int n, time[100001][3];
	fn(*time, 100001 * 3, 0);
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> time[i][0] >> time[i][1] >> time[i][2];
	}
	bool check = false;
	for(int i = 0; i < n; i++){
		if(i == 0){
			int go = time[0][1] + time[0][2];
			if(time[i][0] == go || (go < time[i][0] && (time[i][0] - go) % 2 == 0)){
				continue;
			}else check = true;
		}else{
			int go = abs(time[i][1] - time[i-1][1]) + abs(time[i][2] - time[i-1][2]);
			int can = time[i][0] - time[i-1][0];
			if(can == go || (go < can && (can - go) % 2 == 0)){
				continue;
			}else check = true;
		}
	}

	if(check) cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数


int main()
{
  int n ;
  cin >> n ;
  int cnt = 0 ;
  ll h, w ;
  cin >> h >> w ;
  REP(i,n){
    ll a, b ;
    cin >> a >> b ;
    if(a>=h && b>=w){
      cnt++ ;
    }
  }
  
  cout << cnt <<endl ;
    


  return 0 ;
}




Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
//#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")

template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200010;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;

int cumV[2020][2020], cumH[2020][2020], cumW[2020][2020];
char A[2020][2020];
void solve() {
	int N, M, Q; cin >> N >> M >> Q;
	REP(i, N)REP(j, M) {
		cin >> A[i][j];
	}
	REP(i, N) {
		REP(j, M) {
			if (A[i][j]=='1')cumV[i + 1][j + 1]++;
			if (A[i][j] == '1' && A[i + 1][j] == '1')cumH[i + 1][j + 1]++;
			if (A[i][j] == '1' && A[i][j + 1] == '1')cumW[i + 1][j + 1]++;
		}
	}
	FOR(i,1, N + 1) {
		FOR(j,1, M + 1) {
			cumV[i][j] += cumV[i - 1][j] + cumV[i][j - 1] - cumV[i - 1][j - 1];
			cumH[i][j] += cumH[i - 1][j] + cumH[i][j - 1] - cumH[i - 1][j - 1];
			cumW[i][j] += cumW[i - 1][j] + cumW[i][j - 1] - cumW[i - 1][j - 1];
		}
	}
	while (Q--) {
		int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
		int res = 0;
		res += cumV[x2][y2] + cumV[x1 - 1][y1 - 1] - cumV[x2][y1 - 1] - cumV[x1 - 1][y2];
		res -= cumH[x2-1][y2] + cumH[x1 - 1][y1 - 1] - cumH[x2-1][y1 - 1] - cumH[x1 - 1][y2];
		res -= cumW[x2][y2-1] + cumW[x1 - 1][y1 - 1] - cumW[x2][y1 - 1] - cumW[x1 - 1][y2-1];
		print(res);
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// int q;cin>>q;
	// while(q--)
	//test();
	solve();
}




Measured memory_bytes: 53504
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
 
int main() {
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	cout <<s1.at(0)<<s2.at(0)<<s3.at(0)<< endl;
}


Measured memory_bytes: 3644
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"5 3 3
1 2 4"# => r#"1"#,

r#"7 3 2
4 5 6"# => r#"0"#,

r#"10 7 5
1 2 3 4 6 8 9"# => r#"3"#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize, m: usize, x: usize,
        a: [usize; m],
    }

    let mut mass = vec![0; n + 1];

    for i in x + 1..n + 1 {
        // println!("{}", i);
        for j in 0..m {
            if i == a[j] {
                mass[i] = 1;
                break;
            }
        }
        mass[i] += mass[i - 1];
    }

    for i in (0..x).rev() {
        // println!("{}", i);
        for j in 0..m {
            if i == a[j] {
                mass[i] = 1;
                break;
            }
        }
        mass[i] += mass[i + 1];
    }
    // println!("{:?}", mass);

    std::cmp::min(mass[0], mass[n]).to_string()
}

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

using namespace std;

const int N=200000;

int n,dp[N+5],ma=0;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        dp[x]=dp[x-1]+1;
        ma=max(ma,dp[x]);
    }
    cout<<n-ma<<"\n";
    return 0;
}
/**



**/


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

int main(){
  int N,A[102];
  int i,j,mini,t,cnt=0;

  cin >> N;
  for (i=0;i<N;i++)cin >> A[i];

  for (i=0;i<N;i++){
    mini=i;
    for (j=i;j<N;j++){
      if (A[mini]>A[j])mini=j;
    }
    if (i!=mini){
      t=A[i];
      A[i]=A[mini];
      A[mini]=t;
      cnt++;
    }
  }

  for (i=0;i<N-1;i++)
    cout << A[i] << " ";

  cout << A[i] << endl;
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 3072
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; }                            /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; }                            /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { return *(char *)a - *(char *)b; }                     /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) { return strcmp(*(const char **)a, *(const char **)b); } /* aaa,aab.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define rep(i, n) for (int i = 0; i < n; i++)
#define MAX 105
#define MOD 1000000007

typedef long long int lli;

int main(void)
{
  char s[MAX];
  lli k;

  scanf("%s", s);
  scanf("%lld", &k);

  int chars = strlen(s);
  int count = 0;
  int judge = 1;
  rep(i, chars - 1)
  {
    if (s[i] != s[i + 1])
    {
      judge = 0;
      break;
    }
  }
  if (judge == 1)
  {
    printf("%lld\n", chars * k / 2);
    return 0;
  }
  int ci;
  for (ci = 1; ci < chars; ci++)
  {
    if (s[ci - 1] != s[ci])
      continue;
    count++;
    ci++;
  }
  lli ans = k * count;
  for (judge = 1; judge < chars; judge++)
  {
    if (s[judge] != s[judge - 1])
      break;
  }
  if (judge % 2 == 1 && ci == chars && s[0] == s[chars - 1])
    ans += k - 1;
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 128
while True:

    s = input()

    if s == "#":
        break

    index = -1

    bits = []

    for i in range(2<<11):
        bit = []
        for j in range(11):
            bit.append(i >> j & 1 == 1)
        bits.append(bit)
        

    def formula(string):
        global index
        index += 1
        if string[index] == "T":
            return True
        elif string[index] == "F":
            return False
        elif string[index] == "-":
            return not formula(string)
        elif string[index] == "(":
            left = formula(string)
            index += 1
            ope = string[index]
            if ope == "-":
                index += 1
            right = formula(string)
            index += 1
            if ope == "+":
                return left or right
            elif ope == "*":
                return left and right
            else:

                return False if left and not right else True
        else:
            return bit[ord(string[index]) - ord("a")]
    
    f = True
    for bit in bits:
        l,r = s.split("=")

        index = -1 
        l_b = formula(l)
        index = -1
        r_b = formula(r)

        if l_b != r_b:
            f = False
    
    if f:
        print("YES")
    else:
        print("NO")

    # l,r = s.split("=")
    # l_b = formula()


Measured memory_bytes: 7168
#include "bits/stdc++.h"
using namespace std;
using Graph = vector<vector<int>>;

vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true;

    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue;
        dfs(G, next_v);
    }
}

int main() {
    int N, M; cin >> N >> M;

    vector<int> A(M), B(M);
    for (int i = 0; i < M; i++) {
        cin >> A[i] >> B[i];
        A[i]--, B[i]--;
    }

    int ans = 0;
    for (int i = 0; i < M; i++) {
        Graph G(N);
        int count = 0;
        for (int j = 0; j < M; j++) {
            if (i == j) continue;
            else {
                G[A[j]].push_back(B[j]);
                G[B[j]].push_back(A[j]);
            }
        }
        seen.assign(N, false);
        for (int v = 0; v < N; v++) {
            if (seen[v]) continue;
            dfs(G, v);
            count++;
        }
        if (count > 1) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
fun main(arr:Array<String>) {
    val n = readLine()!!.toInt()
    val blue = (0 until n).map { readLine()!! }
    val m = readLine()!!.toInt()
    val red = (0 until m).map { readLine()!! }

    val ans = blue.toSet().map { a-> blue.count { a == it } - red.count{ a == it } }.max()!!
    println(Math.max(ans, 0))
}

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

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

const int MAXN=50;

int n;
ll a[MAXN];

bool ok(ll K) {
	ll need=0;
	REP(i,n) {
		// a[i]-x*N+(K-x)<=N-1 -> x>=(a[i]+K-(N-1))/(N+1)
		ll x=(a[i]+K-(n-1)+n)/(n+1);
		need+=x;
	}
	return need<=K;
}

void run() {
	scanf("%d",&n); REP(i,n) scanf("%lld",&a[i]);
	ll ret=LLONG_MAX;
	REPE(off,n) {
		ll l=-1,h=(ll)100000001*100000000;
		while(l+1<h) { 
			ll m=l+(h-l)/2; 
			if(ok(m*(n+1)+off)) h=m; else l=m;
		}
		ll cur=h*(n+1)+off;
		//printf("%d: %lld\n",off,cur);
		ret=min(ret,cur);
	}
	printf("%lld\n",ret);
}

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


Measured memory_bytes: 256
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

setrecursionlimit(1000000)
INF = 10**10

(H, W, D) = reads()
L = W * H

inv = [None] * L


for j in range(H):
    A = reads()
    for i in range(W):
        inv[A[i]-1] = (i, j)

psum = [0] * L

def dist(p, q):
    (x, y) = p
    (z, w) = q
    return abs(y-w) + abs(z-x)

for i in range(D, L):
    psum[i] = psum[i-D] + dist(inv[i], inv[i-D])

# print(psum, file=stderr)

Q = read()

for i in range(Q):
    (L, R) = reads()
    print(psum[R-1] - psum[L-1])


Measured memory_bytes: 14824
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <deque>
#include <map>
#include <set>
#include <complex>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>

#define ft first
#define sc second
#define pb push_back
#define len(v) (int)v.size()
#define int ll

using namespace std;
typedef long long ll;
typedef long double ld;

int inf = 1e16;

vector<int> tree;
int N = 1;

void upd(int v) {
	if(v == 0) 
		return;
	tree[v] = min(tree[v * 2], tree[v * 2 + 1]);
	upd(v / 2);
}

int get(int v, int l, int r, int vl, int vr) {
	if(vr <= l || r <= vl)
		return inf;
	if(vl <= l && r <= vr) {
		return tree[v];
	}
	int m = (l + r) / 2;
	return min(get(v * 2, l, m, vl, vr), get(v * 2 + 1, m, r, vl, vr));
}

signed main() {
	#ifdef PC
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif	

	int n, k, e;
	cin >> n >> e >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++) 
		cin >> a[i];

	while(N < (n + 2)) 
		N *= 2;

	tree = vector<int> (2 * N, inf);
	vector<int> suf(n + 1, inf);
	suf[n - 1] = k;
	int uk = n - 2;
	tree[N + (n - 2)] = k + a[n - 1] + suf[n - 1];
	upd((N + (n - 2)) / 2);

	for (int i = n - 2; i >= 0; i--) {

		while(uk > 0 && 2 * (a[uk] - a[i]) >= k) {
			tree[N + uk] = 2 * a[uk] + a[uk + 1] + suf[uk + 1];
			upd((N + uk) / 2);
			uk--;
		}
		int ans = max(k, 2 * (a[n - 1] - a[i])) + (a[n - 1] - a[i]);
		int l = uk;
		// cout << ans << " " << i << " " << l << " " << get(1, 0, N, i, l + 1) << " " << uk << endl;
		ans = min(ans, get(1, 0, N, i, l + 1) - a[i]);
		if(l + 1 < n - 1) {
			ans = min(ans, get(1, 0, N, l + 1, n - 1) - 3LL * a[i]);
		}
		suf[i] = ans;
		if(i != 0) {
			tree[N + (i - 1)] = k + a[i] + suf[i];
			upd((N + (i - 1)) / 2);
		}
		// cout << i << " " << suf[i] << endl;
	}
	cout << a[0] + suf[0] + (e - a[n - 1]) << endl;
	return 0;
}

// j

// 

Measured memory_bytes: 3968