akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
using namespace std;

int main(){
    long long n, K;
    cin >> n >> K;
    string s;
    cin >> s;
    vector<long long> nums;

    if(s[0] == '0'){
        nums.push_back(0);
    }

   
    for (long long i = 0; i < s.size();) {
        long long j = i;
        while (j < s.size() && s[j] == s[i]) ++j; // S[i] の数値がどこまで続くか
        nums.push_back(j - i);
        i = j;
    }

    if(s.back() == '0'){
        nums.push_back(0);
    }

    vector<long long> sums(nums.size()+1, 0);

    for(long long k = 0; k < nums.size(); k++){
        sums[k+1] = sums[k] + nums[k];
    }

    long long maxv = 0;

    /*for(long long k = 0; k <= n; k += 2){
       
        if(k+2*K+1 > n){
            maxv = max(maxv, sums[n]-sums[k]);
        }
        else{
            maxv = max(maxv, sums[k+2*K+1]-sums[k]);
        }
        
    }*/

    for (long long left = 0; left < sums.size(); left += 2) {
        long long right = left + K*2+1;
        if (right >= sums.size()) right = sums.size() - 1;
        maxv = max(maxv, sums[right] - sums[left]);
    }

    cout << maxv << endl;
    return 0;
}


Measured memory_bytes: 4856
#include<bits/stdc++.h>
using namespace std;
int main() {
  int s; cin >> s;
  set<int> fn;
  fn.insert(s);
  int m, next;
  for(int i = 1; i <= 1000000; i++) {
    if(s % 2 == 0) {
      next = s /2;
    }
    else {
      next = s *3 +1;
    }
    if(fn.count(next)) {
      m = i+1;
      break;
    }
    else {
      fn.insert(next);
      s = next;
    }
  }
  cout << m << endl;
}

Measured memory_bytes: 3636
#include<iostream>


using namespace std;

int main(){
        int x,y;
        int r;

        cin >>x >> y;

        if(x<y) swap(x,y);
        while( y>0){
                r=x%y;
                x=y;
                y=r;
        }
        cout<< x<<endl;
        return 0;

}



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

int main(){
	char s[200002];
	scanf("%s",s);
	int l = strlen(s);
	int a=0,b=0;
	for(a=0;a<l;a++){
		if (s[a] == 'A')
		{
			break;
		}
	}
	for(b=l-1;b>=0;b--){
		if (s[b] == 'Z')
		{
			break;
		}
	}
	printf("%d\n", (b-a+1));
	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
using namespace std;
typedef long double float128;
typedef long long i64;
const int MAXN = 2e5 + 10;
const float128 PI = acos(float128(-1));

int X1, X2, Y1, Y2;
int N;
int flagX, flagY;
float128 answer;
int stk[MAXN], top;

pair<int, int> p[MAXN];

int main(int argc, char **argv)
{
	//cerr << (sizeof (float128)) << endl;
	cin >> X1 >> Y1 >> X2 >> Y2 >> N ;
	flagX = flagY = 1;
	if(X1 > X2)
		flagX = -1, X1 = -X1, X2 = -X2;
	if(Y1 > Y2)
		flagY = -1, Y1 = -Y1, Y2 = -Y2;

	for(int i = 1; i <= N; i++)
	{
		cin >> p[i].first >> p[i].second ;
		p[i].first *= flagX, p[i].second *= flagY;

		if(!(X1 <= p[i].first && p[i].first <= X2 && Y1 <= p[i].second && p[i].second <= Y2))
			N --, i --;
	}
	cerr << N << endl ;
	sort(p + 1, p + 1 + N);
	for(int i = 1; i <= N; i++)
		if(top == 0 || p[i].second > stk[top])
			stk[++top] = p[i].second;
		else
			*(upper_bound(stk + 1, stk + top + 1, p[i].second)) = p[i].second;
	cerr << top << endl ;
	answer = 100.0L * (X2 - X1 + Y2 - Y1) + (PI - 4) * 5 * top;
	if(top == min(X2 - X1 + 1, Y2 - Y1 + 1))
		answer += PI * 5;
	cout << fixed << setprecision(20) << answer << endl ;
}



Measured memory_bytes: 2560
#include <cstdio>
#include <math.h>
#include <iostream>
using namespace std;
int main()
{
    int n,B,C,s;
    char a[9],b[8],c[8];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%s",a);
        B=0;
        C=0;
        for(int j=0;j<8;j++){
            b[j]=a[j];
            c[j]=a[j];
        }
        for(int j=0;j<8;j++){
            for(int k=j+1;k<8;k++){
                if(b[j]<=b[k]){
                    swap(b[j],b[k]);
                }
                if(c[j]>=c[k]){
                    swap(c[j],c[k]);
                }
            }
        }
        s=0;
        for(int j=7;j>=0;j--){
            B+=(b[s]-'0')*pow(10,j);
            C+=(c[s]-'0')*pow(10,j);
            s++;
        }
        printf("%d\n",B-C);
    }
    return 0;
}

