akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define mp make_pair
#define mt make_tuple
#define X first
#define Y second
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define D double
#define ll long long
#define REP(i,a) for(int i=0;i<a;i++)
#define REP1(i,a,b) for(int i=a;i<b;i++)
#define REP2(i,a,b) for(int i=a;i<=b;i++)
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define RREP1(i,a,b) for(int i=a;i>b;i--)
#define RREP2(i,a,b) for(int i=a;i>=b;i--)
#define SREP(i,x) for(auto i:x)
#define MS0(x) memset((x),0,sizeof((x)))
#define MS1(x) memset((x),-1,sizeof((x)))
#define MSF(x) memset((x),127,sizeof(x))
#define pb push_back
#define LE(x) (int)((x).size())
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDD pair<D,D>
#define im guagua
#define RI(x) x=rit()
#define RII(a,b) a=rit(),b=rit()
#define RIII(a,b,c) a=rit(),b=rit(),c=rit()
#define debug 0
const int INF = 0x7F7F7F7F;
const double EPS = 1e-10 ;
const ll mod7 = 1e9+7;
const ll mod9 = 1e9+9;
using namespace std;
inline ll rit(){
    ll f=0,key=1;
    char c;
    do{
        c=getchar();
        if(c=='-') key=-1;
    }while(c<'0' || c>'9');
    do{
        f=f*10+c-'0';
        c=getchar();
    }while(c>='0' && c<='9');
    return f*key;
}
inline void fprt(D f){
    printf("%.08lf",f);
}
void init(){
}
const int Z = 100005;
ll n,a,b,x[Z];
void read(){
    RIII(n,a,b);
    REP(i,n){
        RI(x[i]);
    }
}
void solve(){
    ll p = x[0];
    ll ans=0;
    REP1(i,1,n){
        ans+=min((x[i]-p)*a,b);
        p = x[i];
    }
    cout<<ans<<endl;
}
int main(){
    int nn=1;
    // nn=rit();
    while(nn--){
        // while(cin>>n) 
            init(),read(),solve();
    }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;




int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout<<setprecision(10);
  int k;
  cin>>k;
  while(k%2==0)k/=2;
  while(k%5==0)k/=5;
  int loop=0;
  int m=1;
  vector<int>edge;
  vector<int>f(k,0);
  do {
    edge.push_back(m);
    if(f[m]==0)f[m]=1;
    else break;
    m*=10;
    m%=k;
    loop++;
  }while(m!=1);
  //cout<<loop<<endl;
  //  cout<<k<<endl;
  if(k==1){cout<<1<<endl;return 0;}
  if(loop==k-1){cout<<2<<endl;return 0;}
  vector<int>dist(k,0);

  queue<int>que;
  que.push(1);
  while(!que.empty())
  {
    int now=que.front();que.pop();
    for(int i:edge)
    {
      int tmp=(i+now)%k;
      if(dist[tmp]>0)continue;
      dist[tmp]=dist[now]+1;
      if(tmp==0)
      {
        cout<<dist[tmp]+1<<endl;
        return 0;
      }
      que.push(tmp);
    }
  }



  return 0;

}


Measured memory_bytes: 1660
// import chie template :) {{{
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
    std.range, std.container, std.bigint, std.ascii, std.typecons;

// }}}
// nep.scanner {{{
class Scanner
{
    import std.stdio : File, stdin;
    import std.conv : to;
    import std.array : split;
    import std.string : chomp;

    private File file;
    private char[][] str;
    private size_t idx;

    this(File file = stdin)
    {
        this.file = file;
        this.idx = 0;
    }

    private char[] next()
    {
        if (idx < str.length)
        {
            return str[idx++];
        }

        char[] s;
        while (s.length == 0)
        {
            s = file.readln.chomp.to!(char[]);
        }

        str = s.split;
        idx = 0;

        return str[idx++];
    }

    T next(T)()
    {
        return next.to!(T);
    }

    T[] nextArray(T)(size_t len)
    {
        T[] ret = new T[len];

        foreach (ref c; ret)
        {
            c = next!(T);
        }

        return ret;
    }

    void scan()()
    {
    }

    void scan(T, S...)(ref T x, ref S args)
    {
        x = next!(T);
        scan(args);
    }
}
// }}}

void main()
{
    auto cin = new Scanner;

    while (true)
    {
        int n, p;
        cin.scan(n, p);
        if (n == 0 && p == 0) break;
        int[] ar = new int[n];
        int sum;
        for (int i = 0; i < n; i = (i + 1) % n)
        {
            if (p == 0)
            {
                p = ar[i];
                sum -= ar[i];
                ar[i] = 0;
            }
            else
            {
                ++sum;
                ++ar[i];
                --p;
                if (p == 0 && sum == ar[i])
                {
                    writeln(i);
                    break;
                }
            }
        }
    }
}



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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
const char nl = '\n';

#define elif else if
#define def inline auto
#define run __attribute__((constructor)) def _

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i < _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i > _##i; --i)
#define rep(i, n) inc(i, 0, n)
#define be(c) begin(c), end(c)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")


