akhauriyash/Code-Regression huggingface dataset:
/*enjoy karo yaar*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int          long long int
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";

const int inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    char c;
    cin>>c;

    char d=c+1;
    cout<<d;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
	int x,y;
	scanf("%d", &x);
    scanf("%d", &y);
	if(x<y)
	    printf("a < b\n");
	else if(x>y)
	    printf("a > b\n");
	else
	    printf("a == b\n");
	return 0;
}


Measured memory_bytes: 2104
def main():
    n = int(input())
    p_lst = list(map(int, input().split()))
    count = 0

    for i in range(1, n-1):
        p1 = p_lst[i-1]
        p2 = p_lst[i]
        p3 = p_lst[i+1]
        p123_lst = [p1, p2, p3]
        sorted_lst = sorted(p123_lst)

        if p2 == sorted_lst[1]:
            count += 1

    print(count)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9104
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    let a: String = read!();
    let v=a.chars().collect_vec();
    let k: usize = read!();
    for i in 0..k {
        if v[i]!='1' {
            println!("{}",v[i]);
            exit(0);
        }
    }
    println!("1")
}

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

string s, nows;
int memo[27] = {0}, n, ans, now, maxnum, nextn, ch;

int main() {
  int i;
  while(1) {
    cin >> n;
    if(n == 0) break;
    ans = -1;
    nows = "";
    maxnum = 0;
    for(i = 0; i < 26; ++i) memo[i] = 0;
    now = 0;
    for(i = 0; i < n; ++i) {
      cin >> s;
      if(ans > 0) continue;
      if(memo[s[0] - 'A'] == 0) ++now;
      ++memo[s[0] - 'A'];

      if(memo[s[0] - 'A'] >= maxnum) {
        if(nows != s) nextn = maxnum;
        nows = s[0];
        maxnum = memo[s[0] - 'A'];
      }
      else if(memo[s[0] - 'A'] >= nextn)
        nextn = memo[s[0] - 'A'];
      /*ch = (n / now) + 1;
      if(n % now != 0) ++ch;
      if(now == 1) ch = n / 2 + 1;
      if(now == 1 && n % 2 != 0) ++ch;
      if(maxnum >= ch) {
        ans = i + 1;
        // cout << maxnum << " " << now << " ";
      }*/
      if(maxnum > nextn + (n - i - 1)) {
        // cout << maxnum << " " << nextn << " ";
        ans = i + 1;
      }
    }
    // for(i = 0; i < 26; ++i) cout << " " << memo[i];
    if(ans == -1)
      cout << "TIE" << endl;
    else
      cout << nows << " " << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3136
#include <iostream>

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 7; // change if needed

struct Modint {
  ll val;
  
  Modint (ll _val = 0)
    : val(_val % MOD) {}

  Modint operator+ (Modint other) const {
    return Modint(val + other.val);
  }

  void operator+= (Modint other) {
    val += other.val;
    val %= MOD;
  }

  Modint operator- () const {
    return Modint(MOD - val);
  }

  Modint operator- (Modint other) const {
    return Modint(val + MOD - other.val);
  }

  void operator-= (Modint other) {
    val += MOD - other.val;
    val %= MOD;
  }

  Modint operator* (Modint other) const {
    return Modint(val * other.val);
  }

  void operator*= (Modint other) {
    val *= other.val;
    val %= MOD;
  }

  bool operator== (Modint other) const {
    return val == other.val;
  }

  bool operator!= (Modint other) const {
    return val != other.val;
  }
};

Modint exp (Modint a, int k) {
  if (k == 0) {
    return Modint(1);
  } else if (k % 2 == 0) {
    Modint half = exp(a, k / 2);
    return half * half;
  } else {
    return a * exp(a, k - 1);
  }
}

Modint inv (Modint a) {
  return exp(a, MOD - 2);
}

ostream& operator<< (ostream& out, Modint p) {
  out << p.val;
  return out;
}

const int MAX_N = 1e5 + 5;

Modint fact [MAX_N];
Modint cumin [MAX_N];
int arr [MAX_N];

int main () {
  ios::sync_with_stdio(false);

  fact[0] = Modint(1);
  for (int i = 1; i < MAX_N; i++) {
    fact[i] = fact[i - 1] * Modint(i);
  }

  for (int i = 1; i < MAX_N; i++) {
    cumin[i] = inv(i + 1);
    cumin[i] += cumin[i - 1];
  }

  int n;
  cin >> n;

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

  Modint ans (0);
  for (int i = 0; i < n; i++) {
    ans += Modint(arr[i]) * (cumin[i] + cumin[n - 1 - i] + Modint(1));
  }

  ans *= fact[n];
  cout << ans << endl;
}


Measured memory_bytes: 2176
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	int ans=1,n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		ans+=min(ans,k);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lol(i,n) for(int i=0;i<n;i++)
typedef long long ll;

