akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <boost/dynamic_bitset.hpp>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeindex>
#include <typeinfo>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define DEBUG(x) cout << #x << ": " << x << endl
#define INFILE() freopen("input.txt", "r", stdin)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPC(i, a) REP(i, 0, a)
#define RREP(i, a, b) for (int i = (a); i >= (b); i--)
#define RREPC(i, a) RREP(i, a, 0)
#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_i = pair<ll, int>;
using i_ll = pair<int, ll>;
using d_i = pair<double, int>;
using ll_ll = pair<ll, ll>;
using d_d = pair<double, double>;

static constexpr ll LL_MOD = 1000000009;
static constexpr int I_MOD = 1000000007;
static constexpr double EPS = numeric_limits<double>::epsilon();
static constexpr double PI = 3.14159265358979323846264338327950288;

static map<type_index, const char *const> scanType = {{typeid(int), "%d"},
                                                      {typeid(ll), "%lld"},
                                                      {typeid(double), "%lf"},
                                                      {typeid(char), "%c"}};

template <class T> static void scan(vector<T> &v);
static void scan(vector<string> &v, bool isWord = true);
static boost::dynamic_bitset<> scan(char trueValue = 'o');

ll dp[51][51][3000];

int main(int argc, char *argv[]) {
  // INFILE();
	int n, a;
	cin >> n >> a;

	vector<ll> v(n);
	scan(v);
	dp[0][0][0] = 1;

	REPC(i, n) REPC(j, n) REPC(k, 3000) {
		dp[i + 1][j + 1][k + v[i]] += dp[i][j][k];
		dp[i + 1][j][k] += dp[i][j][k];
	}

	ll ans = 0;
	REP(i, 1, n + 1) ans += dp[n][i][i * a];
	cout << ans << "\n";
  return 0;
}