Measured memory_bytes: 1232
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=5050;
//↑templete
int main() {
	cout<<setprecision(20)<<fixed;
	int N;
	cin>>N;
	cout<<double(N-N/2)/double(N)<<endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

int n;
vector<string> s(100010);
vector<char> ans(100010);

void dfs(int idx, int a, int b, int c){
    if(a < 0 || b < 0 || c < 0) return ;
    
    if(idx == n){
        cout << "Yes" << endl;
        for(int i=0; i<n; i++) cout << ans[i] << endl;
        exit(0);
    }

    if(s[idx] == "AB"){
        ans[idx] = 'A';
        dfs(idx + 1, a + 1, b - 1, c);
        ans[idx] = 'B';
        dfs(idx + 1, a - 1, b + 1, c);
    }
    else if(s[idx] == "AC"){
        ans[idx] = 'A';
        dfs(idx + 1, a + 1, b, c - 1);
        ans[idx] = 'C';
        dfs(idx + 1, a - 1, b, c + 1);
    }
    else{
        ans[idx] = 'B';
        dfs(idx + 1, a, b + 1, c - 1);
        ans[idx] = 'C';
        dfs(idx + 1, a, b - 1, c + 1);
    }

    return ;
}

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

    int a, b, c; cin>>n>>a>>b>>c;
    for(int i=0; i<n; i++) cin>>s[i];

    dfs(0, a, b, c);

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 14260
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }

        class City
        {
            public readonly int n;
            public readonly int P;
            public readonly int Y;
            public City(int n, int[] V)
            {
                this.n = n;
                P = V[0];
                Y = V[1];
            }
        }
        static IEnumerable<string> Solve(City[] cities)
        {
            var dict = new Dictionary<int, List<City>>();
            foreach (var city in cities)
            {
                if (!dict.ContainsKey(city.P)) { dict[city.P] = new List<City>(); }
                dict[city.P].Add(city);
            }
            var ids = new List<Tuple<int, string>>();
            foreach (var list in dict.Values)
            {
                int i = 0;
                foreach (var city in list.OrderBy(city => city.Y))
                {
                    var id = string.Format("{0:D6}{1:D6}", city.P, ++i);
                    ids.Add(new Tuple<int, string>(city.n, id));
                }
            }
            return ids.OrderBy(id => id.Item1).Select(id => id.Item2);
        }
        static void Main(string[] args)
        {
            var V = ReadInts();
            int M = V[1];
            var cities = new City[M];
            for (int i = 0; i < M; ++i) { cities[i] = new City(i, ReadInts()); }
            foreach (var ans in Solve(cities)) { Console.WriteLine(ans); }
        }
    }
}

Measured memory_bytes: 46952
#include <stdio.h>
int main(void)
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if (a < b && b < c)
    {
        printf("Yes\n", a, b, c);
    }
    else
    {
        printf("No\n", a, b, c);
    }
}


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

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

//更新順序が非自明
double rec(int c1,int c2,int c3){
    if(flag[c1][c2][c3]) return dp[c1][c2][c3];
    if(c1==0&&c2==0&&c3==0)return 0.0;
    flag[c1][c2][c3] = 1;
    double res = 1;
    if(c1>0) res += rec(c1-1,c2,c3)*c1/N;
    if(c2>0) res += rec(c1+1,c2-1,c3)*c2/N;
    if(c3>0) res += rec(c1,c2+1,c3-1)*c3/N;
    res /= (1 - (double)(N-c1-c2-c3)/N);
    return dp[c1][c2][c3] = res;
}

int main(){
    cin>>N;
    // double dp[310][310][310];
    rep(i,310)rep(j,310)rep(k,310)dp[i][j][k]=0;
    int i = 0, j = 0, k = 0;
    rep(d,N){
        int a;  cin>>a;
        if(a==1)i++;
        else if(a==2)j++;
        else k++;
    }
    cout<<setprecision(12)<<rec(i,j,k)<<endl;
}

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

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

using namespace std;

//-------------------------↓↓↓↓↓↓------------------------

