akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define x first
#define y second
using pii = pair<int, int>;
const int N = 1e3 + 100;


namespace solver {
int n;
int k;
int a[N][N];
int r[N];
int c[N];

const int T = 100;

mt19937 rnd;

bool solve() {
	for (int i = 0; i < n; ++i) {
		fill_n(a[i], n, false);	
	}
	fill_n(r, n, 0);
	fill_n(c, n, 0);
	assert((n * k) % 3 == 0);
	for (int it = 0; it < n * k / 3; ++it) {
		vector<pii> cij;
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j + 1 < n; ++j) {
				if (r[i] < k && c[j] < k && c[j + 1] < k && !a[i][j] && !a[i][j + 1]) {
					cij.emplace_back(i, j);
				}
			}
		}
		if (cij.empty()) {
			return false;
		}
		auto p = cij[rnd() % cij.size()];
		int i = p.x;
		int j = p.y;
		++r[i];
		++c[j];
		++c[j + 1];
		a[i][j] = it + 1;
		a[i][j + 1] = it + 1;
	}
	for (int it = 0; it < n * k / 3; ++it) {
		vector<pii> cij;
		for (int i = 0; i + 1 < n; ++i) {
			for (int j = 0; j < n; ++j) {
				if (r[i] < k && c[j] < k && r[i + 1] < k && !a[i][j] && !a[i + 1][j]) {
					cij.emplace_back(i, j);
				}
			}
		}
		if (cij.empty()) {
			return false;
		}
		auto p = cij[rnd() % cij.size()];
		int i = p.x;
		int j = p.y;
		++r[i];
		++r[i + 1];
		++c[j];
		a[i][j] = it + 1 + n * k / 3;
		a[i + 1][j] = it + 1 + n * k / 3;
	}
	return true;
}
}

char buf[N][N];

void solvex(int x, int y = 3) {
	solver::n = x;
	solver::k = y;
	while (!solver::solve()) {
		;
	}
	for (int i = 0; i < x; ++i) {
		for (int j = 0; j < x; ++j) {
			if (solver::a[i][j]) {
				buf[i][j] = char('a' + solver::a[i][j] - 1);
			} else {
				buf[i][j] = '.';
			}
		}
	}
}

int n;
char ans[N][N];

signed main() {
#ifdef LC
	assert(freopen("input.txt", "r", stdin));
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> n;
	if (n <= 2) {
		cout << "-1\n";
	} else if (n <= 4) {
		solvex(n, n == 4 ? 3 : 1);
		for (int i = 0; i < n; ++i) {
			cout << buf[i] << "\n";
		}
		cout << "\n";
	} else {
		fill_n(ans[0], N * N, '.');
		int i = 0;
		while (n - i >= 8) {
			solvex(4);
			for (int x = 0; x < 4; ++x) {
				for (int y = 0; y < 4; ++y) {
					ans[i + x][i + y] = buf[x][y];
				}
			}
			i += 4;
		}
		int len = n - i;
		assert(4 <= len && len < 8);
		solvex(len);
		for (int x = 0; x < len; ++x) {
			for (int y = 0; y < len; ++y) {
				ans[i + x][i + y] = buf[x][y];
			}
		}
		for (int x = 0; x < n; ++x) {
			for (int y = 0; y < n; ++y) {
				cout << ans[x][y];
			}
			cout << "\n";
		}
	}

	return 0;
}


Measured memory_bytes: 4480
#include<cstdio>
#include<cctype>
#include<algorithm>
using namespace std;
long long n,ans,a[200005];
inline long long read(){
	long long x=0;char ch=getchar();
	while (!isdigit(ch)) ch=getchar();
	while (isdigit(ch)) x=(x<<3)+(x<<1)+ch-48,ch=getchar();
	return x;
}
int main()
{
	n=read();
	for (int i=1;i<=n;++i) a[i]=read()-i;
	sort(a+1,a+1+n);long long mid=a[n+1>>1];
	for (int i=1;i<=n;++i) ans+=abs(a[i]-mid);
	printf("%lld\n",ans);
	return 0;
}


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

using namespace std;

