akhauriyash/Code-Regression huggingface dataset:
//g++ -std=c++17 -Wshadow -Wall -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g PROGRAM -o OUTPUT -DLOCAL -lasan -lubsan
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;

typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;


inline ll modulo(ll a, ll m)
{
    return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
    assert(__gcd(a, m) == 1);
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m, a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
    if (y == 0)
        return 1LL;
    else if (y == 1)
        return x;
    else
    {
        ll ans = modPow(x, y / 2, m) % m;
        if (y & 1)
        {
            return (((ans * ans) % m) * x) % m;
        }
        else
        {
            return (ans * ans) % m;
        }
    }
}

vector<string> split(char d,string s)
{
    stringstream ss(s);
    string t;
    vector<string> words;
    while(getline(ss,t,d))
    {
        words.pb(t);
    }

    return words;
}

int main(int argc, char *argv[])
{
    
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    string s,t;
    cin >> s >> t;
    cout << t + s;

    return 0;
}


Measured memory_bytes: 3668
oldn,q = map(int , input().split())
INF = 2147483647
n = 1

while(n < oldn) :
    n *= 2
dat = []
for i in range(2*n-1):
    dat.append(INF)

def updata(k , a): #k番目(0-indexed)をaに変更
    k += (n-1)
    dat[k] = a
    while (k > 0):
        k = (k-1) // 2 #親の番号
        dat[k] = min(dat[2*k+1],dat[2*k+2])

#[a,b)のminを求める
#k:節点の番号[l,r)その節点の対応する区間
def query(a,b,k,l,r):
    if(r <= a) or (b <= l) : return INF
    if(a <=l) and (r <= b) : return dat[k]
    v1 = query(a,b,2*k+1,l,(l+r)/2)
    v2 = query(a,b,2*k+2,(l+r)/2,r)
    return min(v1,v2)

for i in range(q):
    com,x,y = map(int , input().split())
    if (com == 0) : updata(x,y)
    if (com == 1) : print(query(x,y+1,0,0,n))


Measured memory_bytes: 9020
#include<stdio.h>
#include<stdlib.h>
int main(){
    int n,h[200000];
    int dp[200000]={};
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&h[i]);
    }
    dp[0]=0;
    dp[1]=abs(h[0]-h[1]);
    for(int i=2;i<n;i++){
        if(dp[i-1]+abs(h[i]-h[i-1])>dp[i-2]+abs(h[i]-h[i-2])){
            dp[i]=dp[i-2]+abs(h[i]-h[i-2]);
        }else{
            dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
        }
    }
    
    printf("%d\n",dp[n-1]);
    return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<climits>
#include<set>
#include<map>
#include<stack>
#define ll long long
using namespace std;

