akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>


constexpr int MAXN = 2000000;
int Heap[MAXN + 1];

int parent(int i) {return i / 2;}
int left(int i) {return i * 2;}
int right(int i) {return i * 2 + 1;}

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
int n;
int heapsize;

void ShowHeap(int* Heap) {
    FOR(i, 1, heapsize + 1) {
        std::printf("node %d: key = %d, ", i, Heap[i]);
        if (parent(i)) std::printf("parent key = %d, ", Heap[parent(i)]);
        if (left(i) <= heapsize) std::printf("left key = %d, ", Heap[left(i)]);
        if (right(i) <= heapsize) std::printf("right key = %d, ", Heap[right(i)]);
        std::cout << std::endl;
    }
}

void MaxHeapify(int* H, int i) {
    int l = left(i), r = right(i);
    int largest = i;
    if (l <= heapsize && H[largest] < H[l]) {
        largest = l;
    }
    if (r <= heapsize && H[largest] < H[r]) {
        largest = r;
    }
    if (largest != i) {
        std::swap(H[i], H[largest]);
        MaxHeapify(H, largest);
    }
}

void BuildHeap(int *H) {
    for (int i = heapsize / 2; i >0; --i) {
        MaxHeapify(H, i);
    }
}

void IncreaseKeyHeap(int *H, int i, int k) {
    H[i] = k;
    int p = parent(i);
    while (H[p] < H[i]) {
        if (!p) break;
        std::swap(H[p], H[i]);
        if (!parent(p)) break;
        i = p;
        p = parent(p);
    }
}

void InsertHeap(int *H, int k) {
    H[++heapsize] = 0;
    IncreaseKeyHeap(H, heapsize, k);
}

int ExtractHeapMax(int *H) {
    int max = H[1];
    H[1] = H[heapsize--];
    MaxHeapify(H, 1);
    return max;
}


int main() {
    heapsize = 0;

    while (true) {
        std::string ins;
        std::cin >> ins;
        if (ins == "insert") {
            int i;
            std::cin >> i;
            InsertHeap(Heap, i);
        }else if(ins == "extract"){
            std::cout << ExtractHeapMax(Heap) << std::endl;
        }else{
            break;
        };
    }
}


Measured memory_bytes: 7064
#include <bits/stdc++.h>
using namespace std;
const long long MOD=1e9+7;
const int MAXN=100010;
vector<int> ver[MAXN];
long long dp[MAXN][2];
int n;

long long dfs(int x,int state,int ufa){
	if(dp[x][state]!=-1) return dp[x][state];
	if(ver[x].size()==1&&ver[x][0]==ufa) return dp[x][state]=1;
	long long res=1;
	for(vector<int>::iterator it=ver[x].begin();it!=ver[x].end();++it){
		int y=*it;
		if(y==ufa) continue;
		if(state==1) (res*=dfs(y,0,x))%=MOD;
		else (res*=(dfs(y,1,x)+dfs(y,0,x)))%=MOD;
	}
	return dp[x][state]=res;
}

int main(){
	memset(dp,-1,sizeof(dp));
	cin>>n;
	for(int i=1;i<n;++i){
		int a,b; cin>>a>>b;
		ver[a].push_back(b),ver[b].push_back(a);
	}
	cout<<(dfs(1,0,0)+dfs(1,1,0))%MOD<<endl;
	return 0;
}

Measured memory_bytes: 15616
Module Program
    Sub Main(args As String())
        Dim ND = Console.ReadLine().Split(" ").Select(Function(o)
                                                          Return Long.Parse(o)
                                                      End Function).ToArray()
        Dim N = ND(0), D = ND(1)

        Dim ans = 0
        For i = 1 To N
            Dim XY = Console.ReadLine().Split(" ").Select(Function(o)
                                                              Return Long.Parse(o)
                                                          End Function).ToArray()
            If Math.Sqrt(XY(0) * XY(0) + XY(1) * XY(1)) <= D Then
                ans += 1
            End If
        Next

        Console.WriteLine(ans)
    End Sub
End Module

Measured memory_bytes: 46900
def traverse
	
		a = []
		len = 1
		now = 0
		$list[now] = 1
		loop{
		$n.times do |i|
			if $m[now][i] == 1 && $list[i] == 0
				a << [i, len + 1]
				$data[i].len = len
				$list[i] = 1
			end
		end
	 return nil	if a.empty?
		nex = a.shift
		now = nex[0]
		len = nex[1]
	}
end

D = Struct.new(:len)
$n = gets.to_i
$time = 0
$m = Array.new($n){Array.new($n){0}}
$data = Array.new($n){D.new(-1)}
$list = Array.new($n){0}
$n.times do
	s = gets.split.map(&:to_i)
	i = s[0] - 1
	s[1].times do |l|
		j = s[l + 2] - 1
		$m[i][j] = 1 
	end
end
$data[0].len = 0
traverse



$n.times do |i|
	puts "#{ i + 1 } #{$data[i].len}"
end

Measured memory_bytes: 8744
#include <iostream>
#include <cmath>
#include <array>
using namespace std;
int main(int argc, const char * argv[]) {
    // insert code here...
    int N;
    int cnt = 0;
    array<int, 200> A;
    cin >> N;
    for(int idx = 0; idx < N; ++idx){
        cin >> A[idx];
    }
    
    while(1){
    for(int idx = 0; idx < N; ++idx){
        if(A[idx] % 2 != 0){
            goto OUT;
        }
        else{
            A[idx] /= 2;
        }
    }
    cnt++;
    }
OUT:
    cout << cnt;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    LL n;
    cin >> n;
    VLL a(n);
    REP(i,0,n) cin >> a[i];
    LL ans = 0;
    REP(i,0,n-1) {
        ans += a[i] / 2;
        if (a[i] % 2 && a[i+1]) {
            ++ans;
            --a[i+1];
        }
    }
    ans += a[n-1] / 2;
    cout << ans << endl;
}

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

