akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <functional>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,K;
	while(cin>>N>>K) {
		VI w(N);
		REP(i, N) cin>>w[i];
		ll ans = 0;
		ll last=0;
		while(last<N-1) {
			last+=K-1;
			ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <set>
#include <map>
#include <queue>
using namespace std;
typedef long long int lli;
typedef pair<int, int> pii;
typedef pair<lli, lli> pll;
const lli inf = 1e18;
const lli mod = 1e9 +7;

int main(){
	int n,a,b,c,d;
	cin >> n >> a >> b >> c >> d;
	a++; b++; c++; d++; n+=4;
	string s;
	cin >> s;
	s = "##" + s + "##";
	bool change = (a<b) != (c<d);
	int smax,tmax;
	for(int i=a; i<n-2; i++){
		if(s[i+1] == '#' and s[i+2] == '#'){
			smax = i;
			break;
		}
	}
	for(int i=b; i<n-2; i++){
		if(s[i+1] == '#' and s[i+2] == '#'){
			tmax = i;
			break;
		}
	}
	bool toc = (smax >= c);
	bool tod = (tmax >= d);
	bool canswap = false;
	for(int i=max(a,b)-1; i<=min(c,d)-1; i++){
		if(s[i] == '.' and s[i+1] == '.' and s[i+2] == '.'){
			canswap = true;
		}
	}
	if(toc and tod and (!change or canswap)){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	//cout << toc << " " << tod << " " << change << " " << canswap << endl;
	//cout << smin << " " << smax << " " << tmin << " " << tmax << endl;
	return 0;
}


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

int main() {
	int a, n, min, max;
	cin >> n;
	cin >> a;
	min = a;
	cin >> a;
	max = a - min;
	(min > a) && (min = a);	
	for (int i = 0; i < n - 2; i++) {
		cin >> a;
		(max < ( a - min)) && (max = (a - min));
		(min > a) && (min = a);
	}		
	cout << max << endl;
	return 0;
}

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

int main()
{
    ll x;
    cin >> x;

    ll n = 100;
    int ans = 0;
    while (n < x)
    {
        n += n / 100;
        ans++;
    }

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

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int X;
    cin >> X;
    int a = X/500;
    int b = (X%500)/5;
    cout << a*1000+b*5 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
const long long dy[] = {-1, 0, 0, 1};
const long long dx[] = {0, -1, 1, 0};
string alp = "abcdefghijklmnopqrstuvwxyz";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for (const auto &e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void pt(){cout << endl; return;}
template<class Head> void pt(Head&& head){cout << head; pt(); return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> ll gcd(T1 a, T2 b){return a % b ? gcd(b , a % b) : b;}
template<class T1, class T2> void reduce(T1 &a, T2 &b){ll g = gcd(a, b); a /= g; b /= g; return;}
bool valid(ll H, ll W, ll h, ll w){return 0 <= h && h < H && 0 <= w && w < W;}

int main(){
    ll H1, M1, H2, M2, K; cin >> H1 >> M1 >> H2 >> M2 >> K;
    ll d1 = 60 * H1 + M1;
    ll d2 = 60 * H2 + M2;
    pt(d2 - d1 - K);

    return 0;
}


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

# fizzbuzz = [1, 3, 3, 7, 7, 7, 14, 22, 22, 22, 33, 33, 46, 60]

ans = 0

for i in range(1, N+1):
    if i % 3 != 0 and i % 5 != 0:
        # print(i)
        ans += i
    # print(i)

print(ans)


Measured memory_bytes: 9164
#[allow(unused_imports)]
use std::cmp::Ordering;

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get {
    ([$t: ty]) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn dfs(
    i: usize,
    at: Vec<usize>,
    abcd: &Vec<(usize, usize, usize, usize)>,
    m: usize,
    n: usize,
) -> usize {
    if i == n {
        let mut sum = 0;
        for &(a, b, c, d) in abcd {
            if at[b - 1] - at[a - 1] == c {
                sum += d;
            }
        }
        return sum;
    }
    let mut mx = 0;
    for j in at[i - 1]..m + 1 {
        let mut a = at.clone();
        a.push(j);
        mx = max!(mx, dfs(i + 1, a, abcd, m, n));
    }
    mx
}

fn solve() {
    let (n, m, q) = get!(usize, usize, usize);
    let abcd = get!(usize, usize, usize, usize; q);
    println!("{}", dfs(1, vec![1], &abcd, m, n));
}


Measured memory_bytes: 2252
def is_prime(n):
  if n==1:return False
  for i in range(2,int(n**0.5)+1):
    if n%i==0:return False
  return True
s=[0]*100007;s[2]=1
t=[0]*100007
for i in range(1,100001,2):s[i]+=is_prime(i)
for i in range(1,100001,2):t[i]=(s[i]+s[(i+1)//2])//2
for i in range(1,100007):t[i]+=t[i-1]
for i in range(int(input())):
	l,r=map(int,input().split())
	print(t[r]-t[l-1])

Measured memory_bytes: 7284
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define reps(i, s, n) for(int i = (s); i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, s, n) for(int i = (n) - 1; i >= (s); i--)
#define INF ~(1 << 31)
#define INFL ~(1LL << 63)

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, n){
        cin >> h[i];
    }

    vector<int> ans(n);
    ans[0] = 0;
    reps(i, 1, n){
        int ansmin = INF;
        rep(j, min(i, k)){
            ansmin = min(ansmin, ans[i-j-1] + abs(h[i] - h[i-j-1]));
        }
        ans[i] = ansmin;
    }
    cout << ans[n-1] << endl;
}

Measured memory_bytes: 4028
def comb(a, b, facto):
  # print(a,b)
  ans = facto[a] // (facto[a-b] * facto[b])
  # print(ans)
  return ans

n, k = map(int, input().split())

facto = [1] * (n + k *2)
for i in range(1, n + k *2):
  #print(i)
  facto[i] = facto[i-1] * i
  #print(facto)


mod = 10 ** 9 + 7

for i in range(1, k + 1):
  cnt = comb(n - k + 1 , i , facto) * comb(k - 1, i - 1 , facto) % mod
  #print(cnt)
  #print(comb(n - k, i * 2 - 1, facto))
  #cnt += 2 * comb(n - k - 1, i , facto) * comb(k - 1, i - 1 , facto) % mod
  print(cnt % mod)

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll x,a,b;cin >>x>>a>>b;
    if(abs(a-x)<abs(b-x)){
      puts("A");
    }
    else puts("B");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

int main(){
	ll n;
	cin>>n;
	if(n == 0){
		cout<<0<<endl;
		return 0;
	}
	ll cnt = 0;
	while(n > 0LL){
		cnt++;
		n /= 2ll;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 3104
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<string>
using namespace std ;
int n,a[200005],cho[200005],tot,pt[200005] ;
int main(){
    scanf("%d",&n) ;
    for(int i=1;i<=n;++i) scanf("%d",&a[i]) ;
    //for(int i=1;i<=n;++i) if(a[i] != a[i-1]) cho[++tot] = i ;
    for(int i=n;i>=1;--i){
        int num = 0 ;
        for(int j=2;i*j<=n;++j)
            if(pt[i*j]) num = (!num) ;
        if(num!=a[i]){
            cho[++tot] = i ; pt[i] = 1 ;
        }
    }
    cout<<tot<<endl ; if(!tot) return 0 ;
    for(int i=1;i<=tot;++i) cout<<cho[i]<<" " ;
    cout<<endl ;
    return 0 ;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
std::vector<int> A['   '];
int n, m, S['   '], a, l, r, i, d;
void U(int x, int u) {
  while (x <= n)
    S[x] += u, x += x & -x;
}
int Q(int x) {
  r = 0;
  while (x)
    r += S[x], x -= x & -x;
  return r;
}
int main() {
  scanf("%d%d", &m, &n);
  for (i = 1; i <= m; i++)
    scanf("%d%d", &l, &r), A[r - l + 1].push_back(l);
  for (d = 1; d <= n; d++) {
    a = m;
    for (i = d; i <= n; i += d)
      a += Q(i);
    for (int u : A[d])
      U(u, 1), U(u + d, -1), m--;
    printf("%d\n", a);
  }
  return 0;
}

Measured memory_bytes: 53760
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cassert>
#include <string>
#include <cstring>
#include <bitset>
 
#define FOR(i, a, b) for(int i = a; i < (int) b; i++)
#define F0R(i, a) FOR (i, 0, a)
#define ROF(i, a, b) for(int i = a; i >= (int) b; i--)
#define R0F(i, a) ROF(i, a, 0)
#define GO(i, a) for (auto i : a)
 
#define rsz resize
#define eb emplace_back
#define pb push_back
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define f first
#define s second
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;

const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int ms[] = {+31, +29, +31, 30, +31, +30, +31, +31, +30, +31, +30, +31};

const int N = 1e3 + 5;
const int M = 2e4 + 5;

int n;
i64 dp [N][M];

struct E {
  int peso, aguenta, profit;
  bool operator < (E Other) const {
    return peso + aguenta > Other.peso + Other.aguenta;
  }
} a [N];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  F0R (i, n) cin >> a[i].peso >> a[i].aguenta >> a[i].profit;
  sort (a, a + n);
  FOR (i, 1, n + 1) {
    FOR (j, 0, M) {
      dp[i][j] = max (dp[i][j], dp[i - 1][j]);
      if (j - a[i - 1].peso >= 0) {
        int mn = min (j - a[i - 1].peso, a[i - 1].aguenta);
        dp[i][mn] = max (dp[i][mn], dp[i - 1][j] + a[i - 1].profit);
      }
    }
  }
  i64 mx = 0;
  FOR (i, 1, n + 1) {
    FOR (j, 0, M) {
      mx = max (mx, dp[i][j]);
    }
  }
  cout << mx << '\n';
  return 0;
}


Measured memory_bytes: 156544
fun main(args: Array<String>) {
    abc144e()
}

private data class Member(val cost: Long, val food: Long)

fun abc144e() {
    val (n, k) = readLine()!!.split(" ").map { it.toLong() }
    val aList = readLine()!!.split(" ").map { it.toLong() }
        .sorted().toLongArray()
    val fList = readLine()!!.split(" ").map { it.toLong() }
        .sortedDescending().toLongArray()

    val members = aList.withIndex().map { Member(it.value, fList[it.index]) }

    // すべてのメンバーについてX以下とできるかどうかを二分探索する (条件:X以下にするために必要なK'<=K であること)
    var right = Long.MAX_VALUE / 2L
    var left = -1L
    while (right - left > 1L) {
        val mid = (left + right) / 2L
        val needTrainingSum = members.map { Math.max(0, it.cost - (mid / it.food)) }.sum()

        if (needTrainingSum <= k) right = mid else left = mid
    }

    println(right)
}



Measured memory_bytes: 171084
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;
template<typename T>
struct Edge {
    int u, v;
    T cost;
    Edge(int u, int v, T c) : u(u), v(v), cost(c) {}
    bool operator< (const Edge &e) const {return cost < e.cost;}
};

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

ll ans;

int main(void) {
    string n;
    cin >> n;
    ll x = 0;
    rep(i, 0, sz(n)) x += n[i]-'0';

    if (x%9==0) puts("Yes");
    else puts("No");

    return 0;
}





Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, int> pli;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 15000010;

int main(){
        int n, p;
        while(scanf("%d%d", &n, &p) && n){
                int sum=p;
                vector<int> a(n, 0);
                int cur=0;
                while(true){
                        if(p){
                                ++a[cur];
                                --p;
                                if(a[cur]==sum){
                                        printf("%d\n", cur);
                                        break;
                                }
                                (cur+=1)%=n;
                        }
                        else{
                                p+=a[cur];
                                a[cur]=0;
                                (cur+=1)%=n;
                        }
                }
        }
}


Measured memory_bytes: 3220
#include <stdio.h>

int main(void){
  char S;
  bool n = false, w = false, s = false, e = false;
  while(1){
    scanf("%c", &S);
    if(S == '\n') break;
    else if(S == 'N') n = true;
    else if(S == 'W') w = true;
    else if(S == 'S') s = true;
    else if(S == 'E') e = true;
  }
  if(n == s && w == e) printf("Yes\n");
  else printf("No\n");

  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

void QSort(long x[ ], int left, int right)
{
    int i, j;
    int pivot;

    i = left;                      /* ソートする配列の一番小さい要素の添字 */
    j = right;                     /* ソートする配列の一番大きい要素の添字 */

    pivot = x[(left + right) / 2]; /* 基準値を配列の中央付近にとる */

    while (1) {                    /* 無限ループ */

        while (x[i] < pivot)       /* pivot より大きい値が */
            i++;                   /* 出るまで i を増加させる */

        while (pivot < x[j])       /* pivot より小さい値が */
            j--;                   /*  出るまで j を減少させる */
        if (i >= j)                /* i >= j なら */
            break;                 /* 無限ループから抜ける */

        Swap(x, i, j);             /* x[i] と x[j]を交換 */
        i++;                       /* 次のデータ */
        j--;
    }

    if (left < i - 1)              /* 基準値の左に 2 以上要素があれば */
        QSort(x, left, i - 1);     /* 左の配列を Q ソートする */
    if (j + 1 <  right)            /* 基準値の右に 2 以上要素があれば */
        QSort(x, j + 1, right);    /* 右の配列を Q ソートする */
}

  /* 配列の要素を交換する */
void Swap(long x[ ], int i, int j)
{
    long temp;

    temp = x[i];
    x[i] = x[j];
    x[j] = temp;
}

int main(){
  long a[100000],n,i,cnt=0,cnt2=0,j,b,c=1;
  scanf("%ld",&n);
  for(i=0;i<n;i++)
    scanf("%ld",&a[i]);
  QSort(a, 0, n - 1);
  /*for(i=0;i<n;i++)
    printf("%d\n",a[i]);*/
  b=a[0];
  for(i=1;i<n;i++){
    if(a[i]==b){
      c=(c+1)%2;
      if(i==n-1)
        cnt+=c;
    }
    else{
      cnt+=c;
      c=1;
      b=a[i];
      if(i==n-1)
        cnt++;
    }
  }
  printf("%ld\n",cnt);
}

Measured memory_bytes: 896
import java.io.*;
import java.util.*;

class Main{
    public static void main(String args[])throws IOException{
      try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
        String day = br.readLine();
        if(day.equals("SUN")){
          System.out.println("7");
        }else if(day.equals("MON")){
          System.out.println("6");
        }else if(day.equals("TUE")){
          System.out.println("5");
        }else if(day.equals("WED")){
          System.out.println("4");
        }else if(day.equals("THU")){
          System.out.println("3");
        }else if(day.equals("FRI")){
          System.out.println("2");
        }else if(day.equals("SAT")){
          System.out.println("1");
        }
      }
    }
}

Measured memory_bytes: 21204
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		int[] D = new int[N];
		Arrays.setAll(D, $ -> Integer.parseInt(sc.get()));
		long sum = 0;
		for (int i = 0; i < N; i++) {
			for (int j = i + 1; j < N; j++) {
				sum += (long) D[i] * D[j];
			}
		}
		System.out.println(sum);
	}
}

class Main {
	public static void main(String... args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<String>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
	}
}

Measured memory_bytes: 26580
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <iterator>
#include <cmath>
#include <stack>
#include <functional>
using namespace std;

 
int main()
{
  int a,b;
  while(cin >> a >> b, !cin.eof()) {
    stringstream ss;
    ss << (a + b);
    string str = ss.str();
    cout << str.size() << endl;
  }
  return 0;
}

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

int main() {
	vector<char> vec1(3);
	vector<char> vec2(3);
	vector<char> vec3(3);

	for (int i = 0; i < 3; i++)
		cin >> vec1.at(i);
	for (int i = 0; i < 3; i++)
		cin >> vec2.at(i);
	for (int i = 0; i < 3; i++)
		cin >> vec3.at(i);

	cout << vec1.at(0) << vec2.at(1) << vec3.at(2) << endl;
}

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 debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#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; }

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

    char a,b;cin>>a>>b;
    string A="",B="";
    rep(i,(b-'0')) A.push_back(a);
    rep(i,(a-'0')) B.push_back(b);
    if(A<B) cout<<A<<endl;
    else cout<<B<<endl;
    return 0;
}


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

def digit_sum(n, d):
    sum = 0
    number = n
    while number > 0:
        sum += number % d
        number = number // d
    return sum

ans = float('inf')
for i in range(N+1):
    ans = min(ans, digit_sum(N-i, 6) + digit_sum(i, 9))
print(ans)


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

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
hN = LIST()

# dp[足場番号] = そこまで行くための最小コスト
dp = [INF] * (N)
dp[0] = 0
for i in range(N):
    if i+1 < N:
        # 1つ先に跳ぶ
        dp[i+1] = min(dp[i] + abs(hN[i+1]-hN[i]), dp[i+1])
    if i+2 < N:
        # 2つ先に跳ぶ
        dp[i+2] = min(dp[i] + abs(hN[i+2]-hN[i]), dp[i+2])
print(dp[N-1])


Measured memory_bytes: 16200
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef long long ll;

template <typename T> void max_self(T& a, T b){
  a = max(a,b);
}

template <typename T> void min_self(T& a, T b){
  a = min(a,b);
}

void solve(){	
  int x,n;
  cin>>x>>n;
  set<int> s;
  int ent;
  pi ans;
  for(int i=0;i<n;++i){
    cin>>ent;
    s.insert(ent);
  }
  for(int i=0; i<=n+1; ++i){
    int a = x-i;
    int b = x+i;
    auto it = s.lower_bound(a);
    if(it == s.end() || *it != a){
      cout<<a<<endl;
      return;
    }
    it = s.lower_bound(b);
    if(it == s.end() || *it != b){
      cout<<b<<endl;
      return;
    }
  }
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  //int t; cin >> t;
  //while(t--) solve();
  //
  solve();
  return 0;
}


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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;


signed main(){

	int A, B, C;
	cin >> A >> B >> C;

	if (A == B && B == C){ Yes; }
	else No;


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define double long double
using namespace std;
signed main() {
	ll inf = 1e9;
	string s;
	cin >> s;
	for (int i = 0; i < s.size() - 2; i++) {
		if (inf > abs((s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0') - 753)) {
			inf = abs((s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0') - 753);
		}
	}
	cout << inf << endl;
	getchar(); getchar(); return 0;
}


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

#define int long long

using namespace std;

//int a[100001];
//int b[100001];

 main () {
 	int n, a, b;
 	cin >> n >> a >> b;
 	if (a > b || (n == 1 && a != b)) {
 		cout << 0;
 		return 0;
 	}
 	int l = a * n - a + b;
 	int r = b * n - b + a;
 	cout << r - l + 1; 
    return 0;           		
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int INTMAX = 2147483647;
const int INTMIN = -2147483648;
const unsigned int UINTMAX = 4294967295;
const long LONGMAX = 9223372036854775807;
const long LONGMIN = -9223372036854775808;
const unsigned long ULONGMAX = 18446744073709551615;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define UNIQ(c) (c).erase(unique((c).begin(), (c).end()), (c).end());
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

bool isprime(int p) {
  if (p==1) return false;
  FOR(i,2,p) {
    if (p%i==0) return false;
  }
  return true;
}

int dig(int n, int a) {return n/(int)pow(10,a)%10;}
int digl(long n, int a) {return n/(long)pow(10,a)%10;}
int digsum(int n) {int r=0;REP(i,10){r+=dig(n,i);}return r;}
int digsuml(long n) {int r=0;REP(i,19){r+=digl(n,i);}return r;}
int dignum(int n) {return n?to_string(n).length():0;}
int dignuml(long n) {return n?to_string(n).length():0;}

int main(){
  int a,b,h;
  cin >> a >> b >> h;
  cout << (a+b)*h/2;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  LL n, m;
  cin>>n>>m;

  if(n!=m && n!=m-1 && n!=m+1){
    cout<<0<<endl;
    return 0;
  }

  LL ans = 1;
  for(LL i=0; i<n; ++i) ans = ans*(i+1)%MOD;
  for(LL i=0; i<m; ++i) ans =ans*(i+1)%MOD;
  if(n==m)ans = ans*2%MOD;

  cout<<ans<<endl;

  return 0;
}


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

int N;
string S;

int main() {
  cin >> S;
  N = S.length();

  int cnt1 = 0, cnt2 = 0;
  
  for (int i = 0; i < N; ++i) {
    if (i % 2 == 0) {
      if (S[i] == '0') cnt1++;
      else cnt2++;
    }
    else {
      if (S[i] == '1') cnt1++;
      else cnt2++;
    }
  }  
  cout << min(cnt1, cnt2) << endl;
}


Measured memory_bytes: 512
import java.util.Scanner;

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

		int[][] bingo = new int[3][3];
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				bingo[i][j] = sc.nextInt();
			}
		}

		int N = sc.nextInt();
		for (int i = 0; i < N; i++) {
			int b = sc.nextInt();
			for (int j = 0; j < 3; j++) {
				for (int k = 0; k < 3; k++) {
					if (bingo[j][k] == b) {
						bingo[j][k] = 0;
					}
				}
			}
		}

		boolean flg = false;
		flg |= bingo[0][0] == 0 && bingo[1][0] == 0 && bingo[2][0] == 0;
		flg |= bingo[0][1] == 0 && bingo[1][1] == 0 && bingo[2][1] == 0;
		flg |= bingo[0][2] == 0 && bingo[1][2] == 0 && bingo[2][2] == 0;
		flg |= bingo[0][0] == 0 && bingo[0][1] == 0 && bingo[0][2] == 0;
		flg |= bingo[1][0] == 0 && bingo[1][1] == 0 && bingo[1][2] == 0;
		flg |= bingo[2][0] == 0 && bingo[2][1] == 0 && bingo[2][2] == 0;
		flg |= bingo[0][0] == 0 && bingo[1][1] == 0 && bingo[2][2] == 0;
		flg |= bingo[0][2] == 0 && bingo[1][1] == 0 && bingo[2][0] == 0;
		System.out.println(flg ? "Yes" : "No");
	}

}

Measured memory_bytes: 21584
//#define NDEBUG

#include <bits/stdc++.h>
#include <bits/extc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define mt make_tuple
#define gt(t, i) get<i>(t)
#define iceil(a, b) ((a + b - 1) / b)
#define tomax(a, b) (a = max(a, b))
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}

//#define TEST

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;
using tiii = tuple<int, int, int>;

const ll MOD = 1000000007;
const ll MAX = 2147483647;

template<typename A, typename B>
ostream& operator<<(ostream& o, pair<A, B> p){
    return o << '(' << p.F << ',' << p.S << ')';
}

int main(){
    StarBurstStream

    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for(int i = 0; i < n; i++) cin >> p[i];
    lsort(p);
    int ans = 0;
    for(int i = 0; i < k; i++) ans += p[i];
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3604
// AOJ ALDS1_2_D Shell Sort
// 2018.4.27 bal4u

#include <stdio.h>

int g[102], m;
int cnt;

void shell_sort(int n, int *a)
{
	int i, j, h, lim;
	int key;

	lim = n / 9;		// 要素数/9
	if (lim < 40) lim = 40;
	
	g[0] = 1;
	m = 0; do m++, g[m] = 3*g[m-1]+1;
	while (g[m] < n && g[m] <= lim);

	cnt = 0, h = g[m-1];
	while (h > 0) {
		for (i = h; i < n; i++) {
			key = a[i];
			j = i-h; while (j >= 0 && a[j] > key) {
				cnt++;
				a[j+h] = a[j];
				j -= h;
			}
			a[j+h] = key;
		}
		h /= 3;
	}
}

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

char buf[20];
void mypr(int n)
{
	int i;
	if (n == 0) { pc('0'); return; }
	i = 0; while (n) buf[i++] = n%10 +'0', n /= 10;
	while (i) pc(buf[--i]);
}

int a[1000002];

int main()
{
	int N, i;

	N = in(); for (i = 0; i < N; i++) a[i] = in();

	shell_sort(N, a);
	
	mypr(m), pc('\n');
	mypr(g[m-1]); for (i = m-2; i >= 0; i--) pc(' '), mypr(g[i]); pc('\n');
	mypr(cnt), pc('\n');
	for (i = 0; i < N; i++) mypr(a[i]), pc('\n');

	return 0;
}


Measured memory_bytes: 5556
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n,m;
    cin >> n >> m;
    int A[n] = {};
    REP(i,m){
        int x,y;
        cin >> x >> y;
        A[x] ++;
        A[y] ++;
    }
    REP(i,n){
        if(A[i] %2 != 0){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 1024
N,K=map(int,input().split())
prob=0
num=0
for i in range(N):
    buf=1/N
    num=i+1
    #print(i+1,K)
    if not(num>=K):
        while num<K:
            num=num*2
            buf=buf*0.5
    prob=prob+buf
print(prob)



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

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int res = 1;
    for(int i = 1; i < n; ++i){
        if(s[i] != s[i-1]){ ++res; }
    }
    cout << res << endl;
}

Measured memory_bytes: 512
def resolve():
    N = int(input())
    a = list(map(int, input().split()))
    dic = dict()
    for i, an in enumerate(a):
        dic[i + 1] = an
    ans = 0
    # print('dic', dic)
    for d in dic.keys():
        if dic[dic[d]] == d:
            ans += 1
    ans = int(ans/2)
    print(ans)
    return
resolve()

Measured memory_bytes: 24356
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] a_asArgs)
		{
			int[] l_aiInput = Console.ReadLine().Split(' ').Select(l_sItem => int.Parse(l_sItem)).ToArray();
			int l_iH = l_aiInput[0];
			int l_iW = l_aiInput[1];
			int l_iK = l_aiInput[2];

			if (l_iW == 1)
			{
				Console.WriteLine("1");
				return;
			}

			List<int[]> l_lPattern = null;
			for (int l_iX = 0; l_iX < l_iW - 1; l_iX++)
			{
				l_lPattern = MakePattern(l_lPattern);
			}

			int[,] l_aiMatrix = new int[l_iH + 1, l_iW];
			l_aiMatrix[0, 0] = 1;

			for (int l_iY = 1; l_iY < l_iH + 1; l_iY++)
			{
				foreach (int[] l_aiPattern in l_lPattern)
				{
					for (int l_iX = 0; l_iX < l_iW; l_iX++)
					{
						if (l_iX > 0 && l_aiPattern[l_iX - 1] == 1)
						{
							l_aiMatrix[l_iY, l_iX] += l_aiMatrix[l_iY - 1, l_iX - 1];
						}
						else if (l_iX < l_iW - 1 && l_aiPattern[l_iX] == 1)
						{
							l_aiMatrix[l_iY, l_iX] += l_aiMatrix[l_iY - 1, l_iX + 1];
						}
						else
						{
							l_aiMatrix[l_iY, l_iX] += l_aiMatrix[l_iY - 1, l_iX];
						}
						l_aiMatrix[l_iY, l_iX] = l_aiMatrix[l_iY, l_iX] % 1000000007;
					}

				}
			}
			Console.WriteLine(l_aiMatrix[l_iH, l_iK - 1]);
		}

		static List<int[]> MakePattern(List<int[]> a_List)
		{
			List<int[]> l_lResult = new List<int[]>();
			if (a_List == null)
			{
				l_lResult.Add(new int[] { 0 });
				l_lResult.Add(new int[] { 1 });
				return l_lResult;
			}
			int[] l_aiDst;
			foreach (int[] l_aiSrc in a_List)
			{
				l_aiDst = new int[l_aiSrc.Length + 1];
				l_aiSrc.CopyTo(l_aiDst, 1);
				l_lResult.Add(l_aiDst);
				if (l_aiSrc[0] == 0)
				{
					l_aiDst = new int[l_aiSrc.Length + 1];
					l_aiSrc.CopyTo(l_aiDst, 1);
					l_aiDst[0] = 1;
					l_lResult.Add(l_aiDst);
				}
			}
			return l_lResult;
		}
	}
}


Measured memory_bytes: 13268
#include <algorithm>
#include <iostream>
#include <vector>
#define MAX 100010
#define x first
#define y second

using namespace std;

int n,a;
int fr[2][MAX];
vector< pair<int,int> >e1,e2;
bool cmp(pair<int,int> t1,pair<int,int> t2){
  return t1>t2;
}

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a,fr[i%2][a]++;
    for(int i=1;i<MAX;i++){
      if(fr[0][i])e1.push_back(make_pair(fr[0][i],i));
      if(fr[1][i])e2.push_back(make_pair(fr[1][i],i));
    }
    e1.push_back(make_pair(0,MAX)); e2.push_back(make_pair(0,MAX));
    sort(e1.begin(),e1.end(),cmp); sort(e2.begin(),e2.end(),cmp);
    if(e1[0].y!=e2[0].y)cout<<n-e1[0].x-e2[0].x<<'\n';
    else cout<<n-max(e1[0].x+e2[1].x,e1[1].x+e2[0].x);
    return 0;
}


Measured memory_bytes: 2044
#include <iostream>
using namespace std;
int main() {
  long long h;
  cin >> h;
  long long ans = 1, k = 0;
  while (h > 1) {
    k += ans;
    ans *= 2;
    h /= 2;
  }
  cout << ans + k << endl;
  return 0;
}

Measured memory_bytes: 256
def q2():
    N,M = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    A = sorted(A, reverse=True)
    sumA = sum(A)
    A = A[:M]

    ans = 'Yes'
    for a in A:
        if a < sumA / (M * 4):
            ans = 'No'
            break
    print(ans)


if __name__ == '__main__':
    q2()

Measured memory_bytes: 38256
def main():
    a, b, c = map(int, input().split())
    l = list(sorted([a, b, c]))
    if l[0] == 5 and l[1] == 5 and l[2] == 7:
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
def resolve():
    H, W, M = map(int, input().split())
    XY = [tuple(map(lambda x: int(x) - 1, input().split())) for _ in range(M)]

    X = [0] * H  # X:各行の爆破対象の個数
    Y = [0] * W  # Y:各列の爆破対象の個数
    for h, w in XY:
        X[h] += 1
        Y[w] += 1
    maxX = max(X)
    maxY = max(Y)

    R = [i for i, x in enumerate(X) if x == maxX]  # R:爆破対象の数が最大となる行の番号
    C = [i for i, y in enumerate(Y) if y == maxY]  # C:爆破対象の数が最大となる列の番号

    bomb = set(XY)
    for r in R:
        for c in C:
            # (r, c)に爆破対象が存在しないとき, maxX + maxY が答えとなることが確定するため,
            # 即座に探索を終了する.
            if (r, c) not in bomb:
                print(maxX + maxY)
                return
    # 座標(A,B)に爆発対象が存在した場合重複し、RAにもCBにも値が 1 足されてしまう。
    # 実際の爆発対象は 1 つしかないため、実際に爆発する爆発対象の個数は RA+CB−1 となる
    print(maxX + maxY - 1)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 90112
#include<iostream>
#include<string>
#include<vector>
using namespace std;
string S, T, U, V; vector<int>D, E; int n, m, a;
int power[10]; int W[10] = { 0,2,4,6,8,1,3,5,7,9 };
int main() {
	cin >> n >> S; int sum = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '*')E.push_back(i);
		if ((S.size() - 1 - i) % 2 == 0 || S[i] == '*')T += S[i];
		else { T += to_string((int)(S[i] - '0') * 2); }
	}
	for (int i = 0; i < T.size(); i++)if (T[i] != '*')sum += (int)(T[i] - '0');
	int cnt = 0; cin >> m; for (int i = 0; i < m; i++) { cin >> a; D.push_back(a); }
	power[0] = 1; for (int i = 1; i < 10; i++) { power[i] = power[i - 1] * D.size(); }
	for (int i = 0; i < power[E.size()]; i++) {
		int bit[10]; for (int j = 0; j < E.size(); j++)bit[j] = (i / power[j]) % D.size();
		int sum2 = 0; for (int j = 0; j < E.size(); j++) { if ((S.size() - 1 - E[j]) % 2 == 0)sum2 += D[bit[j]]; else { sum2 += W[D[bit[j]]]; } }
		if ((sum + sum2) % 10 == 0)cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3388
n=int(input())
a='abcdefghij'
ans=[['']]
for i in range(n):
    s=ans[-1][::]
    l=len(s)
    t=[]
    for j in range(i+1):
        for k in range(l):
            if j>0:
                if a[j-1] not in s[k]:
                    continue
            t.append(s[k]+a[j])
    ans.append(t)
t=sorted(ans[-1])
for s in t:
    print(s)

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 a[3];
  cin >> a[0] >> a[1] >> a[2];
  int32 sum = a[0] + a[1] + a[2];
  int32 mx = max({a[0],a[1],a[2]});
  while(sum < mx * 3 || sum % 3 != 0)sum += 2;
  int32 ans = (sum - (a[0] + a[1] + a[2])) / 2;
  ANS(ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;

int ans=INF;
vector<int> v;
void print()
{
    for(int i=0;i<v.size();i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
void rec(int n, int t)
{
    //cout<<"rec "<<t<<endl;
    for(int i=0; i<v.size(); i++)
    {
        if(n <= t*10+v[i])
        {
            ans = min(ans,t*10+v[i]);
            //cout<<ans<<endl;
        }
        else
        {
            //cout<<"YES"<<endl;
            if(t==0&&v[i]==0)
                continue;
            rec(n, t*10+v[i]);
        }
    }
    return;
}
int main()
{

    int n,k;
    cin>>n>>k;
    set<int> s;
    for(int i=0; i<k; i++)
    {
        int d;
        cin>>d;
        s.insert(d);
    }
    for(int i=0; i<10; i++)
    {
        if(!s.count(i))
            v.push_back(i);
    }
    //print();
    rec(n,0);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#pragma comment(linker, "/STACK:64000000")
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <sstream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define y1 stupid_cmath
#define left stupid_left
#define right stupid_right
#define vi vector <int>
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))

const int inf = (int)1e9;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);

int n;
pair<pii, int> a[100100];
vector<pair<int, pii> > e;
int par[100100];

bool cmp(pair<pii, int> a, pair<pii, int> b) {
    return a.f < b.f;
}

bool cmp1(pair<pii, int> a, pair<pii, int> b) {
    pii x = mp(a.f.s, a.f.f);
    pii y = mp(b.f.s, b.f.f);
    return x < y;
}

int dist(pii a, pii b) {
    return min(abs(a.f - b.f), abs(a.s - b.s));
}

void add_edges() {
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n && j < i + 20; j++) {
            e.pb(mp(dist(a[i].f, a[j].f), mp(a[i].s, a[j].s)));
        }
    }
}

int get_parent(int v) {
    if (v == par[v]) return v;
    return par[v] = get_parent(par[v]);
}

void merge(int x, int y) {
    x = get_parent(x);
    y = get_parent(y);
    if (x == y) return;
    if (rand()&1) par[x] = y;
    else par[y] = x;
}

int main(){

    srand(time(NULL));

    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d%d", &a[i].f.f, &a[i].f.s);
        a[i].s = i;
    }

    sort(a, a + n, cmp);
    add_edges();
    sort(a, a + n, cmp1);
    add_edges();

    for (int i = 0; i < n; i++) {
        par[i] = i;
    }

    sort(all(e));
    ll ans = 0;
    for (int i = 0; i < e.size(); i++) {
        int x = e[i].s.f, y = e[i].s.s;
        if (get_parent(x) != get_parent(y)) {
            ans += e[i].f;
            merge(x, y);
        }
    }

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 52580
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3005;
const int mod = 998244353;
long long mem[2][maxn][maxn];
int C, D;

long long dp(int state, int A, int B) {
  if(A > C || B > D) return 0;
  if(B == D) {
    long long res = 1;
    for(int i = 1; i <= C - A; i++) res = (res * B) % mod;
    return res * (1 - state);
  }
  long long &ans = mem[state][A][B];
  if(ans != -1) return ans;
  ans = 0;
  if(state == 0) {
    ans += dp(0, A, B + 1) * A;
    ans += dp(1, A + 1, B) * B;
    ans %= mod;
  } else {
    ans += dp(1, A + 1, B) * B;
    ans += dp(0, A, B + 1);
    ans %= mod;
  }
  return ans;
}
int main() {
  int A, B;
  cin >> A >> B >> C >> D;
  memset(mem, -1, sizeof mem);
  cout << dp(0, A, B) << endl;
  return 0;
}


Measured memory_bytes: 145172