akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

using ll = long long;
vector<int> ans[2], res;
int a[100005];
ll rlt[2];
int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i ++) {
		int x; cin >> x;
		a[i] = x;
		if(x > 0) ans[i % 2].push_back(i), rlt[i % 2] += x;
	}
	if(ans[0].empty() && ans[1].empty()){
		int x = max_element(a, a + n) - a;
		for(int i = n - 1; i > x; i --) res.push_back(i + 1);
		for(int i = 0; i < x; i ++) res.push_back(1);
		cout << a[x] << '\n';
		cout << res.size() << '\n';
		for(auto it : res) cout << it << '\n';
		return 0; 
	}
	if(rlt[0] > rlt[1]){
		int m = ans[0].size();
		for(int i = n - 1; i > ans[0][m - 1]; i --) res.push_back(i + 1);
		for(int i = 0; i < n; i ++){
			if(i == ans[0][0]) break;
			res.push_back(1);
		}
		for(int i = 1; i < m; i ++){
			int dif = ans[0][i] - ans[0][i - 1];
			for(int j = dif / 2; j >= 1; j --) res.push_back(j + 1);
		}
	}
	else {
		int m = ans[1].size();
		for(int i = n - 1; i > ans[1][m - 1]; i --) res.push_back(i + 1);
		for(int i = 0; i < n; i ++){
			if(i == ans[1][0]) break;
			res.push_back(1);
		}
		for(int i = 1; i < m; i ++){
			int dif = ans[1][i] - ans[1][i - 1];
			for(int j = dif / 2; j >= 1; j --) res.push_back(j + 1);
		}
	}
	cout << max(rlt[0], rlt[1]) << '\n';
	cout << res.size() << '\n';
	for(auto it : res) cout << it << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
struct UnionFind{
    vector<int> par;//親(根)
    vector<int> rank;//木の深さ

    UnionFind(int n){//初期化関数
        par.resize(n);
        rank.resize(n);
        for(int i = 0; i < n; i++){
            par[i] = i;//初めはノード一個の木なので根は自身
            rank[i] = 1;
        }
    }

    int root(int x){//木の根を求める
    if(par[x] == x) return x;
    else return par[x] = root(par[x]);
    }

    bool same(int x, int y){//同じ木かどうか判定
        return root(x) == root(y);//同じ木ならtrue
    }

    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return;//もし同じ木に属していたら何もしない
        if(rank[x] < rank[y]) swap(x, y);//数が大きい方に小さい方を結合させる
        par[y] = x;
        rank[x] += rank[y];//深さが同じ時だけ結合後深さが増える
    }

    int size(int x) {//深さを返す関数
        return rank[root(x)];
    }
};
int main(){
    int N, Q;
    cin >> N >> Q;
    UnionFind U(N);
    for(int i = 0; i < Q; i++){
        int t, u, v;
        cin >> t >> u >> v;
        if(t == 0) U.unite(u, v);
        else cout << (int)U.same(u, v) << endl;
    }
}

Measured memory_bytes: 4860
//love yjl forever
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int INF=0x3f3f3f3f;
int n;
ll ans=0,mi=0;
int main()
{
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	int i;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		ll x;
		scanf("%lld",&x);
		if(x>=mi) mi=x;
		else ans+=(mi-x);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> vs(n), hs(n), ts(m), ss(m);
    vector<int> vsum(n+1);
    for (int i = 0; i < n; ++i) {
        cin >> vs[i] >> hs[i];
        vsum[i+1] = vsum[i]+vs[i];
    }
    for (int i = 0; i < m; ++i) cin >> ts[i] >> ss[i];
    auto dp = make_v(m+1, n+1, -INF<ll>);

    dp[0][0] = 0;
    for (int i = 1; i <= m; ++i) {
        ll val1 = -INF<ll>, val2 = dp[i-1][0];
        for (int j = 0; j <= n; ++j) {
            if(j){
                val1 += hs[j-1]; val2 += hs[j-1];
                if(j >= 2){
                    val1 += abs(hs[j-1]-hs[j-2]);
                }
            }
            val1 = max(val1, val2);
            val2 = dp[i-1][j];
            if(ts[i-1] >= vsum[j]) dp[i][j] = max(val1, val2);
            if(dp[i][j] < ss[i-1]) dp[i][j] = -INF<ll>;
        }
    }
    int ans = ts.back();
    for (int i = 0; i <= n; ++i) {
        if(dp.back()[i] >= 0){
            cout << ans << "\n";
            return 0;
        }
        if(i != n) ans -= vs[i];
    }
    cout << -1 << "\n";
    return 0;
}


Measured memory_bytes: 26352
#ifdef _WIN32
#define DEBUG	1
#endif

#define _CRT_SECURE_NO_WARNINGS
#define MATH_PI 3.14159265358979323846264338327950288419716939
#include <iostream>
#include <string.h>
#include <fstream>
using namespace std;

#ifdef DEBUG
#include "include.h"
#else
inline void wait(){}
inline void dout(const char *arg, ...){}
#endif

template<typename T>inline void swap(T a, T b){T t = a; a = b; b = t;}