signed main() {
    int n, k;
    cin >> n >> k;
    int t = min(n, k-1);
    int nn = 1;
    while(t*pow(2,nn) < k) {
        ++nn;
    }
    double ans = 0;
    double b = 1.0/n;
    if (n >= k) ans = (n - k + 1)*b;
    for(int i = t; 0 < i; --i) {
        while(i*pow(2,nn) < k) {
            ++nn;
        }
        ans += b * 1.0/pow(2, nn);
    }
    cout << ans << nl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
#define sz(a) ll(a.size())
ll f(multiset<p2> s1,multiset<p2> s2,ll op){
	ll cur=0,res=0;
	while(!s1.empty()){
		p2 x;
		if(!op){
		    x=(*prev(s1.end(),1));
			s1.erase(prev(s1.end(),1));
			s2.erase(s2.find({x.second,x.first}));
			if(x.first<cur)
				break;
		}
		else{
			x=(*s2.begin());
			s1.erase(s1.find({x.second,x.first}));
			s2.erase(s2.begin());
			if(x.first>cur)
				break;
		}
		res+=abs(x.first-cur);
		cur=x.first;
		op^=1;
	}
	res+=abs(cur);
	return res;
}
void solve(){
	ll n;
	cin>>n;
	multiset<p2> s1,s2;
	for(ll i=0;i<n;i++){
		ll x,y;
		cin>>x>>y;
		s1.insert({x,y});
		s2.insert({y,x});
	}
	cout<<max(f(s1,s2,0),f(s1,s2,1));
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("in01.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    clock_t z=clock();
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++)
        solve();
    debug("Total Time:%.4Lf\n",(ld)(clock()-z)/CLOCKS_PER_SEC);
}

Measured memory_bytes: 41168
#include <iostream>

using namespace std;

int main(void) {
	int N;
	cin >> N;
	int res = 0;
	int now = 10;
	while (now <= N) {
		res += (now-1)-(now/10)+1;
		now *= 100;
	}
	now /= 10;
	if (N >= now) {
		res += N-now+1;
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>


int main(){
  int I, O, T, J, L, S, Z, k;
  long long int ans=0;
  scanf("%d%d%d%d%d%d%d", &I, &O, &T, &J, &L, &S, &Z);
  k = (I&1)+(J&1)+(L&1);
  if(k>=2&&I>0&&J>0&&L>0){
    ans += 3;
    I -= 1;
    J -= 1;
    L -= 1;
  }
  ans += (long long int) O+(I&~1)+(J&~1)+(L&~1);
  printf("%lld\n", ans);
  return 0;
}


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

using namespace std;
#define rep(i,n) for(int i = 0;i < (int)n;i++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using P = pair<int,int>;
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};
//const int INF = (1 << 29);


int main(){

  ll a,b,k;
  cin >> a >> b >> k;
  ll taka = a-k,ao = b;
  if(a-k<0)ao = b-k+a,taka = 0;
  if(ao < 0)ao = 0;
  cout << taka << " " << ao;


  return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }
        public void Solve(ConsoleInput cin)
        {
            var a = cin.ReadInt;
            var b = cin.ReadInt;
            var c = cin.ReadInt;
            var ans = c - Min(a - b, c);
            WriteLine(ans);
        }
    }
    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
int main(){
	string S,T;
	cin >> S;
	cin >> T;
	// cout << S << endl;
	// cout << T << endl;
	vector<int> sc(26,0);
	vector<int> tc(26,0);
	vector<int> s;
	vector<int> t;
	int k = 1;
	for (ll i = 0;i < S.size();i++){
		if (sc[S[i] - 'a'] == 0){//初めて出てきた文字
			sc[S[i] - 'a'] = k;
			s.pb(k);
			k++;
		}
		else{
			s.pb(sc[S[i] - 'a']);
		}
	}

	k = 1;
	for (ll i = 0;i < S.size();i++){
		if (tc[T[i] - 'a'] == 0){//初めて出てきた文字
			tc[T[i] - 'a'] = k;
			t.pb(k);
			k++;
		}
		else{
			t.pb(tc[T[i] - 'a']);
		}
	}
	int flag = 0;
	for (ll i = 0;i < s.size();i++){
		if (s[i] != t[i]){
			flag = 1;
			break;
		}
	}
	if (flag == 1){
		cout << "No" <<endl; 
	}
	else{
		cout << "Yes" <<endl; 
	}

	return 0;
}

Measured memory_bytes: 2940
#include<stdio.h>
int main(){

int n = 0;
	int a[4][13];//????¬??????????
	int i = 0, j = 0;//i??????????????????????¨?
	int k = 0;//?????????????¢????
	int x = 0;//??????????????????????????????1???????????????0?????£??\
	char m;//????????????

	for(i = 0; i < 4; i++){
		for(j = 0; j < 13; j++){
		a[i][j] = 0;
		}//???????¨?????????????
	}//?????????????????????
	
	scanf("%d",&n);//??????????????°????¢????
	
	for(k = 0; k <2* n; k++){
		scanf("%c %d",&m,&x);
		if(m == 'S')a[0][x-1] = 1;
		else if(m == 'H')a[1][x-1] = 1;
		else if(m == 'C')a[2][x-1] = 1;
		else if(m == 'D')a[3][x-1] = 1;
	}//?????¨???????????????????¬???????????????¨??????????????????????¬????????????????
	
	
	for(i = 0; i < 4; i++){
		for(j = 0; j < 13; j++){
			if(a[i][j] == 0){
					if(i == 0){printf("S %d\n",j+1);}
					else if(i == 1){printf("H %d\n",j+1);}
					else if(i == 2){printf("C %d\n",j+1);}
					else if(i == 3){printf("D %d\n",j+1);}
			}
		
		}
	
	}//???????????????????????????????????????????????´???for??§?????????????????°???????????????
return 0;
}

Measured memory_bytes: 596
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	ll N,K;
	cin>>N>>K;
	if(N>K)
	{
		N%=K;
	}
	else if(N==K)
	{
		cout<<0<<endl;
		return 0;
	}
	ll min=N;
	if(K-N<N)
		min=K-N;
	cout<<min<<endl;
	return 0;
}
 


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

