akhauriyash/Code-Regression huggingface dataset:
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

typedef pair<int, int> pint;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    string ss[n];
    REP(i, n)
    {
        cin >> ss[i];
    }
    bool ans = true;
    for (int i = 1; i < n; i++)
    {
        if (ss[i - 1][ss[i - 1].size() - 1] != ss[i][0])
        {
            ans = false;
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            if (ss[i] == ss[j])
            {
                ans = false;
            }
        }
    }
    if (ans)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3
char s[100001];

int main(){
    scanf("%s", s);
    int n = strlen(s), mini = n;
    repl(i, 1, n) if (s[i - 1] != s[i]) minch(mini, max(i, n - i));
    printf("%d\n", mini);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

class UnionFind {
    int n;
    vector<int> par, rank;

public:
    UnionFind(int N) : n(N), par(N, -1), rank(N) {}
    int root(int i) {
        if (par[i] < 0) return i;
        return par[i] = root(par[i]);
    }
    bool same(int i, int j) { return root(i) == root(j); }
    void unite(int i, int j) {
        i = root(i);
        j = root(j);
        if (i == j) return;
        if (rank[i] <= rank[j]) {
            par[i] = j;
            if (rank[i] == rank[j]) { rank[j]++; }
        } else {
            par[j] = i;
        }
    }
};

class Main {
    int N, M;
    vector<int> p, x, y;
    void input() {
        cin >> N >> M;
        p.resize(N);
        x.resize(M);
        y.resize(M);
        REP(i, N) {
            cin >> p[i];
            p[i]--;
        }
        REP(i, M) {
            cin >> x[i] >> y[i];
            x[i]--;
            y[i]--;
        }
    }
    void output() {
        UnionFind ufd(N);
        REP(i, M) { ufd.unite(p[x[i]], p[y[i]]); }
        int res = 0;
        REP(i, N) { res += ufd.root(p[i]) == ufd.root(i); }
        cout << res << endl;
    }

public:
    Main() {
        input();
        output();
    }
};

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

    Main();

    return 0;
}


Measured memory_bytes: 5276
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
    int n;
    cin>>n;
    if(n%10==2 || n%10==4 || n%10==5 || n%10==7 || n%10==9) {
        cout<<"hon\n";
    }
    else if(n%10==0 || n%10==1 || n%10==6 || n%10==8) {
        cout<<"pon\n";
    }
    else {
        cout<<"bon\n";
    }
}

Measured memory_bytes: 3568
#include <iostream>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
using namespace std;
typedef unsigned long long ull;
typedef pair<ll, ll>P;
const ll mod = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool fl = true;;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
struct edge { ll to, cost; };

int main() {
	ll h, w, n, ans[10] = { 0 };
	cin >> h >> w >> n;
	map<P, ll>c;
	for (int i = 0;i < n;i++) {
		ll x, y;
		cin >> x >> y;
		for (int j = -1;j <= 1;j++) {
			for (int k = -1;k <= 1;k++) {
				if (x + j > 1 && x + j < h && y + k > 1 && y + k < w ) {
					c[P(x + j, y + k)]++;
				}
			}
		}
	}
	ans[0] = (h - 2)*(w - 2);
	for (auto& i : c) {
		ans[0]--;
		ans[i.second]++;
	}
	for (int i = 0;i <= 9;i++) {
		cout << ans[i] << endl;
	}
	}

Measured memory_bytes: 56448
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>

using namespace std;

int main(){
	string s;
	cin>>s;
	int64_t red=0;
	int64_t blue=0;
	for(int64_t i1=0;i1<s.length();i1++){
		char c=s.at(i1);
		if(c=='0'){
			red++;
		}else{
			blue++;
		}
	}
	cout<<min(red,blue)*2<<endl;
	return 0;



}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,s=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		if(x==y)
		{
			s++;
			if(s==3)
			{
				puts("Yes");
				return 0;
			}
		}
		else
			s=0;
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 3680
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K=int(input())
print(a[K-1])


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

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);
    string S; int K; cin >> S >> K;
    int n=S.size();
    int dp[n+1][n+1][K+1];
    rep(i,n+1) rep(j,n+1) rep(k,K+1) dp[i][j][k]=0;
    rep(i,n) dp[i][i+1][0]=1;
    for (int j=2;j<=n;++j)
        for (int i=0;i+j<=n;++i)
            for (int k=0;k<=K;++k){
                chmax(dp[i][i+j][k],max(dp[i+1][i+j][k],dp[i][i+j-1][k]));
                if (S[i]==S[i+j-1]) chmax(dp[i][i+j][k],dp[i+1][i+j-1][k]+2);
                else if (k<K) chmax(dp[i][i+j][k+1],dp[i+1][i+j-1][k]+2);
    }
    int ans=0;
    rep(k,K+1) chmax(ans,dp[0][n][k]);
    cout << ans << endl;
}