int main() {
  int n; cin >> n;
  vector <int> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int len = 1, mx = 1;
  for(int i = 1; i < n; i++) {
    if(a[i - 1] >= a[i]) len++;
    else {
      if(len > mx) {
        mx = len;
      }
      len = 1;
    }
  }
  if(len > mx) mx = len;
  cout << mx - 1 << '\n';
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) cin >> a[i];
    int l = 0, r = 1e9;
    while (r-l>1) {
        int x = (l+r)/2;
        auto f = [&] (int d) {
            int res = 0;
            rep(i, n) res += (a[i]-1) / d;
            return (res <= k);
        };
        if (f(x)) r = x;
        else l = x;
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 3976
import math

class SegTreeMax:
    def __init__(self, n):
        m = 1
        while m < n:
            m *= 2
        self.n = m
        self.dat = [0] * (2 * self.n - 1)

    def update(self, k, x):
        k += self.n - 1 # 木上のインデックス
        self.dat[k] = x
        while k > 0:
            k = (k - 1) // 2
            self.dat[k] = max(
                self.dat[2 * k + 1],
                self.dat[2 * k + 2]
            )
    
    def query(self, a, b, k=0, l=0, r=None):
        if not r:
            r = self.n
        if r <= a or b <= l:
            return 0
        if a <= l and r <= b:
            return self.dat[k]
        m = (l + r) // 2
        vl = self.query(a, b, k * 2 + 1, l, m)
        vr = self.query(a, b, k * 2 + 2, m, r)
        return max(vl, vr)


def submit():
    n = int(input())
    h = list(map(int, input().split()))
    a = list(map(int, input().split()))

    # dpをセグメントツリーで管理
    # dp[hi] = a[i] + max(dp[j]) for j < hi
    sgt = SegTreeMax(n)
    
    for i in range(n):
        d = sgt.query(0, h[i])
        if d > 0:
            sgt.update(h[i] - 1, a[i] + d)
        else:
            sgt.update(h[i] - 1, a[i])
    print(sgt.query(0, n))


if __name__ == "__main__":
    submit()

Measured memory_bytes: 125392
import std.stdio, std.string, std.array, std.conv, std.algorithm;

void main() {
    int n = readln.chomp.to!int;
    double[] v = readln.split.to!(double[]);
    v.sort!("a > b");
    while (v.length > 1) {
        double tmp = v[$-1];
        v.popBack;
        v[$-1] = (v[$-1] + tmp) / 2.0;
    }
    writefln("%.8f", v[0]);
}

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

class sample
{
		static void Main()
		{
				int N = Convert.ToInt32(Console.ReadLine());
				string[] input = Console.ReadLine().Split(' ');
				List<int> list = new List<int>();
				List<int> dislist = new List<int>();

				for(int i=0;i<N;i++)
				{
						list.Add(Convert.ToInt32(input[i]));
				}

				dislist =list.Distinct().ToList();

				if(dislist.Count==list.Count)
				{
					Console.WriteLine("YES");
				}
				else
				{
					Console.WriteLine("NO");
				}
		}
}





Measured memory_bytes: 39732
n, k = list(map(int, input().split()))

snuke = [] # お菓子を持っていないなら0
for i in range(n):
    snuke.append(0) # snukeは0がn個入っているリスト

for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for j in range(d):
        a[j] -= 1 # a[j]番目だけど、0から始める添え字に直すので1引いておく
        if snuke[a[j]] == 0:
            snuke[a[j]] = 1
            n -= 1 # a[j]番目のすぬけくんが初めてお菓子を貰うならnから1引く

print(n)

Measured memory_bytes: 9200
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
using namespace std;
using ll = long long;
using ld = long double;
ll mod = ll(1e9)+7;
ll inf = ll(5e18);
template<typename T1, typename T2> ll ceill(T1 a, T2 b){ return (a+b-1)/b; }
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

namespace dbg {
    using ll = long long;

    class Debug {
    public:
        Debug(){}
        template<typename T>
        void vd(vector<T> vec);
        template<typename T>
        void vd2(vector<vector<T>> vec);
        template<typename T>
        void ad(T *arr, ll n);
        template<typename T, size_t N>
        void ad2(T (&arr)[N], ll n);
        template<typename T>
        void md(T mp);
    };

    template<typename T>
    void Debug::vd(vector<T> vec) {
        for (auto vv : vec) cout << vv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::vd2(vector<vector<T>> vec) {
        for (auto vv : vec) for (auto vvv : vv) cout << vvv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::ad(T *arr, ll n) {
        for (int i = 0; i <= n; i++) cout << arr[i] << " ";
        cout << endl;
    }

    template<typename T, size_t N>
    void Debug::ad2(T (&arr)[N], ll n) {
        for (int i = 0; i <= N; i++) for (int j = 0; j <= n; j++) cout << arr[i][j] << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::md(T mp) {
        cout << "key : value" << endl;
        for (auto const &m : mp) cout << m.first << " : " << m.second << endl;
        cout << endl;
    }

}

#endif //INCLUDE_DEBUG_HPP

using dbg::Debug;
Debug debug;

class BReversi {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int n;
	    in >> n;
	    vector<int> c(n);
	    for(int i=0; i<n; i++){
	        in >> c[i];
	    }

	    vector<ll> dp(n+1, 0);
	    vector<ll> memo(200005, 0);
	    dp[0] = 1;
	    for(int i=0; i<n; i++){
	        if(i != 0 && c[i-1] == c[i]) {
	            dp[i+1] = dp[i];
	            continue;
	        }
            dp[i+1] = dp[i] + memo[c[i]];
            dp[i+1] %= mod;
            memo[c[i]] = dp[i+1];
	    }

	    //debug.vd(dp);

	    out << dp[n] << endl;
	}
};


int main() {
	BReversi solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 4096
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#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++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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; }

ll N,sum;

int main(){
    cin>>N;
    ll A[N];
    rep(i,N){
        cin>>A[i];
        if(i%2==0)sum+=A[i];
        else sum-=A[i];
    }
    cout<<sum<<" ";
    rep(i,N-1){
        sum=A[i]-sum/2;
        sum*=2;
        cout<<sum<<" ";
    }
    out("");
    
    

}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl



int main(){
    int n,m,x;
    cin>>n>>m>>x;
    int l=0,r=0;
    REP(i,m){
        int a;
        cin>>a;
        if(a<x){
            l++;
        }else{
            r++;
        }
    }
    cout<<min(l,r)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


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

  ll ans = 0;
  int cnt = 0;
  while (h){
    h /= 2;
    ans += pow(2, cnt);
    cnt++;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i];
    if(i == SZ(s)-1) {
      cout << endl;
    } else {
      cout << " ";
    }
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);
  double d; cin >> d;

  cout << max(floor(d+eps) + 1, d * sqrt(2)) << endl;

}



Measured memory_bytes: 3232
<?php

[$N] = fscanf(STDIN, "%d");
$A = fscanf(STDIN, str_repeat("%d", $N));
$max = $A[0];
$ans = 0;
foreach($A as $value){
    if($value > $max){
        $max = $value;
    }else{
        $ans += $max - $value;
    }
}
echo $ans;

Measured memory_bytes: 27440
/* 実装例　Atcoder Beginers Contest 174-F Range Set query */
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
signed main(){
    int n,q;
    std::cin >> n >> q;
    int sq=2*sqrt(n);
    std::vector<int> c(n);
    rep(i,n){
        std::cin >> c[i];
        c[i]--;
    }
    std::vector<int> l(q),r(q);
    rep(i,q){
        std::cin >> l[i] >> r[i];
        l[i]--;
    }
    
    std::vector<int> qu(q);
    rep(i,q) qu[i]=i;
    std::sort(ALL(qu),[&](int i,int j){if(l[i]/sq!=l[j]/sq) return l[i]<l[j]; else return r[i]<r[j];});
    
    std::vector<int> ans(q);
    std::vector<int> cnt(n,0);
    int nl=0,nr=0;
    int res=0;
    for(int i:qu){
        while(nl>l[i]){
            nl--;
            if(cnt[c[nl]]++==0) res++;
        }
        while(nl< l[i]){
            if(--cnt[c[nl]]==0) res--;
            nl++;
        }
        while(nr< r[i]){
            if(cnt[c[nr]]++==0) res++;
            nr++;
        }
        while(nr> r[i]){
            nr--;
            if(--cnt[c[nr]]==0) res--;
        }
        /* ここから結果 */
        ans[i]=res;
    }
    rep(i,q) std::cout << ans[i] << "\n";
}


Measured memory_bytes: 15460
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;

string T;

int main(){
    cin>>T;

    rep(i,T.size()){
        if(T[i]=='?') T[i]='D';
    }

    cout<<T<<endl;
}

Measured memory_bytes: 3760
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]

s_set = set(s)

ans = 0
for card in s_set:
    count = s.count(card) - t.count(card)
    ans = max(count, ans)

print(ans)


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(input.readLine());

        System.out.println(n == getRevers(n) ? "Yes" : "No");
    }

    public static int getRevers(int n){
        int reverse = 0;
        while (n > 9){
            reverse = reverse * 10 + (n %10);
            n /= 10;
        }
        if (n > 0)
            reverse = reverse  * 10 + n;

        return reverse;
    }
}


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