#define CLIP(ptr, min, max) {if((min)<=(max)){if(ptr<(min)){ptr=(min);}if(ptr>(max)){ptr=(max);}}}
#define max(a, b) a > b ? a : b;
#define min(a, b) a > b ? b : a;
#define Sin(deg) sin((deg)*MATH_PI/180)
#define Cos(deg) cos((deg)*MATH_PI/180)
#define Tan(deg) tan((deg)*MATH_PI/180)
#define Rad(deg) ((deg)*MATH_PI/180)
#define ff(param, num) for(int param=0 ; param<num ; ++param)
#define fi(num) for(int i=0 ; i<num ; ++i)
#define fj(num) for(int j=0 ; j<num ; ++j)
#define fk(num) for(int k=0 ; k<num ; ++k)
#define fl(num) for(int l=0 ; l<num ; ++l)
#define ffr(param, num) for(int param=num-1 ; param>=0 ; --param)
#define fir(num) for(int i=num-1 ; i>=0 ; --i)
#define fjr(num) for(int j=num-1 ; j>=0 ; --j)
#define fkr(num) for(int k=num-1 ; k>=0 ; --k)
#define flr(num) for(int l=num-1 ; l>=0 ; --l)
#define gi(p) Scanf("%d", p)
#define gi2(p1, p2) Scanf2("%d %d", p1, p2)
#define gi3(p1, p2, p3) Scanf3("%d %d %d", p1, p2, p3)
#define gi4(p1, p2, p3, p4) Scanf4("%d %d %d %d", p1, p2, p3, p4)
#define gll(p) Scanf("%lld", p)
#define gll2(p1, p2) Scanf2("%lld %lld", p1, p2)
#define gll3(p1, p2, p3) Scanf3("%lld %lld %lld", p1, p2, p3)
#define gll4(p1, p2, p3, p4) Scanf4("%lld %lld %lld %lld", p1, p2, p3, p4)
#define gf(p) Scanf("%f", p)
#define gf2(p1, p2) Scanf2("%f %f", p1, p2)
#define gf3(p1, p2, p3) Scanf3("%f %f %f", p1, p2, p3)
#define gf4(p1, p2, p3, p4) Scanf4("%f %f %f %f", p1, p2, p3, p4)
#ifdef DEBUG
#define gc(buf) fscanf(local_in.fp, "%s", buf)
#define Scanf(expr, p) fscanf(local_in.fp, expr, &p)
#define Scanf2(expr, p1, p2) fscanf(local_in.fp, expr, &p1, &p2)
#define Scanf3(expr, p1, p2, p3) fscanf(local_in.fp, expr, &p1, &p2, &p3)
#define Scanf4(expr, p1, p2, p3, p4) fscanf(local_in.fp, expr, &p1, &p2, &p3, &p4)
#else
#define gc(buf) Scanf("%s", buf)
#define Scanf(expr, p) scanf(expr, &p)
#define Scanf2(expr, p1, p2) scanf(expr, &p1, &p2)
#define Scanf3(expr, p1, p2, p3) scanf(expr, &p1, &p2, &p3)
#define Scanf4(expr, p1, p2, p3, p4) scanf(expr, &p1, &p2, &p3, &p4)
#endif
#define ans(p) cout << p << endl;
signed main() {

	int ii, jj, kk, ll;
	int N;
	int ret = 0;
	int flag = 0;
	char cbuf[8192];

	int M, C;
	gi3(N, M, C);

	int B[20];
	fi(M) gi(B[i]);
		
	fi(N){
		flag = 0;
		fj(M){
			gi(ii);
			flag += ii * B[j];
		}
		if(flag + C > 0) ++ret;
	}
	ans(ret);

	wait();

	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
list1 = list(map(int, input().split()))
list2 = [1] * n
for _ in range(m):
    a, b = map(int, input().split())
    if list1[a - 1] < list1[b - 1]:
        list2[a - 1] = 0
    elif list1[a - 1] > list1[b - 1]:
        list2[b - 1] = 0
    else:
        list2[a - 1] = 0
        list2[b - 1] = 0
print(list2.count(1))

Measured memory_bytes: 20144
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod= 1e9+7;
const ll INF = 1LL<<40;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll a[220000];
main(){
  ll n,b,c,ans=1e9;
  cin>>n;
  rep(i,0,n)cin>>a[i];
  sort(a,a+n);
  bool q=true;
  rep(i,0,n-1){
    if(a[i]==a[i+1])q=false;
  }
  if(q)cout<<"YES";
  else cout<<"NO";
}


Measured memory_bytes: 1920
import sys
N, M = map(int, input().split())
if N == 1:
    print(1)
    sys.exit()
ana = [0] * M
ans = [0] * N
mod = 10 ** 9 + 7
if M != 0:
    for i in range(M):
      ans[int(input())-1] = -1
if ans[0] == -1 and ans[1] == -1:
    print(0)
    sys.exit()
elif ans[0] == -1:
    ans[0] = 0
    ans[1] = 1
elif ans[1] == -1:
    ans[0] = 1
    ans[1] = 0
else:
    ans[0] = 1
    ans[1] = 2

if N != 2:
    for i in range(2,N):
        if ans[i] == -1:
            ans[i] = 0
        else:
            ans[i] = (ans[i-1]  + ans[i-2]) % mod
print(ans[N-1])


Measured memory_bytes: 6900
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  string s;
  while(cin >> s){

    int n = s.size();

    vector<string> ans;
    
    REP(i,n){
      if(ans.empty()){
        ans.push_back(s.substr(i,1));
      }else{
        if(ans.back().size() == 2){
          ans.push_back(s.substr(i,1));
        }else{
          if(ans.back()[0] == s[i]){
            if(i==n-1){
              ans.back() += s[i];
            }else{
              ans.push_back(s.substr(i,2));
              ++i;
            }
          }else{
            ans.push_back(s.substr(i,1));
          }
        }
      }
    }

    //join(cerr, ALL(ans));
    
    cout << ans.size() << endl;
  }
  
  return 0;
}


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

#define PI 4*atan(1)
#define INF 1e8

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

int l = 0, r = 0, u = 0, down = 0;