Measured memory_bytes: 106752
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
right_answer=0
for i in range(N):
  A=list(map(int,input().split()))
  if sum(a*b for a,b in zip(A,B))+C>0:
    right_answer+=1
print(right_answer)

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

int main()
{
    set<int> s1, s2;
    int n, m;

    cin >> n;
   
    int a;

    for( int i = 0; i < n; i++ )
    {
        cin >> a;
        s1.insert(a);
    }

    cin >> m;

    for( int i = 0; i < m; i++ )
    {    
        cin >> a;
        s2.insert(a);
    }

    set<int>::iterator itr1 = s1.begin(), itr2 = s2.begin();
    for(; itr1 != s1.end() && itr2 != s2.end(); )
    {
        if( *itr1 < *itr2 )
        {
            cout << *itr1 << endl;
            itr1++;
        }
        else if( *itr1 > *itr2 )        //s2の集合の値は小さくても出力しない。s1の要素からs2の要素を省いたものが差集合だから。
            itr2++;
        else
        {    
            itr1++;
            itr2++;
        }
    }

    for(; itr1 != s1.end(); itr1++ )    //前のfor分を抜けた時、もとの集合の要素が余る場合（s2の集合の最大要素よりも大きい要素がある時）、全部出力する必要がある。
        cout << *itr1 << endl;

    return 0;
}


Measured memory_bytes: 21864
#include<iostream>
using namespace std;
int main(){
	int n,x,i,j,l,count=0;
	for(;;){
	cin>>n>>x;
	if(n==0&&x==0){
	break;
	}
	for(i=1;i<=n;i++){
		for(j=i+1;j<=n;j++){
			for(l=j+1;l<=n;l++){
			if(i+j+l==x){
				count++;
			}
			}
		}
	}
	cout<<count<<endl;
	count=0;
	}
return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef pair<int,int> P;
typedef long long int ll;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

const int MAX_N = 1100;
const int MAX_M = 1100;
int n, m;
string s, t;
int dp[MAX_N+1][MAX_M+1];

int main(){
    int q; cin >> q;
    
    rep(i,q){
        cin >> s >> t;
        n = s.size();
        m = t.size();
        rep(i,n){
            rep(j,m){
                if(s[i]==t[j]){
                    dp[i+1][j+1] = dp[i][j] + 1;
                }else{
                    dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
                }
            }
        }

        cout << dp[n][m] << endl;
    }

        
    return 0;
}
 
 



Measured memory_bytes: 7472
import copy
n=int(input())
a=[int(x) for x in input().rstrip().split()]
aa=copy.deepcopy(a)
a=[0]+a+[0]
sa=[]
for i in range(n+1):
  sa.append(abs(a[i+1]-a[i]))

SUM=sum(sa)
for i in range(1,n+1):
  print(SUM-(sa[i-1]+sa[i])+abs(a[i-1]-a[i+1]))

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

vector<vector<pair<int, int>>> G;
vector<int> ans;

void dfs(int v, int cnt, int pre) {
  int k = 1;
  for (auto g : G.at(v)) {
    if (g.first == pre) continue;
    ans.at(g.second) = (k == cnt) ? ++k : k;
    k++;
    dfs(g.first, ans.at(g.second), v);
  }
}

int main() {
  int N;
  cin >> N;
  G.resize(N);
  ans.resize(N - 1);
  for (int i = 0, a, b; cin >> a >> b; i++) {
    a--, b--;
    G.at(a).push_back({b, i});
    G.at(b).push_back({a, i});
  }

  dfs(0, -1, -1);

  int mx = 0;
  for (int i = 0; i < N; i++) mx = max(mx, (int)G.at(i).size());
  cout << mx << "\n";

  for (int i = 0; i < N - 1; i++) cout << ans.at(i) << "\n";
}

Measured memory_bytes: 8320
#include <iostream>
#include <iomanip>
#define MAXN 3005
using namespace std;

int N;
double p[MAXN], dp[MAXN][MAXN];

int main() {
	cin >> N;
	for (int i=1; i<=N; i++) {
		cin >> p[i];
	}

	dp[0][0] = 1;
	for (int i=1; i<=N; i++) {
		for (int j=0; j<=i; j++) {
			if (j == 0) {
				dp[i][j] = dp[i - 1][j] * (1 - p[i]);
				continue;
			}
			dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1 - p[i]);
		}
	}
	double ans = 0;
	// for (int i=0; i<=N; i++) {
	// 	for (int j=0; j<=N; j++) {
	// 		cout << dp[i][j] << ' ';
	// 	}
	// 	cout << "\n";
	// }
	for (int i=(N/2) + 1; i<=N; i++) {
		ans += dp[N][i];
	}
	cout << fixed << setprecision(9) << ans;
}