int n, a[10], cnt;
string s;
long long ans=0, c;

int main(){
cin >> n;
for(int i =0; i<n; i++){
    cin >> s;
    if(s[0]=='M')a[0]++;
    if(s[0]=='A')a[1]++;
    if(s[0]=='C')a[2]++;
    if(s[0]=='R')a[3]++;
    if(s[0]=='H')a[4]++;
}
for(int i =0; i<(1<<5); i++){
        cnt =0;c=1;
    for(int j =0; j<5; j++){
        if(i&(1<<j))cnt++;
    }
    if(cnt==3){
        for(int j=0; j<5; j++){
            if(i&(1<<j)){
                c*=a[j];
            }
        }
        ans+=c;
    }

    
}
cout << ans << endl;

return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)  for(long long i=0;i<n;++i)
#define rep1(i,n) for(long long i=1;i<=n;++i)
#define deb(x) cerr << #x <<": " << x << '\n';
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long double ld;
typedef long long ll;

int main(){
    ios;
    int k; cin >> k;
    string s;
    cin >> s;
    int len = s.size();
    
    rep(i,min(len,k)){
        cout << s[i];
    }
    if(s.size() > k){
    rep(i, 3){
        cout << '.';
    }
        }
    return 0;
}


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

int main() {
    string s;
    cin>>s;
    string l[4]={"dream","dreamer","erase","eraser"};
    rep(i,4) reverse(l[i].begin(),l[i].end());
    reverse(s.begin(),s.end());
    bool f1=true;
    rep(i,s.size()) {
        bool f2=false;
        rep(j,4) {
            string t=l[j];
            if (s.substr(i,t.size())==t) {
                f2=true;
                i+=t.size()-1;
            }
        }
        if (!f2) {
            f1=false;
            break;
        }
    }
    if (f1) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  vector<string> w(n);
  rep(i, n) cin >> w[i];
  string prev = w[0];
  unordered_set<string> dic;
  dic.insert(w[0]);
  REP(i, 1, n) {
    if (dic.find(w[i]) != dic.end()) {
      cout << "No" << endl;
      return 0;
    }
    dic.insert(w[i]);
    if (prev[prev.size() - 1] != w[i][0]) {
      cout << "No" << endl;
      return 0;
    }
    prev = w[i];
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL N, M, X;
	cin >> N >> M >> X;
	VLL C(N);
	VVLL A;
	A.resize(N, VLL(M));
	for (LL n = 0; n < N; n++) {
		cin >> C[n];
		for (LL m = 0; m < M; m++) {
			cin >> A[n][m];
		}
	}
	LL ans = 1e9;
	for (LL code = 0; code < ((LL)1 << N); code++) {
		VLL temp(M,0);
		LL tempc = 0;
		for (LL n = 0; n < N; n++) {
			if ((code & ((LL)1 << n)) == 0)continue;
			tempc += C[n];
			for (LL m = 0; m < M; m++) {
				temp[m] += A[n][m];
			}
		}
		LL m = 0;
		for (; m < M; m++) {
			if (temp[m] < X)break;
		}
		if (m == M)ans = min(ans,tempc);
	}
	cout << (ans == 1e9?-1:ans) << "\n";
	return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<61;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

typedef complex<double> vec;

// ??\???
void In(vec& p){
	double x,y;
	cin>>x>>y;
	p=vec(x,y);
}

// ??????
void Out(vec p){
	cout<<syosu(10)<<p.real()<<' '<<p.imag()<<endl;
}

// ??????
double IP(vec p,vec q){
	return p.real()*q.real()+p.imag()*q.imag();
}

// ?°???±
vec Proj(vec a,vec b,vec p){
	vec A=p-a,B=b-a;
	double l=abs(B);
	return B*IP(A,B)/(l*l)+a;
}

// ????°?
vec Ref(vec a,vec b,vec p){
	return Proj(a,b,p)*2.0-p;
}

int n;
vec a,b;

int main(){
	In(a);In(b);
	cin>>n;
	for(int i=0;i<n;i++){
		vec p;
		In(p);
		Out(Ref(a,b,p));
	}
}

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

using namespace std;

#define PI 3.14159265358979323846264338327950L

int main(void){
    int ans=0,max=-100;
    string str;

    cin>>str;


    ans=0;
    for(int i=0;i<str.size();i++){
        if(str[i] == 'R'){
            ans++;
        }else{
            if(max < ans){
                max=ans;
            }
            ans=0;
        }
    }

                if(max < ans){
                max=ans;
            }

    


    cout<<max<<endl;

    return 0;
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define SORT(v) sort((v).begin(), (v).end())
#define REV(v) sort((v).begin(), (v).end(), greater<int>())
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};

int main() {
  int n;
  cin >> n;
  int d[n];
  rep(i, n) cin >> d[i];
  sort(d, d + n);
  if(n % 2 == 1) {
    cout << 0;
    return 0;
  } else {
    int m = n / 2 - 1;
    cout << d[m + 1] - d[m] << endl;
  }
  return 0;
}


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

int main(void){
  int a, b;
  cin >> a >> b;
  int m = 1, ans = 0;
  while(1){
    if(m >= b) break;
    m += a - 1;
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 2222222
#define M 1000000007
typedef long long LL;

LL f[N];

LL qpow(LL x, int y)
{
	if(!y) return 1;
	LL t = qpow(x, y >> 1);
	t = t * t % M;
	if(y & 1) t = t * x % M;
	return t;
}

LL S(int x, int y)
{
	LL ans = f[x + y + 2];
	ans = ans * qpow(f[y + 1], M - 2) % M;
	ans = ans * qpow(f[x + 1], M - 2) % M;
	return ans - 1;
}

int main() 
{
	int r1, c1, r2, c2, m, i, j;
	LL sum;
		
	scanf("%d%d%d%d", &r1, &c1, &r2, &c2);
	m = r2 + c2 + 2;
	for(i = 2, f[0] = f[j = 1] = 1; i <= m; j = i++){
		f[i] = f[j] * (LL)i % M;
	}
	sum = S(r2, c2) - S(r1 - 1, c2);
	if(sum < 0) sum += M;
	sum -= S(r2, c1 - 1);
	if(sum < 0) sum += M;
	sum += S(r1 - 1, c1 - 1);
	if(sum >= M) sum -= M;
	printf("%lld\n", sum);
		
	return 0;
}

Measured memory_bytes: 16512
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int A[511][511];

LL M[511][511];
LL P[511][511];

LL MINUS(int l, int r) {
    LL tmp = M[r][r] - M[r][l] - M[l][r] + M[l][l];
    LL ret = 0;
    for (int i=l; i<r; i++) for (int j=i+1; j<r; j++) {
        ret += A[i][j];
    }
    assert(tmp == ret);
    return tmp;
}
LL PLUS(int k, int l, int r) {
    LL tmp = P[r][k] - P[l][k];
    LL ret = 0;
    for (int i=l; i<r; i++) for (int j=0; j<k; j++) {
	ret += A[i][j];
    }
    assert(tmp == ret);
    return tmp;
}

LL dp[511][511];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) REP (j, N) {
	if (i == j) continue;
	scanf("%d", &A[i][j]);
    }

    //N = 500;
    //REP (i, N) REP (j, N) A[i][j] = rand() % 1000000000;

    REP (i, N+1) REP (j, N+1) {
	P[i+1][j+1] = P[i][j+1] + P[i+1][j] - P[i][j];
	M[i+1][j+1] = M[i][j+1] + M[i+1][j] - M[i][j];
	if (i < j) M[i+1][j+1] += A[i][j];
	if (i > j) P[i+1][j+1] += A[i][j];
    }

    memset(dp, 0x3f, sizeof dp);
    const LL INF = dp[0][0];
    dp[0][0] = 0;
    for (int i=0; i<N; i++) for (int j=(i? i+1: 0); j<N; j++) if (dp[i][j] < INF) {
	for (int k=j+1; k<=N; k++) {
	    amin(dp[j][k], dp[i][j] + MINUS(j, k) + PLUS(i, j, k));
	}
    }

    LL ans = INF;
    REP (i, N) {
	//if (dp[i][N] == 0) eprintf("%d\n", i);
	amin(ans, dp[i][N]);
    }
    printf("%lld\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             998244353
#define endl            "\n"
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
int max(int a, int b) {if (a > b) return a; else return b;}
int min(int a, int b) {if (a < b) return a; else return b;}
// #DEBUG
void __print(int x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i : x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
// ###################################################################

void fast()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// #ifndef ONLINE_JUDGE
//   freopen("input.txt", "r", stdin);
//   freopen("output.txt", "w", stdout);
// #endif
}
vector<int> stones;
int ans1 = INT_MAX;
int ans2 = INT_MAX;
int n, k;
int dp[100005];
// *MEMO
int solve(int start) {

  if (start == n - 1) {
    return 0;
  }
  if (dp[start] != -1) {
    return dp[start];
  }
  else {
    int mini = INT_MAX;
    for (int i = 1; i <= k; i++) {
      if (start + i < n) {
        dp[start + i] = solve(start + i);
        mini = min(mini, abs(stones[start] - stones[start + i]) + dp[start + i]);
      }
    }
    dp[start] = mini;
    return dp[start];

  }
}
int32_t main()
{
  fast();
  cin >> n >> k;
  memset(dp, -1, sizeof dp);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    stones.push_back(a);
  }
  cout << solve(0);
}

Measured memory_bytes: 6644
#include <cstdio>
#include <stack>
int n, m, a[2005][2005], pos[2005][2005];
char buf[2005][2005];
std::stack<std::pair<int, int> > s;
int main() {
	std::scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) {
		std::scanf("%s", buf[i] + 1);
		for (int j = 1; j <= m; j++) buf[i][j] = buf[i][j] == '#';
	}
	for (int i = 1; i < n; i++)
		for (int j = 1; j < m; j++)	{
			a[i][j] = !(buf[i][j] ^ buf[i][j + 1] ^ buf[i + 1][j] ^ buf[i + 1][j + 1]);
			if (a[i][j]) pos[i][j] = pos[i - 1][j] + 1;
		}
	int ans = std::max(n, m);
	for (int i = 1; i < n; i++) {
		s.push(std::make_pair(pos[i][1], 1));
		for (int j = 2; j < m; j++) {
			int tmp = 1;
			while (s.size() && s.top().first >= pos[i][j]) {
				tmp += s.top().second;
				ans = std::max(ans, tmp * (s.top().first + 1));
				s.pop();
			}
			s.push(std::make_pair(pos[i][j], tmp));
		}
		int tmp = 1;
		while (s.size()) {
			tmp += s.top().second;
			ans = std::max(ans, tmp * (s.top().first + 1));
			s.pop();
		}
	}
	std::printf("%d\n", ans);
	return 0;
}

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

using namespace std;

#define INF (int)(1e9)

// The recurrence we will be optimizing is
// c(n) = min(c(n - 1) + cost(n, n - 1),
//            c(n - 2) + cost(n, n - 2))

// h[i] is the "value" of stone i
// cost(i, j) = abs(h[i] - h[j])

// I think this way is more natural
int solve_backwards(const vector<int> &h, int N) {
	if (N < 0)
		return INF;
	if (N == 0)
		return 0;

	return min(solve_backwards(h, N - 1) + abs(h[N] - h[N - 1]),
		   solve_backwards(h, N - 2) + abs(h[N] - h[N - 2]));
}

int solve_forwards(const vector<int> &h, int N) {
	if ((size_t)N >= h.size())
		return INF;
	if ((size_t)N == h.size() - 1)
		return 0;

	return min(solve_forwards(h, N + 1) + abs(h[N] - h[N + 1]),
		   solve_forwards(h, N + 2) + abs(h[N] - h[N + 2]));
}

// position -> cost
// the shortest path to i will inform us about the shortest
// path to get to i + 1 and i + 2
// this will solve to the shortest path to N in general
// This is really just adding a cache to the original
// brute force recurrence
// Easiest way to apply DP in general
map<int, int> map_dp;
int solve_memo(const vector<int> &h, int N) {
	if (map_dp.find(N) != map_dp.end())
		return map_dp[N];

	if (N < 0)
		return INF;
	if (N == 0)
		return 0;

	return map_dp[N] = min(solve_memo(h, N - 1) + abs(h[N] - h[N - 1]),
			       solve_memo(h, N - 2) + abs(h[N] - h[N - 2]));
}

// Same idea as last time
// Instead of doing it top down, we will do it bottom up
// Building up smaller values of this optimization first and using
// them to find the answer for N
// This is just changing the order
// You need to know the order of your computations for this to work.
// This case is easy. Generally this means topologically sorting your
// computations
// If this is hard, you may just want to do something like solve_memo.
int solve_tab(const vector<int> &h, int N) {
	vector<int> dp(N);

	// Initial conditions
	dp[0] = 0;
	// This is here because so
	// the recurrence doesn't reach too
	// far back with indices
	dp[1] = abs(h[0] - h[1]);

	// Original recurrence
	for (int i = 2; i <= N; ++i) {
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]),
			    dp[i - 2] + abs(h[i] - h[i - 2]));
	}

	return dp[N - 1];
}