Measured memory_bytes: 1024
import sys
# input = sys.stdin.readline

def readlines(n):
    for _ in range(n):
        yield map(int, input().split())


def main():
    s = input()

    subst = 0
    for i in range(len(s)):
        if s[i] in "ACGT":
            subst += 1
        else:
            yield subst
            subst = 0
    
    yield subst
    

print(max(main()))


Measured memory_bytes: 2940
N, C = map( int, input().split())
S = [ list( map( int, input().split())) for _ in range(N)]
X = [0]*(N+1)
RX = [0]*(N+1)
CX = [-C]*(N+1)
RCX = [-C]*(N+1)
now = 0
M = -C
m = -C
for i in range(N):
    X[i+1] = X[i] + S[i][1] - S[i][0] + now
    now = S[i][0]
    M = max(M, X[i+1])
    CX[i+1] = M
now = 0
for i in range(N):
    x, v = S[-i-1]
    x = C - x
    RX[i+1] = RX[i] + v - x + now
    now = x
    m = max(m, RX[i+1])
    RCX[i+1] = m
ans = 0
CX[0] = 0
RCX[0] = 0
RS = S[::-1]
S.insert(0,[0,0])
RS.insert(0,[C,0])

for i in range(N+1):
    ans = max( ans, X[i] + max(RCX[N-i] - S[i][0], 0))
    ans = max( ans, RX[i] + max(CX[N-i] - (C - RS[i][0]),0))
print(ans)

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