using namespace std;
int main(){
    ll n; cin>>n;
    multiset<ll> S;
    lol(i,n){
	ll a;cin>>a;
	S.insert(a);
    }
    ll ans=0;
    while(S.size()>=2){
	auto i=--S.end();
	ll x=*i;
	S.erase(i);
	ll t; for(t=1;t<=x;t*=2);
	auto j=S.find(t-x);
	if(j!=S.end()){
	    ans++;
	    S.erase(j);
	}
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N; cin >> N;
  vector<ll> a(N), sum(N);
  rep(i, N) {
    cin >> a[i];
    if(i) sum[i] = sum[i-1]+a[i];
    else sum[i] = a[i];
  }
  ll ans = INF;
  rep(i, N-1) {
    chmin(ans, abs((sum[N-1]-sum[i]) - sum[i]));
  }
  cout << ans << endl;
}

Measured memory_bytes: 3456
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional>
using namespace std;
int main(void){
    int N,M,X;
    cin>>N>>M>>X;
    int a=0,b=0;
    int A;
    for(int i=0;i<M;i++){
        cin>>A;
        if(A<X){
            a+=1;
        }
        else {
            b+=1;
        }
    }
    if(a>b){
        cout<<b<<endl;
    }
    else {
        cout<<a<<endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  std::string S;
  
  std::cin >> S;

  int size = S.size();
  
  long long dp[111111][4] = {0};

  dp[0][0] = 1;

  for (int i = 0; i < size; i ++) {
    if (S[i] != '?') {
      (dp[i + 1][0] += dp[i][0]) %= MOD;
      (dp[i + 1][1] += dp[i][1]) %= MOD;
      (dp[i + 1][2] += dp[i][2]) %= MOD;
      (dp[i + 1][3] += dp[i][3]) %= MOD;
    }
    else {
      (dp[i + 1][1] += dp[i][0]    ) %= MOD;
      (dp[i + 1][2] += dp[i][1]    ) %= MOD;
      (dp[i + 1][3] += dp[i][2]    ) %= MOD;
      
      (dp[i + 1][0] += dp[i][0] * 3) %= MOD;
      (dp[i + 1][1] += dp[i][1] * 3) %= MOD;
      (dp[i + 1][2] += dp[i][2] * 3) %= MOD;
      (dp[i + 1][3] += dp[i][3] * 3) %= MOD;
    }
      
    if (S[i] == 'A') {
      (dp[i + 1][1] += dp[i][0]) %= MOD;
    }
    else if (S[i] == 'B') {
      (dp[i + 1][2] += dp[i][1]) %= MOD;
    }
    else if (S[i] == 'C') {
      (dp[i + 1][3] += dp[i][2]) %= MOD;
    }
  }

  std::cout << dp[size][3] << std::endl;

  return 0;
}


Measured memory_bytes: 3920
#include<stdio.h>
int x[100001],f[100001],su[100001];
int main(void)
{
	int n,m,i,j,y,a,b,c;
	long long sum,nn,mm;
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++)	scanf("%d",&x[i]);
	for(i=1;i<=n;i++)	f[i]=0;
	for(i=0;i<m-1;i++){
		if(x[i]<x[i+1]){
			f[x[i]]++;	f[x[i+1]]--;
		}
		else{
			f[x[i+1]]++;	f[x[i]]--;
		}
	}
	y=0;
	for(i=1;i<=n;i++){
		y+=f[i];	su[i]=y;
	}
	sum=0;
	for(i=1;i<n;i++){
		scanf("%d %d %d",&a,&b,&c);
		nn=(long long)a*su[i];
		mm=(long long)b*su[i]+c;
		if(nn<mm) sum+=nn;
		else sum+=mm;
	}	
	printf("%lld\n",sum);	
	return 0;
}

Measured memory_bytes: 3892
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;



int main() {
    int S;
    cin>>S;
    
    int a,b;
    b = S%100;
    a = (S -b)/100;
    bool YYMM = 0;
    bool MMYY = 0;
    
    YYMM =(1 <= b && b <= 12);
    MMYY =(1 <= a && a <= 12);

    if(YYMM == 1 && MMYY == 0){
        cout<<"YYMM"<<endl;
    }
    else if(YYMM == 0 && MMYY == 1){
        cout<<"MMYY"<<endl;
    }
    else if(YYMM == 1 && MMYY == 1){
        cout<<"AMBIGUOUS"<<endl;
    }
    else{
        cout<<"NA"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

ll gcd(ll a, ll b) { //gcdを返す
	if(a == 0){
		return b;
	} else if (b == 0){
		return a;
	} else {
	  if(a < b) return gcd(b, a);
	  ll r;
	  while ((r=a%b)) {
	    a = b;
	    b = r;
	  }
	  return b;
	}
}
ll ketasum(ll n) { //桁の数字全ての和を返す 例: 112 -> 4
	ll sum=0;
	if (n<0) return 0;
	while (n>0) {
		sum += n%10;
		n /= 10;
	}
	return sum;
}

typedef pair<ll, ll> pair_t;

bool comp(const pair_t &a, const pair_t &b) {
        return a.first < b.first;
}

void sort2vectors(vector<ll> &av, vector<ll> &bv)
{ // ふたつの配列をまとめてそーと A[2,1] B[3,4] -> 1,4 2,3
        ll n = av.size();
        vector<pair_t> p(n);
        vector<ll> av2(n), bv2(n);
        for (ll i = 0; i < n; i++)
                p[i] = make_pair(av[i], bv[i]);
        sort(p.begin(), p.end(), comp);
        for (ll i = 0; i < n; i++) {
                av2[i] = p[i].first;
                bv2[i] = p[i].second;
        }
        av = av2;
        bv = bv2;
}
ll facctorialMethod(ll k){ //階乗
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}
vl primes(ll n){
	vl x(n);
	REP(i, n){
		x[i] = 0;
	}
	for(ll i = 2; i < sqrt(n) + 2; i++){
		while(n % i == 0){
			n /= i;
			x[i-1] += 1;
		}
	}
	if(n > 1){
		x[n-1] += 1;
	}
	return x;
}
const ll mod = 1000000007;
int main(){
	ll N;
	cin >> N;
	ll ans = 1;
	vl xok(N);
	for(ll i = 2; i <= N; i++){
		vl x = primes(i);
		for(ll j = 0; j < i; j++){
			if(x[j] != 0){
				xok[j] += x[j];
			}
		}
	}
	REP(i,N){
		if(xok[i] != 0){
			ll modxok = (xok[i] + 1) % mod;
			ans *= modxok;
			ans %= mod;
		}
	}
	ll ansok = ans % mod;
	cout << ansok << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define ll long long

using namespace std;
long long int N,K,L,R,MOD=1e9+7;

int main(){
    


	cin >> N >> K;
	long long int ans = 0;
	for (long long int i = K; i <= N + 1; i++) {
		L = i * (i - 1) / 2;
		R = N * i - L;
		ans += R - L+1;
	}
	cout << ans % MOD << endl;
}


Measured memory_bytes: 3608
//                             In The Name Of Allah                                           
//                             	Mohammad Hosseini
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std; 

const int N = 1e5 + 100, OO = 1e9, T = 4500 + 100, M = 924844033, P = 6151, SQ = 280, lg = 30;
typedef pair <int, int> pii;
int a[N];

int32_t main() {
	use_fast;
	int n, l;
	cin >> n >> l;
	for(int i = 0; i < n; i++) 
		cin >> a[i];
	for(int i = 1; i < n; i++) {
		if(a[i] + a[i - 1] >= l) {
			cout << "Possible" << endl;
			for(int j = 0; j < i - 1; j++)
				cout << j + 1 << endl;
			for(int j = n - 2; j >= i; j--)
				cout << j + 1 << endl;
			cout << i << endl;
			return 0;
		}
	}
	cout << "Impossible" << endl;
	return 0;
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- uploaded by ubuntu 20.04 
5- ...
*/



Measured memory_bytes: 4436
def knapsack(n, w, info):
  dp = [[0]*(w + 1) for i in range(n + 1)]

  for i in range(n):
    for j in range(w + 1):
      weight, value = info[i]
      if j < weight:
        dp[i + 1][j] = dp[i][j]
      else:
        dp[i + 1][j] = max(dp[i][j], dp[i][j - weight] + value)
  return dp

N,T = map(int,input().split())
food = []
for _ in range(N):
  food.append(list(map(int,input().split())))
food.sort(key= lambda x: x[0])
dp = knapsack(N,T,food)

C = [0]*(N+1)
for i in range(N)[::-1]:
  C[i] = max(C[i+1], food[i][1])

ans = 0
for i in range(N+1):
  ans = max(dp[i][-2] + C[i], ans)

print(ans)


Measured memory_bytes: 116568
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
 
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;
}
 
const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 100005;
 
ll N, M;
vector<ll> a;
ll suffSum[MX];
 
// Is it possible to get v score with M pairs?
bool pos(ll v) {
	// ll orig = v;
	// cout << "v: " << v << "\n";
	ll pairs = M;
	ll avg = ceil((long double)v / pairs);
	
	int bounds[N];
	for (int i = 0; i < N; i++) bounds[i] = i + 1;
	
	while (pairs) {
		bool change = false;
		for (int i = N - 1; i >= 0; i--) {	
			if (!bounds[i] || a[i] + a[bounds[i] - 1] < avg) continue;
			if (!v || !pairs) break;
			if (bounds[i] == i + 1 && 2 * a[i] >= avg) {
				pairs--;
				v -= min(v, 2 * a[i]);
				bounds[i] = i;
				change = true;
				if (!v || !pairs) break;
				avg = ceil((long double)v / pairs);
			}
						
			// Bound is index out of pairs
			auto it = upper_bound(a.begin(), a.end(), avg - a[i] - 1);
			if (it == a.end()) continue;
 
			// # of numbers greater than needed to create avg.
			ll limit = it - a.begin();
			if (limit >= bounds[i]) continue;			
			
			change = true;
			ll index = max(limit, bounds[i] - (pairs / 2));
			ll total = suffSum[index] - suffSum[bounds[i]];
						
			v -= min(v, 2 * total);
			v -= min(v, (bounds[i] - index) * 2 * a[i]);
			pairs -= 2 * (bounds[i] - index);
			if (pairs == 1 && index > limit) {
				v -= min(v, a[index - 1] + a[i]);
				pairs--;
			}
			
			bounds[i] = index;
			if (!pairs || !v) break;
			avg = ceil((long double)v / pairs);	
		}
		if (!change) break;
	}
	
	// cout << v << "\n";
	// cout << "\n";
	return v == 0;
}
 
ll bsearch(ll l, ll r) {
	if (l == r) return r;
	if (l + 1 == r) {
		if (pos(r)) return r;
		return l;
	}
	
	ll m = (l + r) / 2;
	if (pos(m)) return bsearch(m, r);
	else return bsearch(l, m - 1);
}
 
void solve() {
    cin >> N >> M;
    a.resize(N);
    for (auto& i : a) cin >> i;
    sort(a.begin(), a.end());
	suffSum[N - 1] = a[N - 1];
	for (int i = N - 2; i >= 0; --i) suffSum[i] = a[i] + suffSum[i + 1];
	// cout << "\n";
	cout << bsearch(0, 2e15);
}
 
int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}
 
/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
using namespace std;
long long n,m,i,j,ans;
string st;
set<char> s;
long long solve(string st)
{
	long long ans=0,i,len=0;
	fz0k(i,st.length()){
		if(st[i]==st[i-1]) len++;
		else{
			ans+=len/2;
			len=1;
		}
	}
	ans+=len/2;
	return ans;
}
int main()
{
	cin>>st>>n;
	if(n==1){
		cout<<solve(st)<<endl;
		return 0;
	}
	fz0k(i,st.length()){
		s.insert(st[i]);
	}
	if(s.size()==1){
		m=n*st.length();
		printf("%lld\n",m/2);
		return 0;
	}
	printf("%lld\n",(solve(st+st)-solve(st))*(n-1)+solve(st));
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf()
#define MAX_T 100000

int
main(int argc, char** argv)
{
	int t[MAX_T + 1];
	int n, T;
	int l, r;
	int i;

	scanf("%d %d", &n, &T);
	for (i = 0; i <= T; ++i)
		t[i] = 0;

	for (i = 0; i < n; ++i)
	{
		scanf("%d %d", &l, &r);
		t[l]++;
		t[r]--;
	}

	int max = 0;
	int acc = 0;
	for (i = 0; i <= T; ++i)
	{
		acc += t[i];
		if (acc > max)
			max = acc;
	}

	printf("%d\n", max);
	return 0;
}

Measured memory_bytes: 992
#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;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
 
// template from zscoder
 
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    int n,t,x,y,pt(0);
    cin >> n;
    ii c;
    c.fi = 0;
    c.se = 0;
    bool ok = true;
    for(int i = 0; i < n; i++)
    {
        cin >> t >> x >> y;
        int tt = t - pt;
        pt = t;
        int d = abs(x-c.fi) + abs(y-c.se);
        c.fi = x; c.se = y;
        if(d>tt)ok = false;
        else
        {
            tt-=d;
            if(tt>0&&tt%2==1)ok = false;
        }
    }
    if(ok)cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> V(M);
    for (int i = 0, a, b; cin >> a >> b; i++) {
        if (a > M) continue;
        V.at(--a).push_back(b);
    }
    priority_queue<int> Q;
    long ans = 0;
    for (int i = 0; i < M; i++) {
        for (auto a : V.at(i)) Q.push(a);
        if (!Q.size()) continue;
        ans += Q.top(), Q.pop();
    }
    cout << ans << "\n";
}

Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)
#define all(V) V.begin(), V.end()
using i64 = int_fast64_t;
using P = pair<int,int>;

void dfs(vector<vector<int>>& G, vector<vector<int>>& visited, int v, int dist){
    if(visited[v][dist%3] <= dist) return;
    visited[v][dist%3] = dist;
    for(auto nxt : G[v]) dfs(G, visited, nxt, dist+1);
}

int main(){
    int N, M;
    cin >> N >> M;
    vector<vector<int>> G(N);
    vector<vector<int>> visited(N, vector<int>(3, 1e9));

    int u, v;
    rep(i, M){
        cin >> u >> v; u--, v--;
        G[u].emplace_back(v);
    }
    int S ,T;
    cin >> S >> T; S--, T--;

    bool bfs = true;

    chrono::steady_clock::time_point start = chrono::steady_clock::now();
    const chrono::milliseconds limit = 500ms;

    struct info{int now, dist;}; 
    queue<info> que;
    que.push({S, 0});
    visited[S][0] = 0;
    while(!que.empty() && visited[T][0] == 1e9){
        info foo = que.front(); que.pop();
        visited[foo.now][foo.dist%3] = foo.dist;
        for(int nxt : G[foo.now]){
            chrono::steady_clock::time_point now = chrono::steady_clock::now();
            chrono::milliseconds t = chrono::duration_cast<chrono::milliseconds>(now - start);
            if(t > limit) {
                bfs = false;
                visited[T][0]--;
                break;
            }
            if(visited[nxt][(foo.dist+1)%3] != 1e9) continue;
            que.push({nxt, foo.dist+1});
        }
    }

    if(!bfs){
        visited = vector<vector<int>>(N, vector<int>(3, 1e9));
        dfs(G, visited, S, 0);
    }

    int ans = visited[T][0];
    if(ans != 1e9) ans /= 3;
    else ans = -1;
    cout << ans << endl;
}


Measured memory_bytes: 22156
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		while(true){
			int n = stdIn.nextInt();
			if(n==0){
				return;
			}
			int[] d = new int[4001];
			boolean[] f = new boolean[4001];
			int[] log = new int[4000];
			for(int i=1;i<=n;i++){
				int num = stdIn.nextInt();
				if(log[num]==0){
					log[num] = i;
				}
				int single = stdIn.nextInt();
				int element = stdIn.nextInt();
				for(int j=0;j<element;j++){
					if(!f[num]){
						d[num] += single;
					}
					else{
						break;
					}
					if(d[num]>999999){
						f[num] = true;
						break;
					}
				}
			}
			boolean output = true;
			for(int i=1;i<=4000;i++){
				for(int j=0;j<4000;j++){
					if(log[j]==i){
						if(f[j]){
							System.out.println(j);
							output = false;
						}
						else{
							break;
						}
					}
				}
			}
			if(output){
				System.out.println("NA");
			}
		}
	}
}

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