int main() {

	cin.tie(NULL);
	ios_base::sync_with_stdio(false);

	int N;
	cin >> N;
	vector<int> h(N);
	for (auto &e : h) {
		cin >> e;
	}
	// cout << solve_backwards(h, N - 1) << '\n';
	// cout << solve_forwards(h, 0) << '\n';
	cout << solve_memo(h, N - 1) << '\n';
	// cout << solve_tab(h, N) << '\n';

	return 0;
}


Measured memory_bytes: 9216
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	string S; cin >> S;
	while (true) {
		S = S.substr(0, (int)S.length() - 2);
		int half = (int)S.length() / 2;
		string s1, s2;
		s1 = S.substr(0, half);
		s2 = S.substr(half, half);
		//cout << s1 << " " << s2 << endl;
		if (s1 == s2) {
			cout << S.length() << endl;
			return 0;
		}
	}

    return 0;
}


Measured memory_bytes: 256
for(w=x=y=z=0,i=require("fs").readFileSync("/dev/stdin","utf8").split(/\s|,/),c=j=-1;c=i[j+=2];n='\n')c=='A'?w++:c=='B'?x++:c=='O'?z++:y++;console.log(w+n+x+n+y+n+z)

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

constexpr int MAX=10000;

std::string command;

int x,y;