int main() {

	int k;
	string s;

	cin >> k;
	cin >> s;

	if (s.size() > k)
	{
		cout << s.substr(0,k) << "..." << endl;
	}
	else {
		cout << s << endl;
	}

	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000001
//0=48,A=65,a=97

int main() {
    ll n,k;cin >> n >> k;
    ll ans=k;
    for(int i = 0; i < n-1; i++) {
        ans *= k-1;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
#define fst first
#define snd second
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
const int mk=18;
const int mn=1<<mk;
typedef pair<int,int> pii;
pii f[mn][2];
pii b[4];
int main(){
	ios::sync_with_stdio(false);
	int klim; scanf("%d",&klim);
	int zlim=1<<klim;
	for (int i=0;i<zlim;i++) {
		int x; scanf("%d",&x);
		f[i][0]=MP(x,i);
		f[i][1]=MP(-1,-1);
	}
  for (int k=0;k<klim;k++) {
    for (int z=0;z<(1<<klim);z++) {
      if (z&(1<<k)) {
      	for (int t=0;t<2;t++) b[t]=f[z][t];
      	for (int t=0;t<2;t++) b[t+2]=f[z^(1<<k)][t];
      	sort(b,b+4);
      	int has=0;
      	for (int i=3;i>=0;i--) {
      		if (i==3||b[i]!=b[i+1]) {
      			f[z][has++]=b[i];
      			if (has==2) break;
      		}
      	}
      }
    }
  }
  int ans=0;
  for (int z=1;z<zlim;z++) {
  	int cand=f[z][0].fst+f[z][1].fst;
  	chkmax(ans,cand);
  	printf("%d\n",ans);
  }
}


Measured memory_bytes: 7168
#include <iostream>
#include <map>
#include <string>

using namespace std;




int main(int argc, char *argv[])
{
	int t;
	int ans;

	cin >> t;

	for (int i = 111; i <= 999; i += 111){
		if (t <= i){
			ans = i;
			break;
		}
	}
	cout << ans << endl;

	return 0;
}



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

using namespace std;

int main()
{
  int  h,n;
  cin>>h>>n;
  std::vector<int> v1(n),v2(n);
  for (int i = 0; i < n; ++i)
  {
    cin>>v1[i]>>v2[i];
  }
  std::vector<int> dp(h+2);
  for (int i = 0; i <=h; ++i)
  {
    dp[i]=1e9;
  }
  dp[h]=0;
  for (int i = h; i >0 ; --i)
  {
    for(int j=0;j<n;j++)
    {
      dp[max(0,i-v1[j])]=min(dp[max(0,i-v1[j])],dp[i]+v2[j]);
    }
  }
  cout<<dp[0]<<'\n';
}


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

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define fs first
#define sc second
#define fr(i, a, b) for(int i = a ; i < b ; i++)
#define frr(i, a, b) for(int i = a ; i >= b ; i--)
#define tr(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define trr(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define its(x) static_cast< ostringstream & >( ( ostringstream() << dec << x ) ).str() // int to string
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)
#define deb(x) cout << #x" = " << x << '\n'
#define has(cont, x) ((cont).find((x)) != (cont).end())
#define sz(x) ((int)(x).size())

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

int main() {
//    freopen("input.in", "r", stdin);
	int a, b;
	char x;
	cin >> a >> x >> b;
	bool plus, subs, mul, div;
	plus = subs = mul = div = false;
	if(x == '+')	{
		cout << a+b << '\n';
		return 0;
	}
		cout << a-b << '\n';
		
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

V<string> s;
int memo[1020][1020];

ll dp(int i, int j) {
	if (memo[i][j] != INF)return memo[i][j];
	if (i == 1 && j == 1)return 1;
	if (s[i - 1][j - 1] == '#')return 0;

	ll ret = 0;
	if (i > 1)ret += dp(i - 1, j);
	if (j > 1)ret += dp(i, j - 1);
	memo[i][j] = ret % MOD;
	return memo[i][j];
}

int main() {

	int h, w;
	cin >> h >> w;
	s.resize(h);
	rep1(i, h)rep1(j, w)memo[i][j] = INF;
	rep(i, h)cin >> s[i];

	cout << dp(h, w) << endl;

}

Measured memory_bytes: 5504
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int h,w;
  cin >> h >> w;
  vector<vector<int>> a(h,vector<int>(w));
  vector<vector<int>> b(h,vector<int>(w));
  rep(i,h){
    rep(j,w){
      cin >> a[i][j];
    }
  }
  rep(i,h){
    rep(j,w){
      cin >> b[i][j];
    }
  }

  vector<vector<vector<bool>>> dp(h,vector<vector<bool>>(w,vector<bool>(6401,false)));
  dp[0][0][abs(a[0][0]-b[0][0])] = true;
  rep(i,h){
    rep(j,w){
      rep(k,6401){
	if(dp[i][j][k]){
	  if(i+1<h){
	    int d = abs(a[i+1][j]-b[i+1][j]);
	    if(k+d<=6400){
	      dp[i+1][j][k+d] = true;
	    }
	    if(0<=k-d){
	      dp[i+1][j][k-d] = true;
	    }
	    if(0<=d-k){
	      dp[i+1][j][d-k] = true;
	    }
	  }
	  if(j+1<w){
	    int d = abs(a[i][j+1]-b[i][j+1]);
	    if(k+d<=6400){
	      dp[i][j+1][k+d] = true;
	    }
	    if(0<=k-d){
	      dp[i][j+1][k-d] = true;
	    }
	    if(0<=d-k){
	      dp[i][j+1][d-k] = true;
	    }
	  }	  
	}
      }
    }
  }

  
  int res=6500;
  rep(i,6401){
    if(dp[h-1][w-1][i]) res = min(res,i);
  }

  cout << res << "\n";
  
  return 0;
}


Measured memory_bytes: 5760
use proconio::{fastout, input};

use std::cmp::{min, Reverse};
use std::collections::BinaryHeap;

#[fastout]
fn main() {
    input! {
        t: usize,
    }
    for _ in 0..t {
        input! {
            n: usize,
            mut klr: [(usize, i64, i64); n],
        }
        let mut ans = 0;
        klr.sort_by_key(|&(k, _, _)| k);
        for (_, l, r) in klr.iter() {
            ans += min(l, r);
        }
        let (a, b): (Vec<_>, Vec<_>) = klr.into_iter().partition(|&(_, l, r)| l >= r);
        let mut s = BinaryHeap::new();
        let mut idx = 0;
        for i in 1..=n {
            while idx < a.len() && a[idx].0 == i {
                let (_, l, r) = a[idx];
                s.push(Reverse(l - r));
                idx += 1;
            }
            while s.len() > i {
                s.pop();
            }
        }
        while let Some(Reverse(lr)) = s.pop() {
            ans += lr;
        }
        let mut idx = b.len();
        for i in 1..=n {
            while idx > 0 && b[idx - 1].0 == n {
                idx -= 1;
            }
            while idx > 0 && b[idx - 1].0 == n - i {
                let (_, l, r) = b[idx - 1];
                s.push(Reverse(r - l));
                idx -= 1;
            }
            while s.len() > i {
                s.pop();
            }
        }
        while let Some(Reverse(rl)) = s.pop() {
            ans += rl;
        }
        println!("{}", ans);
    }
}


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

int main() {
  string S;
  cin >> S;
  string answer;
  if ( S == "Sunny" ) {
    answer = "Cloudy";
  }
  else if ( S == "Cloudy" ) {
    answer = "Rainy";
  }
  else if ( S == "Rainy" ) {
    answer = "Sunny";
  }
  cout << answer << endl;
}

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

int main() {
  
  int s;
  cin >> s;
  
 int s3 = s % 10;
 int s2 = ( s - s3 ) / 10 % 10;
 int s1 = ( s - s3 - s2 ) /100;
  cout << s3 + s2 + s1 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

#define NUM 99999999999999999

struct Info{
	ll num,words_num;
};

ll total[18];

ll getNUM(ll value){

	ll digit = 0;

	while(pow(10,digit+1) < value){
		digit++;
	}

	ll tmp = 0;

	for(int i = 0; i < digit; i++){
		tmp += total[i];
	}

	ll left_num = pow(10,digit);

	ll num_3 = value/3-left_num/3;
	ll num_5 = value/5-left_num/5;
	if(left_num%5 == 0){
		num_5++;
	}
	ll num_15 = value/15-left_num/15;

	return tmp+4*(num_3+num_5-2*num_15)+8*num_15+(digit+1)*(value+1-left_num-(num_3+num_5-num_15));
}

Info calc(ll number){

	Info ret;
	ret.num = 0;
	ret.words_num = 0;

	ll left,right,m,tmp;
	left = 1,right = NUM,m = (left+right)/2;

	while(left <= right){
		if((tmp = getNUM(m)) <= number){
			ret.num = m;
			ret.words_num = tmp;
			left = m+1;
		}else{
			right = m-1;
		}
		m = (left+right)/2;
	}
	return ret;
}


int main(){

	ll left,right,num_3,num_5,num_15;

	total[0] = 21;

	for(ll i = 1; i <= 17; i++){
		left = pow(10,i);
		right = pow(10,i+1);
		right -= 1;

		num_3 = right/3-left/3;
		num_5 = right/5-left/5+1;
		num_15 = right/15-left/15;

		total[i] = 4*(num_3+num_5-2*num_15)+8*num_15+(i+1)*((right+1-left)-(num_3+num_5-num_15));
	}

	ll number;
	scanf("%lld",&number);

	Info next = calc(number-1);

	string ans;

	for(ll i = 1; i <= 20; i++){
		if((next.num+i)%15 == 0){
			ans.append("FizzBuzz");
		}else if((next.num+i)%3 == 0){
			ans.append("Fizz");
		}else if((next.num+i)%5 == 0){
			ans.append("Buzz");
		}else{
			ans.append(to_string(next.num+i));
		}
	}

	ll index;
	for(index = 1;next.words_num+index < number ;index++);

	for(ll i = 0; i < 20; i++){
		printf("%c",ans[index-1+i]);
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 3508
#include <bits/stdc++.h>
#define int long long
const int MOD=1e9+7;
using pii=std::pair<int,int>;
using namespace std;

int l;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> l;
    long double lb3 = l / 3.0;
    cout << setprecision(12) << lb3 * lb3 * lb3 << "\n";
    //cout << (l / 3) * ((l + 2) / 3) * ((l + 2) / 3) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	bool t=true;
	for(int i=0;s[i]!='\0';i++)
	{
		if(i%2==0&&s[i]=='L')
		{
			t=false;
			break;
		}
		else if(i%2!=0&&s[i]=='R')
		{
			t=false;
			break;
		}
	}
	if(t) cout<<"Yes";
	else cout<<"No";
	return 0;
}

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

print(0)
left = input().rstrip("\n")
if left == "Vacant":
    exit()
print(N - 1)
right = input().rstrip("\n")
if right == "Vacant":
    exit()

even = left
odd = "Female" if even == "Male" else "Male"

left = 0
right = N - 1
while right - left > 1:
    mid = (right + left) // 2
    print(mid)
    s = input().rstrip("\n")
    if s == "Vacant":
        exit()
    
    if mid % 2 == 0:
        if even == s: # (mid, right]に空席
            left = mid + 1
        else: # [left, mid)に空席
            right = mid - 1
    else:
        if odd == s: # (mid, right]に空席
            left = mid + 1
        else: # [left, mid)に空席
            right = mid - 1

print(left)
s = input().rstrip("\n")
if s == "Vacant":
    exit()
print(right)
s = input().rstrip("\n")
if s == "Vacant":
    exit()

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(x) x.begin(),x.end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

int main() {
 int h, w, k;
 cin >> h >> w >> k;
 vector<vector<char>> f(h, vector<char>(w));
 rep(i, h) {
  rep(j, w) cin >> f[i][j];
 }
 int res = 0;
 for(int i = 0; i < (1 << h); ++i) {
  for(int j = 0; j < (1 << w); ++j) {
   int count = 0;
   for(int ii = 0; ii < h; ++ii) {
    if((1 << ii) & i ) continue;
    for(int jj = 0; jj < w; ++jj) {
     if((1 << jj) & j ) continue;
     if(f[ii][jj] == '#') count++;
    }
   }
   if(count == k) res++;
  }
 }
 cout << res << endl;
 return 0;
}

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

using namespace std;
using ll = long long;

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

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    for(int i = k; i < n; ++i) {
        if(a[i - k] < a[i]) printf("Yes\n");
        else printf("No\n");
    }

    return 0;
}

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

using namespace std;

int N, W, v[101], w[101], dp[101][10001];

int main(void) {
    cin >> N >> W;
    for (int i = 0; i < N; i++)
        cin >> v[i] >> w[i];
    
    memset(dp[0], 0, sizeof dp[0]);

    for (int i = 1; i <= N; i++)
        for (int j = 0; j <= W; j++) {
            if (j < w[i - 1]) dp[i][j] = dp[i - 1][j];
            else dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
        }
    
    cout << dp[N][W] << endl;
    
    return 0;
}


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

int main()
{
    int n;

    while( cin >> n )
    {
        if( n == 0 )
            break;

        int m[n+1][n+1];
        for( int i = 0; i < n + 1; i++ )
            for( int j = 0; j < n + 1; j++ )
                m[i][j] = 0;

        for( int i = 0; i < n; i++ )
            for( int j = 0; j < n; j++ )
                cin >> m[i][j];

        for( int i = 0; i < n; i++ )
        {
            int line = 0;
            for( int j = 0; j < n; j++ )
                line += m[i][j];
            m[i][n] = line;
            m[n][n] += m[i][n];
        }

        for( int i = 0; i < n; i++ )
        {
            int row = 0;
            for( int j = 0; j < n; j++ )
                row += m[j][i];
            m[n][i] = row;
        }

        for( int i = 0; i < n + 1; i++ )
        {
            for( int j = 0; j < n + 1; j++ )
                cout << setw(5) << m[i][j];
            cout << endl;
        }
    }    

    return 0;
}


Measured memory_bytes: 3088
//#include <bits/stdc++.h> 実務では使わない方が無難
#include <iostream>
#include <string.h>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; ++i)
//using namespace std; 魔界への入り口

int main()
{
    // スペース区切りの整数の入力
    int x, n;
    std::cin >> x >> n;
    std::vector<bool> v(102, 0);
    rep(i,n){
        int p;
        std::cin >> p;
        v[p] = 1;
    }
    std::pair<int, int> ans(0, x);
    if(v[x] == 0)
    {
        ans = std::make_pair(0, x);
    }
    else
    {
        ans = std::make_pair(9999, -1);
        for (int i = 0; i <= 101; ++i)
        {
            if (v[i] == 1)
                continue;
            else
            {
                int dif = abs(x-i);
                ans = std::min(ans, std::pair<int, int>(dif, i));
            }
        }
    }
    // 出力
    std::cout << ans.second << std::endl;
    return 0;
}

Measured memory_bytes: 3640
/*
Wai u read my code xD
*/
#include <bits/stdc++.h>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vi vector <ll> 
#define qu queue <ll>
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


void solve()
{
    ll h; cin >> h;
    ll ans = 1, ind = 2;
    while (h>1)
    {
        ans += ind;
        ind*=2;
        h/=2;
    }
    nout(ans);
}

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

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;

vector<int> X,Y;
int x,y;

int main(){
    string s;
    cin>>s;
    cin>>x>>y;
    int flag = 0;// 0 is x;
    int l = s.size();
    int dist = 0;
    int start = 0;
    if(s[0]=='F'){
        int tmp = 1;
        rep1(i,l-1){
            if(s[i]=='F'){
                tmp++;
                if(i==l-1){
                    start = i+1;
                }
            }
            else{
                start = i;
                break;
            }
        }
        x -= tmp;
    }
    for(int i = start; i < l; i++){
        if(s[i]=='T'||(i==l-1)){
            if(s[i]=='F')dist++;
            if(dist){
                if(!flag)X.push_back(dist);
                else Y.push_back(dist);
            }
            flag = !flag;
            dist = 0;
        }
        else{
            dist++;
        }
    }
    // cout<<"aim "<<x<<" "<<y<<endl;
    // cout<<X.size()<<" "<<Y.size()<<endl;
    // for(auto i:X)cout<<i<<" ";
    // cout<<endl;
    // for(auto i:Y)cout<<i<<" ";
    // cout<<endl;

    set<ll> SX,SY;
    if(X.size()==0)SX.insert(0);
    else{
        SX.insert(X[0]);
        SX.insert(-X[0]);
    }
    if(Y.size()==0)SY.insert(0);
    else{
        SY.insert(Y[0]);
        SY.insert(-Y[0]);
    }
    rep1(i,X.size()-1){
        set<ll> tmp;
        for(auto j:SX){
            tmp.insert(j+X[i]);
            tmp.insert(j-X[i]);
        }
        SX = tmp;
    }
    rep1(i,Y.size()-1){
        set<ll> tmp;
        for(auto j:SY){
            tmp.insert(j+Y[i]);
            tmp.insert(j-Y[i]);
        }
        SY = tmp;
    }
    if(SY.count(y)&&SX.count(x))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 4088
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iomanip>
using namespace std;

#define PI 3.14159265358979323846264338327950L

int main() {
	string S;

	cin >> S;

	if (S.compare("ABC") == 0) {
		cout << "ARC" << endl;
	}
	else {
		cout << "ABC" << endl;
	}
	return 0;
}

Measured memory_bytes: 3536
#include<bits/stdc++.h>
#define int long long
using namespace std;
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 (a>b) { a=b; return 1; } return 0; }

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

    int N; cin>>N;
    string s; cin>>s;

    int ans=0;
    for(int i=0;i<N;){
        int i0=i;
        while(i<N and s[i]==s[i0]) i++;
        ans++;
        // cout<<i<<' '<<i0<<endl;
    }
    cout<<ans<<endl;
    return 0;
}

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


int main(){

  string s;
  vector <char> ans;
  cin >> s;
  rep(i,s.size()){
    
    if(s.at(i)=='0' || s.at(i)=='1'){
      ans.push_back(s.at(i));
    }else{
      if(!ans.empty()){
      	ans.pop_back();
       /* rep(i,ans.size())
  			cout << ans.at(i);
        cout << endl;*/
      }
    }
    //cout << c << endl;
    
    //cout << ans << endl;
  }
  rep(i,ans.size())
  cout << ans.at(i);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
using namespace std;
typedef long long ll;

vector<pair<int, int>> to[100010];
bool visited[100010];
ll dist[100010];
ll gcd(ll a, ll b)
{
   if (b == 0)
   {
       return a;
   }
    return gcd(b, a%b);
}
void dfs(int now, ll d) {
  visited[now] = true;
  dist[now] = d;
  for (auto p : to[now]) {
    if (visited[p.first]) continue;
    dfs(p.first, d + p.second);
  }
}

int main() {
    int n;
    string s;
    cin>>n;
    vector<int>a(n+1);
    rep(i,1,n+1){
        cin>>a[i];
    }
    ll ans=0;
    rep(i,1,n+1){
        if(i%2 && a[i]%2) {
            ans++;
        }
    }
   
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5980
package main

import "fmt"

var f []int

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

func abs(i int) int {
	if i < 0 {
		return -i
	}
	return i
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	h := make([]int, n+1)
	for i := 0; i < n; i++ {
		fmt.Scan(&h[i])
	}

	f = make([]int, n+1)
	f[0] = 0
	f[1] = abs(h[1] - h[0])
	for i := 2; i < n; i++ {
		m := 1000000000
		for j := 1; j <= k && i-j >= 0; j++ {
			m = min(m, f[i-j]+abs(h[i-j]-h[i]))
		}
		f[i] = m
	}
	fmt.Println(f[n-1])
}

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

lint n;

lint partial_sum(lint k) {
    lint num = n / k;
    return (k + num * k) * num / 2;
}

int main() {
    cin >> n;
    lint ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += partial_sum(i);
    }
    cout << ans << endl;
}

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

int main(){
	typedef long long ll;
	ll h,n;
	ll no = 0;
	cin >> h >> n;
	for(ll i=0;i<n;i++){
		ll a;
		cin >> a;
		no+=a;
	}
	if(no>=h)cout << "Yes";
	else cout << "No";
}

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

const int64_t INF = 1LL << 60;

int main() {
  int N, W;
  cin >> N >> W;

  vector<int> weight(N), value(N);
  rep(i, N) cin >> weight[i] >> value[i];

  int MAX_VALUE = 1e5;
  vector<vector<int64_t>> dp(N + 1, vector<int64_t>(MAX_VALUE + 1));
  rep(i, N + 1) rep(v, MAX_VALUE + 1) {
    dp[i][v] = INF;
  }

  dp[0][0] = 0;

  rep(i, N) rep(v, MAX_VALUE + 1) {
    if (v >= value[i]) {
      dp[i + 1][v] = min(dp[i][v - value[i]] + weight[i], dp[i][v]);
    } else {
      dp[i + 1][v] = dp[i][v];
    }
  }

  int64_t ans = 0;
  rep(v, MAX_VALUE + 1) {
    if (dp[N][v] <= W) {
      ans = v;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 80256
// ???????¨????????????????????????????????????????????????¶????????????

#include <iostream>
#include <vector>
#define rep(i,p) for(int i=0;i<p;i++)
#define pb push_back
#define MAX 10100
using namespace std;
int N,W,temp1,temp2;
std::vector<int> v;
std::vector<int> w;
int dp[MAX][MAX] = {0};
int main(){
  cin >> N >> W;

  v.pb(0);
  w.pb(0);
  
  rep(i,N) {
    cin >> temp1 >> temp2;
    v.pb(temp1); // ??????
    w.pb(temp2); // ??????
  }

  for (int i=1; i<=N; i++)
    for (int c=1; c<=W; c++) {
      temp1 = v.at(i);
      temp2 = w.at(i);
      if (c-temp2 < 0)
        dp[i][c] = dp[i-1][c];
      else
        dp[i][c] = max(temp1+dp[i][c-temp2],dp[i-1][c]);
    }
  cout << dp[N][W] << endl;
  return 0;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int size = in.nextInt(), arr1[] = new int[size], arr2[] = new int[size];
		for(int i = 0; i < size; i++) {
			arr1[i] = Integer.parseInt(in.next());
		}

		int query = in.nextInt();
		for(int i = 0; i < query; i++) {
			int begin = Integer.parseInt(in.next()), middle = Integer.parseInt(in.next()), end = Integer.parseInt(in.next());
			int sta1 = end - middle, sta2 = end - begin;

			for(int j = 0; j < sta2; j++) {
				arr2[begin + ((j + sta1) % sta2 )] = arr1[begin + j];
			}

			for(int j = 0; j < sta2; j++) {
				arr1[begin + j] = arr2[begin + j];
			}
		}

		for(int i = 0; i < size; i++) {
			out.printf("%d%s", arr1[i], (i < size - 1) ? " " : "\n");
		}
		out.flush();
		in.close();
	}

}



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

namespace AtCoder_Beginner_Contest_128
{
    class Program
    {
        static public int[] SIn() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static void Main(string[] args)
        {
            var AP = SIn();
            WriteLine($"{(AP[0] * 3 + AP[1]) / 2}");
        }
    }
}

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

using namespace std;

bool ok(int H, int W, int K, vector<string> c, int mask_r, int mask_c)
{
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			if ((mask_r & (1 << i)) || (mask_c & (1 << j))) {
				c[i][j] = 'R';
			}
		}
	}
	int black = 0;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			if (c[i][j] == '#') {
				++black;
			}
		}
	}
	return black == K;
}

int main()
{
	int H, W, K;
	cin >> H >> W >> K;
	vector<string> c(H);
	for (auto& s : c) {
		cin >> s;
	}

	int ans = 0;
	for (int mask_r = 0; mask_r < (1 << H); ++mask_r) {
		for (int mask_c = 0; mask_c < (1 << W); ++mask_c) {
			if (ok(H, W, K, c, mask_r, mask_c)) {
				++ans;
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 3632
#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 ALL(v) v.begin(), v.end()

int main() {
  std::cout << std::fixed << std::setprecision(20);

  int X;
  cin >> X;

  if(X < 600){
    cout << "8" << endl;
  }else if(X < 800){
    cout << "7" << endl;
  }else if(X < 1000){
    cout << "6" << endl;

  }else if(X < 1200){
    cout << "5" << endl;

  }else if(X < 1400){
    cout << "4" << endl;
  }else if(X < 1600){
    cout << "3" << endl;
  }else if(X < 1800){
    cout << "2" << endl;
  }else if(X < 2000){
    cout << "1" << endl;
  }
}

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

int main(){
    vector<int>a(3);
    for(int i=0;i<3;i++){
        cin>>a.at(i);
    }
    if(a.at(0)==a.at(1)){
        cout<<a.at(2);
    }
    else if(a.at(1)==a.at(2)){
        cout<<a.at(0);
    }
    else{
        cout<<a.at(1);
    }

}


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

using namespace std;

int n;
vector<pair<int, int>> a;
vector<bool> vis;
long double res = 0;

void dfs(int i, pair<int, int> pre, double tmp) {
  if (i == n) {
    res += tmp;
    return;
  }
  for (int j = 0; j < n; j++) {
    if (vis[j]) continue;
    vis[j] = true;
    double t = 0;
    if (i != 0) {
      t = (a[j].first - pre.first) * (a[j].first - pre.first) + (a[j].second - pre.second) * (a[j].second - pre.second);
      t = sqrt(t);
    }
    dfs(i + 1, a[j], tmp + t);
    vis[j] = false;
  }
}

int main() {
  cin >> n;
  vis.resize(n, false);
  int x, y;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    a.emplace_back(x, y);
  }
  dfs(0, make_pair(-1, -1), 0.0);
  for (int i = 1; i <= n; i++) {
    res /= i;
  }
  cout << fixed << setprecision(10) << res << '\n';
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
import bisect

n, m = map(int, input().split())
seen = set()
ab = []
for _ in range(n):
    a, b = map(int, input().split())
    ab.append((a, b))
    seen.add(a)
ab.sort()

seen_list = list(seen)
seen_list.sort()
comp = dict()
comp_inv = dict()
for i, item in enumerate(seen_list):
    comp[item] = i
    comp_inv[i] = item
node_num = len(comp)

d = [0] * (node_num + 1)
prev = 0
for a, b in ab:
    if b != prev:
        d[comp[a]] = 1
    prev = b
if prev != 0:
    d[node_num] = 1
# print("d", d)

switch_dict = dict()
lr = []
for i in range(m):
    l, r = map(int, input().split())
    lft = bisect.bisect_left(seen_list, l)
    rgt = bisect.bisect_right(seen_list, r)
    if lft != rgt:
        lr.append((lft, rgt))
        switch_dict[(lft, rgt)] = i + 1
# print("lr", lr)

edge = [[] for _ in range(node_num + 1)]
for l, r in lr:
    edge[l].append(r)
    edge[r].append(l)
# print("edge", edge)

visited = [0] * (node_num + 1)
ans = []
def dfs(p, v):
    ret = d[v]
    for nv in edge[v]:
        if nv == p:
            continue
        if not visited[nv]:
            visited[nv] = 1
            val = dfs(v, nv)
            if val == 1:
                if v < nv:
                    ans.append(switch_dict[(v, nv)])
                else:
                    ans.append(switch_dict[(nv, v)])
                ret += 1
    return ret % 2

for i in range(node_num + 1):
    if visited[i]:
        continue
    visited[i] = 1
    ret = dfs(-1, i)
    # Check last node is ok or not
    if ret == 1:
        print(-1)
        exit()

# Check trees cover all 1 or not
for c, is_visited in zip(d, visited):
    if not is_visited and c:
        print(-1)
        exit()

ans.sort()
print(len(ans))
print(*ans)

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

const ll INF = 1LL << 60;

ll N, T;
vector<P> v;

// 最後の料理を選ぶ
ll dp[3010][3010];

int main() {
    cin >> N >> T;
    v.resize(N);
    rep(i, N) {
        ll a, b;
        cin >> a >> b;
        v[i] = P(a, b);
    }
    sort(v.begin(), v.end());

    ll ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < T; j++) {
            // 選ばない
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);

            // 選ぶ
            ll A = v[i].first;
            ll B = v[i].second;
            if (j + A < T) {
                dp[i + 1][j + A] = max(dp[i + 1][j + A], dp[i][j] + B);
            }
        }

        // 最後の料理を選ぶ
        ans = max(ans, dp[i][T - 1] + v[i].second);
    }

    cout << ans << endl;
}

Measured memory_bytes: 74164
#include<iostream>
#include<vector>
#include<algorithm>
#include<iterator>
#include<cmath>
#include<functional>
using namespace std;

int binsearch(long l, long r, long A, long B, vector<long> h, bool (*ptn)(long, long, long, vector<long>)){
    while(r - l > 1){
        long m = (l + r) / 2;
        if(ptn(m, A, B, h)){
            l = m;
        }else{
            r = m;
        }
    }
    return l;
}

bool search(long i, long A, long B, vector<long> h){
    if(*max_element(h.begin(), h.end()) <= B*i){
        return false;
    }
    long r = 0;
    for(auto j = h.begin(); j < h.end(); j++){
        r +=  (long) max(0.0,  ceil((double(*j) - double(B)*i)/double(A-B)));
    }
    if(r <= i){
        return false;
    }
    return true;
}

int main(){
    long N, A, B;
    cin >> N >> A >> B;
    vector<long> h(N);
    for(long i=0;i<N;i++){
        cin >> h.at(i);
    }
    cout << 1 + binsearch(0, 1000000000, A, B, h, search) << endl;
}



Measured memory_bytes: 5596
// Etavioxy
#include<cstdio>
#include<cctype>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ll long long
#define il inline
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch; int f=1;
	while(!isdigit(ch=getchar())) f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar())) x=(x*10)+(ch^'0');
	return f*x;
}