int main() {
  int N;
  string A ,S = "Three";
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> A;
    if(A == "Y"){
      S = "Four";
      break;
    }
  }
  cout << S;
}


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

long long int A, B, C, D, i;

int main(){
    scanf("%lld %lld %lld", &A, &B, &C);
    D = A + B + C;
    if(D & 1)return 0 & puts("0");
    if(!(A ^ B) && !(B ^ C))return 0 & puts("-1");
    for(i = 0;; ++i){
        if((A & 1) | (B & 1) | (C & 1)){
            break;
        }else{
            A = (D - A) / 2;
            B = (D - B) / 2;
            C = (D - C) / 2;
        }
    }
    cout << i << endl;
    return 0;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        try {
            BufferedReader stdReader = new BufferedReader(new InputStreamReader(System.in));
            
            String line;
            int c = 0;
            int count = 0;
            while((line = stdReader.readLine()) != null) {
                if(c == 0) {
                    count = Integer.parseInt(line);
                    c++;
                    continue;
                }
                
                // ?????????????§???????????????§????????????????????\??????
                String[] array = line.split(" ", 0);
                
                // ????????????????????\????????????
                String[] invArray = new String[count];
                int inv = count - 1;
                for(int i = 0; i < count; i++) {
                    invArray[inv - i] = array[i];
                }
                
                // ??\???????????????????????¨?????????
                for(int j = 0; j < count; j++) {
                    System.out.print(invArray[j]);
                    if(j != (count-1)) {
                        System.out.print(" ");
                    }
                }
                System.out.println();
                c = 0;
            }
            stdReader.close();
        } catch(Exception e) {
            e.getStackTrace();
            System.exit(-1);
        }
    }
}

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