int main(void){

       cin.tie(0);
    ios::sync_with_stdio(false);
      
      long long int sum = 0, pos, l, tmp = 1, hen, tyo, from, to, add[100], addcnt = 0, cntt = 0, cnt = 0, cost;
      bool fl = false;

      cin >> l;

      while(1){
        sum += tmp;
        cnt++;
        if(sum >= l)break;
        tmp *= 2;
      }
      
      sum -= tmp;
      tyo = cnt;
      hen = (cnt - 1) * 2;
      pos = l - 1 - sum;
      cnt = 1;

      while(1){
        if(pos == 0)break;
        if(cnt > pos){
          if(cnt % 2 == 0)cnt /= 2;
          add[addcnt++] = cnt;
          pos -= cnt;
          hen++;
          cnt = 1;
        }
        cnt *= 2;
      }

      cout << tyo << " " << hen << "\n";

      cnt = 1;
      from = 1;
      to = 2;

      while(1){
        cout << from << " " << to << " " << 0 << "\n";
        cout << from << " " << to << " " << cnt << "\n";
        cnt *= 2;
        from++;
        to++;
        if(to == tyo+1)break;
      }

      reverse(add,add + addcnt);

      rep(i,addcnt){
        cnt = 1;
        cntt = 1;
        rep(j,30){
          if(cnt == add[i]){
            cost = l - cnt;
            l -= cnt;
            if(l == sum + 1)fl = true;
            cout << cntt << " " << tyo << " " << cost << "\n";
            break;
          }
          cnt *= 2;
          cntt++;
        }
        if(fl)break;
      }

       
return 0;
}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.par = [-1 for i in range(n)]

    def root(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.root(self.par[x]) # contraction
            return self.par[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            if self.par[x] > self.par[y]:
                x, y = y, x
            self.par[x] += self.par[y]
            self.par[y] = x

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def size(self, x):
        return -self.par[self.root(x)]


n, m = map(int, input().split())
edge = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]

uf = UnionFind(n)
ans = n * (n-1) // 2
anss = []
for i in reversed(range(m)):
    anss.append(ans)
    # print(uf.par)
    # print(uf.size, [uf.size[uf.find(i)] for i in range(n)])
    a, b = edge[i]
    if not uf.same(a, b):
        ans -= uf.size(a) * uf.size(b)
    # print(i, a, b)

    uf.unite(a, b)

for i in reversed(range(m)):
    print(anss[i])


Measured memory_bytes: 33424
#include <stdio.h>

int main(void)
{
    int n;
    scanf("%d", &n);
    switch (n)
    {
        case 25:
            printf("Christmas\n");
            break;
        case 24:
            printf("Christmas Eve\n");
            break;
        case 23:
            printf("Christmas Eve Eve\n");
            break;
        case 22:
            printf("Christmas Eve Eve Eve\n");
            break;
        default:
            break;
    }
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int n;
vector<string> group;
vector<vector<string> > member;
set<string> ret;

void solve(string s)
{
    int k = find(group.begin(), group.end(), s) - group.begin();
    if(k == n){
        ret.insert(s);
        return;
    }

    for(unsigned i=0; i<member[k].size(); ++i)
        solve(member[k][i]);
    member[k].clear();
}

int main()
{
    for(;;){
        cin >> n;
        if(n == 0)
            return 0;

        group.assign(n, "");
        member.assign(n, vector<string>(0));

        for(int i=0; i<n; ++i){
            char c;
            for(;;){
                cin >> c;
                if(c == ':')
                    break;
                group[i] += c;
            }
            string s;
            for(;;){
                cin >> c;
                if(c == '.'){
                    member[i].push_back(s);
                    break;
                }
                if(c == ','){
                    member[i].push_back(s);
                    s.clear();
                }else{
                    s += c;
                }
            }
        }

        ret.clear();
        solve(group[0]);
        cout << ret.size() << endl;
    }
}

Measured memory_bytes: 1012
#include <bits/stdc++.h>
#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

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,typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v){ t = v; }

template<typename T,typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    auto dp = make_v<LL>(s.size()+5, 4);
    dp[0][0] = 1;
    REP(i, s.size())
    {
        REP(j, 4) (dp[i+1][j] += dp[i][j] * (s[i] == '?' ? 3 : 1)) %= MOD;
        if(s[i] == 'A' || s[i] == '?')
        {
            (dp[i+1][1] += dp[i][0]) %= MOD;
        }
        if(s[i] == 'B' || s[i] == '?')
        {
            (dp[i+1][2] += dp[i][1]) %= MOD;
        }
        if(s[i] == 'C' || s[i] == '?')
        {
            (dp[i+1][3] += dp[i][2]) %= MOD;
        }
        
    }
    cout << dp[s.size()][3] << endl;
}

Measured memory_bytes: 7376
#include <bits/stdc++.h>
#define ll long long
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int N = 105 , W = 5 + 1e5;
int n , w , its[N] , wie[W];
ll dp[N][W];
ll calc(int p , int c){
	if (p == n){
		if (c <= w) return 0;
		else return -1e9;}
	if (c > w) return -1e9;
	if (dp[p][c] != -1) return dp[p][c];
	ll tk = calc(p + 1 , c + wie[p]) + its[p];
	ll ntk = calc(p + 1 , c);
	return dp[p][c] = max(tk , ntk);
}
int main() { fastIO
    cin >> n >> w;
    memset(dp , -1 , sizeof dp);
    for (int i = 0 ; i < n ; i++) cin >> wie[i] >> its[i];
    cout << calc(0 , 0) << endl;
}

Measured memory_bytes: 85664
n = int(input())

march = [0, 0, 0, 0, 0]