int main(){
	char s[7];
	scanf("%s",s);
	puts( s[2]==s[3] && s[4]==s[5] ?"Yes":"No");
	return 0;
}


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

int main()
{
	int n,a[100000];
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	
	int i=0,v;
	for(v=1;v<n;v++){
		if(a[i]==2) break;
		i=a[i]-1;
	}
	
	cout<<((v==n)? -1:v)<<endl;
	
	return 0;
}


Measured memory_bytes: 640
class Dice():

    def __init__(self, label):
        self.label = label

    def north(self):
        self.change([2, 6, 3, 4, 1, 5])

    def west(self):
        self.change([3, 2, 6, 1, 5, 4])

    def east(self):
        self.change([4, 2, 1, 6, 5, 3])

    def south(self):
        self.change([5, 1, 3, 4, 6, 2])

    def change(self, convert):
        num = []
        for i in range(6):
            num.append(self.label[convert[i] - 1])
        self.label = num


def main():
    f = [int(x) for x in input().split()]
    s = [int(x) for x in input().split()]
    dice = Dice(f)
    labels = []
    for i in range(6):
        if i < 4:
            dice.north()
        elif i == 4:
            dice.east()
            dice.south()
        elif i == 5:
            dice.south()
            dice.south()
        for j in range(4):
            dice.west()
            labels.append(dice.label)
    if s in labels:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Measured memory_bytes: 7788
