akhauriyash/Code-Regression huggingface dataset:
use std::cmp;
const INF: u32 = 1e9 as u32;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };

    let h: usize = sc.read();
    let w: usize = sc.read();
    let board: Vec<Vec<char>> = (0..h).map(|_| sc.chars()).collect();
    let rotated: Vec<Vec<char>> = (0..w)
        .map(|i| (0..h).map(|j| board[j][i]).collect())
        .collect();

    let mut ans = 0;
    for i in 1..w {
        ans += solve(&rotated[i - 1], &rotated[i]);
    }
    println!("{}", ans);
}

fn solve<T: PartialEq>(a: &[T], b: &[T]) -> u32 {
    let n = a.len();
    let mut cost = vec![vec![0; n + 1]; n + 1];
    for removed in 0..n {
        cost[0][removed] = (0..(n - removed))
            .filter(|&i| a[i + removed] == b[i])
            .count() as u32;
        cost[removed][0] = (0..(n - removed))
            .filter(|&i| a[i] == b[i + removed])
            .count() as u32;
    }

    for i in 0..n {
        for j in 0..n {
            cost[i + 1][j + 1] = cost[i][j] - if a[n - 1 - i] == b[n - 1 - j] { 1 } else { 0 };
        }
    }

    let mut dp = vec![vec![INF; n + 1]; n + 1];
    dp[0][0] = 0;
    for i in 0..(n + 1) {
        for j in 0..(n + 1) {
            if i + 1 <= n {
                dp[i + 1][j] = cmp::min(dp[i + 1][j], dp[i][j] + cost[i][j]);
            }
            if j + 1 <= n {
                dp[i][j + 1] = cmp::min(dp[i][j + 1], dp[i][j] + cost[i][j]);
            }
        }
    }
    dp[n][n]
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
N , D = (map(int , input().split()))
sc = [list(map(int, input().split())) for i in range(N)]
a_list = []
for i in range(len(sc)):
    for j in range(i+1,len(sc)):
        t = 0
        for k in range(D):
            t += ((sc[i][k] - sc[j][k])**2)
        a_list.append(t)
ans = 0
for i in a_list:
    for j in range(i+1):
        if j**2 == i:
            ans += 1
            break
print(ans)

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

using namespace std;

#define endl '\n'

int h,w,k;
vector <string> grid;
bool check(int r,int c){
  int cnt = 0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if(r & (1 << i) || c & (1 << j))
          continue;
        if(grid[i][j] == '#')
          cnt++;
      }
    }
    return cnt == k;
}