std::vector<int> vec,xs,ys;

bool dx[MAX][MAX*2+1],dy[MAX][MAX*2+1];

int main() {

    std::cin>>command>>x>>y;

    vec.emplace_back(0);

    for(auto ch : command){
        if(ch=='F')
            ++vec.back();
        else
            vec.emplace_back(0);
    }

    if(vec.size()==1){
        if(x==vec.front()&&y==0)
            std::cout<<"Yes"<<std::endl;
        else
            std::cout<<"No"<<std::endl;
        return 0;
    }

    if(vec.size()==2){
        if(x==vec.front()&&abs(y)==vec[1])
            std::cout<<"Yes"<<std::endl;
        else
            std::cout<<"No"<<std::endl;
        return 0;
    }

    x-=vec.front();

    for(int i=2;i<vec.size();i+=2)
        xs.emplace_back(vec[i]);
    for(int i=1;i<vec.size();i+=2)
        ys.emplace_back(vec[i]);

    x+=MAX;
    y+=MAX;

    dx[0][MAX-xs.front()]=true;
    dx[0][MAX+xs.front()]=true;

    for(int i=1;i<xs.size();++i){
        for(int j=0;j<=MAX*2;++j){
            if(j-xs[i]>=0)
                dx[i][j]|=dx[i-1][j-xs[i]];
            if(MAX>=j+xs[i])
                dx[i][j]|=dx[i-1][j+xs[i]];
        }
    }

    dy[0][MAX-ys.front()]=true;
    dy[0][MAX+ys.front()]=true;

    for(int i=1;i<ys.size();++i){
        for(int j=0;j<=MAX*2;++j){
            if(j-ys[i]>=0)
                dy[i][j]|=dy[i-1][j-ys[i]];
            if(MAX>=j+ys[i])
                dy[i][j]|=dy[i-1][j+ys[i]];
        }
    }

    if(dx[xs.size()-1][x]&&dy[ys.size()-1][y])
        std::cout<<"Yes"<<std::endl;
    else
        std::cout<<"No"<<std::endl;

    return 0;
}