void dfs(int x, int y, int num, vector<vector<int>> S){
  bool f = false;
  l = min(l, y);
  r = max(r, y);
  u = min(u, x);
  down = max(down, x);
  if(S[num][0] != -1)dfs(x - 1, y, S[num][0], S);
  if(S[num][1] != -1)dfs(x, y + 1, S[num][1], S);
  if(S[num][2] != -1)dfs(x + 1, y, S[num][2], S);
  if(S[num][3] != -1)dfs(x, y - 1, S[num][3], S);
  return;
}

int main(){
  int N;
  while(cin >> N, N){
    r = 0; l = 0; u = 0; down = 0;
    vector<int> n(N), d(N);
    vector<vector<int>> S(N, vector<int>(4, -1));
    for(int i = 1; i <= N - 1; i++){
      cin >> n[i] >> d[i];
      S[n[i]][d[i]] = i;
    }
    dfs(0, 0, 0, S);
    cout << down - u + 1 << " " << r - l + 1 << endl;
  }
}

Measured memory_bytes: 5356
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    int N, X, M;
    cin >> N >> X >> M;
    int sum = 0;
    unordered_map<int, pair<int, int>> mp;
    REP(i, N) {
        // 循環した初回のみループ変数iを最終ループへ飛ばす
        if (mp.count(X) > 0) {
            // 循環する長さ
            int len = i - mp[X].first;
            // 循環する回数 (加算後は最大でもN-1)
            int cnt = (N - 1 - i) / len;
            sum += (sum - mp[X].second) * cnt;
            i += len * cnt;
        } else {
            mp[X] = {i, sum};
        }
        sum += X;
        X = X * X % M;
    }
    cout << sum << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 6080
#include<bits/stdc++.h>
using namespace std;
int main(){long long t,j,i,p,r=0;
cin>>t;
for(i=1;i<=9;i++){
    if(t%i==0){
        p=t/i;
        if(p<=9){
            r=1;break;
        }
    }
}if(r==1)
cout<<"Yes";
else
cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
  int n, a, b, x;

  x = 0;
  
  std::cin >> n;
  
  for (int i = 0; i < n; i++) {
    std::cin >> a >> b;
    x += (1 + b - a);  
  }
  
  std::cout << x << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        s: Chars,
        t: Chars,
    }

    let mut min = std::usize::MAX;
    for i in 0..=(s.len() - t.len()) {
        let mut count = 0;
        for j in 0..t.len() {
            if s[i + j] != t[j] {
                count += 1;
            }
        }
        if count < min {
            min = count;
        }
    }
    println!("{}", if min == std::usize::MAX { t.len() } else { min });
}


Measured memory_bytes: 2200
n = int(input())
c = []
for _ in range(n):
    s = input()
    tmp = [0] * 26
    for cc in s:
        tmp[ord(cc) - ord('a')] += 1
    c.append(tmp)
c.sort()
tmp = 1
ans = 0
for i in range(1, n):
    if c[i-1] == c[i]:
        tmp += 1
    else:
        if tmp > 1:
            ans += (tmp * (tmp-1) )// 2
        tmp = 1
if tmp > 1:
    ans += tmp * (tmp-1) // 2
print(ans)

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

int vec[110000];
int main(){
  int n,q;
  cin>>n>>q;
  string s;
  cin>>s;
  vec[0]=0;
  for(int i=0;i<s.size()+1;i++){
    if(i==0){
      vec[i+1]=0;
    }
    else{
      if(s[i-1]=='A'&&s[i]=='C'){
        vec[i+1]=vec[i]+1;
      }
      else{
        vec[i+1]=vec[i];
      }
    }
  }
  for(int i=0;i<q;i++){
    int a,b;
    cin>>a>>b;
    cout<<vec[b]-vec[a]<<endl;
  }
}

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