using namespace std;
typedef long long ll;

int main () {
    int N, A, B;  cin >> N >> A >> B;
    vector<int> P(N);
    for (int i = 0; i < N; ++i) {
        cin >> P[i];
    }

    int cnt1 = 0, cnt2 = 0, cnt3 = 0;
    for (int i = 0; i < N; ++i) {
        if (P[i] <= A) ++cnt1;
        else if (P[i] > A && P[i] <= B) ++cnt2;
        else ++cnt3;
    }

    int m = min(cnt2, cnt3);
    int res = min(cnt1, m);

    cout << res << endl;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int n,i;cin>>n>>i;
    cout<<n-i+1<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std; 
int n,p[110000],ans,num;
int main(){
	scanf("%d",&n);
	fo(i,1,n) scanf("%d",&p[i]);
	fo(i,1,n+1) if (i==p[i]) num++;
	else if(num>0){
		ans+=(num+1)/2;//ans+=max(1,num-1);
		num=0;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
#a,bの最大公約数
def gcd(a, b):
  while b:
    a, b = b, a % b
  return a

#a,bの最小公倍数
def lcm(a, b):
  return a * b // gcd (a, b)

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

print(lcm(m,n))

Measured memory_bytes: 2940
S,T=gets.chomp.split(' ')
A,B=gets.chomp.split(' ').map{|n| n.to_i}
U=gets.chomp

if U == S then
  puts "#{A - 1} #{B}"
elsif T == U then
  puts "#{A} #{B - 1}"
else
  puts "#{A} #{B}"
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,i;
    long long a[100005];
    long long dp[100005];
    cin>>n;
    for(i=0;i<n+4;++i)
      dp[i]=100000000000000000;
    for(i=1;i<=n;++i)
      cin>>a[i];
    dp[1]=0;
    for(i=1;i<n;++i)
    {
       dp[i+1]=min(dp[i+1],dp[i]+abs(a[i]-a[i+1]));
       if((i+2)<=n)
       {
          dp[i+2]=min(dp[i+2],dp[i]+abs(a[i]-a[i+2]));
       }
    }
 cout<<dp[n];   
}


Measured memory_bytes: 1792
import java.math.BigDecimal;
import java.util.*;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        long X = sc.nextLong();

        if (X <= 6) {
            System.out.println(1);
        } else {
            long numOfSet = X / 11; // set is (6, 5)
            long remain = X % 11;
            if (remain == 0) {
                System.out.println(2 * numOfSet);
            } else if (remain <= 6) {
                System.out.println(2 * numOfSet + 1);
            } else {
                System.out.println(2 * numOfSet + 2);
            }
        }
    }
}