Measured memory_bytes: 157952
N = int(input())
As = list(map(int, input().split()))
Ns = {}
for A in As:
  if not(A in Ns):
    Ns[A] = 0
  Ns[A] += 1
r = 0
for A in Ns:
  n = Ns[A]
  if n >= A:
    r += n-A
  else:
    r += n
print(r)


Measured memory_bytes: 17780
N = int(input())
A = map(int, input().split())

# N が 2 で何回割れるか
def how_many_times(N):
    exp = 0
    while N % 2 == 0:
        N //= 2
        exp += 1
    return exp

result = min(map(how_many_times, A))
print(result)

Measured memory_bytes: 9044
import sys
 
stdin = sys.stdin

mod = 1000000007
inf = 1 << 60
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

d, n = na()

def f(x):
    res = 0
    while x % 100 == 0:
        x //= 100
        res += 1
    return res

cnt = 0
m = 0
while cnt < n:
    m += 1
    if f(m) == d:
        cnt += 1

print(m)

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

class WeightedUnionFind {
  std::vector<int> par;  // 親の番号
  std::vector<int> ws;   // 親との重みの差

 public:
  WeightedUnionFind(int n) : par(n, -1), ws(n, 0) {}

  // x の親を返す
  int find(int x) {
    if (par[x] < 0) {
      return x;
    } else {
      int parent = find(par[x]);
      ws[x] += ws[par[x]];
      return par[x] = parent;
    }
  }

