akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using f64 = double;
using f80 = long double;

#define FOR(v, a, b) for(i64 v = (a); v < (b); ++v)
#define FORE(v, a, b) for(i64 v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(i64 v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

using namespace std;

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T> void pout(const T &value){std::cout << value << "\n";}
template <typename T, typename ...Args> void pout(const T &value, const Args&... args){std::cout << value << " ";pout(args...);}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}
template <typename T> auto make_vector(int n, int m, const T &value){return vector<vector<T>>(n, vector<T>(m, value));}


struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  int N, M;

  while(cin >> N >> M){
    vector<int> H(N); cin >> H;

    int ans = 0;

    vector<vector<int>> g(N);
    REP(i,M){
      int a, b; cin >> a >> b;
      --a, --b;
      g[a].push_back(b);
      g[b].push_back(a);
    }

    REP(i,N){
      bool ok = true;

      for(auto j : g[i]){
        if(H[i] <= H[j]){
          ok = false;
        }
      }


      if(ok) ans += 1;
    }

    
    pout(ans);
  }


  return 0;
}


Measured memory_bytes: 8716
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define fs first
#define ss second



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

   if( s[2] == s[3] && s[4] == s[5]) cout <<"Yes" <<endl;
   else cout <<"No"<<endl;
 

}

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

int main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int x; cin >> x;
	for(int i = 1800, j = 1; i >= 400; i -= 200, j++) {
		if(x >= i) {
			cout << j << endl;
			return 0;
		}
	}
}

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

using namespace std;

int main() {
  long long n, k, ans = 0;
  cin >> n >> k;
  ans += (n / k) * (n / k) * (n / k);
  if (k % 2 == 0) {
    long long num = (n + k / 2) / k;
    ans += num * num * num;
  }
  cout << ans << "\n";
}

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

int main(int argc, char* argv[]) {
	int n;
	cin >> n;
	vector<long long> a (n);
	long long ans = 1;
	int zero = 0;
	for (auto& x:a) {
		cin >> x;
		zero += (x==0) ? 1 : 0;
	}
	if (zero) {
		cout << 0 << endl;
		return 0;
	} else {
		for (auto x:a) {
			if (x > 1000000000000000000/ans) {
				cout << -1 << endl;
				return 0;
			} else {
				ans *= x;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4044
def dist(p1, p2):
    return abs(p1[0] - p2[0]) + abs(p1[1] - p2[1])

N, M = map(int, input().split())
students = [tuple(map(int, input().split())) for _ in range(N)]
cps = [tuple(map(int, input().split())) for _ in range(M)]
for s in students:
    ans = (float('inf'), -1)
    for i, cp in enumerate(cps, 1):
        ans = min(ans, (dist(s, cp), i))
    print(ans[1])

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define MOD 998244353 
#define INF 1000000000000000000
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main()
{
	int n, m;
	cin >> n >> m;
	priority_queue <int> pq;
	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		pq.push(x);
	}
	while(!pq.empty() && m--)
	{
		int x = pq.top();
		pq.pop();
		pq.push(x / 2);
	}
	ll ans = 0;
	while(!pq.empty())
	{
		ans += pq.top();
		pq.pop();
	}
	cout << ans;
}


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

int n;
int main()
{
  scanf("%d", &n);
  
  int t = n;
  int temp = 0;
  while (t) {
    temp += t%10;
    t /= 10;
  }
  if (n % temp == 0)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}


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

using namespace std;

const int nax=1e5+5;
int a[nax],b[nax],c[nax],dp[nax][3];


int main()
{
    int n; cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i]>>b[i]>>c[i];
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<3;j++)
        {
            for(int k=0;k<3;k++)
            {
                if(j==k) continue;
                int cost;
                if(j==0) cost=a[i];
                if(j==1) cost=b[i];
                if(j==2) cost=c[i];
                dp[i][j]=max(dp[i][j],dp[i-1][k]+cost);
            }
        }
    }
    int res=dp[n][0];
    res=max(res,dp[n][1]);
    res=max(res,dp[n][2]);
    cout<<res;
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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; }

using namespace std;

const int MX = 2005;
bool d[3][3][MX];

int main(){
    vector<string> s(3);
    rep(i, 3) cin >> s[i];
    sort(s.begin(), s.end());
    int ans = MX*3;
    do {

        rep(i, 3){
            rep(j, 3) {
                rep(k, s[i].size()) {
                    if (i >= j) continue;
                    bool ok = true;
                    for (int ni = k; ni < s[i].size(); ni++) {
                        int nj = ni - k;
                        if (nj >= s[j].size()) break;
                        if (s[i][ni] == '?' || s[j][nj] == '?') continue;
                        if (s[i][ni] != s[j][nj]) ok = false;
                    }

                    d[i][j][k] = ok;
                }
            }
        }

        auto f = [&](int i, int j, int k) {
            if (k >= s[i].size()) return true;
            return d[i][j][k];
        };
        rep(x, MX){
            rep(y, MX) {
                if (!(f(0, 1, x))) continue;
                if (!f(1, 2, y)) continue;
                if (!f(0, 2, x+y)) continue;
                int now = 0;
                chmax(now, int(s[0].size()));
                chmax(now, int(x + s[1].size()));
                chmax(now, int(x + y + s[2].size()));
                chmax(now, int(s[0].size()));
                chmin(ans, now);
            }
        }

    } while(next_permutation(s.begin(), s.end()));
    cout << ans << endl;
}