int main() {
	string s;
	cin >> s;

	vector<vector<int>> d(26, vector<int>(s.size(), 0));
	for (int i = 0; i < s.size(); ++i) {
		int c = s[i] - 'a';
		for (int j = 0; j < 26; ++j) {
			if (j == c) { d[j][i] += 1; }
			if (i > 0) { d[j][i] += d[j][i - 1]; }
		}
	}

	ll res = 1;
	for (int i = 0; i < s.size(); ++i) {
		int c = s[i] - 'a';
		ll tmp = (s.size() - i - 1) - (d[c][s.size() - 1] - d[c][i]);
		res += tmp;
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 21764
#include <iostream>

int main() {
  int N, A, B;
  std::cin >> N >> A >> B;

  int answer = 0;

  for (int i = 1; i <= N; i++) {
    int s = 0;

    for (int j = i; j > 0; j /= 10) {
      s += j % 10;
    }

    if (A <= s && s <= B) {
      answer += i;
    }
  }

  std::cout << answer << std::endl;
}


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

using namespace std;

#define int long long
#define u64 unsigned long long
#define u32 unsigned int
#define reg register
#define Raed Read
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define rep(a,b,c) for(reg int a=(b),a##_end_=(c); a<=a##_end_; ++a)
#define ret(a,b,c) for(reg int a=(b),a##_end_=(c); a<a##_end_; ++a)
#define drep(a,b,c) for(reg int a=(b),a##_end_=(c); a>=a##_end_; --a)
#define erep(i,G,x) for(reg int i=(G).Head[x]; i; i=(G).Nxt[i])

inline int Read() {
	int res = 0, f = 1;
	char c;
	while (c = getchar(), c < 48 || c > 57)if (c == '-')f = 0;
	do res = (res << 3) + (res << 1) + (c ^ 48);
	while (c = getchar(), c >= 48 && c <= 57);
	return f ? res : -res;
}

template<class T>inline bool Min(T &a, T const&b) {
	return a > b ? a = b, 1 : 0;
}
template<class T>inline bool Max(T &a, T const&b) {
	return a < b ? a = b, 1 : 0;
}

const int N = 1e5+5,M = 2e5 + 5,mod = 99999997;

bool MOP1;

struct node {
	int a,b;
	bool operator<(node _)const {
		return b!=_.b?b>_.b:a>_.a;
	}
} A[N];

bool MOP2;

int Fa[N];

int find(int x) {
	return Fa[x]==x?Fa[x]:Fa[x]=find(Fa[x]);
}

inline void _main(void) {
	int n=Raed(),m=Raed();
	rep(i,1,n)A[i]=(node)<%Read(),Read()%>;
	rep(i,1,m+1)Fa[i]=i;
	sort(A+1,A+n+1);
	int Ans=0;
	rep(i,1,n) {
		if(A[i].a>m)continue;
		int pos=find(A[i].a);
		if(pos==m+1)continue;
		Ans+=A[i].b,Fa[pos]++;
	}
	cout<<Ans;
}

signed main() {
#define offline1
#ifdef offline
	freopen("truck.in", "r", stdin);
	freopen("truck.out", "w", stdout);
	_main();
	fclose(stdin);
	fclose(stdout);
#else
	_main();
#endif
	return 0;
}

Measured memory_bytes: 2560
def main():
    x = int(input())
    if x % 11 == 0:
        print(2 * (x // 11))
    elif x % 11 <= 6:
        print(2 * (x // 11) + 1)
    else:
        print(2 * (x // 11) + 2)
    return


main()


Measured memory_bytes: 2940
from collections import defaultdict


def main():
    N = int(input())
    a_list = [int(input()) for _ in range(N)]
    used = set()
    now = 1
    ans = 0
    while True:
        if now == 2:
            print(ans)
            return
        now = a_list[now - 1]
        if now in used:
            print(-1)
            return
        used.add(now)
        ans += 1

if __name__ == '__main__':
    main()


Measured memory_bytes: 13560
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define inf 1000000000
#define mod 1000000007
#define li 100005
#define FOR for(int i=1;i<=n;i++)
typedef pair< int,int > PII;
typedef long long int lo;
lo n,m,cev,b;
string s;
vector<int> v;
int main(){
	scanf("%lld",&n);
	lo bas=1;
	lo son=n;
	while(bas<=son){
		lo mid=(bas+son)/2;
		if(mid*(mid+1)/2>=n){
			son=mid-1;
		}
		else bas=mid+1;
	}
	printf("%lld",bas);
	return 0;
}


Measured memory_bytes: 256
# coding: utf-8
N = int(input())

F = []
P = []

table = [2**i for i in range(10)]

for i in range(N):
    lis = list(map(int, input().split(' ')))
    F.append(lis)

for i in range(N):
    lis = list(map(int, input().split(' ')))
    P.append(lis)

maxx = -1000000001

for i in range(1, 1024):
    total = 0
    for j in range(N):
        n = 0
        for t in range(10):
            n += (1 if i&table[t] != 0 else 0)*F[j][t]
        total += P[j][n]
    if total > maxx:
        maxx = total

print(maxx)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const int MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
vector<ll> ans;
vector<vector<ll>> vec;
unordered_map<ll,ll> mp;
vector<bool> tf;
ll dp[200020];
void dfs(ll a){
  for(ll i=0;i<(ll)vec.at(a).size();i++){
    if(tf.at(vec.at(a).at(i))==false){
      dp[vec.at(a).at(i)+1]=dp[a+1]+mp[vec.at(a).at(i)+1];
      tf.at(vec.at(a).at(i))=true;
      dfs(vec.at(a).at(i));
    }
  }
}
int main(){
  ll N,Q;
  cin>>N>>Q;
  tf.resize(N);
  ans.resize(N);
  vec.resize(N,vector<ll>(0));
  for(ll i=0;i<N-1;i++){
    ll a,b;
    cin>>a>>b;
    vec.at(a-1).push_back(b-1);
    vec.at(b-1).push_back(a-1);
  }
  for(ll i=0;i<Q;i++){
    ll a,b;
    cin>>a>>b;
    mp[a]+=b;
  }
  tf.at(0)=true;
  dp[1]=mp[1];
  dfs(0);
  for(ll i=0;i<N;i++){
    cout<<dp[i+1]<<" ";
  }
}

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

namespace abc153
{
    class Program
    {
        static void Main(string[] args)
        {
           var h = long.Parse(Console.ReadLine());
            long ans = 1;
            long cnt = 1;
            while (h>1)
            {
                h = h / 2;
                cnt *= 2;
                ans = ans + cnt;
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S="MARCH";
    int n;
    cin >> n;
    vector<string> s(n);
    vl cnt(5,0);
    rep(i,n){
        cin >> s[i];
        rep(j,5){
            if(s[i][0]==S[j]){
                cnt[j]++;
            }
        }
    }
    ll ans=0;
    rep(i,3){
        FOR(j,i+1,4){
            FOR(k,j+1,5){
                ans+=cnt[i]*cnt[j]*cnt[k];
            }
        }
    }
  	cout << ans << endl;
}

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

int main() {
  ll H;
  cin >> H;
  int r = 0;
  ll ans = 0;
  while (H>0) {
    H /= 2;
    ans += pow(2, r);
    ++r;
  }
  cout << ans << endl;
  return 0;
}

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

const int mod=998244353,N=20010;
int jc[N],inv[N],n,c01,c11,f[N],c[N],mi[5010][10010];
char s[N],t[N];

int C(int a,int b)
{
	if (a<b||b<0) return 0;
	return 1ll*jc[a]*inv[b]%mod*inv[a-b]%mod;
}

int quickmi(int a,int b)
{
	int t=1;
	for (; b; b>>=1,a=1ll*a*a%mod)
		if (b&1) t=1ll*t*a%mod;
	return t;
}

int main()
{
	jc[0]=1;
	for (int i=1; i<N; i++) jc[i]=1ll*jc[i-1]*i%mod;
	inv[N-1]=quickmi(jc[N-1],mod-2);
	for (int i=N-1; i; i--) inv[i-1]=1ll*inv[i]*i%mod;
	scanf("%s%s",s,t),n=strlen(s),c01=c11=0;
	for (int i=0; i<n; i++) if (s[i]=='1')
		{if (t[i]=='1') c11++; else c01++;}
	for (int i=0; i<=c01; i++)
	{
		mi[i][0]=1;
		for (int j=1; j<=c01+c11; j++) mi[i][j]=1ll*mi[i][j-1]*i%mod;
	}
	for (int j=0; j<=c01; j++) c[j]=1ll*C(c01,j)*(((c01-j)&1)?(mod-1):1)%mod;
	int ans=0,nw;
	for (int m=0; m<=c11; m++)
	{
		nw=0;
		for (int j=0; j<=c01; j++) nw=(nw+1ll*c[j]*mi[j][c01+c11-m])%mod;
		ans=(ans+1ll*nw*jc[c11-m]%mod*C(c01+c11,m)%mod*C(c11,m)%mod*jc[m]%mod*jc[m]%mod*jc[c01])%mod;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 194816
#include<iostream>
using namespace std;
int main(){
  int x;
  int y;
  for(int i=1;;i++){
    cin >> x >> y;
    if(x==0 && y==0)break;
    if(x<=y){
      cout << x << " " << y << endl;
    }else{
      cout << y << " " << x << endl;
    }
  }
}


Measured memory_bytes: 2988
import java.util.Scanner;
class Main {
	public void small() {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a < b) {
			System.out.println("a < b");
		} else {
			if(a > b) {
				System.out.println("a > b");
			} else {
				System.out.println("a == b");
			}
		}
	}
	public static void main(String[] args) {
		new Main().small();
	}
}

Measured memory_bytes: 17160
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(n)-1,i##_len=(int)(s);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};
//今回の変数

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
ll Minl(ll a, ll b) {
	return (a)<(b) ? (a) : (b);
}
ll Maxl(ll a, ll b) {
	return (a)>(b) ? (a) : (b);
}

int main() {
	char s[5];
	scanf("%s", s);

	int cnt = 0;
	FOR(i, 'A', 'Z' + 1) {
		int tmpcnt = 0;
		REP(j, 4) {
			if (s[j] == i)tmpcnt++;
		}
		if (tmpcnt == 2)cnt++;
	}
	if (cnt == 2) {
		puts("Yes");
	}
	else {
		puts("No");
	}
}


Measured memory_bytes: 128
n = int(input())
g = [input().split()[2:] for _ in range(n)]

from collections import deque
que = deque()
que.append(0)
d = [0] + [-1] * n

while que:
    u = que.popleft()

    for v in g[u]:
        v = int(v) - 1

        if d[v] < 0:
            d[v] = d[u] + 1
            que.append(v)

for i in range(n):
    print(i+1, d[i])

"""
・グラフの数を受け取る
・グラフを作る．今回は隣接リストで必要な部分だけを残してリスト化する
・キュー用の配列を作る（これはなんでもいい．普通のリストでも可）．そのキューには1番初めのスタート位置を入れておく
・最短距離を置いておくリストを用意
・queの中身がなくなるまで続ける
・queの中身を取り出して，それにくっついてるノードを全て舐めていく．int方で入力を受け取っていないから注意．1-indexを0-indexに変える．
・もしそこにまだBFSが訪れていなかったら，そこに前回の場所から1足した物を代入
・探索用のqueに追加しておく．追加しておくことでまたそのノードとつながってるところを調べることができる
・最後は出力．全てのノードの最短距離を出力
"""



Measured memory_bytes: 6056
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

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

    scanf("%d %d", &a, &b);

    if (b % a == 0) {
        ans = a + b;
    } else {
        ans = b - a;
    }

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

    return 0;
}


Measured memory_bytes: 128
object Main extends App {
var k = readLine.split(" ")(3).toInt
var a, b, c = readLine.split(" ").map(_.toLong)
var sum = for (v1 <- a; v2 <- b) yield {
v1 + v2
}
java.util.Arrays.sort(sum)
  sum = sum.reverse
var sum2 = for (v1 <- sum.take(k); v2 <- c) yield {
v1 + v2
}
java.util.Arrays.sort(sum2)
val out = new java.io.PrintWriter(System.out)
for (i <- 0 to k - 1) {
out.println(sum2(sum2.length - 1 - i))
}
out.flush
}

Measured memory_bytes: 185848
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    cout << (c / a) * b << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
int ask(LL a,LL b){
	LL ans=a*b,s=a*b-b,c=b/2,d=b&1;
	for (LL k=1;k<a;s-=b,k++)
		ans=min(ans,max(d*k,max(abs(s-c*k),abs(s-(b-c)*k))));
	return ans;
}
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	printf("%d\n",min(ask(a,b),min(ask(b,a),
	min((a%3?b:0),(b%3?a:0)))));
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>

using namespace std;

int a[300000],b[300000];

int main ()
{
	int n,m;
	scanf ("%d",&n);
	m=n;
	for (int i=1;i<=n;i++)
		scanf ("%d",&a[i]);
	int j=0;
	for (int i=n;i>0;i-=2)
		b[++j]=a[i];
	for (int i=n-1;i>0;i-=2)
		b[m--]=a[i];
	for (int i=1;i<n;i++)
		printf ("%d ",b[i]);
	printf ("%d\n",b[n]);
	return 0;
}


Measured memory_bytes: 3712
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int n, k;
vector<int> a;
int sum = 0;
int ans = 0;

bool check(int v) {
  vector<int> b(n);
  REP(i, n) b[i] = a[i] % v;
  sort(ALL(b));
  vector<ll> b_sum(n + 1);
  b_sum[0] = 0;
  REP(i, n) b_sum[i + 1] = b_sum[i] + b[i];
  REP(i, n + 1) {
    ll cnt1 = b_sum[i];
    ll cnt2 = 1ll * v * (n - i) - (b_sum[n] - b_sum[i]);
    if (max(cnt1, cnt2) <= k) return true;
  }
  return false;
}

int main() {
  cin >> n >> k;
  a.resize(n);
  REP(i, n) cin >> a[i];
  REP(i, n) sum += a[i];
  for (int i = 1; i * i <= sum; ++i) {
    if (sum % i == 0) {
      if (check(i)) ans = max(ans, i);
      if (check(sum / i)) ans = max(ans, sum / i);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int Keisan(int N, int Y , int *kekka);

int main(void){

	int N,Y;
	int kekka[3] = {0};
	scanf("%d %d",&N,&Y);
	// 1000yenだけで数えた枚数n
	Keisan(N,Y,&kekka[0]);

	printf("%d %d %d",kekka[0],kekka[1],kekka[2]);

	return 0;
}


int Keisan(int N, int Y , int *kekka){
	int n = Y / 1000;
	int j,i = 0;
	for(j = 0; n - 9*j >= N; j++){
		while(1){
			if(N - i - j < 0){
				i = 0;
				break;
			}
			if(N == n - (4*i + 9*j)){
				kekka[0] = j;
				kekka[1] = i;
				kekka[2] = N - i - j;
				return 0;
			}
			i++;
		}
	}

	kekka[0] = -1;
	kekka[1] = -1;
	kekka[2] = -1;

	return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    while (true){
        C -=B;
        if (!(C>0)){
            cout << "Yes";
            return 0;
        }
        A-=D;
        if (!(A>0)){
            cout << "No";
            return 0;
        }
    }
}

Measured memory_bytes: 3636
a,b=[int(i) for i in input().split()]
abab=abs(abs(a) - abs(b))
saab=abs(b-a)
if b < a and b * a >0:
  print(saab + 2)
elif b > a and b * a >=0:
  print(saab)
elif b < a and b * a <=0:
  print(min(saab + 1,abab+1))
elif b > a and b * a <0:
  print(min(saab,abab+1))

Measured memory_bytes: 3064
#include<stdio.h>

int main(){
        long long a, b, c, d, ans;
        scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
        ans=a*c;
        if(ans<a*d)ans=a*d;
        if(ans<b*c)ans=b*c;
        if(ans<b*d)ans=b*d;
        printf("%lld", ans);
        return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){

  int a,b;
  cin >> a >> b;
  cout << (a+b)%24 << endl;





  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int n, m;
int ingrade[100002];
vector<int>v[100002];
int dp[100002]; // longest path to node i
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    for(int i = 1; i <= m; ++i)
    {
        int a, b;
        cin >> a >> b;
        v[a].push_back(b);
        ++ingrade[b];
    }
    deque<int>d;
    for(int i = 1; i <= n; ++i)
        if(!ingrade[i])
            d.push_back(i);
    while(!d.empty())
    {
        int node = d[0];
        d.pop_front();
        for(int i = 0; i < v[node].size(); ++i)
        {
            int next = v[node][i];
            --ingrade[next];
            dp[next] = max(dp[next], dp[node] + 1);
            if(ingrade[next] == 0)
                d.push_back(next);
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; ++i)
        ans = max(ans, dp[i]);
    cout << ans;
    return 0;
}


Measured memory_bytes: 6528
#include<iostream>
#include<algorithm>
#include<vector>
#define PP std::pair<int,int>
#define INF (1<<30)
#define LL long long
int H, W;
LL cost[11];
bool d[11];
LL c[11][11];
LL ans;


int main() {
	std::cin >> H >> W;
	for (int i = 0; i <= 9; i++) {
		for (int j = 0; j <= 9; j++) {
			std::cin >> c[i][j];
		}
	}
	for (int i = 0; i <= 9; i++) {
		cost[i] = c[i][1];
	}
	std::vector<int> fig;
	fig.push_back(1);
	d[1] = true;
	while (fig.size() != 10) {
		for (int i = 0; i < (int)fig.size(); i++) {
			for (int j = 0; j <= 9; j++) {
				cost[j] = std::min(cost[fig[i]] + c[j][fig[i]], cost[j]);
			}
		}
		std::vector<PP> tmp;
		for (int i = 0; i <= 9; i++) {
			if (!d[i])
				tmp.push_back(PP(cost[i], i));
		}
		std::sort(tmp.begin(), tmp.end());
		fig.push_back(tmp[0].second);
		d[tmp[0].second] = true;
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			int a;
			std::cin >> a;
			if(a>=0)
			ans += cost[a];
		}
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <climits>
#include <ctime>
#include <random>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define eps 1e-9
#define inf 0x3f3f3f3f
#define mod 1000000007
using namespace std;

int main() {
	speed;
	int n, m, k;
	cin >> n >> m >> k;
	vector<int>a(n), b(m);
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int i = 0; i < m; ++i)
		cin >> b[i];
	reverse(a.begin(), a.end()), reverse(b.begin(), b.end());
	int tmp = 0, ans = 0;
	vector<int>t;
	while (k > 0 && a.size())
		k -= a.back(), t.push_back(a.back()), a.pop_back(), ++tmp;
	if (k < 0)
		k += t.back(), t.pop_back(), --tmp;
	ans = tmp;
	while (t.size() && b.size()) {
		while (b.back() > k && t.size())
			k += t.back(), t.pop_back(), tmp--;
		while (b.size() && k >= b.back())
			k -= b.back(), b.pop_back(), tmp++;
		ans = max(ans, tmp);
	}
	cout << ans;
}

Measured memory_bytes: 5448
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	int A, B, K;
	cin >> A >> B >> K;
	int lim = min(A, B);
	int N = 0;
	vector<int> ans;

	for (int i = 1;i<=lim; i++) {
		if(A%i==0&&B%i==0){
			ans.push_back(i);
		}
	}

	sort(all(ans), greater<int>());

	cout << ans[K - 1] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll n, ans;
double t[1010], a, T, sa;
int main(void){
    // Your code here!
    sa = 1000000;
    cin >> n >> T >> a;
    for (ll i = 1; i <= n; i++){
        double h;
        cin >> h;
        t[i] = T - h * 6 / 1000;
    }
    for (ll i = 1; i <= n; i++){
        if (sa > (a - t[i] > 0 ? a - t[i] : t[i] - a)){
            sa = (a - t[i] > 0 ? a - t[i] : t[i] - a);
            ans = i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

struct CombInv{
                const long long MOD = 1e9+7;

                //nPrを返す
                long long Permutation(long long n, long long r){
                        long long tmp = 1;
                        long long i = n;
                        while(i!=n-r){
                                tmp *= i;
                                tmp %= MOD;
                                --i;
                        }
                        return tmp;
                }

                //x!を返す
                long long Factorial(long long x){
                        long long tmp = 1;
                        long long i = 1;
                        while(i<=x){
                                tmp *= i;
                                tmp %= MOD;
                                ++i;
                        }
                        return tmp;
                }

                //x^pを返す
                long long FastPow(long long x, long long p){
                        if(p==1) return x;
                        if(p%2==0){
                                long long sr = FastPow(x, p/2);
                                return (sr*sr)%MOD;
                        }else{
                                long long sr = FastPow(x, (p-1)/2);
                                return ((x*sr)%MOD*sr)%MOD;
                        }
                }

                //chi/parをMODで割った余りを返す
                long long InverseElement(long long par, long long chi=1){
                        return (chi%MOD*FastPow(par, MOD-2))%MOD;
                }

                //nCrを返す
                long long Combination(long long n, long long r){
                        return (Permutation(n,r)*(InverseElement(Factorial(r))))%MOD;
                }
        };

int main(){
        ll n,a,b,ans;
        cin >> n >> a >> b;
        CombInv ci;
        ans = ci.FastPow(2, n) - 1;
        ans -= ci.Combination(n,a);
        if(ans<0) ans += MOD;
        ans -= ci.Combination(n,b);
        if(ans<0) cout << ans+MOD << endl;
        else cout << ans << endl;
        return 0;
}

Measured memory_bytes: 3636
#include <string>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;


int main() {
    ll n, k;
    scanf("%lld %lld", &n, &k);
    vector<pll> a(n);
    ll f, s;
    for (int i = 0; i < n; i++) {
        scanf("%lld %lld", &f, &s);
        a[i].second = f; a[i].first = s;
    }
    // 美味しさ降順にソート
    sort(a.begin(), a.end(), greater<pll>());
    ll ans = 0;
    ll sum = 0; // 美味しさ sum
    ll kind = 0; // 何種類食べたか
    // 降順に並べるpriority queue
    priority_queue<ll, vector<ll>, greater<ll> > PQ;
    // 食べた種類を格納する
    set<ll> S;
    
    for (int i = 0; i < k; i++) {
        sum += a[i].first;
        if (S.count(a[i].second) == 0) {
            kind++;
            S.insert(a[i].second);
        }
        else {
            PQ.push(a[i].first);
        }
    }

    ans = sum + kind * kind;

    // 美味しさがk番目に大きいやつ以降を調べる
    for (ll i = k; i < n; i++) {
        if (PQ.empty()) break;
        // i 番目のやつがまだ食べてない種類なら
        if (S.count(a[i].second) == 0) {
            kind++;
            sum -= PQ.top(); PQ.pop();
            sum += a[i].first;
            S.insert(a[i].second);
            ans = max(ans, sum + kind * kind);
        }
    }

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


Measured memory_bytes: 5116
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;
char str[5];

int main() {
	while(~scanf("%s", str)) {
		int cnt = 0;
		for(int i = 0; i < strlen(str); i++) {
			if(str[i] == '1') cnt++;
		}
		printf("%d\n", cnt);
	}
	return 0;
}

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


int main()
{
	unsigned int n, a, max = 0, min = 1000000001;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a;
		if (a <= min) {
			min = a;
		}
		if (a >= max) {
			max = a;
		}
	}
	cout << max - min;
}

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

int main() {
  int64_t ans;
  string S;
  cin >> S;
  int N = S.size();
  vector<int> vec(N);
  for (int i=0; i<N; i++) {
    vec.at(i) = S.at(i) - '0';
  }
  if (N > 1) {
    for (int i=0; i<=N-2; i++) {
      for (int j=0; j<= N-2-i ;j++) {
        ans += pow(10,j) * pow(2,N-2-i-j) * vec.at(i) * pow(2,i); 
      }
      ans += pow(10,N-1-i) * vec.at(i) * pow(2,i);
    }
    ans += vec.at(N-1) * pow(2,N-1);
  } else {
      ans += vec.at(0);
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>
using namespace std;

int main(int argc, const char * argv[]) {
    
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    A--; B--; C--; D--;
    string S;
    cin >> S;
    
    bool flag1 = true;
    for (int i = A; i < max(C, D) - 1; i++) {
        if (S.substr(i, 2) == "##") {
            flag1 = false;
            break;
        }
    }
    if (!flag1) {
        cout << "No" << endl;
        return 0;
    }
    
    if (C < D) {
        cout << "Yes" << endl;
        return 0;
    } else {// 途中でsがfを抜く
        bool flag2 = false;
        for (int i = B - 1; i < D; i++) {
            if (S.substr(i, 3) == "...") {
                flag2 = true;
                break;
            }
        }
        if (flag2) cout << "Yes" << endl; else cout << "No" << endl;
    }
    
    return 0;
}


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

#define fastio {\
    ios::sync_with_stdio(0);\
    cin.tie(0);\
}

#define file {\
    freopen("io\\in.txt", "r", stdin);\
    freopen("io\\out.txt", "w", stdout);\
    freopen("io\\err.txt", "w", stderr);\
}

#ifdef LOCAL
#define debug(args...) {\
    string _s(#args);\
    replace(_s.begin(), _s.end(), ',', ' ');\
    stringstream _ss(_s);\
    istream_iterator<string> _it(_ss);\
    debug1(_it, args);\
}

#pragma GCC diagnostic ignored "-Wunused-parameter"
void debug1(istream_iterator<string> it) {
    cerr << endl;
}
#pragma GCC diagnostic pop

template<class T, class... Args>
void debug1(istream_iterator<string> it, T a, Args... args) {
    cerr << '>' << *it << " = " << a << "; ";
    debug1(++it, args...);
}
#else
#define debug(args...)
#define cerr if (false) cerr
#endif

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using si = set<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

#define rep(i, n)   for (int i = 0; i < n; i++)
#define dotc()      int tcs; if (cin >> tcs) rep(tc, tcs)
#define sz(x)       (int)x.size()
#define eb          emplace_back
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define all(x)      x.begin(), x.end()
#define rall(x)     x.rbegin(), x.rend()
#define fi          first
#define se          second

const int inf(0x3fffffff);
const int mod(1000000007);
const double pi(acos(-1.0));

signed main() {
    fastio;
#ifdef LOCAL
    file;
#endif

    int h, w, k;
    cin >> h >> w >> k;
    vector<string> m(h);
    rep(i, h) cin >> m[i];

    int cnt = 0;
    rep(i, 1 << h) {
        rep(j, 1 << w) {
            vector<string> t(m);

            rep(x, h) {
                if (i >> x & 1) {
                    rep(r, w) t[x][r] = '.';
                }
            }

            rep(y, w) {
                if (j >> y & 1) {
                    rep(r, h) t[r][y] = '.';
                }
            }

            int c = 0;
            rep(x, h) rep(y, w) if (t[x][y] == '#') c++;
            if (c == k) cnt++;
        }
    }

    cout << cnt;

    return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

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

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int X, Y;
    cin >> X >> Y;
    for(int i = 0; i <= 100; ++i) {
        for(int j = 0; j <= 100; ++j) {
            if(i + j == X && i * 2 + j * 4 == Y) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  string S;
  cin >> S;
  int N = S.size();
  int ng = 0;
  REP(i, N) {
    if (S[i] == 'x') ng++;
  }
  if (8 <= ng)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 256
class Dice:
  def __init__(self, m1, m2, m3, m4, m5, m6):
    self.m1 = m1
    self.m2 = m2
    self.m3 = m3
    self.m4 = m4
    self.m5 = m5
    self.m6 = m6

  def moveDice(self, dir):
    if dir == 'S':
      self.m1, self.m2, self.m6, self.m5 = self.m5, self.m1, self.m2, self.m6
    elif dir == 'N':
      self.m1, self.m2, self.m6, self.m5 = self.m2, self.m6, self.m5, self.m1
    elif dir == 'E':
      self.m1, self.m4, self.m6, self.m3 = self.m4, self.m6, self.m3, self.m1
    elif dir == 'W':
      self.m1, self.m3, self.m6, self.m4 = self.m3, self.m6, self.m4, self.m1

n1, n2, n3, n4, n5, n6 = map(int, input().split())
direct = input()

dice1 = Dice(n1, n2, n3, n4, n5, n6)
for i in range(len(direct)):
  dice1.moveDice(direct[i])

print(dice1.m1)      


Measured memory_bytes: 5608
#include <iostream>
#include<string>

using namespace std;

int main()
{   int Count=0;
    string S,T;
    cin>>S>>T;
    for(int i=0;i<S.size();i++){
        if(S[i]!=T[i]){
            Count+=1;
        }
    }
    cout<<Count;

    return 0;
}


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

int main(){
    ll n, m, k;
    cin >> n >> m >> k;

    vector<ll> a(n);
    vector<ll> a_acc(n+1, 0);
    vector<ll> b(m);
    vector<ll> b_acc(m+1, 0);
    rep(i, n) {
        cin >> a[i];
        a_acc[i+1] = a[i] + a_acc[i];
    }
    rep(i, m) {
        cin >> b[i];
        b_acc[i+1] = b[i] + b_acc[i];
    }
 

    ll max_cnt = 0;
    rep(i, n+1) {
        if (a_acc[i] > k) {
            break;
        }
        auto it = upper_bound(b_acc.begin(), b_acc.end(), (k - a_acc[i]));
        ll j = it - b_acc.begin();
        max_cnt = max(max_cnt, i+j-1);
    }

    cout << max_cnt << endl;
    return 0;
}


Measured memory_bytes: 9576
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int N,K,res=0;
	cin>>N>>K;
	for(int i=0;i<N;i++)
	{
		int t;
		cin>>t;
		res+=min(abs(t-K)*2,t*2);
	}
	cout<<res<<endl;
}


Measured memory_bytes: 256