  // x の重み(親との相対値)を返す
  int weight(int x) {
    find(x);
    return ws[x];
  }

  // 頂点 x, y を (xの重み) + w = (yの重み) となるように Unite
  bool unite(int x, int y, int w) {
    w += weight(x);
    w -= weight(y);
    x = find(x);
    y = find(y);

    if (x != y) {
      if (par[y] < par[x]) {  // 多い方が根になるようにスワップする.
        int tmp = x;
        x = y;
        y = tmp;
        w = -w;
      }
      par[x] += par[y];
      par[y] = x;
      ws[y] = w;
      return true;
    } else {
      return false;
    }
  }

  bool same(int x, int y) { return find(x) == find(y); }

  void init(int size) {
    for (int i = 0; i < size; i++) {
      par[i] = -1;
      ws[i] = 0;
    }
  }
};

using namespace std;

int main() {
  int n, q;
  cin >> n >> q;
  WeightedUnionFind uf(n);
  for (int i = 0; i < q; i++) {
    int id;
    cin >> id;
    if (id) {
      int x, y;
      cin >> x >> y;
      if (uf.same(x, y)) {
        cout << -uf.weight(x) + uf.weight(y) << endl;
      } else {
        cout << "?" << endl;
      }
    } else {
      int x, y, z;
      cin >> x >> y >> z;
      uf.unite(x, y, z);
    }
  }
}



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

struct test{int p; int b;};
vector<test> xy[16];
int N;

// a[i]
int a_i(int a, int i){
    if(a & (1 << i)) return 1;
    return 0;
}

int C(int a){
    int res = 0;
    for (int i = 0; i < N; ++i) {
        if(a_i(a, i) == 0) continue;
        for (auto x: xy[i]) {
            if(a_i(a, x.p) != x.b) return 0;
        }
        res++;
    }
    return res;
}

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        for (int j = 0; j < a; ++j) {
            int x, y;
            cin >> x >> y;
            x--;
            xy[i].push_back({x, y});
        }
    }
    int ans = 0;
    int m = 1;
    for (int i = 0; i < N; ++i) {
        m *= 2;
    }
    for (int i = 0; i < m; ++i) {
        ans = max(ans, C(i));
    }
    cout << ans << "\n";
    return 0;
}

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

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

#define MOD 1000000007