template <class T> static void scan(vector<T> &v) {
  auto tFormat = scanType[typeid(T)];
  for (T &n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string> &v, bool isWord) {
  if (isWord) {
    for (auto &n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

static boost::dynamic_bitset<> scan(char trueValue) {
  string s;
  getline(cin, s);

  if (s.size() == 0) {
    getline(cin, s);
  }

  for_each(begin(s), end(s),
           [trueValue](char &c) { c = (c == trueValue) ? '1' : '0'; });
  return boost::dynamic_bitset<>(string(rbegin(s), rend(s)));
}


Measured memory_bytes: 60032
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
#define for1(i,a,n)  for(int i=0;i<n;i++)
using namespace std;
//**********************************************DO IT NOW***************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
signed main()
{   
    fastio();
    int t=1;
   // cin>>t;
    while(t--)
    { 
       int n,m;
       cin>>n>>m;
       if(n==m)
       cout<<"Yes";
       else
       cout<<"No";
    }
}
// 🍪 🍪 🍪


Measured memory_bytes: 3576
N = int(input())
A = list(map(int, input().split()))
for val in A:
    if val % 2 == 1:
        continue
    elif val % 2 == 0:
        if val % 3 == 0:
            continue
        elif val % 5 == 0:
            continue
        else:
            print('DENIED')
            break
else:
    print('APPROVED')

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

using namespace std;

const int N=2e5+10;
const int M=30;
int n,a[2][N];
int ra[2][N];

int p[2][N];
int tmps[N];

vector <int> v[2][2];
int range[N];
void prepare(){
        cin>>n;
        for(int i=1;i<=n;i++) cin>>a[0][i];
        for(int i=1;i<=n;i++) cin>>a[1][i];
        for(int i=1;i<=n;i++) p[0][i]=p[1][i]=i;
}

int solve(){
        int ans=0;
        for(int lay=0;lay<M;lay++){
                for(int i=0;i<=1;i++){
                        for(int bit=0,n1=0;bit<=1;bit++)
                                for(int j=1;j<=n;j++) if (((a[i][p[i][j]]>>lay)&1)==bit) tmps[++n1]=p[i][j];
                        for(int j=1;j<=n;j++) p[i][j]=tmps[j];
                }
                for(int i=0;i<=1;i++)
                        for(int j=1;j<=n;j++) ra[i][j]=a[i][p[i][j]]&((1<<(lay+1))-1);
                for(int i=0;i<=1;i++){
                        v[i][0].clear();
                        v[i][1].clear();
                        for(int j=1;j<=n;j++) v[i][(ra[i][j]>>lay)&1].push_back(ra[i][j]&((1<<lay)-1)); 
                }
                int csum=0;
                for(int u1=0;u1<=1;u1++)
                        for(int u2=0;u2<=1;u2++){
                                int n1=v[0][u1].size(),n2=v[1][u2].size();
                                if (u1!=u2){
                                        ///sum <(1<<lay))
                                        for(int i=0,R=n2-1;i<n1;i++){
                                                while (R>=0&&v[0][u1][i]+v[1][u2][R]>=(1<<lay)) R--;
                                                csum=(csum+(R+1))&1;
                                        }
                                }else{
                                        ///sum >= (1<<lay)
                                        for(int i=n1-1,R=0;i>=0;i--){
                                                while (R<n2&&v[0][u1][i]+v[1][u2][R]<(1<<lay)) R++;
                                                csum=(csum+(n2-R))&1;
                                        }
                                }
                           
                }
                ans+=csum<<lay;
        }
        return ans;
}
int main(){
        prepare();
        cout<<solve();
}


Measured memory_bytes: 8564
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n = 0, a, x, m, ans = 0;
	int test[101] = { 0 }; int uiop[2020] = { 0 };
	cin >> n;
	for (int h = 1; h <= n; h++) {
		cin >> a;
		test[h] = a;
		uiop[a]++;
	}
	cin >> m;
	for (int h = 1; h <= m; h++) {
		cin >> x;
		if (uiop[test[x] + 1] == 0) {
			uiop[test[x]] = 0;
			uiop[test[x] + 1]++;
			test[x]++;
		}
	}
	for (int h = 1; h <= n; h++) {
		cout << test[h] << endl;
	}
	cin >> n;
}


Measured memory_bytes: 3112
N = int(input())

S = input()

W = list(map(int, S.split()))



S_min = 100000000
for i in range(len(W)):
    S_1 = W[0:i+1]
    S_2 = W[i+1:N]
    S_temp = abs(sum(S_1)-sum(S_2))
    if S_min > S_temp:
        S_min = S_temp

print(S_min)


Measured memory_bytes: 3060
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

const MOD: usize = 1000000007;

fn main() {
   input! {
      n: usize,
      k: usize,
      a: [usize; n]
   }
   let mut dp = vec![vec![0usize; k + 2]; n + 1];
   dp[0].add(0, 1);
   for i in 0..n {
      for j in 0..k + 1 {
         let c = if j >= a[i] {
            dp[i].range(j - a[i], j + 1)
         } else {
            dp[i].range(0, j + 1)
         } % MOD;
         dp[i + 1].add(j, c);
      }
   }
   let ans = dp[n].range(k, k + 1) % MOD;
   println!("{}", ans);
}

use std::ops::{AddAssign, Sub};
trait BIT<T: Copy + Clone + Sub + AddAssign> {
   fn add(&mut self, idx: usize, w: T);
   fn sum(&self, idx: usize) -> T;
   fn range(&self, l: usize, r: usize) -> T;
}
impl<T: Copy + Clone + Sub<Output = T> + AddAssign> BIT<T> for [T] {
   /// let mut bit = vec![0; n+1];
   /// for (i, w) in 0..q {
   ///    bit.add(i, w);
   /// }
   fn add(&mut self, idx: usize, w: T) {
      let mut j = (idx + 1) as i64;
      while j < self.len() as i64 {
         self[j as usize] += w;
         j += j & -j;
      }
   }
   /// [0, r]
   fn sum(&self, idx: usize) -> T {
      let mut i = (idx + 1) as i64;
      let mut sum = self[0];
      while i != 0 {
         sum += self[i as usize];
         i -= i & -i;
      }
      sum
   }
   /// [l, r)
   fn range(&self, l: usize, r: usize) -> T {
      match (l, r) {
         (0, _) => self.sum(r - 1),
         _ => self.sum(r - 1) - self.sum(l - 1),
      }
   }
}


Measured memory_bytes: 106748
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt64)
}

func readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func max(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}

func min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

func main() {
	w, a, b := readInt(), readInt(), readInt()
	ans := max(a, b) - min(a, b) - w
	if ans >= 0 {
		fmt.Println(ans)
	} else {
		fmt.Println(0)
	}
}


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

int main()
{
	int n;
	scanf("%d", &n);
	int *a = new int[n];
	for (int i = 0; i < n; i++) scanf("%d", a + i);
	bool is_plus{true};
	long long min1{}, min2{}, sum{};
	for (int i = 0; i < n; i++)
	{
		if (is_plus)
		{
			if (sum + a[i] <= 0)
			{
				min1 += 1 - sum - a[i];
				sum = 1;
			}
			else sum += a[i];
		}
		else
		{
			if (sum + a[i] >= 0)
			{
				min1 += sum + a[i] + 1;
				sum = -1;
			}
			else sum += a[i];
		}
		is_plus = !is_plus;
	}
	sum = 0; is_plus = false;
	for (int i = 0; i < n; i++)
	{
		if (is_plus)
		{
			if (sum + a[i] <= 0)
			{
				min2 += 1 - sum - a[i];
				sum = 1;
			}
			else sum += a[i];
		}
		else
		{
			if (sum + a[i] >= 0)
			{
				min2 += sum + a[i] + 1;
				sum = -1;
			}
			else sum += a[i];
		}
		is_plus = !is_plus;
	}
	printf("%lld\n", std::min(min1, min2));

	delete[] a;

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define ALL(obj) (obj).begin(),(obj).end()

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

vector<int> dy = { 0,0,1,-1 };
vector<int> dx = { 1,-1,0,0 };

template<class T> void corner(bool flg, T hoge) {
	if (flg) {
		cout << hoge << endl;
		exit(0);
	}
	else return;
}

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {
	o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;
}

template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {
	o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;
}

template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {
	o << "{" << obj.first << ", " << obj.second << "}"; return o;
}

template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

void print(void) {
	cout << endl;
}

template <class Head> void print(Head&& head) {
	cout << head;
	print();
}

template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {
	cout << head << " ";
	print(forward<Tail>(tail)...);
}

void YN(bool flg) {
	cout << ((flg) ? "YES" : "NO") << endl;
}

void Yn(bool flg) {
	cout << ((flg) ? "Yes" : "No") << endl;
}

void yn(bool flg) {
	cout << ((flg) ? "yes" : "no") << endl;
}

int main() {
	int N; cin >> N;
	V<double> a(N);
	REP(i, N) cin >> a[i];
	double k = accumulate(ALL(a), 0.)/N;
	REP(i, N) a[i] = abs(a[i] - k);
	k = *min_element(ALL(a));
	REP(i, N) if (k == a[i]) {
		cout << i << endl;

		return 0;
	}






	return 0;
}



Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<ll, ll> P;
const long long MOD = 1e9 + 7;
int main()
{
    int N, tK, K;
    cin >> N >> K;
    tK = K;
    vector<ll> A(N), mA, pA;
    vector<P> ch(N), margeA;
    rep(i, N) {
        cin >> A[i];
        if (A[i] <= 0) mA.push_back(A[i]);
        else pA.push_back(A[i]);
        int pm = (A[i] <= 0 ? -1 : 1);
        ch[i] = {abs(A[i]), pm};
    }

    sort(all(mA));
    sort(all(pA));
    reverse(all(pA));

    int lmi = 0;
    for (int i = 1; i < (int)pA.size(); i += 2) {
        margeA.push_back({pA[i - 1] * pA[i], i + 1});
    }

    for (int i = 1; i < (int)mA.size(); i += 2) {
        margeA.push_back({mA[i - 1] * mA[i], -1});
        lmi = i + 1;
    }

    int marge_len = (int)margeA.size();
    sort(all(margeA));
    reverse(all(margeA));

    ll ans = 1;
    int lpi = 0;
    rep(i, margeA.size()) {
        if (K <= 1) break;
        ans *= (margeA[i].first % MOD);
        ans %= MOD;
        if (margeA[i].second != -1) lpi = margeA[i].second;
        K -= 2;
    }
    // cout << K << endl;
    if (K >= 1) {
        if (lpi < (int)pA.size()) {
            ans *= pA[lpi];
            ans %= MOD;
            K--;
        }
        if (K >= 1) {
            ans = 1;
            sort(all(ch));
            rep(i, tK) {
                ans *= ch[i].first;
                ans *= ch[i].second;
                ans %= MOD;
                if (ans < 0) ans += MOD;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 12552
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
main()
{
   char c;
   cin>>c;
   if(c>='A' && c<='Z')
   {
       printf("A\n");
   }
   else
   {
      printf("a\n");
   }

}


Measured memory_bytes: 3616
/******************************************************************************

                           

*******************************************************************************/

#include <iostream>
#include <string>

using namespace std;

int main()
{
    int yy = 0, mm = 0;
    char a, b;
    string dd;
    cin >> yy >> a >> mm >> b >> dd;
    cout << "2018"  << a << 0 <<  mm << b << dd;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    rep(i,0,n) cin >> a[i];
    const ll MOD = 1e9+7;
    vector<vector<ll>> dp(n,vector<ll>(n));
    vector<vector<int>> time(n,vector<int>(n));
    vector<ll> pow2(q+1,1);
    rep(i,0,q) pow2[i+1]=(2*pow2[i])%MOD;
    rep(i,0,n) rep(j,0,n) {
        if(a[i]>a[j]) ++dp[i][j];
    }
    auto update = [&](int t, int a, int b) {
        if(time[a][b]<t) {
            dp[a][b]=(dp[a][b]*pow2[t-time[a][b]])%MOD;
            time[a][b] = t;
        }
    };
    rep(i,0,q) {
        int x, y;
        cin >> x >> y;
        --x;
        --y;
        rep(z,0,n) if(z!=x && z!=y) {
            update(i, x, z);
            update(i, y, z);
            update(i, z, x);
            update(i, z, y);
            dp[x][z] = dp[y][z] = (dp[x][z]+dp[y][z])%MOD;
            time[x][z] = time[y][z] = i+1;
            dp[z][x] = dp[z][y] = (dp[z][x]+dp[z][y])%MOD;
            time[z][x] = time[z][y] = i+1;
        }
        update(i, x, y);
        update(i, y, x);
        dp[x][y] = dp[y][x] = (dp[x][y]+dp[y][x])%MOD;
        time[x][y] = time[y][x] = i+1;
    }
    ll sum = 0;
    rep(i,0,n) rep(j,i+1,n) {
        update(q,i,j); 
        sum=(sum+dp[i][j])%MOD;
    }
    cout<<sum<<"\n";
}


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

int main(){
    int a,b,c;
    cin >> a >> b >> c;

    if((a == b && b != c) || (b == c && b != a) || (c == a && b != c)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main() {
    const int n = 3;
    int p[n], b = 1, d = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            int a;
            cin >> a;
            if (i == 0) {
                p[j] = a;
            } else if (j == 0) {
                d = a - p[j];
            } else {
                if (a - p[j] != d) b = 0;
            }
        }
    }

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

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
    int n;
    string s;
    cin >> n;
    cin >> s;
    int count = 0;
    while (s.find("ABC") != string::npos) {
        count++;
        s = s.substr(s.find("ABC")+1);
    }
    cout << count << endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n; cin>>n;
    vi l(n);
    rep(i, n) cin>>l[i];
    map<int, int> M;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            M[l[i]+l[j]]++;
        }
    }

    ll ans=1;
	rep(i, 3) ans*=n-i;
	ans /= 6;
    for(auto e:M){
        rep(i, n){
            if (l[i]>=e.fi) ans-=e.se;
        }
    }
    cout << ans << "\n";
	return 0;
}


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

using namespace std;

using ll =  long long;

constexpr ll MOD = 998244353;

ll modpow(ll a, ll t) {
    ll ret = 1LL;
    while(t){
        if(t & 1LL){
            ret *= a;
            ret %= MOD;
        }
        a *= a;
        a %= MOD;
        t >>= 1;
    }
    return ret;
}

inline ll comb(const ll fact, const ll rfact1, const ll rfact2) {
    return (fact * ((rfact1 * rfact2) % MOD)) % MOD;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll n;
    cin >> n;

    ll ans = modpow(3LL, n);

    ll fact = 1LL, rfact1 = 1LL, rfact2 = 1LL;
    for(ll i=2;i<=n;++i) {
        fact *= i;
        fact %= MOD;
    }
    for(ll i=2;i<=n/2;++i) {
        rfact1 *= modpow(i, MOD-2);
        rfact1 %= MOD;
    }
    rfact2 = rfact1;

    ll pow_2 = modpow(2LL, n/2);
    ll r2 = modpow(2LL, MOD-2);

    for(ll i=n/2+1;i<=n;++i) {
        pow_2 *= r2;
        pow_2 %= MOD;
        rfact1 *= ll(n-i+1);
        rfact1 %= MOD;
        rfact2 *= modpow(i, MOD-2);
        rfact2 %= MOD;
        ans += MOD - (((2 * comb(fact, rfact1, rfact2)) % MOD) * pow_2) % MOD;
        ans %= MOD;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())

G = {k: [] for k in range(N)}  # 0-indexed
for _ in range(M):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)


def dfs(p, arrived):
    if arrived == 2**N-1:
        return 1

    ret = 0
    for n in G[p]:
        if (arrived >> n) & 1 == 0:
            ret += dfs(n, arrived+2**n)
    return ret


arrived = 1
print(dfs(0, arrived))


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>

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

using namespace std;

int main(void){
  ll a,b,n;
  cin >> a >> b >> n;
  if(n >= b){
    cout << a*(b-1)/b << endl;
  }
  else{
    cout << a*n/b << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
using namespace std;
typedef long long ll;

int main(){
    int n;cin>>n;
    vector<ll> v(n),a(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
        v[i]-=i+1;
    }
    sort(v.begin(),v.end());
    ll yay=v[n/2];
    ll ans=0;
    for(int i=0;i<n;i++){
        ans+=abs(v[i]-yay);
    }
    cout<<ans;
}

Measured memory_bytes: 3328
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define INT_MAX 2147483647
#define LLINT_MAX 9223372036854775807
#define mod 1000000007
#define ll long long int
using namespace std;

int main() {
	int n;
	string s, t;
	cin >> n >> s >> t;
	for (int i = n; i >= 0; i--) {
		if (s.substr(n - i, i) == t.substr(0, i)) {
			cout << n + n - i << endl;
			return 0;
		}
	}
	return 0;
}

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

int n, q;
string s;
vector<int> v;

void solve();

int main() {
  cin >> n >> q >> s;
  solve();
  for(int i = 0; i < q; ++i) {
    int l, r;
    cin >> l >> r;
    cout << v[r] - v[l] << endl;
  }
  return 0;
}

void solve() {
  v.resize(n + 2, 0);
  for(int i = 1; i < n; ++i) {
    v[i + 1] = v[i];
    if(s[i - 1] == 'A' && s[i] == 'C') ++v[i + 1];
  }
}

Measured memory_bytes: 1408
#公式解法見て書いた
iN = int(input())

a6 = [0]*7
for i in range(7):
    a6[i] = 6 ** i
a6.reverse()
a9 = [0]*6
for i in range(6):
    a9[i] = 9 ** i
a9.reverse()

iAns = iN
for i in range(iN+1):
    iD = iN - i
    iC = 0
    for j in range(7):
        if i:
            iG = a6[j]
            if i >= iG:
                iC += (i // iG)
                i %=iG
    for j in range(6):
        if iD :
            iG = a9[j]
            if iD >= iG:
                iC += (iD // iG)
                iD %= iG
    if iAns > iC:
        iAns = iC
print(iAns)


Measured memory_bytes: 3064
import sys
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    n,m,c = IL()
    b = list(IL())
    ans = 0
    for _ in range(n):
        a = list(IL())
        tmp = 0
        for i in range(m):
            tmp += b[i]*a[i]
        if -c<tmp: ans += 1
    print(ans)
    return

if __name__=='__main__':
    Main()

Measured memory_bytes: 9152
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main() {

    string s;
    cin >> s;
    cout << s[0] << (int)s.size() - 2 << s[(int)s.size() - 1] << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

int main(){
    set<int> a={1,3,5,7,8,10,12},b={4,6,9,11};
    int x,y;
    cin>>x>>y;
    if(a.count(x)&&a.count(y)){
        cout<<"Yes"<<endl;
    }
    else if(b.count(x)&&b.count(y)){
        cout<<"Yes"<<endl;
    }
    else if(x==y){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
using namespace std;
#define ll long long
int main()
{
	ll n,i,a,x;
	scanf("%lld%lld",&n,&a);
	for(i=1;i<=a;i++)
	{
		scanf("%lld",&x);
		n=n-x;
	}
	if(n>=0)
		printf("%lld",n);
	else
		printf("-1");
}


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

#define ld long double
#define ll long long int
#define ull unsigned long long int
#define vi vector<int>
#define vl vector<ll>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >
#define repd(i, a, b) for (int i=(a);i<(b);i++)
#define rep(i, n) repd(i,0,n)
#define ALL(v) v.begin(), v.end()
#define INF 1e9

using namespace std;

/**
 * calculate GCD(greatest common divisor)
 * @param a
 * @param b
 * @return
 */
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

/**
 * change minimum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T> inline bool changeMinimum(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * change maximum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T> inline bool changeMaximum(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * output answer
 * @tparam T
 * @param answer
 * @return
 */
template<typename T>
T output(T answer) {
    cout << answer << endl;
    return 0;
}

/** ----from here ---------------------------------------------------------- */


int main() {

    ll N, K;
    cin >> N >> K;

    ll n = N;


    n = N % K;
    while (1){
//        n = abs( - K);
        if (abs(n - K) < n) {
//            continue;
            n = abs(n-K);
//            cout << n;
        } else {
            cout << n << endl;
            return 0;
        }
    }


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod=998244353;
typedef long long ll; 
int x,m,a[100005],f[100005];
ll n,ans=0,t=0,o=0;
int main(){
	cin>>n>>a[1]>>m,f[a[1]]=1,o=a[1];
	for(int i=2;i<=n;i++){
		a[i]=1ll*a[i-1]*a[i-1]%m;
		o+=a[i];
		if(f[a[i]]){
			ll p=0;
			for(int j=1;j<f[a[i]];j++)ans+=a[j],p++;
			for(int j=f[a[i]];j<i;j++)t+=a[j];
			ans+=t*((n-f[a[i]]+1)/(i-f[a[i]])),p+=(n-f[a[i]]+1)/(i-f[a[i]])*(i-f[a[i]]);
			for(int j=f[a[i]];j<f[a[i]]+(n-f[a[i]]+1)%(i-f[a[i]]);j++)ans+=a[j],p++;
			cout<<ans;
			return 0;
		}
		f[a[i]]=i;
	}
	cout<<o;
    return 0;
}

Measured memory_bytes: 4144
/// Bismillahir Rahmanir Rahim
/* Author: Mohammad Morsalin
    Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define PI acos(-1)
#define IOS ios::sync_with_stdio(false);
using namespace std;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
int main()
{
    IOS
    int n;
    cin>>n;
    long long ans=1;
    ll arr[n];
    bool ov=0;
    bool z=0;
    for(int i=0;i<n;i++){cin>>arr[i];if(arr[i]==0) z= 1;}
    if(z){cout << 0 << endl;return 0;}
    for(int i=0;i<n;i++){
        ll x=arr[i];
        if(x>1000000000000000000/ans){ov=1;cout << "-1\n"<< endl;return 0;}
        ans*=x;
    }

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


Measured memory_bytes: 4432
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

int main() {
    char n[4];
    scanf("%s",n);

    if(n[0] == n[2]) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main {
	public void kami() {
		Scanner sc = new Scanner(System.in);
		
		int H = sc.nextInt();
		int W = sc.nextInt();
		int H2 = H;
		int W2 = W;
		int H3 = H - 2;
		while(H != 0 || W != 0){
			while(0 < H){
				if(H == 1 || H == H2){
					for(int i = 1; i <= W; i++){
						System.out.print("#");
					}
					System.out.println();
				}else{
					
					while(0 < H3){
						System.out.print("#");
						for(int i = 1; i <= W2 - 2; i++){
							System.out.print(".");
						}
						System.out.println("#");
						H3--;
					}
					
				}
				H--;
				
			}
			System.out.println();
			H = sc.nextInt();
			W = sc.nextInt();
			H2 = H;
			W2 = W;
			H3 = H - 2;
		}
		
	}

	public static void main(String[] args) {

		new Main().kami();
	}

}

Measured memory_bytes: 24772
N, *A = open(0).read().split()

S = [[0] * 21 for _ in range(21)]

ans = 0
for a in A:
    idx = a.find(".")
    if idx == -1:
        c2 = c5 = 0
    else:
        c2 = c5 = -(len(a) - idx - 1)

    a = int(a.replace(".", ""))
    while a % 2 == 0:
        c2 += 1
        a //= 2
    while a % 5 == 0:
        c5 += 1
        a //= 5
    c2 = min(c2, 10)
    c5 = min(c5, 10)
    ans += sum(S[i][j] for i in range(10 - c2, 21) for j in range(10 - c5, 21))

    S[c2 + 10][c5 + 10] += 1

print(ans)

Measured memory_bytes: 116428
#include<bits/stdc++.h>
using namespace std;
int findsum(int n){
  int sum=0;
  while(n>0){
    sum+=n%10;
    n/=10;
  }
  return sum;
}
int main(){
  int N,A,B;cin>>N>>A>>B;
  int total=0;
  for(int i=1;i<=N;i++){   
    int sum=findsum(i);
    if(sum>=A&&sum<=B){
      total += i;
    }
  }
  cout<<total;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
using namespace std;

int n;
vector<int> lz, mz;
vector<pair<int, int> > mv;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a < 0)
			lz.push_back(a);
		else
			mz.push_back(a);
	}
	if (lz.size() == 0) {
		sort(mz.begin(), mz.end());
		while (mz.size() > 2) {
			mv.push_back({ mz[0], mz.back() });
			mz[0] -= mz.back();
         	mz.pop_back();
		}
		mv.push_back({ mz.back(), mz[0] });
	}
	else if (mz.size() == 0) {
		sort(lz.begin(), lz.end());
		reverse(lz.begin(), lz.end());
		while (lz.size() > 2) {
			mv.push_back({ lz[0], lz.back() });
			lz[0] -= lz.back();
          	lz.pop_back();
		}
		mv.push_back({ lz[0], lz.back() });
	}
	else {
		for (int i = 1; i < mz.size(); i++)
			mv.push_back({ lz[0], mz[i] }), lz[0] -= mz[i];
		for (int i = 1; i < lz.size(); i++)
			mv.push_back({ mz[0], lz[i] }), mz[0] -= lz[i];
		mv.push_back({ mz[0], lz[0] });
	}
	cout << mv.back().first - mv.back().second << '\n';
	for (int i = 0; i < mv.size(); i++)
		cout << mv[i].first << ' ' << mv[i].second << '\n';
}


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

using namespace std;

long long n, m;
pair<long long, long long> V[100005];
vector<long long> Ans;
long long t[100005], Nr[100005];

long long find(long long x)
{
    while (t[x]!=0)
        x=t[x];
    return x;
}

void unite(long long x, long long y)
{
    long long fx=find(x);
    long long fy=find(y);
    if (Nr[fx]>Nr[fy])
    {
        t[fy]=fx;
        Nr[fx]+=Nr[fy];
    }
    else
    {
        t[fx]=fy;
        Nr[fy]+=Nr[fx];
    }
}


int main()
{
    cin>>n>>m;
    for (long long i=1; i<=m; i++)
    {
        cin>>V[i].first>>V[i].second;
    }
    for (long long i=1; i<=n; i++)
        Nr[i]=1;
    long long ans = n*(n-1)/2;
    Ans.push_back(ans);
    for (long long i=m; i>1; i--)
    {
        long long x = V[i].first, y=V[i].second;
        if (find(x)==find(y))
            Ans.push_back(ans);
        else
        {
            ans-=Nr[find(x)]*Nr[find(y)];
            unite(x, y);
            Ans.push_back(ans);
        }
    }
    for (long long i=Ans.size()-1; i>=0; i--)
    {
        cout<<Ans[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 5364
const t=map(x->parse(Int,x),split(readall("/dev/fd/0")))
function main()
    n,k=shift!(t),shift!(t)
    e=zeros(Int,n)
    a=k
    for v=t
        (e[v]+=1)>1-(v<2)&&(a=(k-e[v])a%(10^9+7))
    end
    show(a)
end
main()

Measured memory_bytes: 206156
#include<stdio.h>
int main(void) {
	int h[301];
	int w[301];
	int i;
	int t;
	int u;
	int v;
	int x;
	for (i = 1; i <= 300; i++) {

		scanf("%d %d", &h[i], &w[i]);
		if ((h[i] == 0) && (w[i] == 0))break;
	}
	for (t = 1; t <= 300; t++) {
		if (i == t)break;
		for (v = 1; v <= h[t]; v++) {
			if((v==1)||(v==h[t])){
				for (u = 1; u <= w[t]; u++) {
					printf("#");
				}
			}else {
				for (x = 1; x <= w[t]; x++) {
					if ((x == 1) || (x == w[t])) {
						printf("#");
					}
					else {
						printf(".");
					}	
				}
			}
			
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 572
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include <algorithm> 
using namespace std;

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

int p[10];
int c[10];

int dfs(int depth,int D,int G,int kanzenList[]){
    if(depth==D){
        long long int sum=0;
        int count=0;
        int max_i=-1;
        for(int i=0;i<D;i++){
            if(kanzenList[i]==1){
                sum   += p[i]*(i+1)*100+c[i];
                count += p[i];
            } else {
                max_i=max(max_i,i);
            }
        }
        if(sum >= G){
            return count;
        } else if(G-sum <= (p[max_i]-1)*(max_i+1)*100) {
            return count + (G-sum)/((max_i+1)*100) + ((G-sum)%((max_i+1)*100)==0?0:1);
        } else {
            return 10000000;
        }
    }

    kanzenList[depth]=1;
    int ret1=dfs(depth+1,D,G,kanzenList);
    kanzenList[depth]=0;
    int ret2=dfs(depth+1,D,G,kanzenList);

    return min(ret1,ret2);
}

int main()
{
    int D,G;cin >> D >> G;
    int list[10]={};

    for(int i=0;i<D;i++){
        cin >> p[i] >> c[i];
    }

    p(dfs(0,D,G,list))
} 

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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/f.in", "r", stdin);
//  freopen("../IO/f.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}

struct dsu {
  vector<int> r, p;
  dsu() = default;
  dsu(int n) {
    r.assign(n, 0);
    p.assign(n, -1);
  }
  void merge(int u, int v) {
    int x = find(u), y = find(v);
    if (x == y) return;
    if (r[x] < r[y]) p[x] = y;
    else if (r[x] > r[y]) p[y] = x;
    else {
      p[x] = y;
      r[x]++;
    }
  }
  int find(int x) {
    if (p[x] == -1) return x;
    else return p[x] = find(p[x]);
  }
};

void solve(std::istream &in, std::ostream &out) {

  int n, k, l;
  in >> n >> k >> l;
  dsu d1(n), d2(n);
  for (int i = 0, u, v; i < k; ++i) {
    in >> u >> v;
    --u;
    --v;
    d1.merge(u, v);
  }
  for (int i = 0, u, v; i < l; ++i) {
    in >> u >> v;
    --u;
    --v;
    d2.merge(u, v);
  }
  map<pair<int, int>, int> mp;
  for (int i = 0; i < n; ++i) {
    mp[{d1.find(i), d2.find(i)}]++;
  }
  for (int i = 0; i < n; ++i) {
    out << mp[{d1.find(i), d2.find(i)}] << ' ';
  }
}


Measured memory_bytes: 17564
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int n, m, ans = 0;
      scanf("%d %d", &n, &m);
      int balls[n + 1];
      bool red[n + 1];
      for(int i = 1; i <= n; i++){
        balls[i] = 1;
        red[i] = false;
      }
      red[1] = true;
     
     
      for(int i = 0; i < m; i++){
        int x, y;
        scanf("%d %d", &x, &y);
        if (red[x]){
          red[y] = true;
          if (balls[x] == 1) {
            red[x] = false;
          }
        }
        balls[x]--;
        balls[y]++;
      }
      for(int i = 1; i <= n; i++){
        ans += (red[i] ? 1 : 0);
      }
      printf("%d\n", ans);
      return 0;
    }

Measured memory_bytes: 768
S = gets.chomp
N = S.size

def kaibun?(s)
  0.upto(s.size / 2) do |i|
    return false if s[i] != s[s.size - 1 - i]
  end
  true
end

if kaibun?(S) && kaibun?(S[0...(N-1)/2]) && kaibun?(S[(N+3)/2-1...N])
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int m, k; cin >> m >> k;
	int n = 1 << m;
	if(m <= 1 && k > 0 || n <= k){
		cout << -1 << endl;
		return 0;
	}
	vi ans;
	set<int> skip;
	rep(i, n) if(__builtin_popcount(i) == 1 && (i & k)) skip.insert(i);
	ans.insert(ans.end(), skip.rbegin(), skip.rend());
	for(int i = n - 1; i >= 0; i--) if(!skip.count(i)) ans.pb(i);
	ans.insert(ans.end(), skip.begin(), skip.end());
	rep(i, n) if(!skip.count(i)) ans.pb(i);
	rep(i, ans.size()) cout << ans[i] << (i==ans.size()-1 ? "\n":" ");
	assert(ans.size() == 2 * n);
	return 0;
}

Measured memory_bytes: 2992
//
//  ROIGold.cpp
//  Main calisma
//
//  Created by Rakhman on 05/02/2019.
//  Copyright © 2019 Rakhman. All rights reserved.
//

#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const int MXN = 2e5 + 1;
const long long MNN = 5e3 + 100;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const int OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

llong h, w, ans;

llong get(llong a, llong b, llong div){
    vector<llong> v;
    v.pb(div * a);
    b -= div;
    llong k = a / 2;
    v.pb(b * k);
    v.pb(b * (a - k));
    sort(v.begin(), v.end());
    return v[2] - v[0];
}

int main () {
    cin >> h >> w;
    if(h % 3 == 0 || w % 3 == 0){
        cout << 0;
        return 0;
    }
    ans = min(w, h);
    for(int i = 1; i < h; i++){
        ans = min(ans, get(w, h, i));
    }
    for(int i = 1; i < w; i++){
        ans = min(ans, get(h, w, i));
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
d = {}
for i in a:
    if i not in d:
        d[i] = 1
    else:
        d[i] += 1
ans = 0
for i in d.keys():
    if i > d[i]:
        ans += d[i]
    else:
        ans += d[i] - i
print(ans)

Measured memory_bytes: 17780
n = int(input())
c = [i for i in range(0,n+1) if i%4 == 0]
d = [j for j in range(0,n+1) if j%7 == 0]
for x in range(len(c)):
    for y in range(len(d)):
        if c[x] + d[y] == n:
            print("Yes")
            exit()
print("No")

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;

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

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

	double a,b;
	cin>>a>>b;
	printf("%.10f\n",(a*b)/(a+b));

	return 0;
}


Measured memory_bytes: 384
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

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


int main() {
	vector<vector<int>> a(3,vector<int>(3));
	rep(i, 3) rep(j, 3) cin >> a[i][j];
	int n;
	cin >> n;

	bool re[3][3];
	rep(i, 3) rep(j, 3) re[i][j] = false;
	//rep(i, 3) rep(j, 3) re[i][j] = false;
	rep(i,n){
		int A;
		cin >> A;
		rep(j, 3){
			rep(k, 3) {
				if (A == a[j][k]) {
					re[j][k] = true;
				}
			}
		}
	}
	bool is_exist = false;
	rep(i, 3) {
		if (re[i][1] == true && re[i][0] == true && re[i][2] == true) is_exist = true;
	}
	rep(i, 3) {
		if (re[0][i] == true && re[1][i] == true && re[2][i] == true) is_exist = true;
	}
	if((re[0][0] == true && re[1][1] == true && re[2][2] == true) || (re[1][1] == true && re[0][2] == true && re[2][0] == true))is_exist = true;
	if (is_exist) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int a = s[0];
  int b = s[1];
  int c = s[2];
  int d = s[3];
  int e = 0;
  if (a==b) e++;
  if (b==c) e++;
  if (c==d) e++;
  if (b==d) e++;
  if (a==c) e++;
  if (e>=3) {
  cout << "Yes" << endl;
  } else {
      cout << "No" << endl;
  }
}

Measured memory_bytes: 384
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, d, x, res = 0;
  cin >> n >> d >> x;
  REP(i,n) {
    int a, cur = 1;
    cin >> a;
    while(cur <= d) { cur += a; res++; }
  }
  cout << res + x << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    int n, m;
    cin >> n >> m;
    cout << n*(n-1)/2 + m*(m-1)/2 << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 256