Measured memory_bytes: 22608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef pair<ll, ll> P;

int main(){
    int n, d;   cin >> n >> d;
    vector<vector<int>> v(n, vector<int>(d));

    for(int i=0; i<n; i++)
        for(int j=0; j<d; j++)
            cin >> v.at(i).at(j);
    int ans=0;
    for(int i=0; i<n-1; i++){
        for(int j=i+1; j<n; j++){
            int sum=0;
            for(int k=0; k<d; k++){
                int dis = abs(v[i][k]-v[j][k]);
                sum += dis*dis;
            }
            for(int i=0; i<=sum; i++){
                if(i*i==sum) ans += 1;
                if(sum<i*i) break;
            }

        }
    }
    cout << ans << endl;
    

}
    

Measured memory_bytes: 256
while True:
    h, w = map( int, input().split() )
    if not h and not w:
        break
    if h <3 or w < 3:
        print(("#" * w + "\n") * h)
    else:
        print('#' * w +'\n' + ('#' + '.' * (w-2) + '#\n') * (h-2) + '#' * w + '\n')

Measured memory_bytes: 7660
import numpy as np
import sys

N = int(input())
ls = [list(map(int,input().split())) for i in range(N)]
ls = np.array(ls)
#ls = ls[ls[:,0].argsort(), :]
ls = ls[ls[:,1].argsort(), :]
# print(ls)
k=ls[0,0]
if ls[0,0]>ls[0,1]:
  print('No')
  sys.exit()