int main(void) {
    ll N;
    ll number = 1;
    ll temp = 1;
    cin >> N;
    while((temp *= 2) <= N) number = temp;
    cout << number << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main()
{
    int N;
    cin >> N;

    long long sum = 0;
    for (int i = 1; i <= N; i++) {
        if (i % 3 != 0 && i % 5 != 0) {
            sum += i;
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3184
using System;
using static System.Console;
using System.Collections.Generic;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(ReadLine());
            char[] S = ReadLine().ToCharArray();
            var rgb = new Dictionary<char,long> { {'R',0},{'G',0 },{'B',0 }};
            int tmp = 0;

            for(long i = 0; i < N; i ++)
            {
                rgb[S[i]] += 1;

                for(long j = i + 1; j < N; j++)
                {
                    if(S[i] != S[j] && j * 2 - i < N)
                    {
                        if(S[j * 2 - i] != S[i] && S[j * 2 - i] != S[j])
                        {
                            tmp += 1;
                        }
                    }
                }
            }
            WriteLine(rgb['R'] * rgb['G'] * rgb['B'] - tmp);
        }
    }
}


Measured memory_bytes: 18004
N = int(input())
List_A = list(map(int, input().split()))
result = 'APPROVED'
for i in range(N):
    if List_A[i] % 2 == 0:
        if List_A[i] % 3 != 0 and List_A[i] % 5 != 0:
            result = 'DENIED'
            break
print(result)


Measured memory_bytes: 2940
#include <cstdio>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;


const int inf = (int)1e8;


struct plane {

	set<pair<int, int> > xs, ys;

	void init()
	{
		xs.insert({-inf, +inf});
		ys.insert({+inf, -inf});

		xs.insert({+inf, -inf});
		ys.insert({-inf, +inf});
	}

	void print_all()
	{
		printf("pt:");
		for(auto pt : xs)
			printf(" (%d, %d)", pt.first, pt.second);
		printf("\n");
	}

	void add_point(int x, int y)
	{
		// assert is_conflicted(x, y) == false;

		auto l_pt1 = xs.lower_bound({x, y});
		auto r_pt2 = ys.lower_bound({y, x});
		auto r_pt1 = xs.lower_bound({r_pt2->second, r_pt2->first});
		auto l_pt2 = ys.lower_bound({l_pt1->second, l_pt1->first});
		bool can_put = false;
		bool can_del = false;

		if(*l_pt1 <= *r_pt1) {
			can_put = true;
			can_del = true;
		} else {
			auto r_next_pt1 = r_pt1;
			++r_next_pt1;
			if(l_pt1 == r_next_pt1 && x < l_pt1->first && y < r_pt1->second)
				can_put = true;
		}

		if(can_del) {
			xs.erase(l_pt1, ++r_pt1);
			ys.erase(r_pt2, ++l_pt2);
		}

		if(can_put) {
			xs.insert({x, y});
			ys.insert({y, x});
		}
	}

	bool is_conflicted(int x, int y)
	{
		auto r_next = xs.lower_bound({x, -inf});
		auto r = --r_next;
		return r->second < y;
	}

	int size()
	{
		// assert xs.size() == ys.size();
		return xs.size();
	}
};

struct point3 {
	int x, y, z;
	bool operator<(const point3 &rhs) const
	{
		if(x != rhs.x)
			return x < rhs.x;
		if(y != rhs.y)
			return y > rhs.y;
		return z > rhs.z;
	}
};

int generate_rand(int A, int B, bool init) {
	static int a, b;
	if(init) {
		a = A;
		b = B;
	}
	const int C = ~(1<<31), M = (1<<16)-1;
	a = 36969 * (a & M) + (a >> 16);
	b = 18000 * (b & M) + (b >> 16);
	return (C & ((a << 16) + b)) % 1000000;
}


int main()
{
	while(true) {

		int m, n, a, b;
		vector<point3> pts;
		vector<plane> box;

		scanf("%d%d%d%d", &m, &n, &a, &b);
		if(n + m == 0)
			break;
		for(int i = 0; i < m; ++i) {
			int x, y, z;
			scanf("%d%d%d", &x, &y, &z);
			pts.push_back({x, y, z});
		}
		for(int i = 0; i < n; ++i) {
			int x = generate_rand(a, b, i == 0);
			int y = generate_rand(a, b, false);
			int z = generate_rand(a, b, false);
			pts.push_back({x, y, z});
		}
		sort(pts.begin(), pts.end());

		box.push_back(plane());
		box[0].init();
		box[0].add_point(-1, -1);

		for(auto pt : pts) {

			//printf("[%d %d %d]\n", pt.x, pt.y, pt.z);

			if(box[box.size() - 1].is_conflicted(pt.y, pt.z)) {
				box.push_back(plane());
				box[box.size() - 1].init();
				box[box.size() - 1].add_point(pt.y, pt.z);
				//printf("added: %d(new)\n", box.size() - 1);
				//box[box.size() - 1].print_all();
				continue;
			}

			int lb = 0, ub = box.size() - 1;

			while(ub - lb > 1) {

				int mid = (lb + ub) / 2;

				//printf("check: %d\n", mid);
				//box[mid].print_all();

				if(box[mid].is_conflicted(pt.y, pt.z))
					lb = mid;
				else
					ub = mid;
			}

			box[ub].add_point(pt.y, pt.z);
			//printf("added: %d\n", ub);
			//box[ub].print_all();
		}

		int ans = box.size() - 1;

		printf("%d\n", ans);
	}

	return 0;
}

Measured memory_bytes: 37780
#include <bits/stdc++.h>
// #include "ane.cpp"

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 55;
const int MMAX = 100005;
const int KMAX = 1005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
// #define DEBUG

// frequently used macros

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> pl;
typedef pair<ll, ll> pll;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// dump vector
#ifdef DEBUG
#define DUMPV(v, c) do{       \
  printf("%s: ", #v);         \
  for (int i = 0; i < (c); ++i) \
  {                           \
  cout << (v)[i] << " ";      \
  }                           \
  cout << endl;               \
} while(0)
#else
#define DUMPV(v,c)
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( (T*)array, (T*)(array+N), val );
}

// binary search
ll BSearch(ll _begin, ll _end, bool (*f)(int)){
  ll mid;
  while(_end - _begin > 1LL) {
  mid = (_begin + _end) / 2LL;
  if(f(mid)) {
    debug("BSearch: f(%d) == true\n", mid);
    _end = mid;
  }
  else
  {
    debug("BSearch: f(%d) == false\n", mid);
    _begin = mid;
  }
  }
  return _end;
}


ll N,M,K,A[NMAX],B,C,D,E;
ll dp[NMAX][NMAX][2520] = {};

string S;
vec v;

ll ans = 0;

void solve(){
  // main algorithm
  dp[0][0][0] = 1;
  for (int i = 0; i < N; ++i)
  {
    for(int j = 0; j <= i; ++j){
      for (int k = 0; k <= 2500; ++k)
      {
        if (dp[i][j][k])
        {
          debug("dp[%d][%d][%d]: %lld\n", i, j, k, dp[i][k]);
          dp[i+1][j][k] += dp[i][j][k];
          dp[i+1][j+1][min(2500, k + (int)A[i])] += dp[i][j][k];
        }
      }
    }
  }
  for (int i = 1; i <= N; ++i)
  {
    ans += dp[N][i][i * M];
  }
}
void debug(){
  // output debug information

}
void answer(){
  // output answer
  printf("%lld\n", ans);
}
int main(int argc, char const *argv[])
{
  // operate inputs

  // Fill(dp, -1);
  scanf("%lld%lld", &N,&M);
  for (int i = 0; i < N; ++i)
   {
     scanf("%lld", &A[i]);
   }
  solve();
  #ifdef DEBUG
  debug();
  #endif
  answer();

  return 0;
}

Measured memory_bytes: 53504