int main(){

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

  cin >> h >> w >> k;

  grid.resize(h);

  for(int i=0;i<h;i++)
    cin >> grid[i];
 
  int ans  =0;
  for(int r=0;r<(1<<h);r++){
    for(int c=0;c<(1<<w);c++){
      if(check(r,c))
        ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


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

#define db long double
const db eps = 0;
int sgn(db a, db b = 0) {
	a -= b;
	return (a > eps) - (a < -eps);
}

struct poi {
	db x, y;
	void r() { cin >> x; cin >> y; }
	void w() { cout << x << ' ' << y << '\n'; }
	poi operator -(poi p) {
		return {x - p.x, y - p.y};
	}
	poi operator +(poi p) {
		return {x + p.x, y + p.y};
	}
	poi operator *(db d) {
		return {x * d, y * d};
	}
	poi operator /(db d) {
		return {x / d, y / d};
	}
	bool operator ==(poi p) {
		return !sgn(x, p.x) && !sgn(y, p.y);
	}
	db dot(poi p) {
		return x * p.x + y * p.y;
	}
	db cross(poi p) {
		return x * p.y - y * p.x;
	}
	db len() { return sqrt(x * x + y * y); }
	db len2() { return x * x + y * y; }
	poi proj(poi p, poi q) {
		db s = (*this - p).dot(q - p) / (q - p).len2();
		return p + (q - p) * s;
	}
	db dis(poi p, poi q) {
		if((*this - p).dot(q - p) < 0) return (*this - p).len();
		if((*this - q).dot(p - q) < 0) return (*this - q).len();
		return abs((*this - p).cross(q - p) / (q - p).len());
	}
};
db xmul(poi a, poi b, poi c) {
	return (b - a).cross(c - a);
}

int ccw(poi a, poi b, poi c) {
	poi u = b - a, v = c - a;
	if(u.cross(v) > 0) return 1;
	if(u.cross(v) < 0) return -1;
	if(u.dot(v) < 0) return -2;
	if(u.len2() < v.len2()) return 2;
	return 0;
}
bool si(poi a, poi b, poi c, poi d) {
	return ccw(a, b, c) * ccw(a, b, d) <= 0 &&
		ccw(c, d, a) * ccw(c, d, b) <= 0;
}
poi li(poi a, poi b, poi c, poi d) {
	db u = xmul(c, d, a), v = xmul(c, d, b);
	return (a * v - b * u) / (v - u);
}

const int N = 111;
poi p[N];

int main() {
	cout << fixed << setprecision(12);
	ios :: sync_with_stdio(false);
	int n; cin >> n;
	for(int i = 0; i < n; i ++)
		p[i].r();
	p[n] = p[0];
	int T; cin >> T;
	while(T --) {
		poi t; t.r(); poi s = poi{100007, 100009} + t;
		bool on = false;
		int inter = 0;
		for(int i = 0; i < n; i ++) {
			if(!ccw(p[i], p[i + 1], t))
				on = true;
			if(si(s, t, p[i], p[i + 1])) {
				inter ++;
				//p[i].w(); p[i + 1].w();
			}
		}
		if(on) cout << "1\n";
		else if(inter & 1) cout << "2\n";
		else cout << "0\n";
	}

	return 0;
}

Measured memory_bytes: 3288
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    N = int(input())
    H = [0] + input_nums()
    maxh = H[0]
    cnt = 0
    for i in range(1, N+1):
        if maxh <= H[i]:
            maxh = H[i]
            cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()


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

int main(){
    int A,B;
    cin >> A >> B;
    int ans = A, out = 0;
    for (int i = 1; i < 1000; i++){
        if (ans >= B){
            out = i;
            break;
        }
        ans = ans + A - 1;
    }
    if (B == 1)cout << 0 << endl;
    else cout << out << endl;
}

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

struct shop{
	string name;
	int p;
	int ID;
};
int main(){
	int n;	cin>>n;
	shop a[n];
	for(int i=0;i<n;i++){
		cin>>a[i].name>>a[i].p;
		a[i].ID=i+1;
	}

	for(int i=0;i<n;i++){
		int minj=i;
		for(int j=i;j<n;j++){
			if(a[minj].name<a[j].name)minj=j;	//辞書順とっぷ文字列
		}
		while(minj>0){
			swap(a[minj],a[minj-1]);
			minj--;
		}
	}
	for(int i=0;i<n;i++){
		int minj=i;
		for(int j=i;j<n;j++){
			if(a[minj].name==a[j].name&&a[minj].p<a[j].p)minj=j;	//辞書順とっぷ文字列
		}
		while(minj>i){
			swap(a[minj],a[minj-1]);
			minj--;
		}
	}

	for(int i=0;i<n;i++){
		cout<<a[i].ID<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
m,n=map(int,input().split())
a =[]
for _ in range(m):
    a.append(list(map(int,input().split())))
for index in range(m):
    a[index].append(sum(a[index]))
for a_column in a:
    for num in a_column[:-1]:
        print(num, end=' ')
    print(a_column[-1])
for row_index in range(n):
    sum = 0
    for a_column in a:
        sum += a_column[row_index]
    print(sum, end=' ')
sum = 0
for a_column in a:
    sum += a_column[-1]
print(sum)



Measured memory_bytes: 6228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7,INF=mod*mod*3;//M_PI
#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

ll N;
ll u,v;
ll ans;
vector<ll> vec[100005];
ll parent[100005];
bool leaf[100005]; //falseなら葉
void tree(ll par,ll n){
    if(parent[n]!=0)  return;
    parent[n]=par;
    for(auto &i:vec[n]) tree(n,i);
    return;
}
ll Adis[100005];
ll Tdis[100005];
void Adfs(ll n,ll dis){
    if(Adis[n]!=-1) return;
    Adis[n]=dis;
    for(auto&i:vec[n]) Adfs(i,dis+1);
    return;
}
void Tdfs(ll n,ll dis){
    if(Tdis[n]!=-1) return;
    Tdis[n]=dis;
    for(auto&i:vec[n]) Tdfs(i,dis+1);
    return;
}
int main(){

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

cin>>N>>u>>v;
rep(i,N-1){
    ll a,b;
    cin>>a>>b;
    vec[a].pb(b);
    vec[b].pb(a);
}
tree(-1,v);
rep1(i,N+1){
    ll n=parent[i];
    if(n!=-1) leaf[n]=true;
}
fill(Adis+1,Adis+N+1,-1);
fill(Tdis+1,Tdis+N+1,-1);
Adfs(v,0);
Tdfs(u,0);
rep1(i,N+1){
    if(!leaf[i]){
        if(Tdis[i]<Adis[i]) ans=max(ans,Adis[i]);
    }
}
cout<<ans-1<<endl;

}
    


Measured memory_bytes: 10880
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,flag=-1, cnt=0,a,b;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>a>>b;
        if(a==b)
        {
            cnt++;
            if(cnt==3)
            {
                flag=1;
            }
        }
        if(cnt==3)
        {
            flag=1;
        }
        else if(a!=b)
        {
            cnt = 0;
        }
    }
    if(flag==1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


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

using namespace std;

using int64 = long long;

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

  int a, b;
  cin >> a >> b;
  if (b == 1) {
    cout << 0 << endl;
    return 0;
  }
  int count = 1;
  int current = a;
  while (current < b) {
    count++;
    current += a - 1;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int ans = 0;
  if(n < 1000){
    ans = 1000 - n;
  }
  else if(n%1000 == 0){
    ans = 0;
  }
  else{
    int a;
   a = n/1000;
    ans = (a+1)*1000 - n; 
  }
  cout << ans << endl;
}


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

long long MOD=1000000007;

int main() {
	// your code goes here
	int n;
	cin >> n;
	long long a,b,c;
	int j;
	c = 0;a = 1;
	cin >> j;
	for(int i = 1;i < n;i++){
		if(j < (i-c)*2-1){
			a *= i-c;
			a %= MOD;
			c++;
		}
		cin >> j;
	}
	for(int i = n-c;i > 0;i--){
		a *= i;
		a %= MOD;
	}
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
-- end of templete

f arr 0 = 1
f arr k = wl + wr
  where
    (ll, lr, kl, kr) = arr!k
    fl = f arr kl
    fr = f arr kr
    lgcd = gcd ll lr
    rl = ll `div` lgcd
    rr = lr `div` lgcd
    wb = lcm (fl * rl) (fr * rr)
    wl = wb `div` rl
    wr = wb `div` rr

findRoot n xs = fst $ head $ dropWhile (uncurry (==)) $ zip [1..n] $ xs ++ [-1]

main = do
    n <- getInt
    when (n/=0) $ do
        ds <- map (apply4 (,,,)) <$> replicateM n getInts
        let arr = listArray (1,n) ds :: Array Int (Int,Int,Int,Int)
        let notRoot = sort $ [x | (_,_,x,_) <- ds, x/=0] ++ [y | (_,_,_,y) <- ds, y/=0]
        print $ f arr $ findRoot n notRoot
        main

Measured memory_bytes: 4460
#include <bits/stdc++.h>
using namespace std;
#define fu(i, a, b) for(int i = a, I = (b) + 1; i < I; ++i)
#define fd(i, a, b) for(int i = a, I = (b) - 1; i > I; --i)
template <class T> inline void rd(T &x) {
    x = 0; T f = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9') f = ch == '-' ? -1 : 1, ch = getchar();
    while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
    x *= f;
} 
typedef long long ll;

const int N = 100005;
int n, q, tp;
ll x, a[N], f[N], d[N];

void solve(int p, ll len, ll t) {
	int nxtp = lower_bound(a + 1, a + p + 1, len) - a - 1;
	if(!nxtp) d[1] += t, d[len + 1] -= t;
	else f[nxtp] += t * (len / a[nxtp]), solve(nxtp, len % a[nxtp], t); 
} 

int main() {
	rd(n), rd(q);
	a[++tp] = n;
	fu(i, 1, q) {
		rd(x);
		while(tp && x <= a[tp]) --tp;
		a[++tp] = x;
	}
	f[tp] = 1; 
	fd(i, tp, 1) solve(i, a[i], f[i]);
	fu(i, 1, a[1]) printf("%lld\n", d[i] += d[i - 1]);
	n -= a[1]; while(n--) puts("0");
	return 0;
}

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

Measured memory_bytes: 128
#include<stdio.h>
#include<set>
#include<algorithm>
using namespace std;
int x,y,a,b,c;
int p[100005],q[100005];
int r[300005];
bool cmp(int &a,int &b)
{
    return a>b;
}
int main()
{
    scanf("%d%d%d%d%d",&x,&y,&a,&b,&c);
    for(int i=0;i<a;i++) scanf("%d",&p[i]);
    for(int i=0;i<b;i++) scanf("%d",&q[i]);
    for(int i=0;i<c;i++) scanf("%d",&r[i]);
    sort(p,p+a,cmp);
    sort(q,q+b,cmp);
    for(int i=0;i<x;i++) r[c++]=p[i];
    for(int i=0;i<y;i++) r[c++]=q[i];
    sort(r,r+c,cmp);
    long long sum=0;
    for(int i=0;i<x+y;i++) sum+=r[i];
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <numeric>
#include <iomanip>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
#define pi 3.14159265358979323846
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};

int main(){
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double x, y;
    if(m==0) x = 30*h;
    else x = 30*h+double(30*m/60);
    y = m*6;
  //  cout << x << " " << y << endl;
    double z = min(360-abs(x-y), abs(x-y));
    //cout << z << endl;
    double ans = a*a+b*b-2*a*b*cos(pi*z/180.0);
  //  cout << cos(z*pi/180) << endl;
     cout << fixed << setprecision(15) << sqrt(ans)<< endl;
   // cout << sqrt(ans) << endl;
    return 0;
}


Measured memory_bytes: 4216
#include<stdio.h>

int main(int argc, char* argv[])
{
  int i;
  int n, an[100];

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

  for(i = n - 1; 0 <= i - 1; i--){
    printf("%d ", an[i]);
  }
  printf("%d\n", an[i]);
  return(0);
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll dp[3005][3005];
int main()
{
	
  	// cout<<"hello";
  	ll i , j , maxi=0 ;
  	string s , t ,temp;
  	cin>>s>>t;
  	if(t.length()>s.length())
  	{
  		temp = t;
  		t=s;
  		s=temp;
  	}
  	memset(dp,0,sizeof(dp));
  	for(i=1;i<=s.length();i++){
  		
  		for(j=1;j<=t.length();j++){
  			if(s[i-1]==t[j-1]){
  				dp[i][j]=dp[i-1][j-1]+1;
  			}
  			else 
  				dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
  		}
  	}
  	j=t.length();
  	string str="";
  	for(i=s.length();i>=0;i--){
  		for(;j>0;j--){
  			
  			if(dp[i][j]!=dp[i][j-1])
  				{str+=t[j-1];while(i>=0&&dp[i-1][j]==dp[i][j]){i--;}break;}
  		}
  		
  	}
  	reverse(str.begin(),str.end());
  	cout<<str;
  	return 0;
  	
}

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

using namespace std;

#define ll long long

int main() 
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, k;
    cin>>n>>k;
    vector<int> neg;
    vector<int> noneg;
    int temp;
    for (int i = 0; i<n; i++) 
    {
        cin>>temp;
        if (temp<0) neg.push_back(temp);
        else noneg.push_back(temp);
    }
    int t = neg.size();
    int l = n-t;
    reverse(neg.begin(), neg.end());
    int minn = 1000000000;
    if (t>=k) minn = min(minn, -neg[k-1]);
    if (l>=k) minn = min(minn, noneg[k-1]);
    for (int i = 1; i<=min(k, t); i++)
    {
        int j = k-i;
        if (l>=j&&j>0)
        {
            minn = min(minn, abs(2*neg[i-1])+noneg[j-1]);
            minn = min(minn, 2*noneg[j-1]+abs(neg[i-1]));
        }
    }
    cout<<minn;
}


Measured memory_bytes: 1020
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

#define Maxn 200005

long long n, a[Maxn], dp[Maxn][3], sum, ans;

int main() {
	register int i;
	scanf("%lld", &n);
	memset(dp, 0x3f, sizeof(dp));
	for (dp[0][0] = 0, i = 1; i <= n; i ++) {
		scanf("%lld", a + i);
		dp[i][0] = min(dp[i - 1][0], sum) + (a[i] & 1 ? 1 : (a[i] ? 0 : 2));
		dp[i][1] = min(dp[i - 1][1], dp[i - 1][2]) + (a[i] & 1 ? 1 : (a[i] ? 0 : 2));
		dp[i][2] = min(dp[i - 1][0], min(dp[i - 1][2], sum)) + (a[i] & 1 ? 0 : 1);
		sum += a[i];
	}
	for (sum = 0, ans = 1e18, i = n; i >= 0; i --)
		ans = min(ans, min({dp[i][0], dp[i][1], dp[i][2]}) + (sum += a[i + 1]));
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define ll long long
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define uset unordered_set
#define umap unordered_map
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>

ll s;

int main() {
    cin >> s;
   	ll val = sqrt(s) + 200000LL;
   	val = min(val, 1000000000LL);
   	for(ll x1 = val; x1 >= 1LL; --x1) {
   		for(ll y2 = val; y2 >= 1LL; --y2) {
			ll z = x1 * y2 - s;
			if(z <= 1000000000LL) {
				cout << "0 0 " << x1 << ' ' << z << ' ' << 1 << ' ' << y2 << endl;
				return 0;
			}
   		}
   	}
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<P> vp;
typedef vector<bool> vb;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

int n,A,B,ans;
vi a;

int main(){
	cin>>n>>A>>B;
	a=vi(n);
	for(auto i=a.begin();i!=a.end();i++) cin>>*i;
	sort(a.begin(),a.end());
	for(auto i=a.begin();i!=a.end();i++){
		if(*i>=A&&*i<B) continue;
		ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AtCoder problem = new AtCoder(sc);
        problem.solve(out);

        out.flush();
    }

}

class AtCoder {

    final String s1, s2, s3;

    AtCoder(FastScanner sc) {
        s1 = sc.next();
        s2 = sc.next();
        s3 = sc.next();
    }

    void solve(PrintWriter out) {
        out.println("A" + s2.charAt(0) + "C");
    }

}

class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


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

#define ll long long
#define ld long double
#define xx first
#define yy second
#define vi vector<int>
#define pii pair<int,int>
#define all(v) v.begin(),v.end()

#define MAX 400005

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    ll n, m;
    cin >> n >> m;

    ll yes=0;

    for(int i=1;i<=n;i++)
    {
        ll rem = n - i;

        if(i*2 + rem*4  == m) yes=1;
        if(i*4 + rem*2 == m) yes=1;
    }

    cout << (yes? "Yes":"No") << endl;

    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
int selection(int A[],int n)
{
	for(int i = 0;i<n;i++)
	{
		int minj = i;
		for(int j = i;j<n;j++)
		{
			if(A[j]<A[minj])
			{
				minj = j;
			}
		}
		int tmp = A[i];
		A[i] = A[minj];
		A[minj] = tmp;
	}
}
int main()
{
	int A[50];
	int n;
	int k;
	std::cin >> n;
	std::cin >> k;
	for(int i = 0;i<n;i++)
	{
		std::cin >> A[i];
	}
	selection(A,n);
	int ret= 0;
	for(int i = 0;i<k;i++)
	{
		ret += A[n-(i+1)];
	} 
	std::cout << ret << std::endl;
	return 0;
}

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,j,N) for(int i = (N-1);i >= (j);i--)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

const int maxh = 305;
int H,W,D;

struct P{
    int x,y;
    int num;
    P(int x,int y,int num):x(x),y(y),num(num){;}
    bool operator<(const P &p){
        return num < p.num;
    }
};

vector<P> vp[maxh*maxh];
vector<int> vi[maxh*maxh];
vector<LL> sum[maxh*maxh];

int main()
{
    scanf("%d %d %d",&H,&W,&D);
    _rep(i,1,H){
        _rep(j,1,W){
            int num;
            scanf("%d",&num);
            vp[num%D].push_back(P(i,j,num));
            vi[num%D].push_back(num);
        }
    }
    _for(i,0,D){
        sort(ALL(vp[i]));
        sort(ALL(vi[i]));
    }
    _for(i,0,D){
        sum[i].push_back(0);
        _for(j,1,vp[i].size()){
            sum[i].push_back(sum[i][j-1] + abs(vp[i][j-1].x-vp[i][j].x) + abs(vp[i][j-1].y - vp[i][j].y));
        }
    }
    int Q;
    scanf("%d",&Q);
    while(Q--){
        int L,R;
        scanf("%d %d",&L,&R);
        int l = lower_bound(ALL(vi[L%D]),L) - vi[L%D].begin();
        int r = lower_bound(ALL(vi[L%D]),R) - vi[R%D].begin();

        cout <<sum[L%D][r] - sum[L%D][l] << endl;

    }

    return 0;
}


Measured memory_bytes: 15360
// https://atcoder.jp/contests/abc126/tasks/abc126_d

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF (1e9)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
// int gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// int lcm(long a, long b) { return a * b / gcd(a, b); }

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    //最初は全てが根であるとして初期化
    UnionFind(int size) : par(size, -1) {}
    // xとyの木を併合
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x != y) {
            if (par[y] < par[x])
                swap(x, y);
            par[x] += par[y];
            par[y] = x;
            return true;
        } else {
            return false;
        }
    }
    // 2つのデータx, yが属する木が同じならtrueを返す
    bool same(int x, int y) { return root(x) == root(y); }
    // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    int root(int x) { return par[x] < 0 ? x : par[x] = root(par[x]); }
    int size(int x) { return -par[root(x)]; }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;

    UnionFind tree(n);
    set<int> st;
    int k = n;

    for (int i = 0; i < m; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        k -= tree.unite(--x, --y);
    }
    cout << k << endl;

    return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
 
using namespace ::std;
 
#define all(x)  x.begin(),x.end()
#define Unique(x) x.erase(unique(x.begin(), x.end()), x.end())

template< class T > T SQR(T N) {return (T) N * N;}
template< class T > double DIST(T a, T b) {return 1.0 * sqrt(SQR(double(a)) + SQR(double(b)));}
template< class T > bool CROSS(pair< T,T > a, pair< T,T > b, pair< T,T > c) {return (b.first - a.first) * (c.second - b.second) >= (b.second - a.second) * (c.first - b.first);}
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair< int,int > pi;
 
int px[] = {0, 1, -1, 0, -1, -1, 1, 1};
int py[] = {1, 0, 0, -1, -1, 1, -1, 1};

const double eps = 1e-9;
 
inline ll power(ll a, ll p, ll mod)
{
    ll x = a, res = 1;
 
    while(p)
    {
        if(p&1) res = (res * x)%mod;
        p /= 2, x = (x * x)%mod;
    }
    return res;
}

int main()
{
    int n, m, c, d, a, b, k;
 
    int test;
 
    // scanf("%d", &test);
    // while(test--)
    // {
        scanf("%d", &n);
        
        ll tot = 0;
        for(int i = 1; i<=n; ++i)
            tot += (1LL * i * (i + 1))/2;
        for(int i = 1; i<n; ++i)
            scanf("%d%d", &a, &b),
            tot -= ll(min(a, b)) * ll(n - max(a, b) + 1);
        printf("%lld\n", tot);
    //}
}

Measured memory_bytes: 3816
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n,ans=0;
    cin >> n;
    ll v[n],c[n];
    rep(i,n) cin >> v[i];
    rep(i,n) cin >> c[i];
    rep(i,n){
        if(v[i]-c[i]>0) ans+=v[i]-c[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1e9 + 7
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<ll, ll> P;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }


int main() {
  string s;
  cin >> s;
  int n = s.size(),co=0;
  string rs = s;
  reverse(rs.begin(), rs.end());
  if(rs == s) co++;
  

  string ts = s.substr(0,(n-1)/2);
  string trs = ts;
  reverse(trs.begin(), trs.end());
  if(ts == trs) co++;
  
  string ks = s.substr((n+3)/2-1);
  string krs = ks;
  reverse(krs.begin(),krs.end());
  if(krs == ks) co++;


  if(co == 3){
      cout << "Yes" << endl;
  }else{
      cout << "No" << endl;
  }

  



  return 0;


}



Measured memory_bytes: 256
import java.util.Scanner;

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

		int x = 0, y = 0;

		while (true) {
			x = sc.nextInt();
			y = sc.nextInt();
			if(x == 0 && y == 0){
				break;
			}

			if (x < y) {
				System.out.println(x + " " + y);// ??????
			} else {
				System.out.println(y + " " + x);
			}
		}
	}
}

Measured memory_bytes: 34844
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    string s;
    cin >> s;
    s.pop_back();
    if (s.size()&1) s.pop_back();
    while (true) {
        int m = s.size()/2;
        if (s.substr(0,m) == s.substr(m,m)) {
            break;
        }
        s.pop_back();
        s.pop_back();
    }
    cout << s.size() << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

int main() {
    map<char, int> dict;
    for (char i = 'a'; i <= 'z'; ++i) {
        dict[i] = 0;
    }
    string s;
    cin >> s;
    for(const auto& c : s) ++dict[c];
    string ret = "None";
    for (const auto& item : dict) {
        if (item.second == 0) {
            ret = item.first;
            break;
        }
    }
    cout << ret << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 512
#include <iostream>
#include <sstream>  // istringstream
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main()
{   
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    string ans = "";
    int h = ty - sy;
    int w = tx - sx;

    // 1往復目
    for(int i=0; i<h; ++i) ans += "U";
    for(int i=0; i<w; ++i) ans += "R";
    for(int i=0; i<h; ++i) ans += "D";
    for(int i=0; i<w; ++i) ans += "L";
    // 2往復目
    ans += "L";
    for(int i=0; i<h+1; ++i) ans += "U";
    for(int i=0; i<w+1; ++i) ans += "R";
    ans += "D";
    ans += "R";
    for(int i=0; i<h+1; ++i) ans += "D";
    for(int i=0; i<w+1; ++i) ans += "L";
    ans += "U";

    cout << ans << endl;

    return 0;
}

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

// int 1つ: int.Parse(Console.ReadLine());
// int 配列: Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

class Program {
    static void Main(string[] args) {
        var n = int.Parse(Console.ReadLine());
        var t = new int[3] {0, 0, 0};
        bool ans = true;
        for (int i = 0; i < n; i++) {
            var u = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            var dur = u[0] - t[0];
            var dist = Math.Abs(t[1] - u[1]) + Math.Abs(t[2] - u[2]);
            if (dur < dist || dist % 2 != dur % 2) {
                ans = false;
                break;
            }
            t = u;
        }

        if (ans) Console.WriteLine("Yes");
        else Console.WriteLine("No");

    }
}


Measured memory_bytes: 15160
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n >> a >> b;
  ans = LINF;
  if (abs(a - b) % 2 == 0) {
    ans = abs(a - b) / 2;
  }
  // aを1に
  cnt = a - 1;
  tmp = b - (a - 1);
  cnt += (tmp % 2 == 0 ? tmp / 2 : tmp / 2 + 1);
  ans = min(ans, cnt);
  //
  cnt = n - b;
  tmp = a + (n - b);
  tmp = n - tmp;
  cnt += (tmp % 2 == 0 ? tmp / 2 : tmp / 2 + 1);
  ans = min(ans, cnt);
  Cout(ans);
  return 0;
}

Measured memory_bytes: 256
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = iss()
    ret = 0
    for s in S:
        ret += int(s)

    print('Yes' if ret % 9 == 0 else 'No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 10016
// #include<bits/stdc++.h>
// using namespace std;
 
// const int N = 1000000000, MAXI = 3, D = 1000;
 
// int main() {
//     freopen("output.txt", "r", stdin);
//     freopen("input.txt", "w", stdout);
//     srand(time(nullptr));
//     int tc = 99998, flag = 1;
//     cout << tc << "\n";
//     int n = MAXI;
//     while (tc--)
//     {
//     	cout << n << "\n~\n";
//     	n++;
//     }
 
//     return 0;
// }
 
 
 
 
 
 
 
 
//---------------------------------------------//
 
 
 
/*
#define int long long 
#define mod (int)(1e9+9)
#define endl '\n'
#define MAXI (int)(3e17+10)
#define N 200005
 */ 
 
 
 
 

//  /* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
#define int long long
#define MAXI (int)(3e17+10)
#define mod (int)(1e9+7)
#define N 1005

int n, m;
char a[N][N];
int dp[N][N];


int MEM(int i, int j)
{
	if(i==n-1 and j==m-1)
		return 1;

	if(dp[i][j]!=-1)
		return dp[i][j];

	int ans = 0;
	if(i+1<n and a[i+1][j]=='.')
		ans = (ans + MEM(i+1, j))%mod;

	if(j+1<m and a[i][j+1]=='.')
		ans = (ans + MEM(i, j+1))%mod;	

	return dp[i][j] = ans;
}

// Driver code to test above functions
int32_t main()
{
    
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    cin >> n >> m;
    for(int i=0;i<n;i++)
    	for(int j=0;j<m;j++)
    		cin >> a[i][j];

    memset(dp, -1, sizeof dp);

    cout << MEM(0, 0);
    
    return 0;
 
} 


Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
//#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef pair<int,int> PP;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << -1 << endl;return 0
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N;
    int A[114514],B[114514];
    cin >> N;
    REP(i,N){
        cin >> A[i];
    }
    
    //B[0]をx/2とする
    int num=0;
    REP(i,N){
        num=A[i]-num;
    }
    //x=num
    B[0]=num;
    REP(i,N-1){
        B[i+1]=2*A[i]-B[i];
    }
    REP(i,N){
        if(i!=0)cout << " ";
        cout << B[i];
    }
    cout << endl;
    return 0;
}




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

// definitions
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i, l, r) for (long long i = (l); i < (long long)(r); i++)
#define repb(i, r, l) for (long long i = (r); i > (long long)(l); i--)
#define high(x) __builtin_popcountll(x)
#define pb push_back
#define pf push_front
#define mod1 998244353
#define mod 1000000007
#define MAX_CHAR 256
#define pi 3.1415926535897932384

using namespace std;
typedef vector<long long> vl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector< pair<long long, long long> > vp;
typedef vector<tuple<long long , long long , long long> > vtup;
typedef deque <long long> dql;
typedef deque <char> dqc;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

const ll INF=1e18;
// prevent collisions in unordered_map
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
typedef unordered_map <long long, long long, custom_hash> umap;

// cin and cout overloaded for vectors and sets
template <typename T> 
ostream& operator<<(ostream& os, vector<T>& v) 
{ 
    for (auto i:v) os << i << " "; 
    return os; 
} 
template <typename T>
istream &operator>>(istream &is, vector<T> &v) 
{
    ll n=v.size();
    rep(i,0,n){ ll a; cin >>a; v[i]=a;}
    return is;            
}
template <typename T> 
ostream& operator<<(ostream& os, set<T>& s) 
{ 
    for (auto i:s) os << i << " "; 
    return os; 
}

// standard functions
ll mystoi(string str)
{
    stringstream ss(str);
    ll ans=0;
    ss >> ans;

    return ans;
}

ll exp(ll x, ll ex) 
{
    ll ans = 1ll;
    while (ex > 0) 
    {
        if (ex & 1ll) ans = (ans * x);
        ex >>= 1ll;
        x = (x * x);
    }
    return ans;
}

bool sort_cond(const pair<ll,ll> &a, const pair <ll,ll> &b)
{
    return a.first < b.first;
}

// code beigns in main
int main()
{

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll t=1;
    // cin >> t;
    while(t--)
    {
        ld a,b,v,w;
        cin >> a >>v;
        cin >>b >>w;
        ld t;
        cin >> t;

        ld val;
        if(a>b)
        {
            val=(a-b)/(v-w);
        }
        else val=(b-a)/(v-w);

        if(val>0 && t>=val) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}


Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, N, a, b) for(int i = a; i < N; i += b)

int main(){
	int N, T, A;
	cin >> N >> T >> A;

	vector<int> H(N);
	rep(i, N) cin >> H.at(i);
	double val = (T - A) / 0.006;
	// cout << val << endl;
	double vmin = INT64_MAX;
	int ans = 0;
	rep(i, N){
		double diff = val - H.at(i);
		if (diff < 0) diff *= -1;
		if (diff < vmin){
			vmin = diff;
			ans = i + 1;
		}
		// cout << diff << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = int(input())
x = list(map(int, input().split()))
y = list(range(1,N+1))

cnt = 0
for i in range(N):
  if x[i] != y[i]:
    cnt += 1
    
if cnt > 2:
  print('NO', end='')
else:
  print('YES', end='')

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<int, int> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  cout << n - k + 1 << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9+7;
#define REP(i,j,n) for(int i=j;i<n;i++)
#define rep(i,n) REP(i,0,n)


// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    ll ary[n];
    rep(i,n) cin >> ary[i];


    ll sum = 0;
    rep(i,n) sum ^=ary[i];
    rep(i,n)
    {
        ll tmpn = ary[i]^sum;
        if (i==n-1)
        {
            cout << tmpn << endl;

        }
        else
        {
            cout << tmpn << " ";
            /* code */
        }
        
    }
}


Measured memory_bytes: 5180
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int A,B,C,D;
cin>>A>>B>>C>>D;
if(C<=A&&B<=D)cout<<B-A;
else if(A<=C&&D<=B)cout<<D-C;
else
{
if(C<A){swap(A,C);swap(B,D);}
cout<<max(0,B-C);
}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

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

	string ans = "No";
	rep(i, 3) {
		if (N[i] == '7')
			ans = "Yes";
	}


	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
#define N 8
#define FREE -1
#define NOT_FREE 9999
#define PUT 1
#define NOT_PUT 0

int p[N+1][N+1];
int dpos[2*N+1] = {FREE};
int dneg[2*N+1] = {FREE};
int col[N+1] = {FREE};
int row[N+1] = {FREE};

//最後の行で出力できるかどうか確認
void backTracking()
{
  int i,j;
  
  for(i = 0;i < N;i++){
    for(j = 0;j < N;j++){
      if(p[i][j] == PUT){
	if(row[i] != j) return;
      }
    }
  }
  //printf("Tracking ended\n");

  for(i = 0;i < N;i++){
    for(j = 0;j < N;j++){
      if(row[i] == j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

void putQueen(int i)
{
  if(i == N){
    backTracking();
    return;
  }
  
  int j;
  for(j = 0;j < N;j++){
    if(col[j] == NOT_FREE || dpos[i+j] == NOT_FREE || dneg[i-j+N-1] == NOT_FREE) continue;

    //put a queen at (i, j)
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;

    //try the next row
    putQueen(i+1);
    
    //remove the queen at (i, j) for backtracking
    col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
  }
}

int main()
{
  int i,j,k;
  int n;

  scanf("%d", &n);

  for(i = 0;i < n;i++){
    for(j = 0;j < n;j++) p[i][j] = NOT_PUT;
  }
  
  for(k = 0;k < n;k++){
    scanf("%d%d", &i, &j);
    p[i][j] = PUT;
  }

  putQueen(0);

  /*for(i = 0;i < N;i++){
    for(j = 0;j < N;j++){
      if(row[i] == j) printf("Q");
      else printf(".");
    }
    printf("\n");
    }
  */
  return 0;
}



Measured memory_bytes: 2108
/// IN THE NAME OF METAL
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define sz(x)                       (ll) x.size()
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second

ll Pow(ll a, ll b, ll md, ll ans = 1) {
    for (; b; b >>= 1, a = a * a % md)
        if (b & 1)
            ans = ans * a % md;
    return ans % md;
}

const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
ll A[MAXN], dist[MAXN], dp[MAXN], q, n, D;

int main() {
    scanf("%lld%lld", &n, &D);
    for (ll i = 1; i <= n; i++) scanf("%lld", &A[i]);
    scanf("%lld", &q);
    dist[0] = D;
    for (ll i = 1; i <= n; i++) {
        if (abs(dist[i - 1] - A[i]) >= dist[i - 1]) dist[i] = dist[i - 1];
        else dist[i] = abs(dist[i - 1] - A[i]);
    }
    dp[n] = 1;
    for (ll i = n - 1; i >= 1; i--) {
        if (dp[i + 1] <= A[i + 1] / 2) dp[i] = dp[i + 1];
        else dp[i] = dp[i + 1] + A[i + 1];
    }
    while (q--) {
        ll id; scanf("%lld", &id);
        if (dist[id - 1] >= dp[id]) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}



Measured memory_bytes: 18304
#include <bits/stdc++.h>
#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 sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll n,C;cin>>n>>C;
    vector<vector<ll>> d(C,vector<ll>(C));
    rep(i,C)rep(j,C)cin>>d[i][j];
    vector<vector<ll>> v(3,vector<ll>(31,0));
    rep(i,n)rep(j,n){
        ll x;cin>>x;
        v[(i+j)%3][x-1]++;
    }
    ll res=1e10;
    rep(i,C)rep(j,C)rep(k,C){
        if(i==j||j==k||k==i)continue;
        ll buf=0;
        rep(l,C)buf+=d[l][i]*v[0][l];
        rep(l,C)buf+=d[l][j]*v[1][l];
        rep(l,C)buf+=d[l][k]*v[2][l];
        chmin(res,buf);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() { 
    int a, b;
    cin >> a >> b;
    cout << (a + b + 1) / 2 << endl;
}




Measured memory_bytes: 3620