for i in range(1,N):
  k += ls[i,0]
  if k > ls[i,1]:
    print('No')
    sys.exit()
print('Yes')

Measured memory_bytes: 62476
#include<bits/stdc++.h>
using namespace std;
int main(void){
	string str;
	cin>>str;
	int n=str.size();
	int arr[n]={0};
	int count=0;
	for(int i=0;i<n;i++){
		if(str[i]=='R'){
			count++;
		}
		else{
			arr[i-1]+=count/2;
			arr[i]+=count/2;
			if(count%2!=0) arr[i-1]++;
			count=0;
		}
	}
	count=0;
	for(int i=n-1;i>=0;i--){
		if(str[i]=='L') count++;
		else{
			arr[i+1]+=count/2;
			arr[i]+=count/2;
			if(count%2!=0) arr[i+1]++;
			count=0;
		}
	}
	for(int i=0;i<n;i++) cout<<arr[i]<<" ";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1024
mod = 1000000007
N = int(input())
S = input()
T = input()
a = 1
b = 0 ###前が横だったら0 縦だったら1
i = 0
while i < N:
	if i == 0: ###初期処理
		if N == 1:
			a *= 3
			break
		if N == 2:
			a *= 6
			break
		else:
			if S[0] == S[1]:
				a *= 6
				i += 2
				b = 0
			else:
				a *= 3
				i += 1
				b = 1
	if i == N-1:
		if b == 0: ###前が横で次が縦
			a *= 1
			i += 1
			b = 1
			break
		if b == 1: ###前が縦で次も縦
			a *= 2
			i += 1
			b = 1
			break
	if S[i] == S[i+1]:
		if b == 0: ###前が横で次も横
			a *= 3
			i += 2
			b = 0
			continue
		if b == 1: ###前が縦で次が横
			a *= 2
			i += 2
			b = 0
			continue
	else:
		if b == 0: ###前が横で次が縦
			a *= 1
			i += 1
			b = 1
			continue
		if b == 1: ###前が縦で次も縦
			a *= 2
			i += 1
			b = 1
			continue
print(a % mod)



Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>

using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define repi(i,a) for(auto i = a.begin(); i!= a.end() ;++i) 
#define repdi(i,a) for(auto i = a.begin(); i!=a.end();++i) 
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define INF 1e18
#define sz(a) (ll)a.size() 
#define all(a) a.begin(),a.end()
#define M 998244353
#define limit 100000000

typedef vector<ll> vll;
typedef pair<ll,ll> pii;
typedef vector<pii> vpi;
typedef vector<vector<ll> > vv;


void solve() {
	
	int n; cin >> n;
	int a[n+1]={};

	rep(i,0,n-1) {
		int t; cin >> t;
		a[t]++;
	}
	rep(i,1,n+1) cout << a[i] << nl ;
}


int main() {

    fast;
	int t=1;
	// cin>>t;
	rep(i,0,t) {
		solve() ;
	}
	return 0;
}

Measured memory_bytes: 4440
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main(){
    string s;
    cin >> s;
    int num=0;
    for(int i=0; i<s.size(); i++){
        if(s[i]=='+'){
            num++;
        }else{
            num--;
        }
    }
    cout << num << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

struct card{
  char suit;
  char value;
};

void bubble(struct card a[],int n)
{
  int i,j;
  struct card t;
  for(i=0;i<n;i++){
    for(j=n-1;j>=i+1;j--){
      if(a[j].value < a[j-1].value){
        t=a[j];
        a[j]=a[j-1];
        a[j-1]=t;
      }
    }
  }
}

void select(struct card a[],int n)
{
  int i,j,min;
  struct card t;
  for(i=0;i<n;i++){
    min=i;
    for(j=i;j<n;j++){
      if(a[j].value < a[min].value) min=j;
    }
    t=a[i];
    a[i]=a[min];
    a[min]=t;
  }
}

void print(struct card a[],int n)
{
  int i;
  for(i=0;i<n;i++){
    if(i>0) printf(" ");
    printf("%c%c",a[i].suit,a[i].value);
  }
  printf("\n");
}

int stable(struct card c1[],struct card c2[],int n)
{
  int i,result=1;
  for(i=0;i<n;i++){
    if(c1[i].suit != c2[i].suit) result=0; 
  }
  return result;
}

int main(){
  struct card c1[101],c2[101];
  int n,i;
  char str;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf(" %c%c",&c1[i].suit,&c1[i].value);
  }
  for(i=0;i<n;i++){
    c2[i].suit=c1[i].suit;
    c2[i].value=c1[i].value;
  }
  bubble(c1,n);
  select(c2,n);

  print(c1,n);
  printf("Stable\n");
  print(c2,n);
  if(stable(c1,c2,n)==1){
    printf("Stable\n");
  }else{
    printf("Not stable\n");
  }
  return 0;
}


Measured memory_bytes: 2080
#include <bits/stdc++.h>
const int N=200005;
int n,f[N],g[N];
char s[N];
using namespace std;

int main()
{
	scanf ("\n%s",s+1);
	n=strlen(s+1);
	memset(f,-1,sizeof(f));
	f[0]=g[0]=0;
	for (int i=1;i<=n;i++)
	{
		if (g[i-1]!=-1) f[i]=g[i-1]+1;
		if (f[i-1]!=-1 && s[i]!=s[i-1]) f[i]=max(f[i],f[i-1]+1);
		if (i>1 && f[i-2]!=-1) g[i]=f[i-2]+1;
	}
	printf ("%d",max(f[n],g[n]));
	return 0;
}


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

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

using namespace std;

int main(){
  int n;cin>>n;
  vector<ll> a(3*n);
  rep(i,3*n)cin>>a[i];
  sort(a.begin(), a.end());
  ll result=0, t=0;
  rep(i, n)result+=a[n+i];
  rep(i,n) t += a[n+i*2];
  result = max(result, t);
//cout<<t<<' '<<result<<endl;
  cout<<result;

  return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

ll n, m, t;

int main() {
	cin >> n >> m;
	
	// 差が2以上ならどう並べても同種の動物が隣接する
	if (abs(n-m)>=2) {
		cout << 0 << ln;
		return 0;
	}
	// 差が1ならnの隙間n-1個にm(==n-1)個をぴったりはめるだけ
	// 差が0なら犬猿犬猿か猿犬猿犬の2通り
	t = (n==m ? 2 : 1);
	repst(i,2,n) t = (t*i)%mod;
	repst(i,2,m) t = (t*i)%mod;
	cout << t << ln;
}

Measured memory_bytes: 256
class Node
  def initialize(id)
    @id = id
    @left = nil 
    @right = nil
  end

  attr_accessor :id, :left, :right
end

def reconstruct_visit(node, index, lefts, rights)
  direct_left = compare_by_preorder(lefts)
  direct_right = compare_by_preorder(rights)
  if direct_left >= 0 then
    node.left = Node.new(direct_left)
    left_index = lefts.index(direct_left)
    reconstruct_visit(node.left, 
          direct_left,
          lefts[0...left_index], 
          lefts[left_index+1..-1])
  end
  if direct_right >= 0 then
    node.right = Node.new(direct_right)
    right_index = rights.index(direct_right)
    reconstruct_visit(node.right, 
          direct_right,
          rights[0...right_index], 
          rights[right_index+1..-1])
  end
end

def compare_by_preorder(array)
  return -1 if array.size == 0
  ordered_array = array.map do |item|
    [item, $preorder.index(item)]
  end
  ordered_array.sort! {|x, y| x[1] <=> y[1]}
  return ordered_array[0][0]
end

def postorder(node, array)
  if (node.left != nil) then
    postorder(node.left, array)
  end
  if (node.right != nil) then
    postorder(node.right, array)
  end
  array << node.id
end


n = gets.chomp.to_i
$preorder = gets.chomp.split.map(&:to_i)
$inorder = gets.chomp.split.map(&:to_i)

root_node = Node.new($preorder[0])
root_index = $inorder.index($preorder[0])
reconstruct_visit(root_node, 
      root_index, 
      $inorder[0...root_index], 
      $inorder[root_index+1..-1])

postorder_array = []
postorder(root_node, postorder_array)
puts postorder_array.join(' ')

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]C - Prison
            var line = ReadLine();
            int N = line[0];
            int M = line[1];

            var L = new List<int>();
            var R = new List<int>();

            for(int i = 0; i < M; i++)
            {
                line = ReadLine();

                L.Add(line[0]);
                R.Add(line[1]);
            }

            int cards = R.Min() - L.Max() + 1;

            if (cards < 0)
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(cards);
            }
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> coord;