Measured memory_bytes: 384
s = gets.chomp
k = gets.to_i

def cplus(c, i)
  ((c.ord - 'a'.ord + i) % 26 + 'a'.ord).chr
end

def toa(c)
  ('a'.ord - c.ord + 26) % 26
end

result = ''

s.chars.each do |c|
  toav = toa(c)
  if toav <= k
    k -= toav
    result += 'a'
  else
    result += c
  end
end

result[-1] = cplus(result[-1], k)

puts result


Measured memory_bytes: 103772
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

ll g1(ll n, int p){
    if(n == 0) return 0;
    return n/p + g1(n/p, p);
}

ll g2(ll n, int p){
    if(n%2 == 1){
        return 0;
    }
    ll res = g1(n/2, p);
    return res;
}

int main() {
    ll n;
    cin >> n;
    ll ans = min(g2(n, 2), g2(n, 5));
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<int, int> pi;
tree<int,int,greater<int>,rb_tree_tag,tree_order_statistics_node_update> map_t;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz(x) (int)x.size()
#define f first
#define s second

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,h;
    cin >> h >> n;
    vector<int> a(n),b(n);
    F0R(i,n)
    {
        cin >> a[i];
        cin >> b[i];
    }
    vector<int> dp(h+1,1e9);
    dp[0]=0;
    FOR(i,1,h+1)
    {
        F0R(j,n)
        {
            if(i-a[j]>=0)
                dp[i]=min(dp[i],dp[i-a[j]]+b[j]);
            else
                dp[i]=min(dp[i],b[j]);
        }
    }
    cout << dp[h];

    return 0;
}


Measured memory_bytes: 256
<?php
list($n, $h, $w) = explode(" ", trim(fgets(STDIN)));
$c = 0;
for($i = 0; $i < $n; $i++){
  list($a, $b) = explode(" ", trim(fgets(STDIN)));
  $c+=$h<=$a&&$w<=$b;
}
echo $c;


Measured memory_bytes: 4604
#include <iostream>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    int f = a * b;
    if (f % 2 == 0) {
        cout << "Even" << endl;
    }
    if (f % 2 == 1) {
        cout << "Odd" << endl;
    }
}

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

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

#define vint(v, n) vector<int> v(n); REP(i,n) cin >> v[i];
#define vvint(v, w, n) vector<int> v(n); vector<int> w(n); REP(i,n) cin >> v[i] >> w[i];
#define vlint(v, n) vector<ll int> v(n); REP(i,n) cin >> v[i];
#define vdouble(v, n) vector<double> v(n); REP(i,n) cin >> v[i];
#define vvdoube(v, n1, n2) vector<vector<double> > v(n1, vector<double>(n2, 0)); REP(i,n1) REP(j,n1) cin >> v[i][j];
#define string(x) string x; cin >> x;
#define vstring(v, n) vector<string> v(n); REP(i,n){string a; std::cin >> a; v.push_back(a); }

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).begin(), (v).end(), std::greater<int>()
#define len(v) (v).length()
#define FIND(s, n) (s.find(n) != s.end())
#define SORT(a) sort(all(a))

static const string abet("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
static const long long MOD = 1000000007;
static const double PI=3.1415926535897932;
static const int INF = 0x3f3f3f3f;
static const int INFTY = (1 << 29);
static const long long LINFTY = (1LL << 32);

static const int dy4[]={0, 0, 1, -1};
static const int dx4[]={1, -1, 0, 0};
static const int dx8[] = {1, 1, 1, 0, 0, -1, -1, -1};
static const int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};

#define umin(m,u) u<m&&(m=u)
const int inf=1e9;
int dp[401][401];

int main(void){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,ma,mb,a,b,c,i,j,sa=0,sb=0;scanf("%d%d%d",&n,&ma,&mb);
  for(i=0;i<=400;i++)
	for(j=0;j<=400;j++)
	  dp[i][j]=inf;
  dp[0][0]=0;
  while(n--){
	scanf("%d%d%d",&a,&b,&c);
	for(i=sa;i>=0;i--)
	  for(j=sb;j>=0;j--)
		umin(dp[i+a][j+b],dp[i][j]+c);
	sa+=a,sb+=b;
  }
  int ans=inf;
  for(int k=1;ma*k<=sa&&mb*k<=sb;k++)
	umin(ans,dp[ma*k][mb*k]);
  printf("%d\n",ans==inf?-1:ans);

}


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

using namespace std;