int main(void){
  int a,b; cin >> a >> b;
  if(a >= b){
    for(int i = 0; i < a; i++){
      cout << b;
    }
  }
  else{
    for(int i = 0; i < b; i++){
      cout << a;
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
import Data.List
import Data.Maybe

type Mass = (Double, Double, Double, Double)

main = do
  [a,b,c,d,e,f] <- map read . words <$> getLine :: IO [Double]
  let water = [0..30] :: [Double]
      sugar = [0..100] :: [Double]
      pattern = [(a*100*n, b*100*m, c*l, d*k) | n <- water, m <- water, l <- sugar, k <- sugar, a*100*n + b*100*m + c*l + d*k <= f]
  putStrLn . unwords . map (show . truncate) . (\(x, y, z, w) -> [x+y+z+w, z+w]) $ solve e pattern (0, 0, 0, 0)

mix :: Double -> (Double, Double, Double, Double) -> Double
mix e (a, b, c, d)
  | e / (100 + e) >= (c + d) / (a + b + c + d) = (c + d) / (a + b + c + d)
  | otherwise = -1

solve :: Double -> [Mass] -> Mass -> Mass
solve e [] best = best
solve e (m:ms) best
  | mix e m == e / (100 + e) = m
  | mix e m > mix e best = solve e ms m
  | otherwise = solve e ms best


Measured memory_bytes: 2044
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    ll N, A, B; cin >> N >> A >> B;
    ll X[N]; rep(i, N) cin >> X[i];
    ll ans = 0;
    rep(i, N - 1) {
        ans += min((X[i + 1] - X[i]) * A, B);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N,M=get_i
if N.odd?
    1.upto(M) do|i|
        puts [i,N+1-i].join(" ")
    end
else
    m=M
    1.upto(N/4) do|i|
        puts [i,N/2+1-i].join(" ")
        m-=1
        break if m.zero?
    end
    exit if m.zero?
    (N/2+2).upto(N/2+1+m) do|i|
        puts [i,N+2-i+N/2].join(" ")
    end
end

Measured memory_bytes: 14272
a_n=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

K =int(input())
print(a_n[K-1])

Measured memory_bytes: 3060
h,w = map(int,input().split())
l =[]
q =[]
n=[]
l.append("."*(w+2))
for i in range(h):
  l.append("."+ input()+".")
l.append("."*(w+2))
for i in range(1,h+1):
  for t in range(1,w+1):
    if l[i][t]==".":
      q.append(l[i][t-1])
      q.append(l[i][t+1])
      q.append(l[i-1][t-1])
      q.append(l[i-1][t])
      q.append(l[i-1][t+1])
      q.append(l[i+1][t-1])
      q.append(l[i+1][t])
      q.append(l[i+1][t+1])
      z = q.count("#")
      n.append(z)
      q = []
    else:
      n.append("#")
for t in range(0,h):
  c = n[w*t:w*(t+1)]
  c = map(str,c)
  print(''.join(c))


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	int A, B, C, D;
	cin >> A >> B >> C >> D;
	cout << (A - C) * (B - D) << endl;

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
def main():
    N = int(input())
    
    can_six = []
    can_nine = []
    limit = 100
    for i in range(1, limit):
        six = 6 ** i
        if six <= N:
            can_six.append(six)
        nine = 9 ** i
        if nine <= N:
            can_nine.append(nine)
        if six > N and nine > N:
            break
    can = sorted([1] + can_six + can_nine)

    INF = 10 ** 9
    dp = [INF] * (N + 1)
    dp[0] = 0
    for n in range(N + 1):
        for draw in can:
            if n - draw < 0:
                break
            dp[n] = min(dp[n], dp[n - draw] + 1)
    print(dp[-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 73456
#include<iostream>
using namespace std;
 
int main(){
    while(1){
        int a, b, c;
        char op;
        cin >> a >> op >> b;
        if(op == '?') break;
        if(op == '+') c = a + b;
        if(op == '-') c = a - b;
        if(op == '*') c = a * b;
        if(op == '/') c = a / b;
        cout << c << endl;
    }
    return 0;
}

Measured memory_bytes: 3080
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine();
        var W = new int[n];
        if (s[n - 1] == 'W') W[n - 1] = 1;
        var E = new int[n];
        if (s[0] == 'E') E[0] = 1;
        var Leader = new int[n];

        for (int i = 1; i < n; i++)
            E[i] = E[i - 1] + (s[i] == 'E' ? 1 : 0);
        for (int i = n - 2; i >= 0; i--)
            W[i] = W[i + 1] + (s[i] == 'W' ? 1 : 0);
        for (int i = 0; i < n; i++)
            Leader[i] = E[i] + W[i];
        Console.WriteLine(n - Leader.Max());
    }
}


Measured memory_bytes: 17760
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#define o 1000005
#define re register int
#define ll long long
#define g0(a) memset(a,0,sizeof(a))
#define gc(a,b) memcpy(a,b,sizeof(a))
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define REP(i,a,b) for(int i=a;i>=b;i--)
#define pa pair<int,int>
#define mpp make_pair
#define s1 first
#define s2 second
#define go(x) for(ll i=h[x];i;i=w[i].next)
using namespace std;
inline int read()
{
	register int data=0,w=1;
	char ch=0;
	while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
	if(ch=='-')w=-1,ch=getchar();
	while(ch>='0'&&ch<='9')data=(data<<1)+(data<<3)+(ch^48),ch=getchar();
	return data*w;
}
int n,m,f[22][1<<17],fac[o],s[o],inv[o],a[o];
const int mod=1e9+7;
void fix(int &x){x-=mod;x+=x>>31&mod;}
int KSM(int x,int k)
{
	int tmp=1,y=x;
	for(int i=k;i;i>>=1,y=1ll*y*y%mod)if(i&1)tmp=1ll*tmp*y%mod;
	return tmp;
}
int A(int n,int m){
	return n<m?0:1ll*fac[n]*inv[n-m]%mod;
}
int main()
{
	n=read(),m=read();
	FOR(i,1,m)a[i]=read();
	sort(a+1,a+m+1);
	fac[0]=1;
	FOR(i,1,(1<<n)-1)fac[i]=1ll*fac[i-1]*i%mod;
	FOR(i,0,(1<<n)-1)inv[i]=KSM(fac[i],mod-2);
	f[m+1][0]=1;
	REP(i,m,1)FOR(j,0,(1<<n)-1)
	{
		if(!f[i+1][j])continue;
		int sz=(1<<n)-a[i];
		FOR(k,0,n-1)if(j>>k&1)sz-=1<<k;
		if(sz<0)continue;
		FOR(k,0,n-1)if(!(j>>k&1))fix(f[i][j|1<<k]+=1ll*A(sz,(1<<k)-1)*(1<<k)%mod*f[i+1][j]%mod);
		fix(f[i][j]+=f[i+1][j]);
	}
	int ans=0;
	s[0]=mod-1;
	FOR(i,0,(1<<n)-1)
	{
		s[i]=mod-s[i-(i&-i)];
		if(!f[1][i])continue;
		int sz=(1<<n)-1;
		FOR(j,0,n-1)if(i>>j&1)sz-=1<<j;
		ans=(ans+1ll*s[i]*f[1][i]%mod*fac[sz])%mod;
	}
	cout<<1ll*ans*(1<<n)%mod<<'\n';
	return 0;
}

Measured memory_bytes: 7836
import itertools
h,w,k=map(int,input().split())
lst=[list(input()) for i in range(h)]
lst2=[lst[i] for i in range(h)]

pin=0
for i in range(h):
  pin+=lst[i].count('#')

ans=0

for hei in itertools.product(range(2),repeat=h):
  for wid in itertools.product(range(2),repeat=w):
    cnt=0
    for i in range(h):
      for j in range(w):
        if hei[i]==1 and wid[j]==1 and lst[i][j]=="#":
          cnt+=1
    
    if cnt==k:
      ans+=1

    
print(ans)

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

int M,N;
typedef pair<int,int> P;
int X[1111],Y[1111];

const int INF = (1<<29);

//up,right,down,left;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
P G[1111][4];

void add_edge(int i,int j){
  if( X[i] != X[j] ) {
    if( X[i] > X[j] ) swap( i, j );
    G[i][1] = P(j, X[j]-X[i]);
    G[j][3] = P(i, X[j]-X[i]);
  } else {
    if( Y[i] > Y[j] ) swap( i, j );
    G[i][0] = P(j, Y[j]-Y[i]);
    G[j][2] = P(i, Y[j]-Y[i]);
  }
}

struct state{
  int id,d,ky,ps;
  state(){}
  state(int id,int d,int ky,int ps):id(id),d(d),ky(ky),ps(ps){}
  bool operator<(const state& st) const{
    if( ky == st.ky ) return ps > st.ps;
    return ky > st.ky;
  }
};

P H[1111][4];

bool isright(int d,int nd){
  if( (d+1)%4 == nd ) return true;
  return false;
}

void solve(int s,int t){
  for(int i=0;i<=M;i++)
    for(int j=0;j<4;j++)
      H[i][j] = P(INF,INF);
  priority_queue<state> q;  
  q.emplace( s, 0, 0, 1 );
  q.emplace( s, 1, 0, 1 );
  q.emplace( s, 2, 0, 1 );
  q.emplace( s, 3, 0, 1 );
  H[s][0] = P(0,1);
  H[s][1] = P(0,1);
  H[s][2] = P(0,1);
  H[s][3] = P(0,1);

  while( !q.empty() ) {
    state st = q.top(); q.pop();    
    if( H[st.id][st.d] < P(st.ky,st.ps) ) continue;
    //cout << st.id << " "<< st.d << " "<< st.ky << " " << st.ps << endl;
    if(st.id==t){
      cout << st.ps << endl;
      return;                            
    }
    for(int i=0;i<4;i++){
      if( isright( st.d, i ) ) continue;
      if( (i+2)%4 == st.d ) continue;
      P to = G[st.id][i]; if( to.second == INF ) continue;
      P nc = P( st.ky + to.second, st.ps + 1 );
      if( H[to.first][i] > nc ){
        H[to.first][i] = nc;
        q.emplace( to.first, i, nc.first, nc.second);
      }      
    }
  }
  cout << "impossible" << endl;  
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  while( cin >> M >> N && (M|N) ){
    for(int i=0;i<M;i++)
      for(int j=0;j<4;j++)
        G[i][j] = P(INF,INF);
    unordered_map<string,int> mp;
    for(int i=0;i<M;i++){
      string s; cin >> s;
      cin >> X[i] >> Y[i];
      mp[s] = i;
    }
    for(int i=0;i<N;i++){
      string a,b; cin >> a >> b;
      add_edge( mp[a], mp[b] );
    }
    /*  for(int i=0;i<M;i++){
      for(int j=0;j<4;j++){
        cout << i << ": " << j << " -> " << G[i][j].first << " "<< G[i][j].second << endl;
      }
    }
    */
    string src,dst; cin >> src >> dst;
    solve(mp[src],mp[dst]);
  }
}

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

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

    int n, k;
    cin >> n >> k;
    map<int, int> mp;
    REP(i, n){
        int tmp;
        cin >> tmp;
        mp[tmp]++;
    }
    
    if(mp.size() <= k){
        cout << 0 << endl;
        return 0;
    }

    int diff = mp.size() - k, cnt = 0;
    vector<int> A;
    for(auto x : mp){
        A.push_back(x.second);
    }
    sort(A.begin(), A.end());
    REP(i, diff) cnt += A[i];
    cout << cnt << endl;

    return 0;
}

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

sum_array = [0] * (N + 1)
for i in range(1, N+1):
    exp = (1 + P[i-1]) / 2
    sum_array[i] = sum_array[i-1] + exp

expectation = 0
for i in range(K, N+1):
    expectation = max(sum_array[i] - sum_array[i-K], expectation)
    # print(expectation)

print(expectation)


Measured memory_bytes: 25060
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
int s[110];
int dp[10][110];

int solve() {
    memset(dp, 0, sizeof(dp));
    dp[s[0]%10][0] = s[0];
    int v, w;
    for (int i = 1; i < n; i++) {
        v = s[i] % 10;        
        for (int j = 0; j < 10; j++) {
            dp[j][i] = dp[j][i-1];
        }
        for (int j = 0; j < 10; j++) {
            w = (v + j) % 10;
            if (j == 0 || dp[j][i-1] > 0)
                dp[w][i] = max(dp[w][i], dp[j][i-1] + s[i]);
        }
    }
    int res = 0;
    for (int i = 1; i < 10; i++) {
        res = max(res, dp[i][n-1]);
    }
    return res;
}

void input() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> s[i];
}

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

    input();
    cout << solve() << endl;
}


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

int main() {
    int N, K;
    int x;
    cin >> N >> K;
    int sum = 0;
    rep(i, N) {
        cin >> x;
        int disa = x * 2;
        int disb = (K - x) * 2;
        sum += min(disa, disb);
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3628
#!/usr/bin/python3

import heapq

def main():
    line1 = input()
    line2 = input()

    n, m = list(map(int, line1.split()))
    l = list(map(int, line2.split()))
    ans = sum(l)
    for i in range(len(l)):
        l[i] *= -1
    heapq.heapify(l)
    for i in range(m):
        price = heapq.heappop(l) * (-1)
        new_price = price // 2
        heapq.heappush(l, new_price * (-1))
        ans -= (price - new_price)
    print(ans)
    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 20940
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int k,x; cin>>k>>x;
	cout<<(500*k>=x?"Yes":"No")<<"\n";
	return 0;
}

Measured memory_bytes: 256
from math import factorial as fa
def comb(n, r):
    return fa(n)//(fa(n-r)*fa(r))
n, p = map(int, input().split())
A = list(map(lambda x:int(x)%2, input().split()))
even = A.count(0)
odd = A.count(1)
ans = 0
for i in range(p,odd+1,2):
    ans += comb(odd, i)
print(ans*pow(2,even))

Measured memory_bytes: 9072
#include <bits/stdc++.h>
using namespace std;
#define min(...) minn(__VA_ARGS__)
#define max(...) maxx(__VA_ARGS__)
#define stringio() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
char _;
typedef long long ll;
typedef pair<int,int> pii;
template<typename t>constexpr const t minn(const t x,const t y){return x<y?x:y;}
template<typename t,typename ...r>constexpr const t minn(const t x,const r ...xs){return minn(x,minn(xs...));}
template<typename t>constexpr const t maxx(const t x,const t y){return x>y?x:y;}
template<typename t,typename ...r>constexpr const t maxx(const t x,const r ...xs){return maxx(x,maxx(xs...));}
template <typename t> void scan (t& x) {do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0);}
template <typename t, typename ...r> void scan (t& x, r&... xs) {scan(x); scan(xs...);}
const int MAXN = 100005;
int main() {
    int n,a,mx=INT_MIN,mx2=INT_MIN,ind=0;
    scan(n);
    for (int i = 0; i < n; i++) {
      scan(a);
      if (a > mx) {mx2 = mx, ind = i, mx = a;}
      else mx2 = max(mx2,a);
    }
    for (int i = 0; i < n; i++) {
      if (ind == i) printf ("%d\n",mx2);
      else printf ("%d\n",mx);
    }
    return 0;
}


Measured memory_bytes: 1664
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;

public class Main {

	public static long sum(long x){
		long ret = 0;
		while(x > 0){ ret += x % 10; x /= 10; }
		return ret;
	}
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		final long N = sc.nextLong();
		
		long answer = sum(N);
		
		char[] s = ("" + N).toCharArray();
		s[0]--;
		for(int i = 1; i < s.length; i++){ s[i] = '9'; }
		
		answer = Math.max(answer, sum(Long.parseLong(String.valueOf(s))));
		System.out.println(answer);
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 23124
/* @ by batr (T) */
// AC! (C) DARyn ABu
#include <bits/stdc++.h>

#define Need_For_Speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
#define ll long long
#define pb push_back
#define mp make_pair
#define all(X) (X).begin(), (X).end()
 
#define cmp_all(X) (X).begin(), (X).end(), cmp
 
#define rB rbegin()
#define B begin()
#define E end()
#define sz size()
#define skip continue
 
#define ppi pair<pair<int, int>, int>
#define pii pair<int, int> 
#define pli pair<ll, int>
#define pcc pair<char, char>
 
#define F first
#define S second

using namespace std;
 
const int maxn = 1e5 + 17;
const int MAXN = maxn * 4;
const int darr = 1e3 + 17;
const ll INF = 1e17 + 5;
const int mod = 1e9 + 7;

int n, c, k;
int t[maxn];

int res;

int main () {
	Need_For_Speed
	cin >> n >> c >> k;
	for (int i = 1; i <= n; i++) {
		cin >> t[i];
	}
	sort(t + 1, t + n + 1);
	ll add = 0;
	bool b = 0;
	int ct = 0;
	for (int i = 1; i <= n; i++) {
		if (t[i] <= add && ct < c) {
			ct++;
			skip;
		}
		add = t[i] + k;
		ct = 1;
		res++;
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <iomanip>
using namespace std;
using P = pair<int,int>;
typedef long long ll;


#define rep(i,n) for (int i=0; i<(n); i++)
//const int INF =1001001001;
const ll BIG = 1e9+7;
const double PI = 3.141592653589793;

int main(){
    int x, y;
    cin >> x >> y;
    rep(i, 101) {
        rep (j, 101) {
            int sum = 2*i + 4*j;
            if(sum == y && x == i+j) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main() {
  int K;cin>>K;
  
  ll sum=0;
  for(int i=1;i<=K;i++){
    for(int j=1;j<=K;j++){
      for(int k=1;k<=K;k++){
		sum+=gcd(gcd(i,j),k);
      }
    }
  }
  
  cout << sum << endl;
}


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

int main(void) {
    int n;
    cin >> n;
    vector< int > p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    int count = 0;
    for (int j = 2; j < n; j++) {
        if (p[j - 1] > p[j] && p[j - 1] <= p[j - 2] ||
            p[j - 1] > p[j - 2] && p[j - 1] <= p[j]) {
            ++count;
        }
    }
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    from collections import Counter

    n = int(input())
    s = Counter(input())
    ans = 1
    mod = 10 ** 9 + 7

    # See:
    # https://www.youtube.com/watch?v=g2LMI15ha_U

    # Key Insight
    # 要素がすべて異なる=各要素が1個以下になるように選ぶ
    # それぞれの要素を独立に考えられる
    for index, count in s.items():
        # 選び方：ある文字の個数 + ある文字を選ばない(1通り)
        ans *= count + 1
        ans %= mod

    # すべての文字の積 - すべて選ばない(1通り)
    print(ans - 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int lli;
#define optimize ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define forn(i,n) for(int i = 0; i<n; i++)
#define forab(i,a,b) for(int i = a; i<b; i++)
#define forll(i,a,b) for(lli i = a; i<b; i++)
#define mp make_pair
#define pb emplace_back
#define sortv(v) sort(v.begin(), v.end())
#define debug(x) cout<<#x<<" : "<<x<<endl
#define all(x) x.begin(),x.end()
const int mod1 = 1000000007;
const int mod2 = 998244353;

int main()
{
	optimize
	#ifndef ONLINE_JUDGE
	freopen("inputf.in", "r", stdin);
    freopen("outputf.in", "w", stdout);
	#endif

	int x;
	cin>>x;

	if(x >= 30)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;

	
	return 0;
}

Measured memory_bytes: 3644
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int n, m;

int point(int x, int y, vector<int> &c, vector<int> &d) {
  int result, mn = 1e9;
  for (int i = 0; i < m; i++) {
    int dis = abs(x-c[i]) + abs(y-d[i]);
    if (dis < mn) {
      result = i+1;
      mn = dis;
    }
  }
  return result;
}


int main() {
  cin >> n >> m;
  vector<int> a(n), b(n), c(m), d(m);
  rep(i, n) cin >> a[i] >> b[i];
  rep(i, m) cin >> c[i] >> d[i];
  
  rep(i, n) {
    cout << point(a[i], b[i], c, d) << endl;
  }
  return 0;
}

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

/*long long int f(long long int n)
{
	if(n==1 || n==0)
	return 1;
	long long int fact=1;
	for(int i=2;i<=n;i++)
	fact*=i;
	return fact;
}*/

long long int C(long long int n)
{
	if(n==1 || n==0)
	return 0;
	long long int x;
	x=(n*(n-1))/2;
	return x;
}
int main()
{
	long long int N,M,c;
	cin>>N>>M;
	c=C(M)+C(N);
	cout<<c<<"\n";
	//cout<<C(13)+C(3);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n,q;
  cin>>n>>q;
  vector<Int> A(n),B(q);
  for(Int i=0;i<n;i++) cin>>A[i];
  for(Int i=0;i<q;i++) cin>>B[i];
  
  if(n==1){
    cout<<1<<endl;
    return 0;
  }

  vector<Int> L(n+1,0),R(n+1,0);
  for(Int i=0;i+1<n;i++){
    R[A[i]]=A[i+1];
    L[A[i+1]]=A[i];
  }
  Int lm=A[0],rm=A[n-1];

  for(Int i=0;i<q;i++){
    Int x=B[i];
    if(x==rm){
      Int l=L[x];

      R[l]=0;
      L[x]=0;
      R[x]=lm;
      L[lm]=x;

      lm = x;
      rm = l;
    }else if(x==lm){
      Int r=R[x]; 

      L[r]=0;
      R[x]=0;
      L[x]=rm;
      R[rm]=x;
      
      lm = r;
      rm = x;
    }else{
      Int l=L[x],r=R[x];
      L[x]=rm;
      R[x]=lm;

      R[l]=0;
      L[r]=0;

      L[lm]=x;
      R[rm]=x;

      rm=l;
      lm=r;
    }    
  }
  
  vector<Int> ans;
  while(lm!=0){
    ans.emplace_back(lm);
    lm=R[lm];
  }
  for(Int i=0;i<n;i++){
    if(i) cout<<" ";
    cout<<ans[i];
  }
  cout<<endl;
  return 0;
}



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

const int N=200005;

int n;
int a[N];
bitset<23> bit[N],temp;
 
void calc(int id,int x){
	int num=0,len[25];
	while(x) len[++num]=x%2,x/=2;
	for(int i=1;i<=num;i++) bit[id][i-1]=len[i];
}

void work()
{
	long long ans=0;
	for(int r=1,l=1;r<=n;r++){
		while((bit[r]&temp).any()&&(l<r)) temp^=bit[l++];
		temp|=bit[r];
		ans+=r-l+1;
	}
	cout<<ans<<endl;
}

void init()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		calc(i,a[i]);
	}
}

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

Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<cmath>
#include<algorithm>
#include<complex>
#include<cstdlib>
#include<cctype>

#define DBG cout << '!' << endl;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cout << v[i] << ' ';cout << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cout << v[a][b] << ' ';cout << endl;}cout << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	string n;
	cin >> n;
	
	if(n[0] == '9' || n[1] == '9')
	{
		cout << "Yes"  << endl;
	}
	else 
	{
		cout << "No" << endl;
	}
	
	

	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define  int    long long int
 #define    sp(x)                 setprecision(x)
#define    bp(x)           __builtin_popcount(x)
 #define  ld         long double
 #define  f(i,j,n)            for(int i = j; i <= n; i++)
#define  r(i,n,j)       for(int i = n; i >= j; i--)
 #define  all(container)       container.begin() , container.end()
#define  sz(container)   (int)container.size()
 #define  ff         first
#define  ss    second
 #define  pii      pair <int , int>
#define  sp(x)       setprecision(x)
 #define  endl    "\n"
#define  mod  1000000007
 #define  pb    push_back
#define  mp    make_pair
 #define  T     int ttt; cin >> ttt; while(ttt--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

int32_t main()
{
    fast
    int n,q,x,y;
    cin>>n;
    map<int,int>m;
    int sum=0;
    f(i,1,n)
    {
        cin>>x;
        m[x]++;
        sum+=x;
    }
    cin>>q;
    f(i,1,q)
    {
        cin>>x>>y;
        sum-=m[x]*x;
        sum+=m[x]*y;
        m[y]+=m[x];
        m[x]=0;
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 9536
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;bool b[10];
int main(){
  int n;
  cin>>n;
  int a[n];
  r(i,n)cin>>a[i];
  int m;
  cin>>m;
  while(m--){
    int q,w;cin>>q>>w;
    int s=0;
    r(i,n){
      if(i==q-1)s+=w;
      else s+=a[i];
    }
    cout<<s<<endl;
  }
}

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

int reward(int score){
    int money;
    switch (score){
        case 1:
            money = 300000;
            break;
        case 2:
            money = 200000;
            break;
        case 3:
            money = 100000;
            break;
    }
    
    return money;
}

int main(){
    int x, y;
    cin >> x >> y;
    
    int ans = 0;
    if (x <= 3){
        ans += reward(x);
    }
    if (y <= 3){
        ans += reward(y);
    }
    if (x == 1 and y == 1){
        ans += 400000;
    }

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

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


using namespace std;


enum Animal {
  SHEEP = 0,
  WOLF = 1,
};


enum Answer {
  SAME = 0,
  DIFFER = 1,
};


constexpr int right(int left, int center, int answer)
{
  return (left + center + answer) % 2;
}


vector<int> animals(int fst, int snd, const vector<int>& answers)
{
  size_t size = answers.size();

  vector<int> ret;
  ret.reserve(size);

  ret.push_back(fst);
  ret.push_back(snd);

  for (size_t i=2; i<size; ++i) {
    int r = right(ret[i-2], ret[i-1], answers[i-1]);
    ret.push_back(r);
  }

  if ((ret[size-1] + ret[0] + ret[1] + answers[0]) % 2)
    ret.clear();
  else if ((ret[size-2] + ret[size-1] + ret[0] + answers[size-1]) % 2)
    ret.clear();

  return ret;
}


void show_animals(const vector<int>& animals)
{
  for (auto a : animals) {
    if (a == SHEEP)
      cout << 'S';
    else
      cout << 'W';
  }
  cout << endl;
}


int main()
{
  size_t n;
  vector<int> answers;

  cin >> n;
  answers.reserve(n);

  for (size_t i=0; i<n; ++i) {
    char c;
    cin >> c;
    if (c == 'o')
      answers.push_back(SAME);
    else
      answers.push_back(DIFFER);
  }

  auto r = animals(SHEEP, SHEEP, answers);
  if (! r.empty()) {
    show_animals(r);
    return 0;
  }

  r = animals(SHEEP, WOLF, answers);
  if (! r.empty()) {
    show_animals(r);
    return 0;
  }

  r = animals(WOLF, SHEEP, answers);
  if (! r.empty()) {
    show_animals(r);
    return 0;
  }

  r = animals(WOLF, WOLF, answers);
  if (! r.empty()) {
    show_animals(r);
    return 0;
  }

  cout << "-1" << endl;
  return 0;
}


Measured memory_bytes: 1520
#include <bits/stdc++.h>
using namespace std;
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 int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

struct BIT // 0-indexed
{
    ll n;
    vector<ll> bit;
    // 初期化
    void init(ll n_input)
    {
        n = n_input + 1;
        bit.resize(n + 1);
        for (ll i = 0; i <= n; i++)
        {
            bit[i] = 0;
        }
    }
    // v[0] + ... + v[k-1]
    ll sum(ll k)
    {
        ll res = 0;
        for (ll i = k - 1; i >= 0; i = (i & (i + 1)) - 1)
        {
            res += bit[i];
        }
        return res;
    }
    // v[i] + ... + v[j]
    ll sum_between(ll i, ll j)
    {
        return i <= j ? sum(j + 1) - sum(i) : 0;
    }
    // v[k] += x
    void add(ll k, ll x)
    {
        for (ll i = k; i < n; i |= i + 1)
        {
            bit[i] += x;
        }
    }
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ll lb = 0;
    ll ub = 1LL << 30;
    ll hansu = ((n * (n + 1) / 2) + 1) / 2;
    BIT b;
    while (ub - lb > 1)
    {
        ll mid = (ub + lb) / 2;
        ll tmp = 0;
        b.init(2 * n + 1);
        ll res = 0;
        b.add(tmp + n, 1);
        for (ll i = 0; i < n; i++)
        {
            if (a[i] >= mid)
            {
                tmp++;
            }
            else
            {
                tmp--;
            }
            res += b.sum(tmp + n + 1);
            b.add(tmp + n, 1);
        }
        if (res >= hansu)
        {
            lb = mid;
        }
        else
        {
            ub = mid;
        }
    }
    cout << lb << endl;
}


Measured memory_bytes: 2560
N,M = map(int,input().split())
island = [tuple(map(int,input().split())) for _ in range(M)]

island.sort(key=lambda x:x[1])

right = 0
count = 0

for i in range(M):
    if right <= island[i][0]:
        right = island[i][1]
        count += 1

print(count)

Measured memory_bytes: 61528