ll k[100];
ll p[100];
ll s[100][100];
ll ss[100];
ll n,m;

ll check(){
    /*
    for(int i=0; i<n; i++) cerr << ss[i] << ",";
    cerr << endl;
    */
    for( ll i=0; i<m; i++){
        ll cnt=0;
        for( ll j=0; j<k[i]; j++){
            if( ss[s[i][j]-1] == 1 ) cnt++;
            //cerr << "ij," << i << "," << j << "," << cnt << "," << s[i][j] << endl;
        }
        if(p[i]==(cnt%2));
        else return 0;
    }
    return 1;
}
ll search(ll x){
    if( x==n ) return check();

    ll sum=0;
    ss[x]=0;
    sum+=search(x+1);
    ss[x]=1;
    sum+=search(x+1);

    return sum;
}
int main(){
    cin >> n >> m;

    for( ll i=0; i<m; i++){
        cin >> k[i];
        for( ll j=0; j<k[i]; j++) cin >> s[i][j];
    }
    for( ll i=0; i<m; i++) cin >> p[i];

    for(ll i=0; i<n; i++) ss[i]=0;
    
    cout << search(0) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <math.h>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())

const int MOD = 1000000007;
const int INF = INT_MAX;



int main(){

    int n, k;
    cin >> n >> k;

    double p = 0;
    for(int i=1; i <= n; i++){
        int score = i;
        int cnt = 0;
        while(score < k){
            score *= 2;
            cnt++;
        }
        p += pow(0.5, cnt);
    }


    printf("%.12f", p/n);

    




}