Measured memory_bytes: 68992
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n,s;
    vector<int> a,b;
    s = 0;
    cin >> n;
    for(int i=0; i<n; i++){
        int c;
        cin >> c;
        b.push_back(c);
    }
    
    a.push_back(b[0]);
    for(int j=1; j<n-1; j++){
        if(b[j-1]<=b[j]){
            a.push_back(b[j-1]);
        }
        else{
            a.push_back(b[j]);
        }
    }
    a.push_back(b[n-1]);
    
    for(int k=0; k<n; k++){
        s += a[k];
    }
    
    cout << s << endl;
}

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

int main(){
  long long A,B,K;
  cin >> A >> B >> K;
  for(int i=A;i<B+1;i++){
    if(i<=A+K-1){
      cout << i << endl;
    }else if(i>=B-K+1){
      cout << i << endl;
    }
  }
  return 0;
}

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

int main(){
  int A,B,C,X,Y;
  cin>>A>>B>>C>>X>>Y;
  C*=2;
  int64_t j=10000000000;
  for(int i=0;i<=max(X,Y);i++){
    j=min(j,(int64_t)(A*max(0,X-i)+B*max(0,Y-i)+C*i));
  }
  cout<<j<<endl;
}

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

using namespace std;

#define IOS ios::sync_with_stdio(0);cin.tie(0);

int main(){
	IOS;
	int a,b;
	cin>>a>>b;
	if(a + b == 15){
		cout<<"+"<<endl;
	}
	else if(a*b == 15){
		cout<<"*"<<endl;
	}
	else{
		cout<<"x"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
let () =
  Scanf.scanf "%d\n" @@ fun n ->
  let lst = Array.to_list (Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun d -> d) in
  let (bfr,(x,ans)) = List.fold_left
      (fun (bfr,(stock, money)) x ->
         if bfr < x then (x,(stock+(money/bfr), money - bfr*(money/bfr)))
         else (x, (0, money+bfr*stock))) (List.hd lst, (0, 1000)) (List.tl lst) in
  Printf.printf "%d\n" (bfr*x+ans)

Measured memory_bytes: 3812
namespace Test
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public class Test
    {
        public static void Main(string[] args)
        {
            var t = new Test();
            var s = Console.ReadLine();
            var sb = new StringBuilder();
            var sb2 = new StringBuilder();
            for(var i = 0; i<(s.Length - 1 )/ 2; i++)
            {
                sb.Append(s[i]);
            }

            for (var i = ((s.Length + 3) / 2) -1; i < s.Length; i++)
            {
                sb2.Append(s[i]);

            }

            if(sb.Equals(sb2))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }

        public int Gcd(int a, int b)
        {
            for (var i = b; i > 1; i -= 1)
            {
                if (a % i == 0 && b % i == 0)
                {
                    return i;
                }
            }
            return 1;
        }

        public string[] ReadInput()
        {
            return Console.ReadLine().Split(' ');
        }

        public List<int> ConvertIntList(string[] x)
        {
            var convertedList = new List<int>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(int.Parse(x[i]));
            }

            return convertedList;
        }

        public List<double> ConvertDoubleList(string[] x)
        {
            var convertedList = new List<double>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(double.Parse(x[i]));
            }

            return convertedList;
        }

        public List<long> ConvertLongList(string[] x)
        {
            var convertedList = new List<long>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(long.Parse(x[i]));
            }

            return convertedList;
        }

        public int CountContainWords(string source, string word)
        {
            var count = 0;
            var loopCount = source.Length - (word.Length - 1);
            for (var i = 0; i < loopCount; i++)
            {
                if (source.Substring(i, word.Length) == word)
                {
                    count++;
                }
            }
            return count;
        }
    }
}