for i in range(n):
    r = input()
    if r[0] == "M":
        march[0] += 1
    elif r[0] == "A":
        march[1] += 1
    elif r[0] == "R":
        march[2] += 1
    elif r[0] == "C":
        march[3] += 1
    elif r[0] == "H":
        march[4] += 1

result = 0
result += march[0] * march[1] * march[2]
result += march[0] * march[1] * march[3]
result += march[0] * march[1] * march[4]

result += march[0] * march[2] * march[3]
result += march[0] * march[2] * march[4]

result += march[0] * march[3] * march[4]

result += march[1] * march[2] * march[3]
result += march[1] * march[2] * march[4]

result += march[1] * march[3] * march[4]

result += march[2] * march[3] * march[4]

print(result)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int lli;

bool OK(vector<lli> &t, lli c, lli k, lli cnt){
  lli n = t.size();
  lli time = t[0];
  lli res = 0;
  for (int i = 0; i < n;) {
    lli num = 0;
    while(i < n and time + k >= t[i] and num < c){
      i++, num++; 
    }
    //std::cout << "t[" << i << "]:" << t[i] << std::endl;
    time = t[i];
    res++;
  }
  return res <= cnt;
}

lli binarySearch(vector<lli> &t, lli c, lli k){
  lli l = 0, r = 1e10, mid = (l + r)/2;
  while(r - l > 1){
    if(OK(t, c, k, mid)){
      r = mid;
    }else{
      l = mid;
    }
    mid = (l + r)/2;
  }
  return r;
}