int main() {
  int n;
  string ans;
  cin >> n >> ans;
  string ss(n + 2, 'x'), sw(n + 2, 'x'), ws(n + 2, 'x'), ww(n + 2, 'x');
  ss[0] = ss[1] = sw[0] = ws[1] = 'S';
  sw[1] = ws[0] = ww[0] = ww[1] = 'W';
  bool found = false;
  for (auto sp : {&ss, &sw, &ws, &ww}) {
    auto& s = *sp;
    for (int i = 1; i <= n; i++) {
      if ((ans[i - 1] == 'o' && s[i] == 'S') || (ans[i - 1] == 'x' && s[i] == 'W'))
        s[i + 1] = s[i - 1];
      else s[i + 1] = (s[i - 1] == 'S' ? 'W' : 'S');
    }
    if (s[0] == s[n] && s[1] == s[n + 1]) {
      found = true;
      cout << string(begin(s) + 1, end(s) - 1) << endl;
      break;
    }
  }
  if (!found) cout << -1 << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,l,r) for (int i=l,i##end=r;i<=i##end;++i)
#define per(i,r,l) for (int i=r,i##end=l;i>=i##end;--i)
#define rep0(i,r) for (int i=0,i##end=r;i<i##end;++i)
#define pr pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define ll long long
using namespace std;
const int N=1e6+6;
ll x[N],s[N],l[N],r[N];
int v[N];
int main(){
    int n; ll c; cin>>n>>c;
    rep(i,1,n) scanf("%lld%d",&x[i],&v[i]),s[i]=s[i-1]+v[i];
    rep(i,1,n) l[i]=max(l[i-1],s[i]-x[i]);
    per(i,n,1) r[i]=max(r[i+1],(s[n]-s[i-1])-(c-x[i]));
    ll ans=max(l[n],r[1]);
    rep(i,1,n) ans=max(ans,s[i]-2*x[i]+r[i+1]);
    per(i,n,1) ans=max(ans,(s[n]-s[i-1])-2*(c-x[i])+l[i-1]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 12928
#include <bits/stdc++.h>
    using namespace std;
     
    int main(){
        long long a, b, c, k;
        cin >> a >> b >> c >> k;
        long long ans = b - a;
        if(k % 2 == 0)
	 {
		ans *= -1;
	 }
        cout << ans << endl;
        return 0;
    }

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

using namespace std;
using i64 = long long;

int main(){
    i64 n,d,ans{};
    cin>>n>>d;
    for(i64 i=0;i<n;i++){
        i64 a,b;
        cin>>a>>b;
        ans+=(d*d>=a*a+b*b?1:0);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3632
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
       a: i32, 
       b: i32, 
    }
    if b % a == 0 {
        println!("{}", a+b);
    } else {
        println!("{}", b-a);
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <queue>
#include <stack>

using namespace std;

typedef int itn;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef map<int, int> M;
typedef pair<int, int> P;
typedef stack<int> S;
typedef queue<int> Q;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int s;
    cin >> s;
    int a, b, c;
    for (int i = s; i < 1000; ++i)
    {
        int t = i;        
        a = t % 10; t /= 10;
        b = t % 10; t /= 10;
        c = t % 10;
        if (a == b && b == c)
        {
            cout << i << endl;
            break;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
n = io.read("*n")
t = {}
for i = 1, n do
  a = io.read("*n")
  for j = -1, 1 do
    if not t[a + j] then t[a + j] = 1
    else t[a + j] = t[a + j] + 1
    end
  end
end
c = 0
for k, v in pairs(t) do
  if c < v then c = v end
end
print(c)


Measured memory_bytes: 4332
// 
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define e_b emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
void map_p(map<int,int>& d){cout<<"map: ";for(auto a : d){cout<<"{"<<a.first<<":"<<a.second<<"}";}cout<<endl;} //mapの中身を見る
void set_p(set<int>& d){cout<<"set: ";for(int a : d){cout<<a<<" ";}cout<<endl;} //setの中身を見る


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

    int a,b,c,k;
    cin>>a>>b>>c;
    cin>>k;
    int sosa=0;
    while(a>=b){
        b*=2;
        sosa++;
    }
    while(b>=c){
        c*=2;
        sosa++;
    }
    if(sosa<=k) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

// --------------------------------------------------------------------------------
#define fastio	ios_base::sync_with_stio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long 
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define deb(name,value) cout <<"->>  "<<name<< "= " <<value<<" "
#define frepi(a,b,k) for(int i=a;i<=b;i+=k)
#define frepj(a,b,k) for(int j=a;j<=b;j+=k)
// --------------------------------------------------------------------------------


void solve_main()
{
   	string a,b;cin>>a>>b;
   	int n,m;cin>>n>>m;
   	string c;cin>>c;
   	if(c==a)n--;
   	else m--;
   	cout<<n<<" "<<m;
}

int main()
{
	// #ifndef ONLINE_JUDGE
 //    	freopen("/home/suryakant/input.txt","r",stdin);
 //        freopen("/home/suryakant/output.txt","w",stdout);
 //    #endif
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve_main();
    }
    
}

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    vector<ll>h;
    ll val;
    REP(i,N){
        cin>>val;
        h.pb(val);
    }
    ll now;now=1e9;
    REP(i,N){
        if(h[N-i-1]<now){
            now=h[N-i-1];
            continue;
        }else{
            if(h[N-i-1]-now>1){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 1400
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<Integer>();
		
		for(int i = 0; i < 10; i++){
			int tmp = sc.nextInt();
			list.add(tmp);
		}
		
		Collections.sort(list);
		Collections.reverse(list);
		
		for(int i = 0; i < 3; i++){
			int tmp = list.get(i);
			System.out.println(tmp);
		}
	}
}

Measured memory_bytes: 17320
import java.util.Scanner;

public class Main {

    public static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int d = Integer.parseInt(sc.next());
        int[] c = new int[26];
        int[] cd = new int[26];
        for (int i = 0; i < 26; i++) {
            c[i] = Integer.parseInt(sc.next());
        }
        int[][] s = new int[d][26];
        int[] max = new int[d];
        for (int i = 0; i < d; i++) {
            int maxd = 0;
            for (int j = 0; j < 26; j++) {
                int temp = Integer.parseInt(sc.next());
                s[i][j] = temp;
                maxd = Math.max(maxd, temp);
            }
            max[i] = maxd;
        }
        int[] t = new int[d];
        StringBuilder sb = new StringBuilder();
        int ans = 0;
        for (int i = 0; i < d; i++) {
            int temp = Integer.parseInt(sc.next());
            t[i] = temp;
            cd[temp - 1] = i + 1;
            ans += s[i][temp - 1] - totalSubC(c, cd, i + 1);
            sb.append(ans);
            sb.append("\n");
        }
        System.out.println(sb.toString());
    }

    private static int totalSubC(int[] c, int[] cd, int d) {
        int ans = 0;
        for (int i = 0; i < 26; i++) {
            ans += c[i] * (d - cd[i]);
        }
        return ans;
    }
}

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

class Program
{
    static int[] ans;
    static List<int>[] list;

    static void Main(string[] args)
    {
        var nq = Console.ReadLine().Split();
        var n = int.Parse(nq[0]);
        var q = int.Parse(nq[1]);

        list = new List<int>[n];
        for (int i = 0; i < n - 1; i++)
        {
            var ab = Console.ReadLine().Split();
            var a = int.Parse(ab[0]) - 1;
            var b = int.Parse(ab[1]) - 1;

            if (list[a] == null) list[a] = new List<int>();
            if (list[b] == null) list[b] = new List<int>();

            list[a].Add(b);
            list[b].Add(a);
        }

        ans = new int[n];
        for (int i = 0; i < q; i++)
        {
            var px = Console.ReadLine().Split();
            var p = int.Parse(px[0]) - 1;
            var x = int.Parse(px[1]);
            ans[p] += x;
        }

        dfs(0, 0, 0);

        foreach (var item in ans)
            Console.WriteLine(item);
    }

    static void dfs(int x, int y, int sum)
    {
        ans[x] += sum;
        foreach (var next in list[x])
        {
            if (next == y) continue;
            dfs(next, x, ans[x]);
        }
    }
}


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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

typedef long long ll;

struct Data {
  ll v;
  bool dir; // false -> W, true -> H
  bool operator < ( const Data &data ) const {
    if( v != data.v ) return v < data.v;
    return dir < data.dir;
  }
};

int W,H;

int main(){
  cin >> W >> H;
  vector<ll> p(W),q(H);
  rep(i,W) cin >> p[i];
  rep(i,H) cin >> q[i];
  vector<Data> vec;
  rep(i,W) vec.push_back((Data){p[i],false});
  rep(i,H) vec.push_back((Data){q[i],true});
  sort(vec.begin(),vec.end());
  ll ans = 0;
  ll used_w = 0, used_h = 0;
  
  rep(i,(H+W)) {
    Data &e = vec[i];
    ll sub = -1;
    if( e.dir == false ) sub = used_h;
    else                 sub = used_w;
    ll cnt = -1;
    if( e.dir == false ) cnt = (H+1);
    else                 cnt = (W+1);
    ans += ( cnt - sub ) * e.v;
    if( e.dir == false ) ++used_w;
    else                 ++used_h;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6128
#include<iostream>
#define int long long
using namespace std;
const int N=1e5+2;
const int mod=1e9+7;
int dp[N],sum[N][3],last[3];
signed main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  int n,i,j,k,l=0;
  cin>>s;
  n=s.size();
  s=" "+s;
  dp[0]=1;
  sum[0][0]=1;
  last[1]=-1;
  last[2]=-1;
  bool cac=true;
  for(i=1;i<=n;i++){
    if(s[i]==s[i-1]){
      cac=false;
    }
    if(s[i]=='a'){
      l++;
    }
    else{
      l+=2;
    }
    if(l>=3){
      l-=3;
    }
    for(j=0;j<3;j++){
      sum[i][j]=sum[i-1][j];
      dp[i]+=sum[i][j];
        if(last[l]>-1){
          dp[i]-=sum[last[l]][j];
        }
    }
  	dp[i]-=sum[i][l];
    if(last[l]>-1){
      dp[i]+=sum[last[l]][l];
    }
    dp[i]=(dp[i]%mod+mod)%mod;
    last[l]=i;
    sum[i][l]+=dp[i];
    sum[i][l]%=mod;
    //cout<<dp[i]<<endl;
  }
  if(cac){
    cout<<1;
    return 0;
  }
  if(!l){
    sum[n][l]=(sum[n][l]-1+mod)%mod;
  }
  cout<<sum[n][l];
}

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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    string s, t; cin >> s >> t;
    int ans = 0;
    for(int i = 0; i < s.length(); i++) {
        if(s[i] != t[i]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3752
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string s; cin >> s;
  reverse(ALL(s));
  int n = s.length();
  vector<vector<long long> > dp(n + 1, vector<long long>(13, 0));
  dp[0][0] = 1;
  int digit = 1;
  REP(i, n) {
    if (s[i] == '?') {
      REP(j, 13) REP(k, 10) {
        (dp[i + 1][(j + digit * k % 13) % 13] += dp[i][j]) %= MOD;
      }
    } else {
      int number = s[i] - '0';
      REP(j, 13) (dp[i + 1][(j + digit * number % 13) % 13] += dp[i][j]) %= MOD;
    }
    (digit *= 10) %= 13;
  }
  cout << dp[n][5] << '\n';
  return 0;
}


Measured memory_bytes: 13648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var s = Console.ReadLine();
		
		var k = s.ToCharArray();
		Array.Sort(k);
		
		if(k[0] == k[1] && k[2] == k[3] && k[0] != k[2])
		{
			Console.WriteLine("Yes");
		}
		else
		{
			Console.WriteLine("No");
		}
		
	}

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

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


const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
int w, h;
int c[55][55];
bool seen[55][55];

void dfs(int x, int y){
    seen[y][x] = true;
    rep(i, 4){
        rep(j, 4){
            int nx = x + dx[i];
            int ny = y + dy[j];
            if (nx < 0 || w <= nx || ny < 0 || h <= ny) continue;
            if (c[ny][nx] == 0 || seen[ny][nx]) continue;
            dfs(nx, ny);
        }
    }
}

int main(){
    vector<int> ans;
    while(true){
        cin >> w >> h;
        if (w == 0 && h == 0) break;
        rep(i, h) rep(j, w) cin >> c[i][j];
        memset(seen, 0, sizeof(seen));
        int cnt = 0;
        rep(y, h){
            rep(x, w){
                if(!seen[y][x] && c[y][x] == 1){
                    cnt ++;
                    dfs(x, y);
                }
            }
        }
        ans.push_back(cnt);
    }
    rep(i, ans.size()) cout << ans[i] << endl;
    return 0;
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define DISP1(as)		for(auto it : as) cout<<it.f<<" "<<it.s<<") ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	2e+5 + 99;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, k, l, q, x;
string s;

// <---------------------- > //



// <------------- Start of main() -------------------> //

void MAIN() {
	ll a,b,x;
	cin>>a>>b>>x;
	cout<<(x/a)*b;
	
}


int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {

		MAIN();
	}
	return 0;
}


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved

int main(){
    long long a,b,n;
    cin>>a>>b>>n;

    long long x=min(b-1,n);

    long long ans=(x*a)/b;

    cout<<ans<<endl;
    return 0;

}
/*


*/


Measured memory_bytes: 3636
#include<iostream>

using namespace std;

int main(){
  int i,j,N;
  cin >> N;
  int Mem[N],Sub[N] = {};
  Mem[0] = 0;
  for(i=2;i<=N;i++)
  {
    cin >> Mem[i-1];
    int boss = Mem[i-1];
    Sub[boss - 1]++;
  }
  for(i=1;i<=N;i++)
  {
      cout<<Sub[i-1]<<endl;
  }

  return 0;
}

Measured memory_bytes: 5184
#include<iostream>
using namespace std;
int n, m, s, i, j, pt, x, lst;
struct str{
    int x, y, c;
};
str sol[80];
int main(){
    cin>> s;
    while( (1 << (pt + 1)) <= s){
        pt++;
    }
    n = pt + 1;
    x = 1;
    for(i = n; i > 1; i--){
        sol[++m] = {i - 1, i, 0};
        sol[++m] = {i - 1, i, x};
        x *= 2;
    }
    pt = (1 << pt);
    lst = pt;
    for(i = 1; i < n; i++){
        pt /= 2;
        if( (s & pt) == pt){
            sol[++m] = {1, i + 1, lst};
            lst += pt;
        }
    }
    cout<< n <<" "<< m <<"\n";
    for(i = 1; i <= m; i++){
        cout<< sol[i].x <<" "<< sol[i].y <<" "<< sol[i].c <<"\n";
    }
}


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

#ifdef LOCAL
#include "../dump.hpp"
#else
#define dump(...)
#endif

using namespace std;

#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;i++)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;i++)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

int main(){
  vector<int> a(3); rep(i,3) cin >> a[i];
  int ans = 0;
  while(1){
    sort(all(a));
    if(a[0] == a[2]) break;
    if(a[1] == a[2]){
      a[0]+=2;
      ans++;
    }else{
      a[0]++;
      a[1]++;
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        String b = sc.next();
        String c = sc.next();
        String[] d=b.split("");
        String[] e =c.split("");
        for(int i=0;i<a;i++){
            System.out.print(d[i]+e[i]);
        }
    }
}

Measured memory_bytes: 20816
#    !/usr/bin/env python3
#    encoding: UTF-8
#    Modified: <22/Jun/2019 05:52:43 PM>


#    ✪ H4WK3yE乡
#    Mohd. Farhan Tahir
#    Indian Institute Of Information Technology (IIIT), Gwalior


import sys
import os
from io import IOBase, BytesIO


def main():
    a, b, c, d = get_ints()
    l = 0
    if a % c == 0:
        l = a
    else:
        l = (a // c) * c + c
    r = (b // c) * c
    n1 = (r - l) // c + 1

    if a % d == 0:
        l = a
    else:
        l = (a // d) * d + d
    r = (b // d) * d
    n2 = (r - l) // d + 1

    from fractions import gcd
    g = (c * d) // gcd(c, d)
    if a % g == 0:
        l = a
    else:
        l = (a // g) * g + g
    r = (b // g) * g
    n3 = (r - l) // g + 1

    print(b - a + 1 - (n1 + n2 - n3))


BUFSIZE = 8192


class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill():
            pass
        return super(FastIO, self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill()
            self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        py2 = round(0.5)
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2 == 1:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s: self.buffer.write(s.encode("ascii"))
            self.read = lambda: self.buffer.read().decode("ascii")
            self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)


def get_array(): return list(map(int, sys.stdin.readline().split()))


def get_ints(): return map(int, sys.stdin.readline().split())


def input(): return sys.stdin.readline().strip()


if __name__ == "__main__":
    main()


Measured memory_bytes: 5276
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    
    boolean flg = false;
    
    for(int i = 1; i <= 9; i++) {
      for(int j = 1; j <= 9; j++) {
        if(i * j == a) flg = true;
      }
    }

    if(flg) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  
  }
}

Measured memory_bytes: 22996
#include<stdio.h>
int inverse(int n)
{
	int sum=0;
	while(n>0)
	{
		sum=sum*10+n%10;
		n=n/10;
	}
	return sum;
}
int main()
{
	int n,m,i,h=0;
	scanf("%d%d",&m,&n);
	for(i=m;i<=n;i++)
	{
		if(inverse(i)==i)
		{
	     h++;
		}
	}
	printf("%d",h);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long  ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;

ll p[30];
void init() {
	p[0] = 1;
	rep1(i, 15) {
		p[i] = p[i - 1] * i;
	}
}

string s;
int n;
vector<vec> v;
vec a;
void dfs(int id,int s) {
	if (id == n) {
		v.push_back(a); return;
	}
	Rep(i, s, 10) {
		a.push_back(i);
		dfs(id + 1, i);
		a.pop_back();
	}
}
void solve() {
	init();
	cin >> s;
	n = s.length();
	int sum = 0;
	rep(i, n) {
		sum += (s[i] - '0');
	}
	ll pro = 1;
	rep(i, n) {
		ll t = (s[i] - '0') + 1;
		pro = pro * t;
	}
	dfs(0, 0);
	ll ans = 0;
	rep(i, v.size()) {
		vec &u = v[i];
		ll c = p[n];
		rep(j, n) {
			int le = j;
			while (j + 1 < n&&u[j] == u[j + 1])j++;
			int len = j - le + 1;
			c /= p[len];
		}

		int csum = 0;
		rep(j, n)csum += u[j];
		if (csum < sum) {
			//cout << "sum " << c << endl;
			ans += c; continue;
		}
		else if (csum > sum)continue;
		ll pr = 1;
		rep(j, n)pr *= u[j] + 1;
		if (pr < pro) {
			//cout << "pr " << c << endl;
			ans += c; continue;
		}
		else if (pr > pro)continue;
		vector<vector<ll>> dp(1 << n);
		rep(i, (1 << n))dp[i].resize(2, 0);
		dp[0][0] = 1;
		rep(i, (1 << n)-1) {
			int cnt = 0;
			rep(j, n)if (i&(1 << j))cnt++;
			rep(j, n) {
				if (i&(1 << j))continue;
				if (j > 0) {
					if (u[j] == u[j - 1]) {
						if (i&(1 << (j - 1)))continue;
					}
				}
				int ni = i ^ (1 << j);
				dp[ni][1] += dp[i][1];
				int z = u[j];
				int cc = s[cnt] - '0';
				if (z == cc) {
					dp[ni][0] += dp[i][0];
				}
				else if (z < cc) {
					dp[ni][1] += dp[i][0];
				}
			}
		}
		ans+=dp[(1 << n) - 1][1];
	}
	cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(5);
	//while (cin >> w>>h>>n,n)solve();
	solve();
	//stop
	return 0;
}



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

using namespace std;

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define fo(i, n) for(int i = 1; i <= n; ++i)
#define rep(i, a, b) for(int (i) = (a); (i) < (b); ++(i))

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

const int N = 200200;
const int mod = 1e9 + 7;
const ll INF = 1e18;
int n;
int was[N];
string s;
int a[N], b[N];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>n;
	cin>>s;
	for(int i=0;i<2;++i)
		for(int j=0;j<2;++j)
		{
			a[0]=i,a[1]=j;
			b[0]=i,b[1]=j;
			for(int k=1;k+1<n;++k)
			{
				int nxt=(k+1)%n;
				int prv=(k-1)%n;
				if(a[k]==1)
				{
					if(s[k]=='o')
						a[nxt] = a[prv] ^ 1;
					else
						a[nxt] = a[prv];
				}
				else
				{
					if(s[k]=='x')
						a[nxt] = a[prv] ^ 1;
					else
						a[nxt] = a[prv];
				}
			}
			bool bad = 0;
			for(int k=0;k<n;++k)
			{
				int nxt=(k+1)%n;
				int prv=(k-1+n)%n;
			    if(a[k]==1)
			    {
			    	if(s[k]=='o'&&a[nxt]^1!=a[prv]||s[k]=='x'&&a[nxt]!=a[prv])
			    		bad=1;
			    }
			    else
			    {
			    	if(s[k]=='x'&&a[nxt]^1!=a[prv]||s[k]=='o'&&a[nxt]!=a[prv])
			    		bad=1;
			    }
			}
			if(bad)
				continue;
			for(int k=0;k<n;++k)
				if(!a[k])
					cout<<'S';
				else
					cout<<'W';
			return 0;	
		}
	cout<<-1;
	return 0;	
}

Measured memory_bytes: 976
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))

Sd = input()
T = input()

def match(L):
    for l, t in zip(L, T):
        if l == "?":
            continue
        else:
            if l != t:
                return False
            else:
                pass
    return True

res = []

for i in range(len(Sd)-len(T)+1)[::-1]:
    if match(Sd[i:i+len(T)]):
        res.append((Sd[:i] + T + Sd[i+len(T):]).replace("?", "a"))

if len(res):
    print(sorted(res)[0])
else:
    print("UNRESTORABLE")

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

using namespace std;
typedef long long ll;
const int MAXN = 500100;

int N, M, K;
vector <int> edge[MAXN];
vector <int> bb[MAXN];

int cpar[MAXN];
int bz[MAXN];

int cfind (int x)
{
    if (cpar[x] == x) return x;
    return cpar[x] = cfind (cpar[x]);
}

void uni (int x, int y)
{
    x = cfind (x);
    y = cfind (y);
    if (x == y) return;

    cpar[x] = y;
}

int main()
{
    ios_base::sync_with_stdio(0);

    cin >> N >> M >> K;

    for (int i = 0; i < N; i++)
        cpar[i] = i;


    for (int i = 0; i < M; i++)
    {
        int x, y;
        cin >> x >> y;
        x--, y--;
        uni (x, y);
        edge[x].push_back(y);
        edge[y].push_back(x);
    }

    for (int i = 0; i < K; i++)
    {
        int x, y;
        cin >> x >> y;
        x--, y--;
        bb[x].push_back(y);
        bb[y].push_back(x);
    }

    for (int i = 0; i < N; i++)
        bz[cfind (i)]++;

    for (int i = 0; i < N; i++)
    {
        int ntot = bz[cfind (i)];
        ntot -= 1;
        ntot -= edge[i].size();
        for (int j : bb[i])
        {
            if (cfind (i) == cfind (j))
                ntot--;
        }
        if (i) cout << " ";
        cout << ntot;
    }
}

Measured memory_bytes: 33272
import math

P_lst=[2]
for i in range(1000):
  flag=0
  for j in P_lst:
    if (i+3)%j==0:
      flag=1

  if flag==0:
    P_lst.append(i+3)

X=int(input())

while X<=200000:
  if X==2:
    print(2)
    break
  flag=0
  x=math.sqrt(X)
  for k in P_lst:
    if X%k==0:
      break
    if x<k:
      flag=1
      break
  if flag==1:
    print(X)
    break
  X=X+1

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 3e18;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	vector<pair<int,int>>D(n);

	for(int i=0;i<n;i++){
		cin>>D[i].first>>D[i].second;
	}
	int cnt=0;
	bool flag=false;
	for(int i=0;i<n;i++){
		if(D[i].first==D[i].second){
			cnt++;
		}else{
			cnt=0;
		}

		if(cnt>=3)flag=true;
	}

	cout<<(flag?"Yes":"No")<<'\n';

	
	
	return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
#define SG getchar()
using namespace std;
signed main()
{
	char a(SG),kg(SG),b(SG);
	putchar(((a<b)?('<'):((a>b)?('>'):('='))));
	return putchar(10),0;
}

Measured memory_bytes: 256
S = input()
ans = [0 for _ in range(len(S))]

tmp_r = 1
tmp_l = 1
tmp_r_p = 0
tmp_l_p = 0
for i in range(len(S)-1):
    if(S[i] == 'R' and S[i+1]=='R'):
        tmp_r +=1
    elif(S[i] == 'R' and S[i+1]=='L'):
        tmp_r_p = i
        tmp_l_p = i+1
        if(i == len(S)-2):
            if(tmp_r == tmp_l):
                ans[tmp_r_p] = tmp_r 
                ans[tmp_l_p] = tmp_l

            elif((tmp_r + tmp_l)%2 == 0):
                ans[tmp_r_p] = (tmp_r + tmp_l)//2
                ans[tmp_l_p] = (tmp_r + tmp_l)//2

            elif(tmp_r > tmp_l):
                if(tmp_r%2==0):
                    ans[tmp_r_p] = (tmp_r + tmp_l)//2
                    ans[tmp_l_p] = (tmp_r + tmp_l)//2+1

                else:
                    ans[tmp_r_p] = (tmp_r + tmp_l)//2+1
                    ans[tmp_l_p] = (tmp_r + tmp_l)//2

            elif(tmp_r < tmp_l):
                if(tmp_l%2==0):
                    ans[tmp_r_p] = (tmp_r + tmp_l)//2+1
                    ans[tmp_l_p] = (tmp_r + tmp_l)//2

                else:
                    ans[tmp_r_p] = (tmp_r + tmp_l)//2
                    ans[tmp_l_p] = (tmp_r + tmp_l)//2+1

    elif(S[i] == 'L' and S[i+1]=='L'):
        tmp_l +=1

        if(i == len(S)-2):
            if(tmp_r == tmp_l):
                ans[tmp_r_p] = tmp_r 
                ans[tmp_l_p] = tmp_l

            elif((tmp_r + tmp_l)%2 == 0):
                ans[tmp_r_p] = (tmp_r + tmp_l)//2
                ans[tmp_l_p] = (tmp_r + tmp_l)//2

            elif(tmp_r > tmp_l):
                if(tmp_r%2==0):
                    ans[tmp_r_p] = (tmp_r + tmp_l)//2
                    ans[tmp_l_p] = (tmp_r + tmp_l)//2+1

                else:
                    ans[tmp_r_p] = (tmp_r + tmp_l)//2+1
                    ans[tmp_l_p] = (tmp_r + tmp_l)//2

            elif(tmp_r < tmp_l):
                if(tmp_l%2==0):
                    ans[tmp_r_p] = (tmp_r + tmp_l)//2+1
                    ans[tmp_l_p] = (tmp_r + tmp_l)//2

                else:
                    ans[tmp_r_p] = (tmp_r + tmp_l)//2
                    ans[tmp_l_p] = (tmp_r + tmp_l)//2+1
                    
    elif(S[i] == 'L' and S[i+1]=='R'):
        if(tmp_r == tmp_l):
            ans[tmp_r_p] = tmp_r 
            ans[tmp_l_p] = tmp_l

        elif((tmp_r + tmp_l)%2 == 0):
            ans[tmp_r_p] = (tmp_r + tmp_l)//2
            ans[tmp_l_p] = (tmp_r + tmp_l)//2

        elif(tmp_r > tmp_l):
            if(tmp_r%2==0):
                ans[tmp_r_p] = (tmp_r + tmp_l)//2
                ans[tmp_l_p] = (tmp_r + tmp_l)//2+1

            else:
                ans[tmp_r_p] = (tmp_r + tmp_l)//2+1
                ans[tmp_l_p] = (tmp_r + tmp_l)//2

        elif(tmp_r < tmp_l):
            if(tmp_l%2==0):
                ans[tmp_r_p] = (tmp_r + tmp_l)//2+1
                ans[tmp_l_p] = (tmp_r + tmp_l)//2

            else:
                ans[tmp_r_p] = (tmp_r + tmp_l)//2
                ans[tmp_l_p] = (tmp_r + tmp_l)//2+1
        tmp_r = 1
        tmp_l = 1
    

for i in range(len(ans)-1):
    print(ans[i] ,end=' ')
print(ans[len(ans)-1])

Measured memory_bytes: 52704
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int N, K;
    while(cin >> N >> K){
        vector<int> H(N);
        for(auto& t : H) cin >> t;
        sort(H.begin(), H.end());
        long long res = 0;
        for(int i=0;i<N-K;i++) res += H[i];
        cout << res << endl;
    }
}

Measured memory_bytes: 1024