Measured memory_bytes: 13140
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    auto f = [](u32 x) -> u32 { return x==2 ? 2 : x==2||x==6||x==9||x==11 ? 1 : 0; };
    u32 x, y;
    std::cin >> x >> y;
    x = f(x);
    y = f(y);
    std::cout << (x==y ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding("utf8");
let input = "";
process.stdin.on("data", function(chunk) {input += chunk;});
process.stdin.on("end", function() {main(input.split("\n"));});

function allocNode(key) {
	const p = {};
	p.key = key;
	p.left = null;
	p.right = null;
	return p;
}

function insert(p,c) {
	if (p === null) return c;
	if (c.key < p.key) {
		p.left = insert(p.left,c);
	}	else {
		p.right = insert(p.right,c);
	}
	return p;
}

function inset(p,ary) {
	if (p === null) return;
	inset(p.left,ary);
	ary.push(p.key);
	inset(p.right,ary);
}

function preset(p,ary) {
	if (p === null) return;
	ary.push(p.key);
	preset(p.left,ary);
	preset(p.right,ary);
}

function dump(p,setfunc) {
	const ary = [];
	setfunc(p,ary);
	console.log(ary.map(x => ` ${x}`).join(""));
}

function main(lines){
	const n = Number(lines[0]);
	let p, key, line, root = null;

	for (let i = 0; i < n; i++) {
		line = lines[i+1].split(" ");
		switch(line[0][0]) {
		case "i":
			key = Number(line[1]);
			p = allocNode(key);
			root = insert(root,p);
			break;
		case "p":
			dump(root,inset);
			dump(root,preset);
			break;
		}
	}
}



Measured memory_bytes: 223640
/*
	*	Created By: 'Present_Sir'
	*	Created On: Sunday 05 July 2020 02:36:47 PM IST
*/

#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define int long long
using namespace std;


void solve(){
    int n;
    cin>>n;
    if(n%1000 != 0){
        cout<<1000 - (n%1000);
    }else{
        cout<<"0";
    }
}

int32_t main(){
    IOS;
    //int t; cin>>t; while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 3652
#include <iostream>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;

bool judge(int p[],int n){
    for(int i=0;i<n-1;i++){
        if(p[i]>p[i+1]) return false;
    }
    return true;
}

int main(){
    int n;
    int p[50];
    cin >> n;
    rep(i,n) cin >> p[i];
    if(judge(p,n)){
        cout << "YES" << endl;
        return 0;
    }
    rep(i,n){
        for(int j=i+1;j<n;j++){
            swap(p[i],p[j]);
            if(judge(p,n)){
                cout << "YES" << endl;
                return 0;
            }
            swap(p[i],p[j]);
        }
    }
    cout << "NO" << endl;
    return 0;
}

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
int A, B, C;
cin >> A >> B >> C;
int K;
cin >> K;

int max_X = max(A, max(B, C));
// print(max_X);
int ans = (A + B + C - max_X) + (max_X * pow(2, K));

print(ans);
}

Measured memory_bytes: 384
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
using namespace std;
#define PI 3.14159265358979
#define rep(i,n) for(int i=0;i<n;i++)

bool check(long a)
{   
    bool seven=false;
    bool five = false;
    bool three = false;
    while(a>1)
    {
        if(a%10==3) three = true;
        if(a%10==5) five = true;
        if(a%10==7) seven = true;
        a=floor(a/10);

    }
    if(three&&five&&seven) return true;
    else return false;

}

void saiki(long n,long a,int& ans)
{
    if(a>n) return;
    if(check(a)) ans++;
    for(int i=3;i<=7;i+=2)
    {
        saiki(n,10*a+i,ans);
    }
}

int main(void){

long n;
cin>>n;

int ans =0;
saiki(n,0,ans);

cout<<ans<<endl;

}







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

int N;
int A[210];

int main() {
  cin >> N;
  for (int i = 0; i < N; ++i) cin >> A[i];
  
  int ans = 0;
  
  while (true){
    bool odd = false;
    for (int i = 0; i < N; ++i){
      if (A[i] % 2 != 0) odd = true;
    }
    
    if (odd) break;
    
    for (int i = 0; i < N; ++i){
        A[i] /= 2;
    }
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <stack>
#include <vector>

using namespace std;

using Pair = pair<int, int>;
using lint = long long;

const int mod = 1e9 + 7;
// const int mod = 998244353;

template <typename T>
vector<T> make_v(size_t a) {
  return vector<T>(a);
}

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T>
struct BinaryIndexedTree {
  vector<T> data;
  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for (++k; k > 0; k -= k & -k)
      ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for (++k; k < data.size(); k += k & -k)
      data[k] += x;
  }
};

int main() {
  int n, q;
  cin >> n >> q;
  vector<int> c(n);
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    c[i]--;
  }
  vector<Pair> p(q);
  for (int i = 0; i < q; i++) {
    cin >> p[i].second >> p[i].first;
    p[i].second--;
    p[i].first--;
  }
  vector<Pair> memo = p;
  vector<int> mark(n, -1);
  int qnow = 0;
  BinaryIndexedTree<int> bit(n);
  map<Pair, int> ret;
  sort(p.begin(), p.end());
  for (int i = 0; i < n; i++) {
    if (mark[c[i]] != -1) bit.add(mark[c[i]], -1);
    mark[c[i]] = i;
    bit.add(i, 1);
    while (qnow<q&&p[qnow].first == i) {
      int r = bit.sum(p[qnow].first);
      if (p[qnow].second > 0) r -= bit.sum(p[qnow].second - 1);
      ret[p[qnow]] = r;
      qnow++;
    }
  }
  for (int i = 0; i < q; i++) {
    cout << ret[memo[i]] << endl;
  }
}


Measured memory_bytes: 48740
#include <iostream>
#include <vector>
#define rep(i, n) for(int i=0;i<(n);i++)
using namespace std;

int N, K;
int A[200000];

// 回数k以内で長さlにカットできるかどうか
bool can_cut(int l) {
  int cnt = 0;
  rep(i, N) {
    cnt += A[i] / l;
    if (A[i] % l == 0) cnt--;
  }
  return cnt <= K;
}

int main() {
  cin >> N >> K;
  rep(i, N) cin >> A[i];
  
  // binary search
  int lb = 0, ub = 1e9;
  while (ub - lb > 1) {
    int mid = (lb + ub) / 2;
    if (can_cut(mid)) {
      ub = mid;
    } else {
      lb = mid;
    }
  }
  
  cout << ub;
}

Measured memory_bytes: 4344
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
  int n,m;
  cin>>n>>m;
  vector<int> a(n);
  vector<pair<int,int>> p(m);
  REP(i,n) cin>>a[i];
  REP(i,m){
    int b,c;
    cin>>b>>c;
    p[i]=make_pair(c,b);
  }

  sort(ALL(a));
  sort(ALL(p),greater<pair<int,int>>());
  ll ans=0;
  int j=0;
  REP(i,n){
    if(j==p.size()){
      ans+=a[i];
      continue;
    }
    ans+=max(a[i],p[j].first);
    p[j].second--;
    if(p[j].second==0) j++;
  }
  cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 1536
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 105005
#define PI 	3.14159265358979323846

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    static int a[1000000];
    int n;
    cin >> n;
    fill(a,a+n+1,999999);
    a[0] = 0;
    REP(i,n+1){
        a[i+1] = min((int)a[i+1],(int)a[i]+1);
        for(int j=6;j<=n;j*=6)a[i+j] = min((int)a[i+j],(int)a[i]+1);
        for(int j=9;j<=n;j*=9)a[i+j] = min((int)a[i+j],(int)a[i]+1);
    }
    cout << a[n] << endl;
    return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
 
int main(){
 int A,B,C;
  cin>>A>>B>>C;
  int cincos=0,siete=0;
  if(A==5) cincos++;
  if(A==7) siete++;
  if(B==5) cincos++;
  if(B==7) siete++;
  if(C==5) cincos++;
  if(C==7) siete++;
  
  if(cincos==2&&siete==1)
    cout<<"YES\n";
  else
    cout<<"NO\n";
  
  return 0;
}

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

int main() 
{
    int N;
    cin >> N;
    vector<char>S(N);
    vector<char>T(N);
    for (int i = 0; i < N; i++) {
        cin >> S[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> T[i];
    }
    
    string ans = "";
    for (int i = 0; i < N; i++) {
        ans += S[i];
        ans += T[i];
    }
    cout << ans << endl;    
}

Measured memory_bytes: 256
import scala.collection.mutable.{TreeSet, TreeMap}

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val H, W = sc.nextInt()
  val ABs = Array.fill(H)((sc.nextInt() - 1, sc.nextInt()))
  val s = TreeMap[Int, Int]()
  val v = TreeSet[(Int, Int)]()
  for (i <- 0 until W) {
    s += i -> i
    v += ((0, i))
  }
  val pw = new java.io.PrintWriter(Console.out)
  for (k <- 0 until H) {
    val (a, b) = ABs(k)
    val it = s.keysIteratorFrom(a)
    var mr = -1
    var continue = true
    while (it.hasNext && continue) {
      val e = it.next()
      if (e > b) {
        continue = false
      } else {
        mr = mr.max(s(e))
        v -= ((e - s(e), e))
        s -= e
      }
    }
    if (mr != -1 && b < W) {
      s += b -> mr
      v += ((b - mr, b))
    }
    if (v.isEmpty) {
      pw.println(-1)
    } else {
      pw.println(v.head._1 + k + 1)
    }
  }
  pw.flush()
}

Measured memory_bytes: 110820
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/

int main(){
    int n;
    long double a[100005], hoge[100005];
    cin >> n;
    rep(i, n)cin >> a[i];
    sort(a, a + n);
    hoge[0] = a[0];
    REP(i, 1, n){
        hoge[i] = a[i] + hoge[i - 1];
    }
  
    reverse(a, a + n);
    reverse(hoge, hoge + n);
 /*   
    cout << "a ";
    rep(i, n)cout << a[i] << " ";
    cout << endl;
    cout << "hoge ";
    rep(i, n)cout << hoge[i] << " ";
    cout << endl;
*/
    REP(i, 1, n){
        if(hoge[i] < a[i - 1] / 2){
            cout << i << endl;
            return 0;
        }
    }

    cout << n << endl;
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;

int main(){
    int n, m;
    cin >> n >> m;
    vvi G(n);
    rep(i,m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vi vec(n);
    rep(i,n) vec[i] = i;
    int cnt = 0;
    do {
        // rep(i,n){
        //     printf("%d ", vec[i]);
        // }
        // printf("\n");

        rep(i,n-1){
            bool flag = false;
            for (auto nv : G[vec[i]]){
                if (nv == vec[i+1]) flag = true;
            }
            if (!flag) break;
            if (i == n-2) cnt++;
        }
    } while (next_permutation(vec.begin() + 1, vec.end()));

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	deque <int> q;
	int n, qq, x, i;
	string s;
	cin >> s;
	n = s.length();
	fo(i, 0, n)
	q.push_back(s[i] - 'a');
	
	cin >> qq;
	int cnt = 0;
	fo(i, 0, qq){
		cin >> n;
		if(n == 1)
		cnt++;
		else{
			cin >> x;
			char c;
			cin >> c;
			int sum = x + cnt;
			if(sum % 2) q.push_front(c - 'a');
			else q.push_back(c - 'a');
		}
	}
	s = "";
	for(auto x : q)
	s += char(x + 'a');
	if(cnt & 1) reverse(all(s));
	cout << s;
}


Measured memory_bytes: 2064
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
class Bridge {
private:
	int size_, cnt0; vector<vector<int>>x; vector<int> ord, low, used; vector<pair<int, int>>brd;
public:
	Bridge() : size_(0), x(vector<vector<int>>()) {};
	Bridge(int size__) : size_(size__) {
		x.resize(size__);
		ord.resize(size__);
		low.resize(size__);
		used.resize(size__);
	}
	void unite(int a1, int a2) {
		x[a1].push_back(a2);
		x[a2].push_back(a1);
	}
	void dfs(int p, int k) {
		low[p] = cnt0; used[p] = 1;
		ord[p] = cnt0; cnt0++;
		for (int i = 0; i < x[p].size(); i++) {
			int to = x[p][i];
			if (used[to] == 0) {
				dfs(to, p);
				low[p] = min(low[p], low[to]);
				if (ord[p] < low[to]) {
					int aa1 = p, aa2 = to; if (aa1 > aa2)swap(aa1, aa2);
					brd.push_back(make_pair(aa1, aa2));
				}
			}
			else if (to != k) {
				low[p] = min(low[p], ord[to]);
			}
		}
	}
	vector<pair<int, int>> bridge(int size__, int st) {
		brd.clear(); cnt0 = 0;
		for (int i = 0; i < size__; i++) { ord[i] = 0; low[i] = 0; used[i] = 0; }
		dfs(st, -1);
		return brd;
	}
	int size() { return size_; }
};
int main() {
	int n, m, a, b; cin >> n >> m;
	Bridge B(n + 1);
	for (int i = 0; i < m; i++) {
		cin >> a >> b; B.unite(a, b);
	}
	vector<pair<int, int>>W = B.bridge(n + 1, 1);
	sort(W.begin(), W.end());
	for (int i = 0; i < W.size(); i++)cout << W[i].first << ' ' << W[i].second << endl;
	return 0;
}

Measured memory_bytes: 4416
n = int(input())
P = map(int,input().split())
p = [i for i in P]
p.sort()
if n % 2 == 1:
    print(0)
elif len(p) == 2:
    if p[0]==p[1]:
        print(0)
    else:
        p.sort()
        print(p[1]-p[0])
else:
    if p[(n//2)] == p[(n//2)-1]:
        print(0)
    else:
        print(p[n//2]-p[(n//2)-1])


Measured memory_bytes: 14428
#include<bits/stdc++.h>
using namespace std;
int n,k,a[222222],ans=-1;
int main()
{
	cin>>k>>n;for(int i=0;i<n;++i){
		cin>>a[i];
		if(i>0){
			ans=max(ans,a[i]-a[i-1]);
		}
	}
	cout<<k-max(ans,k-a[n-1]+a[0]);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using stkll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

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

    ll N;
    cin >> N;
    vll m(N, 0), S(N);
    vector<pll> v1, v2;
    vector<string> s(N);
    rep(i, N) {
        cin >> s[i];
        ll tmp = 0;
        for(auto c : s[i]) {
            if(c == '(') tmp++;
            else tmp--;
            chmin(m[i], tmp);
        }
        S[i] = tmp;

        if(S[i] >= 0) v1.emplace_back(-m[i], i);
        else v2.emplace_back(m[i] - S[i], i);
    }
    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());

    ll tot = 0, last = 0;
    for(auto p : v1) {
        auto idx = p.second;
        for(auto c : s[idx]) {
            if(c == '(') last++;
            else last--;
            chmin(tot, last);
        }
    }
    for(auto p : v2) {
        auto idx = p.second;
        for(auto c : s[idx]) {
            if(c == '(') last++;
            else last--;
            chmin(tot, last);
        }
    }
    if(tot == 0 && last == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 65912
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	_, x, y := extgcd(a, b)
	fmt.Printf("%d %d\n", x, y)
}

func extgcd(a, b int) (d, x, y int) {
	if b == 0 {
		x = 1
		y = 0
		return a, x, y
	} else {

	}

	d, y, x = extgcd(b, a%b)
	y -= (a / b) * x
	return d, x, y
}



Measured memory_bytes: 1160
from collections import defaultdict
from operator import itemgetter
N, M = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
ans = float("inf")
for _ in range(M):
    L = []
    cnt = defaultdict(int)
    for a in A:
        if len(a)!=0:
            a0 = a[0]
            L.append(a0)
            cnt[a0] += 1
    ama, ma = max(cnt.items(), key=itemgetter(1))
    ans = min(ans, ma)
    for a in A:
        a.remove(ama)
print(ans)


Measured memory_bytes: 4588
#include<functional>
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>

using namespace std;
using ll = long long;
using vl = vector<ll>;
	
int main() {
	int n;// O(10^5)
	cin >> n;
	vl A(n*3);
	for (int i = 0; i < 3*n; i++) {
		cin >> A[i];
	}
	priority_queue<ll,vl,greater<ll>> que;
	vl S(n+1,0);
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		que.push(A[i]);
		sum += A[i];
	}
	S[0] = sum;
	for (int i =0; i < n; i++) {
		sum += A[i + n];
		que.push(A[i + n]);
		sum -= que.top();
		que.pop();
		S[i+1] = sum;
	}

	priority_queue<ll> que2;
	vl T(n+1,0);
	sum = 0;
	for (int i = 2*n; i < 3*n; i++) {
		que2.push(A[i]);
		sum += A[i];
	}
	T[n] = sum;
	for (int i =n-1; i>=0;i--) {
		sum += A[i + n];
		que2.push(A[i + n]);
		sum -= que2.top();
		que2.pop();
		T[i] = sum;
	}
	ll ans = -10000000000000000;
	for (int i = 0; i <= n  ; i++) {
		if (S[i] >= 0 && T[i] >= 0) {
			ans = max(ans, S[i] - T[i]);
		}
	}
	//for (int i = 0; i <=  n; i++) {
	//	cout << S[i] << " " << T[i] << endl;
	//}
	cout << ans << endl;
	return 0;	
}

Measured memory_bytes: 6516
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    vector<string> S(H);
    for (int i = 0; i < H; ++i) {
        cin >> S[i];
    }

    vector<vector<ll>> left(H, vector<ll>(W, 0));
    vector<vector<ll>> right(H, vector<ll>(W, 0));
    for (int i = 0; i < H; ++i) {
        ll c = 0;
        ll d = 0;

        for (int j = 0; j < W; ++j) {
            left[i][j] = c;
            if (S[i][j] == '#') {
                c = 0;
            } else {
                ++c;
            }

            right[i][W-j-1] = d;
            if (S[i][W-j-1] == '#') {
                d = 0;
            } else {
                ++d;
            }
        }
    }

    vector<vector<ll>> up(H, vector<ll>(W, 0));
    vector<vector<ll>> down(H, vector<ll>(W, 0));
    for (int j = 0; j < W; ++j) {
        ll c = 0;
        ll d = 0;

        for (int i = 0; i < H; ++i) {
            up[i][j] = c;
            if (S[i][j] == '#') {
                c = 0;
            } else {
                ++c;
            }

            down[H-i-1][j] = d;
            if (S[H-i-1][j] == '#') {
                d = 0;
            } else {
                ++d;
            }
        }
    }

    ll ans = 0;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (S[i][j] == '#') {
                continue;
            }

            ans = max(ans, left[i][j] + right[i][j] + up[i][j] + down[i][j] + 1);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 131712
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	a := getNextInt(scanner)
	b := getNextInt(scanner)

	ans := "Hello World"
	if n == 2 {
		ans = fmt.Sprintf("%d", a+b)
	}
	fmt.Fprintln(writer, ans)
	writer.Flush()
}


Measured memory_bytes: 640
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

map<string, LL> dp[105];
map<char, int> idx;

int main() {
	int n;
	cin >> n;
	string ACGT= "ACGT";
	set<string> ng({ "AGC", "ACG", "GAC", "AGTC", "AGGC", "ATGC" ,"AAGC", "AACG", "AGAC", "CAGC", "CACG", "CGAC", "GAGC", "GACG", "GGAC", "TAGC", "TACG", "TGAC"});
	dp[0][""] = 1LL;
	REP(i, n) {
		for (auto s : dp[i]) {
			auto str = s.first;
			auto val = s.second;
			if (ng.end() != ng.find(str))continue;
			REP(j, 4) {
				str = s.first + ACGT[j];
				if (str.length() > 4) {
					str = str.substr(1, 4);
				}
				dp[i + 1][str] = (dp[i + 1][str] + val) % MOD;
			}
		}
	}
	LL ret = 0;
	for (auto s : dp[n]) {
		auto str = s.first;
		auto val = s.second;
		if (ng.end() != ng.find(str))continue;
		ret = (ret + val) % MOD;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000000000
using namespace std;
using ll = long long;
int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    int ans = a + b + c;
    int tmp = max(a, max(b, c));
    ans -= tmp;
    rep(i,k){
        tmp *= 2;
    }
    ans += tmp;
    cout << ans << endl;
}


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

int main(){
    int n; cin >> n;
    int even=0; int odd=0;
    for(int i=0;i<n;i++){
        int a; cin >> a;
        if(a%2==0)even++;
        else odd++;
    }
    if(odd==0||even==0){
        cout << 0 << endl;
    }
    else if(odd%2==1){
        cout << n-1 << endl;
    }
    else{
        cout << n-2 << endl;
    }
}


Measured memory_bytes: 3100
#include <iostream>
//#include <bits/stdc++.h>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <map>
#include <iterator>
#include <iomanip>
#include <queue>
#include <utility>

using namespace std;
#define ll long long int
#define c(x) ll x;cin>>x
#define cc(x,y) ll x,y;cin>>x>>y
#define ccc(x,y,z) ll x,y,z; cin>>x>>y>>z
#define db long double
#define fast cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false)
#define inf 200000000000000
#define mod 1000000007
#define eps 1e-7
#define PI 3.1415926535897932385
#define pb push_back
#define bitc  __builtin_popcountll
#define mp make_pair
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()
#define len(x) (ll)(x).size()
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define foreach(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define print(arr,n) rep(i,n) cout<<arr[i]<<" "; cout<<endl
#define print2(arr,n,m) rep(i,n){ rep(j,m) cout<<arr[i][j]<<" "; cout<<endl; }
#define dyn1(arr,n) ll* arr=new ll[n]; rep(i,n) arr[i]=0;
#define dyn2(arr,n,m) ll** arr=new ll*[(n)]; rep(i,n) arr[i]=new ll[m]; rep(i,n) rep(j,m) arr[i][j]=0
#define carr(arr,n) rep(i,n) cin>>arr[i]
#define carr2(arr,n,m) rep(i,n) rep(j,m) cin>>arr[i][j]
#define debug(a) cout<<" :: "<<#a<<" == "<<a<<endl
#define debug2(a,b) cout<<" :: "<<#a<<" == "<<a<<" :: "<<#b<<" == "<<b<<endl
typedef pair<int,int> ii;
typedef vector<ii> vii;

inline ll maxim(ll a,ll b) {if(a>b) return a; else return b;}
inline ll minim(ll a,ll b) {if(a<b) return a; else return b;}
inline bool equals(double a, double b){ return fabs(a - b) < 1e-9; }
ll gcd(ll a, ll b){ return b==0 ? a : gcd(b, a%b); }


ll binpow(ll a, ll b)
{
    ll res = 1;
    while (b > 0)
    {
        if (b & 1) res = (res * a)%mod;
        a = (a * a)%mod;
        b >>= 1;
    }
    return res;
}
/*
ll ncr(ll n,ll r)
{
  if(r>n) return 0;
  if((n==r)||(r==0))
  {
    return 1;
  }
  if(r==1) return n;
  if(r>n-r)
  {
    r=n-r;
  }

  string key=to_string(n)+"|"+to_string(r);
  if(m.find(key)==m.end())
  {
    ll answer=ncr(n-1,r-1)+ncr(n-1,r);
    m[key]=answer;
  }
  //cout<<key<<" "<<m[key]<<endl;
  return m[key];
}
*/

int modInverse(int a, int m)
{
    int m0 = m;
    int y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        // q is quotient
        int q = a / m;
        int t = m;
        // m is remainder now, process same as
        // Euclid's algo
        m = a % m, a = t;
        t = y;
        // Update y and x
        y = x - q * y;
        x = t;
    }
    // Make x positive
    if (x < 0)
       x += m0;
    return x;
}

ll arr[200001];

int main()
{
  fast;
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  cout<<setprecision(10)<<fixed;
  cc(n,r);
  if(n>=10) cout<<r<<endl;
  else cout<<r+100*(10-n)<<endl;
  return 0;
}


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

using namespace std;
using Int = long long;

signed main(){
    Int n, k;
    cin >> n >> k;
    vector<Int> t;
    for (int i = 1; i < n+1; i++){
        if (k >= i) {
            Int tmp = int(ceil(log2(double(k) / double(i))));
            t.push_back(tmp);
        } else {
            t.push_back(0);
        }
    }
    double deno = n * pow(2, t[0]);
    double num = 1;
    for (int i = 1; i < n; i++){
        num += pow(2, (t[0] - t[i]));
    }
    double ans = num / deno;

    cout << setprecision(12) << ans << endl;
}

Measured memory_bytes: 1400