int main(){
  lli n, c, k;
  std::cin >> n >> c >> k;
  vector<lli> t(n);
  for (int i = 0; i < n; i++) {
    std::cin >> t[i];
  }
  sort(t.begin(), t.end());
  std::cout << binarySearch(t, c, k) << std::endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
const ll INF=100000000000000LL;

int main() {
	string str;
	cin>>str;
	int ans=0;
	for(int i=0;i<3;++i){
		if(str[i]=='1')++ans;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <numeric>
#include <math.h>
#include <climits>
#include <stack>
#include <iomanip>
#include <sstream>

using namespace std;

template <typename T>
inline bool sign(T A) {
    return (A>0)-(A<0);
}
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SREP(i,s,n) for(int i=s; (n-i)*sign(n-s)>0; i+=sign(n-s))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef unsigned long long ull;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

bool _less(pair<int, int> a, pair<int, int> b) {
    return a.second < b.second;
}

template <template<class,class,class...> class C, typename K, typename V, typename... Args>
V map_get(const C<K,V,Args...>& m, K const& key, const V & defval)
{
    typename C<K,V,Args...>::const_iterator it = m.find( key );
    if (it == m.end())
        return defval;
    return it->second;
}

#define MOD (1'000'000'000 + 7
#define INF (ll(1e18))

int main(void)
{
    ll D, G;
    cin >> D >> G;
    vector<ll> p(D), c(D);
    REP(i, D) {
        cin >> p[i] >> c[i];
    }
    const ll N = 200000;
    vector<vector<ll>> dp(D+1, vector<ll>(N, INF));
    dp[0][0] = 0;
    REP(i, D) {
        REP(k, N)
        {
            if (dp[i][k] < INF)
            {
                REP(j, p[i]+1)
                {
                    ll s = (i + 1) * j;
                    if (j == p[i])
                    {
                        s += c[i] / 100;
                    }
                    dp[i + 1][k + s] = min(dp[i][k + s], min(dp[i + 1][k + s], dp[i][k] + j));
                }
            }
        }
    }
    ll score = INF;
    SREP(i, G/100, N) {
        score = min(dp[D][i], score);
    }
    cout << score << endl;
}


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

#include <iostream>

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

    int testcases;
    cin >> testcases;
    while(testcases--)
    {
        int N;
        cin >> N;
        
        std::unordered_map<int, vector<ll>> blueCams;
        std::unordered_map<int, vector<ll>> redCams;

        ll result = 0;
        int blueCamelsSize = 0;
        for(int i = 0; i < N; i++)
        {
            int K, L, R;

            cin >> K >> L >> R;

            if(L >= R)
            {
                result += R;
                blueCams[K].push_back(L-R);
                blueCamelsSize++;
            }
            else
            {
                result += L;
                redCams[N-K].push_back(R-L);
            }
        }


        priority_queue<ll, vector<ll>, greater<ll>> bpq;
        priority_queue<ll, vector<ll>, greater<ll>> rpq;

        for(int i = 0; i <= N; i++)
        {
            for(int camel : blueCams[i])
                bpq.push(camel);
            
            while(bpq.size() > i)
                bpq.pop();
        }

        for(int i = 0; i <= N; i++)
        {
            for(int camel : redCams[i])
                rpq.push(camel);

            while(rpq.size() > i)
                rpq.pop();
        }

        while(!bpq.empty())
        {
            result += bpq.top();
            bpq.pop();
        }

        while(!rpq.empty())
        {
            result += rpq.top();
            rpq.pop();
        }


        std::cout << result << "\n";

    }

    return 0;
}


Measured memory_bytes: 32208
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
Ans = 0
for i in range(N):
    ans = 0
    for j in range(i+1):
        ans += A[j]
    for j in range(i,N):
        ans += B[j]
    Ans = max(Ans,ans)
print(Ans)

Measured memory_bytes: 3060
package main

import (
	"fmt"
	"sort"
)

func main() {

	cnt :=0
	fmt.Scan(&cnt)

	var kagamis = make([]int, cnt)
	for i := 0; i < cnt; i++ {
		fmt.Scan(&kagamis[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(kagamis)))

	result :=0
	var prevKagami = 101
	for i:=0;i<cnt;i++ {
		if kagamis[i] < prevKagami {
			result ++
		}
		prevKagami = kagamis[i]
	}
	fmt.Println(result)
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
	int m, f, r, i;
	while (true){
		cin >> m >> f >> r;
		if (m == -1 && f == -1 && r == -1){ break; }
		if (m + f >= 80){
			cout << "A" << endl;
		}
		if (m + f >= 65 && m + f < 80){
			cout << "B" << endl;
		}
		if (m + f >= 50 && m + f < 65 && m != -1 && f != -1){
			cout << "C" << endl;
		}
		if (m + f >= 30 && m + f < 50 && m != -1 && f != -1){
			if (r < 50){
				cout << "D" << endl;
			}
			if (r >= 50){
				cout << "C" << endl;
			}
		}
		if (m + f<30){
			cout << "F" << endl;
		}
		if (m == -1){
			cout << "F" << endl;
		}
		if (f == -1){
			cout << "F" << endl;
		}
	}
}

Measured memory_bytes: 3088
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>

using namespace std;

using ll = long long int; 

void prime(vector<int> &num, int n){
    for(int i=0;i<=n;i++){
        num[i] = 1;
    }
    num[0] = 0;
    num[1] = 0;
    num[2] = 1;

    for(int i=2;i<=sqrt(n);i++){
        if(num[i] == 1){
            for(int j=2;j<=n/i;j++){
                num[i*j] = 0;
            }
        }
    }
}


ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

int main(void){
   
   int n;
   cin>>n;
   vector<int> l(n);

   for(int i=0;i<n;i++){
       int x;
       cin>>x;
       l[i] = x;
   }
   sort(l.begin(), l.end());

//    for(int i=0;i<n;i++){
//        cout<<l[i]<<" ";
//    }
//    cout<<endl;

   int count = 0;

   for(int i=0;i<n-2;i++){
       for(int j=i+1;j<n-1;j++){
           int length = l[i] + l[j];
           for(int k=j+1;k<n;k++){
               if(l[k]>=length)break;
               count++;
              // cout<<i<<j<<k<<endl;
           }
       }
   }

   cout<<count<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin >> N >> K;
  long long A[N];
  for(int i = 0; i < N; i++) cin >> A[i];
  for(int i = 0; i+K < N; i++){
	if(A[i] < A[i+K]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

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

int SelectionSort(vector<int> &A, int N){
  int cnt = 0;
  for(int i = 0; i < N; i++){
    int minj = i;
    for(int j = i; j < N; j++){
      if(A.at(j) < A.at(minj)){
        minj = j;
      }
    }
    if(minj != i){
      swap(A.at(i), A.at(minj));
      cnt++;
    }
  }
  return cnt;
}

int main(){
	int n;
  cin >> n;
  vector<int> A(n);

  for(int i = 0; i < n; i++){
    cin >> A.at(i);
  }

  int result = SelectionSort(A, n);

  for (size_t i = 0; i < n-1; i++) {
    cout << A.at(i) << " ";
  }
  cout << A.at(n-1) << endl;

  cout << result << endl;

}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807/2;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


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

string s;
ll k;

ll change_count(string s1){
	int t=1;
	ll ret=0;
	ll nc=1;
	while(t<s1.size()){
		if(s1[t-1]==s1[t]){
			nc++;
		}else{
			ret+=(nc/2);
			nc=1;
		}
		if(t==s1.size()-1){
			ret+=(nc/2);
		}
		t++;
	}
	return ret;
}
int main(){
	cin>>s;
	cin>>k;
	if(s[0]!=s[s.size()-1]){
		cout<<change_count(s)*k<<endl;
		return 0;
	}
	
	int flag=1;
	for(int i=1;i<s.size();i++){
		if(s[i]!=s[i-1]){
			flag=0;
			break;
		}
	}
	if(flag){
		cout<<(s.size()*k)/2<<endl;
		return 0;
	}
	
	int sc=1,lc=1;
	int t=0;
	while(s[t]==s[t+1]){
		sc++;
		t++;
	}
	t=s.size()-1;
	while(s[t]==s[t-1]){
		lc++;
		t--;
	}
	//cout<<sc<<" "<<lc<<endl;
	ll mi=change_count(s.substr(sc,s.size()-sc-lc))*k;
	//cout<<s.substr(sc,s.size()-sc-lc)<<endl;
	ll mii=((lc+sc)/2)*(k-1);
	ll miii=lc/2+sc/2;
	cout<<mi+mii+miii<<endl;
	//cout<<" Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (int i = f; i < t; i++)
#define pr(i, f, t) for (int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
bool is_kai(string s)
{

    rp(i, 0, s.size() / 2) if (s[i] != s[s.size() - 1 - i]) return false;
    return true;
}
int main()
{
    string s;
    cin >> s;
    ll n = s.size();
    if (is_kai(s) && is_kai(s.substr(0, ll((n - 1) / 2))) && is_kai(s.substr(ll((n + 3) / 2) - 1, n - ll((n + 3) / 2) + 1)))
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    cout << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleTest
{
    static partial class Program
    {
  

        static void Main(string[] args)
        {
            var nm = Ints();
            var a = Ints();
            long sum = 0;
            for(int i=0; i < a.Length; ++i)
            {
                sum += a[i];
            }
            if(nm[0]<sum)
            {
                Console.WriteLine("-1");
            }
            else
            {
                Console.WriteLine(nm[0]-sum);
            }


        }

    }
    static partial class Program
    {
        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }
        public static int[] Ints()
        {
            return Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        }
        public static long[] Longs()
        {
            return Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
        }
        public static int[][] MultiInts(int num)
        {
            var result = new int[num][];
            for(int i = 0; i < num; ++i)
            {
                result[i] = Ints();
            }
            return result;
        }
        public static T[] MultiItems<T>(int num, Func<string,T> parser)
        {
            var result = new T[num];
            for(int i =0; i < num; ++i)
            {
                result[i] = parser(Console.ReadLine());
            }
            return result;
        }
    }
}


Measured memory_bytes: 29260
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <sstream>
#include <string>
#include <utility>
#include <map>
#include <memory>
#include <set>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>

using namespace std;

struct Node
{
  int prnt;
  int k;
  int *c;
};

class RootedTree
{
public:
  int n;
  Node *nd;
  int solve();
  int depth( int id );
  string nodetype( int id );
  int showChildren( int id );
};

int RootedTree::solve()
{
  int id;
  cin >> n;

  nd = new Node[n];

  for ( int i = 0; i < n; ++i )
    {
      nd[i].prnt = -1;
    }

  for ( int i = 0; i < n; ++i )
    {
      cin >> id;
      cin >> nd[id].k;
      
      nd[id].c = new int[nd[id].k];
      
      for ( int j = 0; j < nd[id].k; ++j )
        {
          cin >> nd[id].c[j];
          nd[nd[id].c[j]].prnt = id;
        }
    }

  for ( int i = 0; i < n; ++i )
    {
      cout << "node " << i << ": parent = ";
      cout << nd[i].prnt << ", depth = ";
      cout << depth( i ) << ", ";
      cout << nodetype( i ) << ", ";
      showChildren( i );
      cout << endl;
    }
  
  return 0;
}

int RootedTree::depth( int id )
{
  int ret = 0;
  
  while( (id = nd[id].prnt) != -1 ) ++ret;
  
  return ret;
}

string RootedTree::nodetype( int id )
{
  if ( nd[id].prnt == -1 )
    return "root";

  if ( nd[id].k == 0 )
    return "leaf";
  else
    return "internal node";
}

int RootedTree::showChildren( int id )
{
  if ( nd[id].k == 0 )
    cout << "[]";
  else
    {
      cout << "[";
      for ( int i = 0; i < nd[id].k; ++i )
        {
          if ( i ) cout << ", ";
          cout << nd[id].c[i];
        }
      cout << "]";
    }
          
  return 0;
}

int main()
{

  RootedTree rt;

  rt.solve();

  return 0;
}

Measured memory_bytes: 6284
#include <cassert>
#include <iostream>
#include <vector>

//
// 重み付きUnion-Find Tree size version
//
// verify: AOJ DSL_1_B
//
template <typename T>
struct WeightedUnionFind {
    std::vector<int> data;
    std::vector<T> ws;
    const int n;
    WeightedUnionFind(int num) : data(num, -1), ws(num), n(num) {}
    int find(int k) {
        assert(0 <= k && k < n);
        if (data[k] < 0) return k;
        auto par = find(data[k]);
        ws[k] += ws[data[k]];
        return data[k] = par;
    }
    T weight(int k) {
        assert(0 <= k && k < n);
        find(k);
        return ws[k];
    }
    bool unite(int x, int y, T w) {
        assert(0 <= x && x < n);
        assert(0 <= y && y < n);
        w += weight(x);
        w -= weight(y);
        x = find(x);
        y = find(y);
        if (x == y) return false;
        if (data[x] > data[y]) {
            std::swap(x, y);
            w *= -1;
        }
        data[x] += data[y];
        data[y] = x;
        ws[y] = w;
        return true;
    }
    int size(int k) {
        assert(0 <= k && k < n);
        return (-data[find(k)]);
    }
    T diff(int x, int y) {
        assert(0 <= x && x < n);
        assert(0 <= y && y < n);
        return weight(y) - weight(x);
    }
};

int main() {
    int N, M;
    std::cin >> N >> M;
    WeightedUnionFind<int> uf(N);
    while (M--) {
        int a, b, c, d;
        std::cin >> a >> b >> c;
        if (a == 0) {
            std::cin >> d;
            uf.unite(b, c, d);
        } else {
            if (uf.find(b) == uf.find(c)) {
                std::cout << uf.diff(b, c) << std::endl;
            } else {
                std::cout << "?" << std::endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3632
# Problem D - Floor Function

import math

# input
A, B, N = map(int, input().split())

# initialization
ans = 0
if N<B:
    ans = math.floor(A*N/B) - A * math.floor(N/B)
else:
    ans = math.floor(A*(B-1)/B) - A * math.floor((B-1)/B)

# output
print(ans)


Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}


int main() {
  int a, b, k;
  cin >> k>> a >> b;
  if (a%k==0 || b %k==0) cout << "OK"<<endl;
  else {
    a=a/k;
    b=b/k;
    if (a!=b) cout << "OK"<<endl;
    else cout << "NG" <<endl;
  }
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORP(i, m, n) for(int i = m; i < n+1; i++)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define pa cout << ans << endl
#define p(x) cout << x << endl
#define pall(x) for(auto iter : x) p(iter)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define yesno(x) cout << (x ? "Yes" : "No") << endl
using namespace std;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
using UnweightedGraph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
const int INF = 2000000000ll;
const long double PI = acosl(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int power(int a, int b) {return b?power(a*a,b/2)*(b%2?a:1):1;}
int perm(int N, int K){
    int x=1;
    for(int i=1;i<=K;i++)
    {
        x=x*(N-i+1);
    }
    return x;
}
int factorial(int N) {return perm(N,N);}
int comb(int N,int K) {return factorial(N)/factorial(K)/factorial(N-K);}
int hcomb(int N, int K) {return comb(N+K-1, N-1);}

int dtoi(double d) {return round(d);}

bool isprime(int n) {
    if (n < 2) return false;
    for (int i = 2; i*i <= n; ++i) {
        if (n % i ==  0) return false;
    }
    return true;
}

int mystoll(string s){
    int ans = 0;
    for (int i = (int) s.length()-1; i >= 0; i--){
        ans += (s[i]-'0') * power(10,s.length()-1-i);
    }
    return ans;
}

template<class T>
int SUM(T a) {
    int sum = 0;
    for(auto itr : a) sum += itr;
    return sum;
}

void solve(int64_t X);

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int64_t X;
    cin >> X;
    solve(X);
    return 0;
}

void solve(int64_t X) {
    int ans = 0;
    int a = 100;
    while (a < X) {
        a *= 1.01;
        ans++;
    }
    pa;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc165/abc165_b && sh test.sh
cd ~/Desktop/Programming/AtCoder/contest/abc165/abc165_b && sh etest.sh
cd ~/Desktop/Programming/AtCoder/contest/abc165/abc165_b && sh submit.sh
*/


Measured memory_bytes: 3700
n = int(input())
p = list(map(int, input().split()))

count = 0
for i in range(1, n-1):
    if ((p[i-1] < p[i] < p[i+1])
        or (p[i-1] > p[i] > p[i+1])):
        count += 1

print(count)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <iomanip>
#include <cstring>
#include <string.h>
#include <iterator>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <limits.h>
#include <string>
#include <bitset>
#include <map>
#include <numeric>
#include<unordered_map>


#define endl cout<<"\n"
#define lli long long int
#define ld long double
#define M_PI (3.14159265358979323846264338327950288)
#define MOD (1000000007)

using namespace std;

//fast-exponentiation-lli
unsigned lli expo_fast(lli a, lli b) {
	a = a;
	lli result = 1;
	while (b) {
		//multiplyint(tos(result), a);
		if (b & 1)result = (result * a);
		b >>= 1;
		a = (a*a);
	}
	return (result);
}


void take_in(vector<lli> *arr) {
	for (int i = 0; i < arr->size(); i++)cin >> (*(arr))[i];
}


lli gcd(lli a, lli b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);

}

/* Iterative Function to calculate (x^y)%p in O(log y) */
unsigned lli power(lli x, unsigned lli y, lli p)
{
	lli res = 1;      // Initialize result 
	x = x % p;  // Update x if it is more than or equal to p 
	while (y > 0) {
		// If y is odd, multiply x with result 
		if (y & 1)res = (res*x) % p;
		// y must be even now 
		y = y >> 1;
		x = (x*x) % p;
	}
	return res;
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, k; cin >> n >> k;
	vector<lli> arr(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> arr[i];
	}
	vector<lli>dp(k + 1,0);
	dp[0] = 0;
	for (int i = 1; i <= k; i++) {
		lli x = 100;
		bool f = false;
		for (int j = 1; j <= n; j++) {
			if (arr[j] > i)continue;
			f = true;
			x = min(x, dp[i - arr[j]]);
		}
		if (x == 1)dp[i] = 0;
		else {
			if (f)dp[i] = 1;
			else dp[i] = 0;
		}
	}
	if (dp[k])cout << "First";
	else cout << "Second";
	//system("PAUSE");
}


Measured memory_bytes: 1024
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

const size_t size = (1ll << 12) + 10;
ll dp[size];
const ll inf = 5e15;

int main() {
    ll N, M;
    cin >> N >> M;
    V<PLL> key(M);
    for(ll i = 0; i < M; i++) {
        ll a, b;
        cin >> a >> b;
        ll bit = 0;
        while(b--) {
            ll c;
            cin >> c;
            c--;
            bit += (1ll << c);
        }
        key[i] = PLL(a, bit);
    }
    fill(dp + 1, dp + size, inf);
    for(ll S = 0; S < (1ll << N); S++) {
        for(auto &&k : key) {
            ll cost, bit;
            tie(cost, bit) = k;
            chmin(dp[S | bit], dp[S] + cost);
        }
    }
    ll ans = dp[(1ll << N) - 1];
    if(inf <= ans) ans = -1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> 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, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

int digit_length(int x) {
    int res = 0;
    while (x) {
        res++;
        x /= 10;
    }
    return res;
}

void _main() {
    int N;
    cin >> N;
    int ans = INF;
    for (int A = 1; A * A <= N; ++A) {
        if (N % A == 0) {
            int B = N / A;
            CHMIN(ans, max(digit_length(A), digit_length(B)));
        }
    }
    cout << ans << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i'))
            freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o'))
            freopen("output.txt", "w", stdout);
    }
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
 
int main(){
 
  int i, j, n, temp, A[1000], minj, count=0;
 
  scanf("%d",&n);
 
  for(i=0; i<n; i++){
    scanf("%d",&A[i]);
  }
 
  for(i=0; i<n-1; i++){
    minj = i;
    for(j=i; j<n; j++){
      if(A[j] < A[minj]){
    minj = j;
      }
    }
    temp = A[i];
    A[i] = A[minj];
    A[minj] = temp;
    if(A[i] != A[minj]){
      count++;
    }
  }
 
  for(i=0; i<n-1; i++){
    printf("%d ", A[i]);
  }
 
  printf("%d\n",A[i]);
  printf("%d\n",count); 
 
  return 0;
}
 

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

int n,a[200001],p[1000001];

int main()
{
    cin>>n;
    reff(i,n)scanf("%d",&a[i]);
    sort(a,a+n);

    reff(i,n){
        if(a[i]==a[i+1]){p[a[i]]++;continue;}
        reff(j,1000000/a[i]+1) p[j*a[i]]++;
    }
    int ans=0;
    reff(i,n){if(p[a[i]]==1) ans++;}
    cout<<ans;

}


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


int main(){
  int a,b,c;
  cin >> a >> b >>c;
  if(a==b){
    cout << c << endl;
  }
  else if(b==c){
    cout << a << endl;
  }
  else{
    cout << b << endl;
  }
}


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

int main(){
  string S ;
  cin >> S ;
  if (S.at(5)=='1'){
    cout << "TBD" << endl;
  }
  else if(S.at(6)>='5'){
    cout << "TBD" << endl;
  }
  else {
    cout << "Heisei" << endl;
  }
}

Measured memory_bytes: 256
import numpy as np

N = int(input())
S = list(input())
S_v = np.array(S)
def pop(S):
    index=[]
    for i in range(len(S)-1):
        if S[i]=='('and S[i+1]==')':
            index.append(i)
            index.append(i+1)
    index = np.array(index)
    answer = np.delete(S,index)
    return answer
p = np.array([])
while len(S_v)!=len(p):
    p = S_v
    S_v = pop(S_v)
#print (S_v)
n_left = len(np.where(S_v==')')[0])
n_right = len(np.where(S_v=='(')[0])
print ('('*n_left+''.join(S)+')'*n_right)

Measured memory_bytes: 12504
#include <cmath>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i++)


int main(void)
{
    int X, Y, Z;
    cin >> X >> Y >> Z;

    int space = 0;
    int ans = 0;

    do
    {
        space += Y;
        if(space > (X-2*Z))
            break;
        else if(space == (X-2*Z)){
            ans++;
            break;
        }
        ans++;
        space += Z;
        
    }while(space <= (X-2*Z));

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256