#include <bits/stdc++.h>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> V;

#define _ cin.tie(0);ios::sync_with_stdio(false);
string s;
int main(){ _;
  cin>>s;
  int ans=2;
  for(int i=2;i<s.length();i+=2){
    int j=0;
    for(j=0;s[j]==s[j+i/2] && j+i/2<i;j++);
    if(2*j-1==i-1)
      ans=max(ans,j+i/2);
    
  }
  cout<<ans<<endl;
      
  return 0;
}


Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
int n, d[101010], dp[101010];
const int INF = INT_MAX; 
int main(){
    cin >> n;
    for(int i = 1;i <= n;i++)cin >> d[i];
    for(int i = 1;i <= n;i++) dp[i] = INF;
    dp[1] = 0;
    for(int i = 2;i <= n;i++){
        if(i == 2)dp[i] = dp[i - 1] + abs(d[i - 1] - d[i]);
        else dp[i] = min(dp[i - 1] + abs(d[i - 1] - d[i]), dp[i - 2] + abs(d[i - 2] - d[i]));
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;


int main(){
    char S[4];

    //input
    cin >> S;

    if(S[1] == 'B'){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }

    return 0;
}


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

int main() {
  int N;
  scanf("%d", &N);
  int a[N];
  for (int i = 0; i < N; ++i) {
    scanf("%d", &a[i]);
  }
  long long ans = 0;

  for (int i = 0; i < N; ++i){
    bool flug = true;
    while(flug==true){
      if(a[i]%2==0){
        a[i] /= 2;
        ++ans;
      }
      else flug = false;
    }
  }

  cout << ans << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<int>;
using A = array<int, 2>;
using P = pair<int, int>;
constexpr int MOD{1000000000 + 7};
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
constexpr array<int, 4> dx{1, 0, -1, 0}, dy{0, 1, 0, -1};
int gcd(int a, int 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;
}
constexpr int div_roundup(int a, int b)
{
    return (a + b - 1) / b;
}

// vector<vector<int>> vec(n_rows, vector<int>(n_cols, value));

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

void solve()
{
    int n;
    cin >> n;
    V a(n);
    int a_max = 0;
    int a_max_idx = 0;
    bool max_dual = false;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if (a[i] == a_max)
        {
            max_dual = true;
        }
        else if (a[i] > a_max)
        {
            a_max = a[i];
            a_max_idx = i;
            max_dual = false;
        }
    }
    if (max_dual)
    {
        for (int i = 0; i < n; i++)
        {
            cout << a_max << endl;
        }
    }
    else
    {
        sort(a.rbegin(), a.rend());
        for (int i = 0; i < n; i++)
        {
            if (i == a_max_idx)
            {
                cout << a[1] << endl;
            }
            else
            {
                cout << a_max << endl;
            }
        }
    }
}

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

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

    solve();
}


Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

// constexpr int MOD = 1e9+7;

int main(void){
  	Cin(int, a);
  	bool f = (1 <= a/100 && a/100 <= 12);
  	bool g = (1 <= a%100 && a%100 <= 12);
  	
  	if(f){
  	    Cout(g ? "AMBIGUOUS" : "MMYY");
  	}
  	else{
  	    Cout(g ? "YYMM" : "NA");
  	}
}

Measured memory_bytes: 256
use proconio::{input, fastout};
#[fastout]
fn main() {
  input!{
    x : String
  }
  let ans = match x.as_str() {
    "RRR" => 3,
    "RRS" | "SRR" => 2,
    "RSR" | "SRS" | "SSR" | "RSS"  => 1,
    _ => 0
  };
  println!("{}" , ans);
}


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

using ll = long long;

int main() {
    // a = b * q + r (r >= K)
    // b > K
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    for (int b = K + 1; b <= N; b++) {
        ans += N / b * (b - K) + max(0LL, N % b - K + 1);
    }
    if (K == 0) ans = N * N;
    cout << ans << "\n";
}

Measured memory_bytes: 256
N, M = map(int,raw_input().split())
INF = 10 ** 8
cost = [[INF for j in xrange(N+10)] for i in xrange(N+10)]
E = [[INF for j in xrange(N+10)] for i in xrange(N+10)]
for _ in xrange(M):
    a,b,c = map(int,raw_input().split())
    a -= 1
    b -= 1
    cost[a][b] = c
    cost[b][a] = c
    E[a][b] = c
    E[b][a] = c
for v in xrange(N):
    cost[v][v] = 0
for k in xrange(N):
    for i in xrange(N):
        for j in xrange(N):
            cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j])
ans = 0
for a in xrange(N):
    for b in xrange(a+1,N):
        if E[a][b] == INF:
            continue
        OK = False
        for s in xrange(N):
            for t in xrange(s+1,N):
                if cost[s][a] + E[a][b] + cost[b][t] == cost[s][t]:
                    OK = True
            if OK:
                break
        if not OK:
            ans += 1
print ans


Measured memory_bytes: 3168