//              g++ -std=c++1z

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define mod 1000000007
#define INF2 9999999999
#define INF (1 << 30)
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)

using namespace std;
using ll = __int64_t;

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

void solve(){
    double n, k;
    double res = 0.0;
    cin >> n >> k;
    for(int i = 1; i <= n; i++){
        int current = i;
        if(current < k){
            int temp = 0;
            while(current < k){
                current *= 2;
                temp++;
            }
            res += (1.0 / n) * pow(0.5, temp);
        }else{
            res += (1.0 / n);
        }
    }
    cout << setprecision(12) << res << endl;
}

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

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char **argv)
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    int num = 0;
    int colors[101] = {};
    colors[a] = 1;
    colors[b] = 1;
    colors[c] = 1;
    for (int i = 0; i < 101; ++i) {
        if (colors[i]) {
            num++;
        }
    }
    printf("%d\n", num);
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
const int MAXA = 3200;
const int MAXS = 15;
const char *RED = "red";
char S[MAXS];
int A;

int main() {
  scanf(" %d%s", &A, S);
  puts((A < MAXA) ? RED : S);
  return 0;
}

Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Sparsh Sanchorawala
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ARounding solver = new ARounding();
        solver.solve(1, in, out);
        out.close();
    }

    static class ARounding {
        public void solve(int testNumber, InputReader s, PrintWriter w) {
            if (s.nextInt() < s.nextInt())
                w.println(0);
            else
                w.println(10);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

int main() {
    int a,b,q;cin>>a>>b>>q;
    ll s[a+2],t[b+2];
    s[0]=t[0]=-1e18;
    s[a+1]=t[b+1]=1e18;
    for (int i=1;i<=a;i++)
        cin>>s[i];
    for (int i=1;i<=b;i++)
        cin>>t[i];
    for (int i=0;i<q;i++) {
        ll x;cin>>x;
        auto it=lower_bound(s,s+a+2,x);
        ll c=*it-x;
        ll d=x-*(it-1);
        it=lower_bound(t,t+b+2,x);
        ll e=*it-x;
        ll f=x-*(it-1);
        ll mn=min(max(c,e),min(c,f)+c+f);
        mn=min(mn,min(d,e)+d+e);
        mn=min(mn,max(d,f));
        cout<<mn<<endl;
    }
    return 0;
}

Measured memory_bytes: 2816
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<cstdlib> 
#include<string>
#include<math.h>
#include<bitset>
#include<algorithm>
#include<vector>
#include<set>
#include<stack>
#include<queue>
using namespace std;

int main(){

	string s,a;
	int ans=0;

	a="CODEFESTIVAL2016";

	cin >> s;

	for(int i=0;i<16;i++){
		if(a[i]!=s[i])ans++;
	}

	cout << ans << endl;

	//while(1);

	return 0;
}

Measured memory_bytes: 256
S =[]
S.append(0)
top = 0
MAX = 1000
t = 0

def initialize():
    top = 0

def isEmpty():
    return top == 0

def isFull():
    return top >= MAX - 1

def push(x):
    global top
    if isFull():
        print("error")
    top += 1
    S.append(x)

def pop():
    global top
    global t
    t = 0
    if isEmpty():
        print("error")
    top -= 1
    t = S[top + 1]
    del S[top + 1]
    return t

L = input().split()

for i in range(len(L)):
    if L[i] == "+":
        push(int(pop()) + int(pop()))
    elif L[i] == "-":
        push(-(int(pop()) - int(pop())))
    elif L[i] == "*":
        push(int(pop()) * int(pop()))
    else:
        push(L[i])
print(S[top])


Measured memory_bytes: 5612
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int X;
  cin>>X;
  if(400<=X && X<600) cout<<8<<endl;
  if(600<=X && X<800) cout<<7<<endl;
  if(800<=X && X<1000) cout<<6<<endl;
  if(1000<=X && X<1200) cout<<5<<endl;
  if(1200<=X && X<1400) cout<<4<<endl;
  if(1400<=X && X<1600) cout<<3<<endl;
  if(1600<=X && X<1800) cout<<2<<endl;
  if(1800<=X && X<2000) cout<<1<<endl;
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//ll inf=1000000007;
const ll maxinput=3005;
const ll mod=998244353;
#define mp make_pair
ll n,mat[16][16],cost[(1<<16)+5]; //cost[i] is the money earned if mask i is in same group, if i=13 (1101) then cost i is the money if we have element 4,3,1 in same group
ll inf=100000000000000017;
ll dp[(1<<16)+5];//dp[i] contains the maximum value attainable among i and all its submasks
ll getcost(ll mask)
{
    if(cost[mask]!=-inf)
        return(cost[mask]);

    ll temp=0;
    for(ll i=n-1;i>=0;i--)
    {
        if(mask&(1<<i))
        {
            ll maskwith_ithbit_off=mask^(1<<i);
            ll c1=getcost(maskwith_ithbit_off);
            for(ll j=0;j<i;j++)
            {
                if(maskwith_ithbit_off&(1<<j))
                    temp+=mat[i][j];
            }
            cost[mask]=temp+c1;
            return(cost[mask]);
        }
    }
}
ll maxprofit(ll mask)
{
    //cout<<mask<<"\n";
    if(__builtin_popcountll(mask)<=1)
        return(cost[mask]);

    if(dp[mask]!=-inf)
        return(dp[mask]);

    ll s=mask;
    ll temp=cost[mask];
    while(s>0)
    {
        s=(s-1)&mask;
        if(s==0)
            break;
        temp=max(temp,maxprofit(s)+maxprofit(s^mask));
    }
    dp[mask]=temp;
    return(temp);
}
int main()
{
    cin>>n;
    for(ll i=0;i<n;i++)
        for(ll j=0;j<n;j++)
            cin>>mat[i][j];

    for(ll i=0;i<(1<<16)+5;i++)
        cost[i]=-inf,dp[i]=-inf;
    for(ll i=0;i<(16);i++)
        cost[1<<i]=0;
    cost[0]=0;
    for(ll i=0;i<(1<<n);i++)
    {
        if(cost[i]==-inf)
            getcost(i);
    }
    //cout<<cost[(1<<n)-1];
    cout<<maxprofit((1LL<<n)-1)<<"\n";
}

Measured memory_bytes: 1280