int main() {
	vector<ll>a(3);
	ll count = 0;
	for (ll i = 0; i < 3; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	while (a[0]!=a[1]||a[1]!=a[2]||a[0]!=a[2]) {
		if (a[2] - a[1] >= 1) {
			a[1]++;
			a[0]++;
		}
		else {
			if (a[2] - a[0] >= 2) {
				a[0]+=2;
			}
			else if (a[2] - a[0] < 2) {
				a[2]++;
				a[1]++;
			}
		}
		count++;
	}
	cout << count << endl;


}


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

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  while(true){
    C -= B;
    if(A <= 0 || C <= 0)
      break;
    A -= D;
    if(A <= 0 || C <= 0)
      break;
  }
  if(A > 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main ()
{
    int a,b,c,i,j;
    cin >> a >> b >>c;
    if(a<=c&& b>=c)
    {
        cout << "Yes"<< endl;
    }
    else
    {
        cout << "No"<< endl;
    }
    return 0;
}


Measured memory_bytes: 256
K, N = [int(n) for n in input().split(" ")]
A = [int(n) for n in input().split(" ")]

L = []
for i in range(N - 1):
    ll = A[i + 1] - A[i] 
    L.append(ll)
L.append(A[0] + K - A[-1])

LL = max(L)

print(K - LL)

Measured memory_bytes: 31660
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

vector<int> vp[100001];
int dd1[100001],dd2[100001];
int d1=0,d2=0;
bool used[100001];
int main(){
    int n,sr,ds;
    cin>>n;
    rep(i,n-1){
        cin>>sr>>ds;
        vp[sr-1].pb(ds-1);
        vp[ds-1].pb(sr-1);
    }
    queue<pint> q;
    q.push(mp(0,0));
    used[0]=true;
    while(!q.empty()){
        pint pi=q.front();q.pop();
        int cur=pi.first;
        dd1[cur]=pi.second;
        rep(i,vp[cur].size()){
            if(!used[vp[cur][i]]){
                q.push(mp(vp[cur][i],pi.second+1));
                used[vp[cur][i]]=true;
            }
        }
    }
    memset(used,0,sizeof(used));
    q.push(mp(n-1,0));
    used[n-1]=true;
    while(!q.empty()){
        pint pi=q.front();q.pop();
        int cur=pi.first;
        dd2[cur]=pi.second;
        rep(i,vp[cur].size()){
            if(!used[vp[cur][i]]){
                q.push(mp(vp[cur][i],pi.second+1));
                used[vp[cur][i]]=true;
            }
        }
    }
    int cnt1=0,cnt2=0;
    rep(i,n){
        if(dd1[i]<=dd2[i]) ++cnt1;
        else ++cnt2;
    }
    if(cnt1>cnt2) cout<<"Fennec"<<endl;
    else cout<<"Snuke"<<endl;
    return 0;
}

Measured memory_bytes: 6784
import sys
import math
import heapq
from operator import itemgetter
import bisect

sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        i = i+1
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        i = i+1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def reset(self):
        t = self.tree
        for i in range(len(t)):
            t[i] = 0

class RBit:
    def __init__(self, n, B0 = None):
        self.BI0 = B0 or Bit(n+10)
        self.BI1 = Bit(n+10)

    def add(self, x, left, right):
        self.BI0.add(left, -x*(left-1))
        self.BI1.add(left, x)
        self.BI0.add(right+1, x*right)
        self.BI1.add(right+1, -x)

    def sum(self, i):
        return self.BI1.sum(i)*i + self.BI0.sum(i)

    def get(self, i):
        return self.sum(i) - (i and self.sum(i-1))

N,D,A=LI()
# RB = RBit(N+10)
PS=[]
HPS=[]
INI=Bit(N+10)
LIN = [LI() for i in range(N)]
LIN.sort(key = itemgetter(0))
for i in range(N):
    pos, hp = LIN[i]
    PS.append(pos)
    INI.add(i, hp)

RB=RBit(N+10, INI)

res = 0
for i in range(N):
    hp = RB.get(i)
    # print(hp)
    if hp > 0:
        atc_cnt = hp // A + (1 if hp%A else 0)
        left = PS[i]
        right = bisect.bisect_right(PS, PS[i]+2*D)-1
        RB.add(-A*atc_cnt, i, right)
        res += atc_cnt

print(res)


Measured memory_bytes: 102620
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int bm = 3010;
ll BIT[bm];
void add(int A, ll B) {
	while (A <= bm) {
		BIT[A] = max(BIT[A], B);
		A += A & -A;
	}
}
ll query(int A) {
	ll kotae = 0;
	while (A > 0) {
		kotae = max(BIT[A], kotae);
		A -= A & -A;
	}
	return kotae;
}

ll V[200000], tmp[200000];

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


	int R, C, K;
	cin >> R >> C >> K;

	rep(i, K) {
		ll r, c, v;
		cin >> r >> c >> v;
		V[i] = v << 30 | r << 12 | c;
	}

	const int b = 12;
	int kazu[1 << b] = {}, kazu2[1 << b] = {};
	rep(i, K) kazu[V[i] & ((1 << b) - 1)]++;
	rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
	for (int i = K - 1; i >= 0; i--) tmp[--kazu[V[i] & ((1 << b) - 1)]] = V[i];
	rep(i, K) kazu2[tmp[i] >> b & ((1 << b) - 1)]++;
	rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
	for (int i = K - 1; i >= 0; i--) V[--kazu2[tmp[i] >> b & ((1 << b) - 1)]] = tmp[i];

	int mae = -1;
	ll A[4] = {};
	ll L[3001];
	int l = 0;
	rep(k, K) {
		int v = V[k] >> 30;
		int i = V[k] >> 12 & 4095;
		int j = V[k] & 4095;
		if (mae != i) {
			mae = i;
			A[0] = 0;
			A[1] = 0;
			A[2] = 0;
			A[3] = 0;
			rep(a, l) add(L[a] & 4095, L[a] >> 12);
			l = 0;
		}
		A[0] = query(j);
		chmax(A[3], A[2] + v);
		chmax(A[2], A[1] + v);
		chmax(A[1], A[0] + v);
		L[l++] = max(max(A[0], A[1]), max(A[2], A[3])) << 12 | j;
	}

	rep(a, l) add(L[a] & 4095, L[a] >> 12);
	ll kotae = query(C);

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 6808
#include <iostream>
#include <algorithm>
#include <string>
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

void swap(string* a, string* b)
{
    string t = *a;
    *a = *b;
    *b = t;
}

void swapi(int* a, int* b)
{
    int t = *a;
    *a = *b;
    *b = t;
}

int partition ( string array[], int array1[], int array2[], int l, int r) {

    string pivot = array[r];
    int pivoti = array1[r];
    int i = (l - 1);

    for (int j = l; j <= r - 1; j++) {
        if (array[j] < pivot) {
            i++;
            swap (&array [i], &array [j]);
            swapi(&array1[i], &array1[j]);
            swapi(&array2[i], &array2[j]);
        }
        else if (array[j] == pivot) {
            if (array1[j] > pivoti) {
                i++;
                swap(&array[i], &array[j]);
                swapi(&array1[i], &array1[j]);
                swapi(&array2[i], &array2[j]);
            }
        }
    }
    swap (&array[i + 1], &array[r]);
    swapi(&array1[i + 1], &array1[r]);
    swapi(&array2[i + 1], &array2[r]);
    return (i + 1);
}

void quickSort( string array[], int array1[], int array2[], int l, int r) {
    if (l < r) {
        int pivot = partition(array, array1, array2, l, r);
        quickSort(array, array1, array2, l, pivot - 1);
        quickSort(array, array1, array2, pivot + 1, r);
    }
}

int main()
{
    int n;
    cin >> n ;
    string s[n];
    int p[n]={0};
    int num[n]={0};
    rep(i,n){
        cin >> s[i] >> p[i];
        num[i] = i+1;
    }
    
    quickSort( s, p, num, 0, n-1 );

    rep(i,n) cout << num[i] << endl;
    
    return 0;
}


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

int main() {
  string t;
  cin >> t;
  for (int i = 0; i < t.size(); i++) {
    if (t.at(i) == '?') {
      if (i == 0) {
        t.at(i) = 'D';
      }
      else if (t.at(i - 1) == 'P') {
        t.at(i) = 'D';
      }
      else if (i == t.size() - 1) {
        t.at(i) = 'D';
      }
      else {
        t.at(i) = 'D';
      }
    }
  }
  cout << t << endl;
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int ub(vector<ll>& a,ll x){
  ll l=-1,r=a.size(),m;
  while(r-l>1){
    m=(l+r)/2;
    if(a[m]>x) r=m;
    else l=m;
  }
  return r;
}

int lb(vector<ll>& a,ll x){
  ll l=-1,r=a.size(),m;
  while(r-l>1){
    m=(l+r)/2;
    if(a[m]>=x) r=m;
    else l=m;
  }
  return l;
}

int main(){
  ll n,ans=0,d[100010],e[100010]={};
  cin>>n;
  vector<ll> a(n);
  vector<ll> b(n);
  vector<ll> c(n);
  fr(i,n) cin>>a[i];
  fr(i,n) cin>>b[i];
  fr(i,n) cin>>c[i];
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());
  fr(i,n) ans+=(1+lb(a,b[i]))*(n-ub(c,b[i]));
  cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
using namespace std;
typedef long long LL;
#define M(a,b) memset(a,b,sizesof(a))
#define pb push_back
int a[100005];
int Min(const int &a,const int &b)
{
    return a<b?a:b;
}
int Max(const int &a,const int &b)
{
    return a>b?a:b;
}
int main()
{
    int n,t;
    scanf("%d%d",&n,&t);
    for (int i=1;i<=n;++i)
        scanf("%d",a+i);
    int ma=0,mi=a[1];
    int cnt=1;
    for (int i=2;i<=n;++i)
    {
        if (ma==a[i]-mi)
            ++cnt;
        ma=Max(ma,a[i]-mi);
        mi=min(mi,a[i]);
    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long int
#define MAX 1000003
#define pii pair<ll,ll>
#define VP vector< pii >
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(ll (i) = (a); (i) < (b); (i)++)
#define all(v) (v).begin(),(v).end()
#define S(x) scanf("%d",&(x))
#define S2(x,y) scanf("%d%d",&(x),&(y))
#define SL(x) scanf("%lld",&(x))
#define SL2(x) scanf("%lld%lld",&(x),&(y))
#define P(x) printf("%d\n",(x))
#define FF first
#define SS second
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
int f=0;
while(n>0){
	int d=n%10;
	if(d==7)f=1;
	n/=10;
}
if(f)cout<<"Yes";
else cout<<"No";
return 0;
}

Measured memory_bytes: 3636
n = gets.chomp.to_i
Node = Struct.new(:num, :parent, :left, :right)

class BinSearchTree
  attr_accessor :root
  def initialize
    @root = nil
  end

  def inorder(r, order)
    if r.nil?.!
      inorder(r.left, order)
      order << r.num
      inorder(r.right, order)
    end
  end
  
  def preorder(r, order)
    if r.nil?.!
      order << r.num
      preorder(r.left, order)
      preorder(r.right, order)
    end
  end
  
  def find(k)
    x = @root
    y = nil
    flag = false
    until x.nil?
       y = x
      if k == x.num
        flag = true
        break
      elsif k < x.num
        x = x.left
      elsif x.num < k
        x = x.right      
      end
    end
    ans = flag ? "yes" : "no"
    puts ans
  end

  def insert(k)
    x = @root
    y = nil
    z = Node.new
    z.num = k
    until x.nil?
      y = x
      if z.num < x.num
        x = x.left
      else
        x = x.right
      end
    end
    z.parent = y
    if y.nil?
      @root = z
    else
      if z.num < y.num
        y.left = z
      else
        y.right = z
      end
    end
  end
end

bst = BinSearchTree.new

n.times do
  cmd, i = gets.chomp.split.map{|t| t.match?(/\d/) ? t.to_i : t}
  case cmd
  when "insert"
    bst.insert(i)
  when "print"
    root = bst.root
    in_res, pre_res = [], []
    bst.inorder(root, in_res)
    puts " " + in_res.map(&:to_s).join(' ')
    bst.preorder(root, pre_res)
    puts " " + pre_res.map(&:to_s).join(' ')
  when "find"
    bst.find(i)
  end
end


Measured memory_bytes: 86016
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  	string s;
    cin>>s;
  	int ans = INT_MIN,count = 0;
  	for(int i=0;i<3;i++)
    {
      if(s[i]=='S')
      {
        ans=max(ans,count);
        count = 0;
      }
     else
       count++;
    }
  	ans = max(ans,count);
  	cout<<ans;
    return 0;
}

Measured memory_bytes: 3620
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{max, min};
use std::collections::*;
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

#[cfg(debug_assertions)]
macro_rules! debug {
    ($( $args:expr ),*) => { eprintln!( $( $args ),* ); }
}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($( $args:expr ),*) => {
        ()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize, a: usize, b: usize);
    if n > a * b || n < a + b - 1 || b > n {
        println!("{}", -1);
        return;
    }
    let mut ret: Vec<_>;
    if a == 1 {
        assert_eq!(b, n);
        ret = (1..=n).rev().collect();
    } else {
        let d = (n - b) / (a - 1);
        let mut e = (n - b) % (a - 1);
        ret = (1..=b).rev().collect();
        let mut l = b + 1;
        for _ in 1..a {
            let mut r = l + d;
            if e > 0 {
                r += 1;
                e -= 1;
            }
            ret.extend((l..r).rev());
            l = r;
        }
    }
    println!(
        "{}",
        ret.iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(" ")
    );
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 23080
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<map>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 20000000000;
typedef std::pair<int,int> P;


	ll ans;
	ll N,A[200010];
	ll K;
	string S;
	set<string> Q;
int main(){
	ios_base::sync_with_stdio(false);
	cin>>S>>K;
	REP(i,S.size()){
		for(int j=0;j<5;j++){
			Q.insert(S.substr(i,j+1));
		}
	}
	int cnt=1;
	for(auto x:Q){
		if(cnt==K){
			cout<<x;
			break;
		}
		cnt++;
	}

}

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

using namespace std;
using ll=long long;

int main()
{
   string s;cin >>s;
   char k[4]={'N','S','W','E'};
   bool c[4];
   for(int i=0;i<4;i++){
    c[i]=false;
   }
   for(int i=0;i<(int)s.size();i++){
    for(int j=0;j<4;j++){
        if(k[j]==s[i])c[j]=true;
    }
   }
   bool flg=true;
   if((c[0]&&!c[1])||(!c[0]&&c[1]))flg=false;
   if((c[2]&&!c[3])||(!c[2]&&c[3]))flg=false;
   if(flg)puts("Yes");
   else puts("No");
    return 0;
}


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

const int inf=INT_MAX;

struct max_flow {
    struct edge { int to, cap, rev; };
    int V;
    vector<vector<edge>> G;
    vector<int> itr, level;

    max_flow(int V) : V(V) { G.assign(V,vector<edge>()); }

    void add_edge(int from, int to, int cap) {
        G[from].push_back((edge) {to, cap, (int) G[to].size()});
        G[to].push_back((edge) {from, 0, (int) G[from].size()-1});
    }

    void bfs(int s) {
        level.assign(V,-1);
        queue<int> q;
        level[s] = 0; q.push(s);
        while (!q.empty()) {
            int v = q.front(); q.pop();
            for(auto &e: G[v]){
                if (e.cap > 0 and level[e.to] < 0) {
                    level[e.to] = level[v] + 1;
                    q.push(e.to);
                }
            }
        }
    }

    int dfs(int v, int t, int f) {
        if (v == t) return f;
        for (int& i = itr[v]; i < (int) G[v].size(); ++i) {
            edge& e = G[v][i];
            if (e.cap > 0 and level[v] < level[e.to]) {
                int d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    int run(int s, int t) {
        int ret = 0, f;
        while (bfs(s), level[t] >= 0) {
            itr.assign(V,0);
            while ((f = dfs(s, t, inf)) > 0) ret += f;
        }
        return ret;
    }
};

int main(){
    //input
    int N;
    cin >> N;
    pair<int,int> red[N], blue[N];
    int x,y;
    int i,j;
    for(i=0; i<N; i++){
        cin >> x >> y;
        red[i]=make_pair(x,y);
    }
    for(i=0; i<N; i++){
        cin >> x >> y;
        blue[i]=make_pair(x,y);
    }

    //calc
    max_flow mf(2*N+2);//sink:2*N, tank:2*N+1
    for(i=0; i<N; i++){
        mf.add_edge(2*N,i,1);
    }
    for(i=0; i<N; i++){
        mf.add_edge(N+i,2*N+1,1);
    }
    for(i=0; i<N; i++){
        for(j=0; j<N; j++){
            if(red[i].first<blue[j].first&&red[i].second<blue[j].second){
                mf.add_edge(i,N+j,1);
            }
        }
    }

    //output
    cout << mf.run(2*N,2*N+1) << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int N,A,B,C,D;
    cin >> N >> A >> B >> C >> D;
    A--;
    B--;
    C--;
    D--;
    string S;
    cin >> S;
    S += '#';
    if(C < D) {
        bool ret = true;
        for(int i = A;i <= C;i++) {
            if(S.at(i) == '#' && S.at(i + 1) == '#') {
                ret = false;
            }
        }
        for(int i = B;i <= D;i++) {
            if(S.at(i) == '#' && S.at(i + 1) == '#') {
                ret = false;
            }
        }
        if(ret == true) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    else {
        bool ret = true;
        for(int i = A;i <= C;i++) {
            if(S.at(i) == '#' && S.at(i + 1) == '#') {
                ret = false;
            }
        }
        for(int i = B;i <= D;i++) {
            if(S.at(i) == '#' && S.at(i + 1) == '#') {
                ret = false;
            }
        }
        bool ret2 = false;
        for(int i = B;i <= D;i++) {
            if(S.at(i - 1) == '.' && S.at(i) == '.' && S.at(i + 1) == '.') {
                ret2 = true;
            }
        }
        if(ret == true && ret2 == true) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
}

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

#include <bits/stdc++.h>
using namespace std;

int main() {
  long int n,k,s,b;
  cin>>n>>k;
  s=n/k;
  s=s*k;
  b=n/k;
  b=b+1;
  b=b*k;
  s=n-s;
  b=b-n;
  if(s>b){
    s=b;
  }
  cout<<s<<endl;
  return 0;
  
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	long long n,ans;
	int d[8]={0,1,2,3,5,7,8,9},tmp,f;
	while(cin>>n,n){
		ans=0;
		tmp=f=0;
		
		while(n>0){
			if(f){
				ans*=10;
				ans+=n%8;
				n/=8;
			}
			else{
				if(n%8==0)tmp++;
				else f=1;
				ans*=10;
				ans+=n%8;
				n/=8;
			}
		}
		for(;ans>0;ans/=10)cout<<d[ans%10];
		for(int i=0;i<tmp;i++)cout<<0;
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 1160
#include<cstdio>

using namespace std;

int main(){
    int a,b;
    scanf("%d", &a);
    scanf("%d", &b);

    for(int i = 1; i <= 3; i++){
        if(a != i && b != i){
            printf("%d\n", i);
            return 0;
        }
    }
    
}

Measured memory_bytes: 128
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N, C = get_ints
D = {}
C.times do |i|
  D[i] = get_ints
end
CX = []
N.times do |i|
  CX[i] = get_ints_minus_one
end

groups = Array.new(3) { [] }
CX.each.with_index do |cx, i|
  cx.each.with_index do |c, j|
    group_index = (i + j) % 3
    groups[group_index] << c
  end
end
group_kouhos = []
groups.each.with_index do |g, i|
  sums = C.times.map do |to_color|
    [to_color, g.map { |from_color| D[from_color][to_color] }.sum]
  end
  group_kouhos << sums.sort { |a, b| a[1] <=> b[1] }
end

def search_best(array, set)
  array.find { |color, sum| !set.include?(color) }
end

ans = 10 ** 18
[0, 1, 2].permutation(3) do |first, second, third|
  colors = Set.new
  sum = 0

  c, s = search_best(group_kouhos[first], colors)
  colors.add(c)
  sum += s

  c, s = search_best(group_kouhos[second], colors)
  colors.add(c)
  sum += s

  c, s = search_best(group_kouhos[third], colors)
  colors.add(c)
  sum += s

  ans = sum if sum < ans
end

puts ans



Measured memory_bytes: 63044
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>

using namespace std;

string s;

int main() {

	cin >> s;
	int cnt = 0;

	for (int i = 0; i < 3; ++i) {
		if (s[i] == 'o') {
			cnt++;
		}
	}

	cout << 700 + 100 * cnt << endl;

	return 0;
}

Measured memory_bytes: 256
N = input()

p = ''
Flag = False
for s in N:
    if p == '':
        p = s
        continue
    else:
        if p == s:
            continue
        else:
            if int(p) > int(s):
                print(p * len(N))
                Flag = True
                break
            else:
                pref = str(int(p) + 1)
                print(pref * len(N))
                Flag = True
                break
if not Flag:            
    print(N)

Measured memory_bytes: 3064
import heapq
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, M = map(int, input().split())
works = [list(map(int, input().split())) for _ in range(N)]

heapq.heapify(works)

cand = []

day = 1
ans = 0
while day <= M:
    while works:
        a, b = heapq.heappop(works)
        if a <= day:
            heapq.heappush(cand, -b)
        else:
            heapq.heappush(works, [a, b])
            break
    if len(cand) > 0:
        ans -= heapq.heappop(cand)
    day += 1
print(ans)


Measured memory_bytes: 92252
import math

def kyori(a,b,c,d):
    return math.sqrt(a**2+b**2-2*a*b*math.cos(abs(c-d)))

A, B, H, M = [int(i) for i in input().split()]
m = M* 2*math.pi/60 #rad
h = H* 2*math.pi/12+ M*2*math.pi/60/12 #rad
#print(h, "\n", m)


k=kyori(A,B,h,m)
print(k)



Measured memory_bytes: 9532
#include <iostream>
#include <cmath>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <vector>
using namespace std;
#define INF 1000000007
#define ll long long
#define rep(i_, __start, __end) for(ll i_=(ll)__start; i_<(ll)__end; i_++)
#define print(_a) cout << _a << endl;
#define printarray(a, len) rep(ii,0,len) cout << a[ii] << " ";
#define printarray2(aa, len) rep(ij,0,len) printarray(aa[ij], aa[ij].size()); print("");


int main(){
    ll x, a, b;
    cin >> x >> a >> b;
    print((x - a) % b);
   
  return 0;
}

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

using namespace std;

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

#define endl "\n"

const ll INF = 1e15;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

mt19937 rng((int) chrono::steady_clock::now().time_since_epoch().count());

const int N = 5e5 + 5;

ll n, m;
ll fact[N], inv[N];

ll fpow(ll a, ll b) {
    a %= MOD;
    if (b == 0) 
        return 1;
    ll res = fpow(a * a, b / 2);
    if (b & 1) 
        res *= a;
    return res % MOD;
}

ll nCr(int n, int r) {
    if (n < r)
        return 0;
    return fact[n] * inv[r] % MOD * inv[n - r] % MOD;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);

    fact[0] = inv[0] = 1;
    for (int i = 1; i < N; ++i) {
        fact[i] = (fact[i - 1] * i) % MOD;
        inv[i] = fpow(fact[i], MOD - 2);
    }

    cin >> n >> m;

    ll ans = nCr(m, n) * fact[n] % MOD;
    ll valid = 0, sign = 1;
    for (int j = 0; j <= n; ++j) {
        valid += sign * nCr(n, j) * nCr(m - j, n - j) % MOD * fact[n - j] % MOD;
        valid %= MOD;
        sign = -sign;
    }
    ans *= valid;
    ans %= MOD;
    cout << (ans + MOD) % MOD << endl;
}



Measured memory_bytes: 11368
n = int(input())
a = list(map(int, input().split()))
ans = [0] * n
for k in range(n, 0, -1):
    cnt = 0
    for x in range(k, n + 1, k):
        cnt += ans[x - 1]
    if cnt % 2 != a[k - 1]:
        ans[k - 1] = 1
m = ans.count(1)
print(m)
if m != 0:
    print(' '.join(map(str, [i + 1 for i, x in enumerate(ans) if x == 1])))

Measured memory_bytes: 18996
#include <bits/stdc++.h>
using namespace std;
#define gc getchar()
inline int read(){
	int x=0;char c=gc;
	for(;c<48||c>57;c=gc)
		if(c=='W')return 0;
		else if(c=='B')return 1;
	for(;c>47&&c<58;c=gc)
		x=x*10+c-48;
	return x;
}
#define io read()

#define maxn 4005
int m,k,n,n2;
int w[maxn][maxn],b[maxn][maxn];

inline void init(){
	m=io;k=io;
	n=k<<1;n2=n<<1;
	while(m--){
		int x=io%n+1,y=io%n+1;
		++(io?b:w)[x][y];
	}
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j){
			b[n+i][j]=b[i][n+j]=b[n+i][n+j]=b[i][j];
			w[n+i][j]=w[i][n+j]=w[n+i][n+j]=w[i][j];
		}
	for(int i=1;i<=n2;++i)
		for(int j=1;j<=n2;++j){
			b[i][j]+=b[i-1][j]+b[i][j-1]-b[i-1][j-1];
			w[i][j]+=w[i-1][j]+w[i][j-1]-w[i-1][j-1];
		}
}

inline int sum(int a[][maxn],int x,int y){
	--x;--y;
	return a[x+k][y+k]-a[x][y+k]-a[x+k][y]+a[x][y];
}
inline void solve(){
	int ans=0;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j){
			int tmp=sum(w,i,j)+sum(b,i+k,j)+sum(b,i,j+k)+sum(w,i+k,j+k);
			if(tmp>ans)ans=tmp;
		}
	printf("%d\n",ans);
}

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

Measured memory_bytes: 125440
W, H, N = map(int, input().split())

x = 0
y = 0
a = 0
p1 = 0
p2 = W
p3 = 0
p4 = H
for i in range(N):
	x, y, a = map(int, input().split())

	if a==1:
		p1 = max(p1, x)
	elif a==2:
		p2 = min(p2, x)
	elif a==3:
		p3 = max(p3, y)
	elif a==4:
		p4 = min(p4, y)

if p1>=p2 or p3>=p4:
	print(0)
else:
	print((p2-p1)*(p4-p3))


Measured memory_bytes: 3064
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
#sys.stdin = open("input.txt", "r")
#sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)


A,B=l()
print(A*B)

Measured memory_bytes: 10648
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

// ============union_find_tree===============
ll MAX_N = 200010;
vector<ll> par(MAX_N);//MAX_N == num of node
vector<ll> tree_rank(MAX_N);

void init(ll n)
{
  for (ll i = 0; i < n; ++i)
  {
    par.at(i) = i;
    tree_rank.at(i) = 0;
  }
}

ll find(ll x)
{
  if (par.at(x) == x)
  {
    return x;
  }
  else
  {
    return par.at(x) = find(par.at(x));
  }
}

void unite(ll x, ll y)
{
  x = find(x);
  y = find(y);
  if (x == y)
  {
    return;
  }
  if (tree_rank.at(x) < tree_rank.at(y))
  {
    par.at(x) = y;
  }
  else
  {
    par.at(y) = x;
    if (tree_rank.at(x) == tree_rank.at(y))
    {
      tree_rank.at(x)++;
    }
  }
}

bool same(ll x, ll y)
{
  return find(x) == find(y);
}
// =======================================

int main()
{
  ll N, M;
  cin >> N >> M;
  init(N + M);
  for (ll i = 0; i < N; ++i) {
    ll K;
    cin >> K;
    for (ll j = 0; j < K; ++j) {
      ll L;
      cin >> L;
      unite(i, L - 1 + N);
    }
  }
  for (ll i = 0; i < N; ++i) {
    find(i);
  }
  ll par_ind = -1;
  for (ll i = 0; i < N; ++i) {
    // cout << par.at(i) << endl;
    if (i == 0) {
      par_ind = par.at(i);
      continue;
    }
    if (par_ind != par.at(i)) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int>v1,v2;
    for(int i=0; i<n; i++)
    {
        int x,y;
        cin >> x >> y;
        v1.push_back(x+y);
        v2.push_back(x-y);
    }
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
    cout << max(v1[v1.size()-1]-v1[0],v2[v2.size()-1]-v2[0]) << endl;
}


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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()         

#define bug(...)                                  __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{     rtn 
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

inline void INP();
const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, Q;
int arr[N+2];


void solve()
{
      
      int h, w;
      cin >> h >> w;

      if( h == 1 or w == 1 )
      {
            cout << 1 << endl;
      }
      else if( w%2 == 0 || h%2 ==  0 )
      {
            cout << (w*h)/2;
      }
      else
      {     
            int o = h/2 + 1;
            int r = h - o;
            int ans = (w/2 + 1)*o + (w/2)*r;
            cout << ans;
      }
      
}


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

      int t = 1;
      //cin >> t;
      while(t--) solve();

}











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


// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //






Measured memory_bytes: 256
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[] for _ in range(num)]
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

N = I()
K = I()
S = str(N)

def calc1(S):
    if len(S)<1:
        return 0
    flag = False
    ans = 0
    for s in S:
        if flag:
            ans += 9
        else:
            if s!='0':
                flag = True
                ans += int(s)
    return ans

def calc2(S):
    bl = len(S)
    ans = 0
    if bl<2:
        return 0
    # 最上位bitに0
    ans += (bl-1)*(bl-2)*81 // 2
    # 最上位bitに1~(その数未満)
    ans += (int(S[0])-1)*9*(bl-1)
    # 最上位bitにその数
    val = -1
    for i in range(1,len(S)):
        if S[i]!='0':
            val = i
            break
    if val!=-1:
        newS = S[val:]
        ans += calc1(newS)
    return ans

def calc3(S):
    bl = len(S)
    if bl<3:
        return 0
    ans = 0
    # 最上位bitに0
    ans += (bl-1)*(bl-2)*(bl-3)*9*9*9 //6
    # 最上位bitに1~（その数未満）
    ans += (int(S[0])-1)*(bl-1)*(bl-2)*81 // 2
    # 最上位bitにその数
    val = -1
    for i in range(1,len(S)):
        if S[i]!='0':
            val = i
            break
    if val!=-1:
        newS = S[val:]
        ans += calc2(newS)
    return ans

if K==1:
    print(calc1(S))
if K==2:
    print(calc2(S))
if K==3:
    print(calc3(S))

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

int main(){
	string s;
	cin >> s;
	queue<int> a;
	stack<int> z;
	rep(i, s.size()){
		if(s[i] == 'A') a.push(i);
		else if(s[i] == 'Z') z.push(i);
	}

	cout << z.top() - a.front() + 1 << endl;
	return 0;
}

Measured memory_bytes: 4384
from collections import deque
s = input()
s = deque(s)
q = int(input())

rev = 0
for i in range(q):
    inp = list(input().split())
    if inp[0] == '1':rev = rev^1
    else:
        if (inp[1] == '1' and rev == 0) or (inp[1] == '2' and rev == 1):
            s.appendleft(inp[2])
        else:
            s.append(inp[2])

s = list(s)
if rev == 1:s = s[::-1]
print(*s, sep = '')

Measured memory_bytes: 12400
#include "bits/stdc++.h"

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return x;}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

template<typename T>
bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>
bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	auto X=in(),N=in();
	auto P=vecin(N);
	set<ll> L;
	for(auto& x:P) L.insert(x);

	ll minC=1<<30,minI=0;
	REP(i,105){
		ll Y=i-2;
		if(L.find(Y)==L.end()){
			ll D=abs(X-Y);
			if(minC>D){
				minC = D;
				minI = i-2;
			}
		}
	}
	
	out(minI);
	return 0;
}


Measured memory_bytes: 3656
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

bool flag[1010101];

int s;
int m = 0;
int main(){
    cin >> s;
    while(flag[s] == false){
        flag[s] = true;
        if(s % 2 == 0)s /= 2;
        else s = 3*s + 1;
        m++;
    }
    cout << m + 1 << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import numpy as np

def gen_check(N: int, S: "List[str]"):
    tmp = [tuple(s)+tuple(s) for s in S]
    S = np.array(tmp+tmp)
    def check(a, b):
        s = S[a:a+N,b:b+N]
        return np.array_equal(s, s.T)
    return check

def solve(N: int, S: "List[str]"):
    ans = 0
    check = gen_check(N, S)
    for a in range(N):
        if check(a, 0):
            ans += N
    return ans

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    print(solve(N, S))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


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

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

    bool ok = false;
    if (s[0] == s[1] && s[2] == s[3]) ok = true;
    if (s[0] == s[2] && s[1] == s[3]) ok = true;
    if (s[0] == s[3] && s[1] == s[2]) ok = true;
    if (s[0] == s[1] && s[1] == s[2] && s[2] == s[3]) ok = false;

    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  string s;
  cin >> s;
  stack<char> stk;
  int co = 0;
  rep(i, s.size()){
    if(s.at(i) == 'S'){
      stk.push('S');
    }else{
      if(!stk.empty()){
        stk.pop();
        co++;
      }
    }
  }
  cout << s.size()-2*co << endl;
  return 0;
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
long long n,x;
long long s[300];
long long a[300][100001];
long long m[300][100001];
long long mod=1000000007;
long long f[300];
long long p[300][300];
long long fp[300][300];
long long calc(long long i,long long t) {
	if(a[i][t]!=-1) return a[i][t];
	else {
		if(i==0) a[i][t]=(t*f[i])%mod;
		else a[i][t]=0;
		for(long long j=0;j<i;j++) a[i][t]=(a[i][t]+fp[j+1][i-j-1]*calc(j,m[j][t]))%mod;
		a[i][t]%=mod;
		return a[i][t];
	}
}
int main()
{
	/*n=200;
	x=100000;
	for(int i=0;i<n;i++) s[i]=x/2+i;*/
	scanf("%lld %lld",&n,&x);
	for(long long i=0;i<n;i++) scanf("%lld",&s[i]);
	sort(s,s+n);
	for(long long i=0;i<n;i++) {
		for(long long j=0;j<=x;j++)  {
			m[i][j]=j%s[i];
			a[i][j]=-1;
		}
	}
	f[0]=1;
	for(long long i=1;i<=n;i++) f[i]=(f[i-1]*i)%mod;
	for(long long i=0;i<=n;i++) {
		p[i][0]=1;
		for(long long j=1;j<=n;j++) p[i][j]=(p[i][j-1]*i)%mod;
	}
	for(long long j=0;j<=n;j++) {
		for(long long i=0;i<=n;i++) {
			if(j==0) fp[i][j]=1;
			else fp[i][j]=(fp[i][j-1]*(i+j-1))%mod;
			//fp[i][j]=f[j]*p[i][j];
		}
	}
	long long ans=0;
	for(long long i=0;i<n;i++) {
		ans=(ans+calc(i,m[i][x])*fp[i+1][n-i-1])%mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 315136
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
mod = 10 ** 9 + 7

ret = 0
ca = [0] * (2001)
cb = [0] * (2001)

for i in range(N) :
    ca[A[i]] += 1
    ca[A[i]] %= mod
    
for i in range(2000) :
    ca[i + 1] = (ca[i + 1] + ca[i]) % mod

for i in range(N - 1, -1, -1) :
    ret += K * sum(cb[:A[i]]) + K * (K - 1) * ca[A[i] - 1] // 2
    ret %= mod
    cb[A[i]] += 1
    
print(ret)

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

string in;
vi s;

bool ok(int num) {
	int c = 0;
	vi t;

	// * 9
	rep(i, s.size()) {
		c = c + s[i] * 9;
		t.pb(c % 10);
		c /= 10;
	}
	if (c) t.pb(c);

	// + num * 9

	vi add;
	int x = num;

	while (x > 0) {
		add.pb(x % 10);
		x /= 10;
	}

	vi add2;
	c = 0;
	rep(i, add.size()) {
		c = c + add[i] * 9;
		add2.pb(c % 10);
		c /= 10;
	}
	if (c) add2.pb(c);
	add = add2;	

	int sz = max(add.size(), t.size());
	while (t.size() < sz) {
		t.pb(0);
	}
	while (add.size() < sz) {
		add.pb(0);
	}

	c = 0;
	rep(i, sz) {
		c += add[i] + t[i];
		t[i] = c % 10;
		c /= 10;
	}

	if (c) {
		t.pb(c);
	}

	int sum = 0;
	for (int x : t) {
		sum += x;
	}
	return sum <= num * 9;
}

int main() {
	cin >> in;
	reverse(ALL(in));
	for (char c : in) {
		s.pb(c - '0');
	}

	int lo = 0, hi = s.size();

	while (hi - lo > 1) {
		int m = (lo + hi) / 2;
		if (ok(m)) {
			hi = m;
		} else {
			lo = m;
		}
	}

	cout << hi << endl;
	return 0;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  
  int cnt = 0;
  rep(i, n){
    if(s.at(i) == 'C' && s.at(i - 1) == 'B' && s.at(i - 2) == 'A'){
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3600