akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i=1,i##_len=(n); i<=i##_len; ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for(int i=(s);i<(t);++i)
#define rng(obj) (obj).begin(), (obj).end()
#define maxs(x,y) (x=max((x),(y)))
#define mins(x,y) (x=min((x),(y)))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x=max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T>>
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vp = vector<P>;
template <class T> inline istream& operator>>(istream&i,v(T)&v)
{ rep(j,sz(v))i>>v[j];return i;}
template <class T> string join(const v(T)&v)
{ stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template <class T> inline ostream& operator<<(ostream&o,const v(T)&v)
{ if(sz(v))o<<join(v); return o;}
template <class T1,class T2> inline istream& operator>>(istream&i ,pair<T1,T2>&v)
{ return i>>v.fi>>v.se;}
template <class T1,class T2> inline ostream& operator<<(ostream&o ,pair<T1,T2>&v)
{ return o<<v.fi<<","<<v.se;}
template <class T> inline ll suma(const v(T)& a) 
{ ll res(0); for(auto&& x:a) res += x; return res;}
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const double eps = 1e-10;
const int MX = 200005;
//----------------------------------------------------------------

#define fileio ifstream fio; if(argc>=2){fio.open(argv[1]); std::cin.rdbuf(fio.rdbuf());}
#define fastio ios_base::sync_with_stdio(false);
#define MOD 1000000007
//----------------------------------------------------------------

void Main(){
  int n;
  cin>>n;
  vl a(n);
  cin>>a;
  unordered_map<ll,ll> m;
  rep(i,n){
    m[a[i]]++;
  }
  ll ans = 0;
  for(auto i:m){
    if(i.se>i.fi) ans+=i.se-i.fi;
    else if(i.se<i.fi) ans+=i.se;
  }
  cout<<ans<<endl;
} int main(int argc,char* argv[]){ 
    fastio; fileio; Main();}


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

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL

// {{{ define basic macro
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

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


int solve(){
  int n;cin>>n;
  set<string> s;
  string w[n];
  rep(i, n){
    cin>>w[i];
  }
  s.insert(w[0]);
  rep(i, 1, n){
    if (s.find(w[i]) != s.end()){
      cout << "No" << endl;
      return 0;
    }
    if (w[i][0] != w[i-1][sz(w[i-1])-1]){
      cout << "No" << endl;
      return 0;
    }
    s.insert(w[i]);
  }
  cout << "Yes" << endl;
  return 0;
}

int test(){ //{{{
  return 0;
}
//}}}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
#ifdef PCM
  test();
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

//#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 6e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, a[N], cur, t[N * 4], ans[N];
vi g[N];
int get(int v, int l, int r, int left, int right) {
  if (left > r || right < l) return 0;
  if (left <= l and r <= right) return t[v];
  return max(get(v + v, l, md, left, right), get(v + v + 1, md + 1, r, left, right));
}
void upd(int v, int l, int r, int pos, int val) {
  if (l == r) {
    t[v] = val;
    return;
  }
  pos <= md ? upd(v + v, l, md, pos, val) : upd(v + v + 1, md + 1, r, pos, val);
  t[v] = max(t[v + v], t[v + v + 1]);
}
void dfs(int v, int pr) {
  int mx = get(1, 1, cur, 1, a[v] - 1);
  ans[v] = max(mx + 1, ans[pr]);
  int was = get(1, 1, cur, a[v], a[v]);
  if (was < ans[v]) upd(1, 1, cur, a[v], mx + 1);
  for (int to : g[v]) {
    if (to != pr) {
      dfs(to, v);
    }
  }
  if (was < ans[v]) upd(1, 1, cur, a[v], was);
}
main() {
  file("threesum");
  ios;
  cin >> n;
  map <int, int> M;
  fo(i, 1, n, 1) cin >> a[i], M[a[i]];
  for (auto & it : M) it.S = ++cur;
  fo(i, 1, n, 1) a[i] = M[a[i]];
  fo(i, 1, n - 1, 1) {
    int u, v;
    cin >> u >> v;
    g[u].eb(v);
    g[v].eb(u);
  }
  dfs(1, 1);
  fo(i, 1, n, 1) cout << ans[i] << "\n";
  return 0;
}
/**

*/


Measured memory_bytes: 37144
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
ll N,M;
const int MAX=3030;
ll dp[MAX+1][MAX+1];
struct Combinatorics {
  using int64 = long long;
  int64 mod;
  int64 fact[202020];
  int64 invfact[202020];
  Combinatorics(int64 mod):mod(mod) {
    fact[0] = invfact[0] = 1;
    for(int i = 1; i < 202020; ++i) {
      fact[i] = fact[i-1]*i%mod;
      invfact[i] = minv(fact[i]);
    }
  }
  int64 mpow(int64 x, int64 n) const {
    int64 res = 1;
    while(n > 0) {
      if(n&1) res = res*x%mod;
      x = x*x%mod;
      n >>= 1;
    }
    return res;
  }
  int64 minv(int64 x) const {
    return mpow(x, mod-2);
  }
  int64 mfact(int64 x) const {
    return fact[x];
  }
  int64 C(int64 n, int64 r) const {
    if(r < 0 || n < r) return 0;
    return fact[n]*invfact[r]%mod*invfact[n-r]%mod;
  }
  int64 P(int64 n, int64 r) const {
    if(r < 0 || n < r) return 0;
    return fact[n]*invfact[n-r]%mod;
  }
};
void calcDP(){
  dp[0][0]=1;
  FOR(i,1,MAX){
    FOR(j,0,i+1){
      (dp[i][j]+=dp[i-1][j]*(j+1)%M)%=M;
      if(j)(dp[i][j]+=dp[i-1][j-1])%=M;
    }
  }
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin>>N>>M;
  calcDP();
  Combinatorics c1(M);
  Combinatorics c2(M-1);
  ll ans=0;
  FOR(k,0,N+1){
    ll cal=0;
    ll b=c1.mpow(2,N-k);
    ll p=1;
    FOR(x,0,N+1){
      cal=(cal+dp[k][x]*p)%M;
      p=p*b%M;
    }
    cal=(cal*c1.C(N,k))%M;
    cal=(cal*c1.mpow(2,c2.mpow(2,N-k)))%M;
    if(k&1){
      ans = (ans - cal + M) % M;
    }else{
      ans = (ans + cal) % M;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 76672
#include<iostream>
using namespace std;
int main(){
  string ans;
  int a,f,s;
  cin>>a;
  f=a/100;
  s=a%100;
  if(f<=12){
    if(f==0&&0<s&&s<=12)
      ans="YYMM";
    if(0<f)
      ans="MMYY";
    if(0<f&&0<s&&s<=12)
      ans="AMBIGUOUS";
  }
  else if(12<f){
    if(0<s&&s<=12)
      ans="YYMM";
    if(12<s||s==0)
      ans="NA";
  }
  if((s==0&&f==0)||(s>12&&f>12))
    ans="NA";
  
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
    char w[201],t[201];
    int a,b,l,i;
    while(1){
        scanf("%s",w);
        if(strcmp(w,"-")==0)
            break;
        l=strlen(w);
        scanf("%d",&a);
        while(a--){
            scanf("%d",&b);
            for(i=0;i<l;i++){
                t[i]=w[(i+b)%l];
            }
            t[l]='\0';
            strcpy(w,t);
        }
        printf("%s\n",t);
    }
    return (0);
}


Measured memory_bytes: 2104
/*
Sharif Hasan - CSE, PUST
Apr 24, 2020 02: 14 PM
*/
#include<bits/stdc++.h>
#define br cout<<"\n"
#define what(x) cout<<"in here var= "<<x<<"\n";

/*STL definations*/
#define pb push_back

#define FOR(i,n) for(int i=0;i<n;i++)
#define FROM(a,i,n) for(int i=a;i<n;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

int cnt[10000001]={-1};
/*Main function*/
int main()
{
    int op=0;
    int n;
    cin>>n;
    for(int i=1;i<=n;++i){
        for(int j=i;j<=n;j+=i){
            //divi[j].push_back(i);op++;
            ++cnt[j];
        }
    }
    unsigned long long ans=0;
    for(unsigned long long i=1;i<=n;++i){
        ans+=i*cnt[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 42664
#include<bits/stdc++.h>
#define ull unsigned long long
#define charToInt(c) (c-'0')
using namespace std;

int main(){
string s;
cin>>s;
ull int sum=0;
for(int i=0;i<s.length();i++){
   sum+=charToInt(s[i]);
}
if(sum%9==0)
    cout<<"Yes";
else
    cout<<"No";
return 0;
}


Measured memory_bytes: 3704
N, M = map(int, input().split())

L_list = []
R_list = []

for i in range(M):
    A, B = map(int, input().split())
    L_list.append(A)
    R_list.append(B)

if max(L_list) > min(R_list):
    print(0)
else:
    print(min(R_list) - max(L_list) + 1)

Measured memory_bytes: 16724
h, w = map(int, input().split())
c = [input() for i in range(h)]
s=0

for i in range(h):
  for j in range(w):
    if c[i][j]=="#":
      s+=1
      
a = 1
x = 0
y = 0

while a<s:
  flg = True
  while x+1<w and c[y][x+1]=="#":
    x+=1
    a+=1
    flg = False
  while y+1<h and c[y+1][x]=="#":
    y+=1
    a+=1
    flg = False
  if flg:
    break
if a==s:
  print("Possible")
else:
  print("Impossible")


  
    

Measured memory_bytes: 62036
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    string s;
    cin >> s;
    string ans;
    for (auto elem : s) {
        if (elem == '0') ans += '0';
        else if (elem == '1') ans += '1';
        else if (ans.size() != 0) ans.pop_back();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import queue

K = int(input())


# 1,,,9をenqueue
q = queue.Queue()
for i in range(1, 10):
    q.put(i)

x = 0
i = 0
# K回繰り返す
while i < K:
    # x = dequeue
    x = q.get()

    one = x % 10
    # xの一桁目が0でなければ(x * 10 + xの一桁目に1加算した値)をenqueue
    if one != 0:
        q.put(x * 10 + one - 1)

    # x * 10をenqueue
    q.put(x * 10 + one)

    # xの一桁目が9でなければ(x * 10 - xの一桁目から1減算した値)をenqueue
    if one != 9:
        q.put(x * 10 + one + 1)

    i += 1

# xが答え
print(x)

Measured memory_bytes: 12480
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = INF+7;
const ll LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define VI vector<int>
#define VII vector<vector<int>>
#define all(v) (v.begin(),v.end())
#define MP make_pair
#define pb(n) push_back(n)


int main(){
    int N,q;
    cin>>N;
    vector<int> p(101,0);
    rep(i,N){cin>>q;++p[q];}
    rrep(i,101)p[i]+=p[i+1];
    rrep(i,101){
        if(p[i]>=i){
            cout<<i<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3104
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>
#include <bitset>
#include <numeric>
#include <cassert>
#ifdef DEBUG
#include "./Lib/debug.hpp"
#else
#define dump(...)
template<class T>inline auto d_val(T a, T b) { return a; }
#endif

/* (=＾o＾=) */
#define int ll

/* macro */
#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define REPI2(it,b,e) for(auto it = (b); it != (e); ++it)
#define REPI(it,c) REPI2(it, (c).begin(), (c).end())
#define RREPI(it,c) REPI2(it, (c).rbegin(), (c).rend())
#define REPI_ERACE2(it, b, e) for(auto it = (b); it != (e);)
#define REPI_ERACE(it, c) REPI_ERACE2(it, (c).begin(), (c).end())
#define ALL(x) (x).begin(),(x).end()
#define cauto const auto&
/* macro func */
#define SORT(x) do{sort(ALL(x));}while(false)
#define RSORT(x) do{sort((x).rbegin(),(x).rend());}while(false)
#define UNIQUE(v) do{v.erase( unique(v.begin(), v.end()), v.end() );}while(false)
#define MAX(x,y) do{x = std::max(x,y);}while(false)
#define MIN(x,y) do{x = std::min(x,y);}while(false)
#define BR do{cout<<"\n";}while(false)

/* type define */
using ll = long long;
using PAIR = std::pair<ll, ll>;
using VS = std::vector<std::string>;
using VL = std::vector<long long>;
using VVL = std::vector<VL>;
using VVVL = std::vector<VVL>;
using VD = std::vector<double>;
template<class T>
using V = std::vector<T>;

/* using std */
using std::cout;
constexpr char endl = '\n';
using std::cin;
using std::sort;
using std::pair;
using std::string;
using std::stack;
using std::queue;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::unordered_multiset;
using std::multiset;
using std::bitset;
using std::priority_queue;

/* constant value */
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;

/* Initial processing  */
struct Preprocessing { Preprocessing() { std::cin.tie(0); std::ios::sync_with_stdio(0); }; }_Preprocessing;

/* Remove the source of the bug */
signed pow(signed, signed) { assert(false); return -1; }

/* define hash */
namespace std { template <>	class hash<std::pair<ll, ll>> { public:	size_t operator()(const std::pair<ll, ll>& x) const { return hash<ll>()(1000000000 * x.first + x.second); } }; }

/* input */
template<class T> std::istream& operator >> (std::istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }

//=============================================================================================

signed main() {
	ll n, m;
	cin >> n >> m;
	priority_queue<ll> q;
	REP(i, n) {
		ll a;
		cin >> a;
		q.emplace(a);
	}

	REP(_, m) {
		ll t = q.top();
		q.pop();
		q.emplace(t / 2);
	}

	ll ans = 0;
	while (!q.empty()) {
		ans += q.top();
		q.pop();
	}
	cout << ans << endl;
}

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

int main() {
  
  int A, B, sum = 0;
  cin >> A >> B;
  
  if(A > B) {
    sum = (2 * A - 1);
  }
  
  else if(A < B) {
    sum = (2 * B - 1);
  }
  
  else {
    sum = 2 * A;
  }
  
  cout << sum << endl;
  
}

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

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

    string s[3];
    for(int i=0; i < 3; ++i) cin >> s[i];

    cout << s[0][0] << s[1][1] << s[2][2] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,k;
int a[110];
bool dp[100010];
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;++i){
		cin>>a[i];
	}
	for(int i=1;i<=k;++i){
		for(int j=1;j<=n;++j){
			if(a[j]<=i){
				if(!dp[i-a[j]])dp[i]=1;
			}
		}
	} 
	if(dp[k])cout<<"First"<<endl;
	else cout<<"Second"<<endl;
	
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

int n;
vector<int> G[100005];
vector<bool> flg(100005, false);
vector<vector<ll>> dp(100005, vector<ll>(2, 0));

void rec(int from, int now){
    if(flg[now]) return;
    flg[now] = 1;
    dp[now][0] = 1;
    dp[now][1] = 1;
    for(auto to:G[now]){
        if(to == from) continue;
        rec(now, to);
        dp[now][0] = dp[now][0] * (dp[to][0]+dp[to][1]) % mod;
        dp[now][1] = dp[now][1] * dp[to][0] % mod;
    }
}


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

    cin >> n;
    for(int i=0; i<n-1; ++i){
        int x,y; cin >> x >> y;
        --x; --y;
        G[x].push_back(y);
        G[y].push_back(x);
    }

    rec(-1, 0);

    cout << (dp[0][1]+dp[0][0])%mod << endl;

	return 0;
}


Measured memory_bytes: 18176
/*  
          ■■■■                                       
          ■■■■■                     ■■■■             
         ■■■ ■■■              ■■■■■■■■■■             
        ■■■   ■■■             ■■■■■■■      ■■■■■■■■■■
       ■■■     ■■■                 ■■      ■■■■■■■■■■
      ■■■       ■■■                ■■      ■■      ■■
     ■■■■        ■■■■              ■■      ■■      ■■
    ■■■           ■■■■       ■■■■■■■■■■■■■ ■■      ■■
  ■■■■■■■■■■■■■■■■  ■■■■     ■■■■■■■■■■■■■ ■■      ■■
 ■■■■  ■■■■■■■■■■■    ■■■■        ■■■      ■■      ■■
■■■                     ■         ■■■      ■■      ■■
                                 ■■■■      ■■      ■■
   ■■■■■■■■■■■■■■■■■■■           ■■■■■■    ■■      ■■
   ■■■■■■■■■■■■■■■■■■■          ■■■■■■■■   ■■      ■■
          ■■       ■■■          ■■ ■■ ■■■  ■■      ■■
          ■■       ■■■         ■■  ■■  ■■  ■■      ■■
          ■■       ■■■        ■■■  ■■   ■  ■■      ■■
          ■■       ■■■       ■■■   ■■      ■■      ■■
          ■■       ■■■       ■■    ■■      ■■      ■■
          ■■       ■■■        ■    ■■      ■■      ■■
          ■■       ■■■             ■■      ■■■■■■■■■■
          ■■   ■■■■■■              ■■      ■■■■■■■■■■
          ■■   ■■■■■■              ■■      ■■      ■■
          ■■                       ■■      ■■      ■■
          ■■                       ■■                
*/

/* 記念に */

#include <iostream>
#include <algorithm>
using namespace std;
 
int main() { 
    long long int n, a, reiwa = 0;
    cin >> n;
    long long int s[n+1] = {};
    s[0] = 0;
    for(int i = 1; i <= n; ++i) {
        cin >> a;
        s[i] += s[i-1] + a;
    }
    sort(s, s+n+1);
    a = 1;
    for(int i = 1; i <= n; ++i) {
        if(s[i] == s[i-1]) {
            a++;
        } else {
            reiwa += a*(a - 1)/2;
            a = 1;
        }
    }
    reiwa += a*(a - 1)/2;
    cout << reiwa << '\n';
}

Measured memory_bytes: 1792
n,m=map(int,input().split())
lst=list(map(int,input().split()))

dp=[[float("inf") for i in range(n+1)] for j in range(m+1)]

for i in range(m+1):
    dp[i][0]=0

for i in range(1,m+1):
    for j in range(1,n+1):
        if j-lst[i-1]>=0:
            dp[i][j]=min(dp[i-1][j],dp[i][j-lst[i-1]]+1)
        else : dp[i][j]=dp[i-1][j]

print(int(dp[m][n]))


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    REPi(i,1,N){
        ll a;
        cin >> a;
        a--;
        A[a]++;
    }

    REP(i,N){
        cout << A[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 4840
package main

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

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

func readInt(sc *bufio.Scanner) int {
	if !sc.Scan() {
		return 0
	}
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func checkDoubleTimes(a int) int {
	ans := 0
	for i := 2; i <= a; i *= 2 {
		if a%i != 0 {
			return ans
		}
		ans++
	}
	return ans
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := readInt(sc)
	m := 0
	for i := 0; i < n; i++ {
		mm := checkDoubleTimes(readInt(sc))
		if i == 0 {
			m = mm
			continue
		}
		m = min(m, mm)
	}
	fmt.Println(m)
}


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

int main() {
  long long N,M,A,B,C,ans;
  cin >>N>>M;
  A=1;
  B=N;
  C=1;
  for(long long i=0;i<M;i++){
    cout<<A<<" "<<B<<endl;
    A++;
    B--;
    if(N%2==0&&B-A<=A+N-B){
      B-=C;
      C=0;
    }
  }
}


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

const int max = 1e5 + 10;

int main()
{
	int h,w,n;
	cin >> h >> w >> n;
	if(h < w) swap(h,w);
	int ans = n / h;
	if(n % h) ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys 
from collections import Counter

def main():
  input = sys.stdin.readline
  N = int(input())
  texts = [''.join(sorted(list(input().rstrip()))) for _ in range(N)]
  c = Counter(texts)
  cnt = 0
  for t in c.values():
    if t > 1:
      cnt += (t * (t-1)) // 2
  print(cnt)
 
if __name__ == '__main__':
  main()


Measured memory_bytes: 19728
#include<cstring>  
#include<sstream>
#include <set>
#include <iterator>
#include<iomanip>
#include<string>
#include <stdio.h>  
#include <iostream>
#include<fstream>
#include<queue>
#define MAXN 1000005
#define ll long long
using namespace std;

int main() {
	string a, b;
	int l;
	cin >> a >> b;
	string c;
	l = b.size();
	for (int i = 0; i < l; i++) {
		c = b[l - 1];
		b.erase(l - 1, 1);
		b.insert(0, c);
		if (a == b) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

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

	int a,b,t;
	cin >> a>>b>>t;

	cout << (t/a)*b << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <functional>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;

llong n;
llong a[200005];

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

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

    llong ans = 1ll << 60ll;
    for (int i = 0; i < n - 1; i++) {
        llong x = a[i];
        llong y = a[n - 1] - a[i];

        ans = min(abs(x - y), ans);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
#define REP(i,n) for(int i=0;i< (n);i++)
#define REPR(i, n) for(int i = (n);i >= 0;i--)
#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define FORR(i, m, n) for(int i = (m);i >= (n);i--)
#define SORT(v, n) std::sort(v, v+n);
#define VSORT(v) std::sort(v.begin(), v.end());
#define VRSORT(v) std::sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define ALL(obj) (obj).begin(),(obj).end()

using namespace std;

const int INF = 99999999;
const ll LINF = 9999999999999;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
int vx[4] = { 0,1,0,-1 };
int vy[4] = { 1,0,-1,0 };


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

	ll n, y;
	cin >> n >> y;


		REP(j, n+1) {
			REP(k, n+1) {
				if (1000 * (n-j-k) + 5000 * j + 10000 * k == y&& n-j-k>=0) {
					cout <<k << " " << j << " " << n - j - k << endl;
					return 0;
				}
			}
		}
	

cout << "-1 -1 -1" << endl;
return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #pragma GCC optimization ("O3,unroll-loops")
// #pragma GCC target ("avx,avx2,fma")
using namespace std;

int32_t main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    string s, t; cin >> s >> t;
    int cnt = 0;
    for (int i = 0; i < s.size(); i++) if (s[i] != t[i]) cnt++;
    cout << cnt;


    return 0;
}

Measured memory_bytes: 3880
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>

//#define int long long

using namespace std;

void Main()
{
	int N;
	cin >> N;

	int ans = 0;
	for (int i = 1; i <= N; i++) {
		string s = to_string(i);
		if (s.size() % 2 == 1) {
			ans++;
		}
	}

	cout << ans << endl;

}
 
int32_t main()
{
	Main();
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	string s; cin >> s;
	int ans;
	if(s == "SAT") ans = 1;
	if(s == "SUN") ans = 7;
	if(s == "MON") ans = 6;
	if(s == "TUE") ans = 5;
	if(s == "WED") ans = 4;
	if(s == "THU") ans = 3;
	if(s == "FRI") ans = 2;
	cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int memo1[200005];
int memo2[200005];

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

    int N; string S; 
    cin >> N >> S;

    int sum = 0;
    for (int i = 0;i < N;i++){
        if(S[i] == '#') sum++;
        memo1[i] = sum;
    }
    sum = 0;
    for (int i = N-1;i >= 0;i--){
        if(S[i] == '.') sum++;
        memo2[i] = sum;
    }

    int ans = INT_MAX;
    for (int i = 0;i < N-1;i++){
        ans = min(memo1[i]+memo2[i+1], ans);
    }

    ans = min(memo2[0], min(ans,memo1[N-1]));

    cout << ans << endl;

    return 0;

}

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

int main() {
  string s, t;
  cin >> s >> t;
  if (s.size() < t.size()) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  for (int i = s.size()-t.size(); i >= 0; i--) {
    bool flag = true;
    for (int j = 0; j < t.size(); j++) {
      if (s[i+j] != t[j] && s[i+j] != '?') {
        flag = false;
        break;
      }
    }
    if (flag) {
      for (int j = 0; j < t.size(); j++) s[i+j] = t[j];
      break;
    }
    if (i == 0) {
      cout << "UNRESTORABLE" << endl;
      return 0;
    }
  }
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '?') s[i] = 'a';
  }
  cout << s << endl;
}

Measured memory_bytes: 256
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
from collections import Counter

n=int(input())
a=lnii()

c=Counter(a)
a_max=max(a)

ans=0
for i in range(a_max+1):
  t_ans=c[i-1]+c[i]+c[i+1]
  ans=max(ans,t_ans)

print(ans)

Measured memory_bytes: 21032
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;


signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int x;
    cin>>x;
    cout<<360/gcd(360,x)<<endl;
    return 0;
}

Measured memory_bytes: 3580
s = int(input())
b = [0 for _ in range(10 ** 6)]
b[s] = 1
n = 1
for i in range(10 ** 6):
    n += 1
    if s % 2 == 0:
        s //= 2
    else:
        s = s * 3 + 1
    if b[s] == 1:
        print(n)
        exit()
    else:
        b[s] = 1

Measured memory_bytes: 10904
// first second push_back unordered return continue break vector visited check flag bool while iterator begin end lower_bound upper_bound temp true false ll_MAX ll_MIN insert erase clear pop push compare ll64_MAX ll64_MIN  reverse replace stringstream string::npos length substr front
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()
const ll mod = 1e9 + 7 ;
const ll inf =
 1e9 + 5 ;
 //1e18L + 5;
const ll nax = 2e5 + 5;
void min_self(ll&a , ll b){a=min(a,b);}
void max_self(ll&a , ll b){a=max(a,b);}
void add_self(ll& a , ll b){a =  (a + b)%mod;}
//#define (x)  get<0>(x) 
//#define (x)  get<1>(x)
//#define (x)  get<2>(x)
signed main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll n  ;cin>> n; 
vector<ll>arr(n);
for(auto &i:arr)cin>>i;

ll i = 0 , j = n -1  ;
ll ans = 0 ;
vector<vector<ll>>dp(n,vector<ll>(n));

for(ll i = n ; i>=0 ; i--){
	for(ll j = i ;j<n; j++){
		if(i==j)dp[i][j] = arr[i];
		else 
		dp[i][j] = max(arr[i] - dp[i+1][j] , arr[j] - dp[i][j-1]);
	}
}
cout<<dp[0][n-1];
	
}

Measured memory_bytes: 70784
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

int n, Q;
ll x[100005], L;
int idx[30][100005]; // ホテルjから2^i日以内に行ける最右ホテルidx

// k日以内でaからbに到達できるか
bool check(int a, int b, int k) {
    if (a >= b) return true;
    if (k == 0) return false;

    int t = 0;
    while (1 << (t + 1) <= k) t++;
    return check(idx[t][a], b, k - (1 << t));
}

int main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) cin >> x[i];
    cin >> L;

    for (int j = 0; j < n; j++) {
        int i = lower_bound(x, x+n, x[j] + L) - x;
        if (i < n && x[i] == x[j] + L) i++;
        i--;
        idx[0][j] = i;
    }

    // ダブリング
    for (int i = 0; i < 29; i++) {
        for (int j = 0; j < n; j++) {
            idx[i+1][j] = idx[i][idx[i][j]];
        }
    }

    cin >> Q;
    for (int q = 0; q < Q; q++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        if (a > b) swap(a, b);

        int l = 0, r = 100000;
        while (r - l > 1) {
            int mid = (r + l) / 2;
            if (check(a, b, mid)) {
                r = mid;
            } else {
                l = mid;
            }
        }

        cout << r << "\n";
    }

    return 0;
}

Measured memory_bytes: 13312
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a ,x=0,arr[100];
    char s;
    cin>>a;
    for(int i=0;i<a;i++)
    {
     cin>> s;
        if(s=='D')
        {
            x-=1;
        arr[i]=x;
        }

        else if(s=='I')
         {
             x+=1;
            arr[i]=x;
         }
    }
    sort(arr,arr + a , greater<int>());
     if(arr[0]>0)
     cout<<arr[0];
     else
        cout<<0;
	return 0;
	}





Measured memory_bytes: 3596
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
const int M = 100005 ;
using namespace std ;
inline int read(){
	char c = getchar(); int x=0,w=1;
	while(c>'9'||c<'0'){if(c=='-') w=-1; c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0' ; c=getchar();}
	return x*w ;
}
int n;
int Ans = 2147480000 ;
inline int Split(int x,int y){
	int tmp = 0 ;
	while(x){
		tmp += x%10;
		x/=10; 
	}
	while(y){
		tmp += y%10 ;
		y/=10 ;
	}
	return tmp ;
}
int main(){
	n = read();
	int x,y,tmp;
	for(int i=1;i<=n-1;i++){
		x = i , y = n-i ;
		tmp = Split(x,y);
	    Ans = min(Ans,tmp) ;
	}
	printf("%d\n",Ans);
	return 0 ;
}

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

using namespace std;

int main()
{
   int n;cin>>n;
   int a[n];
   for(int i=0;i<n;i++)
    cin>>a[i];
   int dp[n+1]={0};
   dp[1]=0;
   dp[2]=abs(a[1]-a[0]);
   for(int i=3;i<=n;i++)
    dp[i]=min(abs(a[i-1]-a[i-2])+dp[i-1],abs(a[i-1]-a[i-3])+dp[i-2]);

   cout<<dp[n];


    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  vector<int> A, B, C;
  A = {2, 4, 5, 7, 9};
  B = {0, 1, 6, 8};
  C = {3};
  int X, Y;
  cin >> X;
  Y = X % 10;
  rep(i, 5) {
    if(A.at(i) == Y) {
      cout << "hon" << endl;
    }
  }
  rep(i, 4) {
    if(B.at(i) == Y) {
      cout << "pon" << endl;
    }
  }
  if(Y == 3) {
    cout << "bon" << endl;
  }
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

int main(){
	
	while(1){
		int h,m,s,l,l2;
		scanf("%d %d %d",&h,&m,&s);
		if(h==-1&&m==-1&&s==-1)return 0;
		l=7200-3600*h-60*m-s;l2=l*3;
		h=l/3600;l-=h*3600;m=l/60;s=l-m*60;
		cout<<0<<h<<":";
		if(m<=9)cout<<0;
		cout<<m<<":";
		if(s<=9)cout<<0;
		cout<<s<<endl;
		h=l2/3600;l2-=h*3600;m=l2/60;s=l2-m*60;
		cout<<0<<h<<":";
		if(m<=9)cout<<0;
		cout<<m<<":";
		if(s<=9)cout<<0;
		cout<<s<<endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
using namespace std;

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

int main() {

  int S;
  int h, m, s;

  cin >> S;

  h = S / 3600;
  S %= 3600;

  m = S / 60;
  S %= 60;

  s = S;

  cout << h << ":" << m << ":" << s << endl;


}

/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, m;
  cin >> n >> m;
  vl a(m);
  vector<vl> c(m);
  rep(i, m) {
    ll b;
    cin >> a[i] >> b;
    rep(j, b) {
      ll cc;
      cin >> cc;
      c[i].push_back(cc - 1);
    }
  }
  vector<vl> dp(m + 1, vl(1 << n, 1e18));
  dp[0][0] = 0;
  rep(i, m) rep(s, 1 << n) {
    dp[i + 1][s] = min(dp[i + 1][s], dp[i][s]);
    ll ns = s;
    for(auto v : c[i]) ns |= (1 << v);
    dp[i + 1][ns] = min(dp[i + 1][ns], dp[i][s] + a[i]);
  }
  ll ans = dp[m][(1 << n) - 1];
  if(ans == 1e18) ans = -1;
  cout << ans << endl;
}

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

int main(){
	int N, H, ans = 0, dam = 0;
	cin >> N >> H;
	int a[N], b[N];
	for(int i = 0; i < N; i++)
		cin >> a[i] >> b[i];
	sort(b,b+N);
	int amax = 0;
	for(int i = 0; i < N; i++)
		amax = max(amax,a[i]);
	for(int i = N-1; i >= 0; i--){
		if(b[i] < amax || dam >= H)
			break;
		dam += b[i];
		ans++;
	}
	while(dam < H){
		dam += amax;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
  int N;
  cin>>N;
  int V[N],C[N];
  rep(i,N){
      cin>>V[i];
  }
  rep(i,N){
      cin>>C[i];
  }
  int profit;
  int sum=0;
  rep(i,N){
      profit=V[i]-C[i];
      if(profit>0){
          sum+=profit;
      }
  }
  
  cout<<sum<<endl;
  
}

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

namespace CSharpSample01
{


    class Program
    {
        
        static void Main(string[] args)
        {           
            int[] data = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();            
            Array.Sort(data);
            Array.Reverse(data);
            

            int cost = 0;

            if((data[0] % 2 == 0 && data[1] % 2 == 0 && data[2] % 2 == 0) || (data[0] % 2 == 1 && data[1] % 2 == 1 && data[2] % 2 == 1))
            {
                int dai = data[0];
                int chu = data[1];
                int sho = data[2];
                cost = (dai - chu) / 2 + (dai - sho) / 2;
                Console.WriteLine(cost);
            }
            else
            {
                int even = 0;                
                for(int i = 0; i < data.Length; i++)
                {
                    if (data[i] % 2 == 0) even++;                   
                }

                if(even == 2)
                {                    
                    for(int i = 0; i < data.Length; i++)
                    {
                        if (data[i] % 2 == 0) data[i]++;                        
                    }
                    cost++;
                    int dai = data[0];
                    int chu = data[1];
                    int sho = data[2];
                    cost += (dai - chu) / 2 + (dai - sho) / 2;
                    Console.WriteLine(cost);
                }
                else
                {
                    for(int i = 0; i < data.Length; i++)
                    {
                        if (data[i] % 2 == 1) data[i]++;
                    }
                    cost++;
                    int dai = data[0];
                    int chu = data[1];
                    int sho = data[2];
                    cost += (dai - chu) / 2 + (dai - sho) / 2;
                    Console.WriteLine(cost);
                }

            }

        }
    }
}

Measured memory_bytes: 13396
#include<iostream>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  while(h!=0){
    int i,j;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	cout << "#";
      }
      cout << endl;
    }
    cout << endl;
    cin >> h >> w;
  }
  return 0;
}


Measured memory_bytes: 3088
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)

	n, m := oneInt(), oneInt()

	conditions := make([][]int, n)

	for i := 0; i < m; i++ {
		k := oneInt()

		for j := 0; j < k; j++ {
			v := oneInt() - 1
			conditions[v] = append(conditions[v], i)
		}
	}
	//fmt.Printf("%#v\n", conditions)
	ps := scanNums(m)

	ans := 0

	for i := 0; i < (1 << uint(n)); i++ {
		b := make([]int, m)
		for j := 0; j < n; j++ {
			if (i>>uint(j))&1 == 1 {
				for _, k := range conditions[j] {
					b[k] ^= 1
				}

			}
		}
		ok := true
		for i := range b {
			if ps[i] != b[i] {
				ok = false
				break
			}
		}

		if ok {
			ans++
		}

	}

	fmt.Println(ans)
}

func oneInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func oneStr() string {
	sc.Scan()
	return sc.Text()
}

func scanNums(len int) (nums []int) {
	for i := 0; i < len; i++ {
		nums = append(nums, oneInt())
	}
	return nums
}

func scanStrings(len int) (strs []string) {
	for i := 0; i < len; i++ {
		strs = append(strs, oneStr())
	}
	return strs
}

func abs(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}

func cumSum(nums []int) []int {
	sums := []int{0}

	for i := 0; i < len(nums); i++ {
		sums = append(sums, sums[i]+nums[i])
	}
	return sums
}


Measured memory_bytes: 768
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<cmath>
#include<algorithm>
#include<complex>
#include<cstdlib>
#include<cctype>

#define DBG cout << '!' << endl;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cout << v[i] << ' ';cout << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cout << v[a][b] << ' ';cout << endl;}cout << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	int n;
	cin >> n;
	
	iv v;
	
	REP(i,n)
	{
		int tmp;
		cin >> tmp;
		v.PB(tmp);
	}
	
	int ans = 0;
	
	if(v[0] == 1)
	{
		swap(v[0],v[1]);
		ans++;
	}
	
	for(int i = 1;i < n;i++)
	{
		if(v[i] == i+1)
		{
			if(v[i] == i)
			{
				swap(v[i],v[i-1]);
				ans++;
			}
			else
			{
				swap(v[i],v[i+1]);
				ans++;
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 892
X, Y = map(int, input().split())

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)


a = (2*X - Y)/3
b = (2*Y - X)/3

if (X+Y)%3 != 0:
    ans = 0

elif a<0 or b<0:
    ans = 0

else:
    ans = cmb(int(a + b), int(a), 10**9 + 7)

print(ans)


Measured memory_bytes: 122000
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cassert>
#include <random>
using namespace std;
 

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pb push_back
#define forn(i, n) for (int i = 0; i < n; ++i)
//#define int long long

 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
 
 
const int MAXN = 2e5 + 5;
const ll MOD = 1e9 + 7;
const ll INF = INT64_MAX;


mt19937 rnd(time(0));


bool cmp1(pii &a, pii&b) {
	return (a.ss < b.ss);
}


bool cmp2(pii &a, pii &b) {
	return (a.ff < b.ff);
}


signed main() {
	//FAST_IO;
	int n;
	cin >> n;
	string s[n];
	vector<pii> more_op, more_cl;
	forn(i, n) {
		cin >> s[i];
		int op = 0, cl = 0;
		forn(j, s[i].size()) {
			if (s[i][j] == '(') {
				op++;
			} else {
				if (op) {
					op--;
				} else {
					cl++;
				}
			}
		}
		if (op >= cl) {
			more_op.pb({op, cl});
		} else {
			more_cl.pb({op, cl});
		}
	}
	sort(all(more_op), cmp1);
	sort(all(more_cl), cmp2);
	int s1 = 0, s2 = 0;
	bool ok = 1;
	forn(i, more_op.size()) {
		s1 -= more_op[i].ss;
		if (s1 < 0) {
			ok = 0;
			break;
		}
		s1 += more_op[i].ff;
	}
	forn(i, more_cl.size()) {
		s2 -= more_cl[i].ff;
		if (s2 < 0) {
			ok = 0;
			break;
		}
		s2 += more_cl[i].ss;
	}
	if (s1 != s2) {
		ok = 0;
	}
	if (ok) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
 	return 0;
}

Measured memory_bytes: 42480