akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for(int i=0;i<((int)(v.size()));++i) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}
bool solve() {
  ll n; cin >> n;
  if(n == 0) return false;
  string s; cin >> s;
  ll ka = 1;
  for(int i=0;i<(52);++i) {
    ka <<= 1;
    ka += s[i] - '0';
  }
  ll nowka = ka, nowsi = 0;
  ll cnt = 1;
  while(cnt < n + 1) {
    ll nxt = ((1ll<<53)-1-nowka) / ka;
    nxt++;
    if(cnt + nxt <= n + 1) {
      cnt += nxt;
      nowka += nxt * ka;
      nowka >>= 1;
      ka >>= 1;
      nowsi++;
      if(ka == 0) break;
    } else {
      nowka += (n + 1 - cnt) * ka;
      break;
    }
  }
  string ans = "";
  for(int i=0;i<(52);++i) {
    ans.push_back((nowka&1)+'0');
    nowka >>= 1;
  }
  for(int i=0;i<(12);++i) {
    ans.push_back((nowsi&1)+'0');
    nowsi >>= 1;
  }
  reverse((ans).begin(),(ans).end());
  cout << ans << endl;
  return true;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  while(1) {
    if(!solve()) break;
  }
}



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

long long n, sum = 0;
vector<long long> a;
map<long long, long long> mp;

int main() {
  cin >> n;
  a.resize(n);
  for(int i = 0; i < n; ++i) {
    cin >> a[i];
    ++mp[a[i]];
  }
  for(auto p : mp)
    if(p.second >= 2) sum += p.second * (p.second - 1) / 2;
  for(int i = 0; i < n; ++i) {
    long long now = mp[a[i]];
    long long res = sum;
    res -= now * (now - 1) / 2;
    --now;
    res += now * (now - 1) / 2;
    cout << res << endl;
  }
  return 0;
}

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

const int MAX=1e5+1;

vector<vector<int>> g(100005);

int df[MAX];
int dl[MAX];

bool bfs(int f,int l){
    memset(df,0,sizeof(df));
    memset(dl,0,sizeof(dl));
    queue<int> quef;
    queue<int> quel;
    quef.push(f);
    quel.push(l);
    while(!quef.empty()){
        int u=quef.front(); quef.pop();
        for(auto it=g[u].begin();it!=g[u].end();it++){
            int next=*it;
            if(!df[next]){
                df[next]=df[u]+1;
                quef.push(next);
            }
        }
    }
    while(!quel.empty()){
        int u=quel.front(); quel.pop();
        for(auto it=g[u].begin();it!=g[u].end();it++){
            int next=*it;
            if(!dl[next]){
                dl[next]=dl[u]+1;
                quel.push(next);
            }
        }
    }
}

int main(){
    int N;
    cin >> N;
    for(int i=0;i<N-1;i++){
        int a,b;
        cin >> a >> b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    bfs(0,N-1);
    int a=0;
    int b=0;
    for(int i=1;i<N-1;i++){
        if(df[i]<=dl[i]){
            a++;
        }else{
            b++;
        }
    }
    if(a>b){
        cout << "Fennec" << endl;
    }else{
        cout << "Snuke" << endl;
    }
}

Measured memory_bytes: 6656
s = list(input())
q = int(input())

from collections import deque
d = deque(s)

r = 1

for i in range(q):
  inp = input().split()
  if len(inp)==1:
    r = r*-1
  else:
    f = int(inp[1])
    if f==1:
      f=1
    else:
      f=-1
    if f*r==1:
      d.appendleft(inp[2])
    else:
      d.append(inp[2])
    #print(r,f, d)

if r==1:
  for i in range(len(d)):
    print(d.popleft(), end='')
else:
  for i in range(len(d)):
    print(d.pop(), end='')

Measured memory_bytes: 8296
N = int(input())
C = list(map(int,input().split()))
M = 10**9+7
C.sort(reverse=True)
ans = 0
tmp = 0
for i in range(N):
    if i == 0:
        t = tmp + pow(2,2*N-1,M)
    else:
        t = tmp + pow(2,2*N-2,M)
    ans += t*C[i]
    tmp = t

print(ans%M)


Measured memory_bytes: 26024
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
int main() {
	int n, a, ret = 0;
	cin >> n;
	rep(i,n) {
		cin >> a;
		int f = 1;
		rep2(j,2,(int) (sqrt(a) + 1)) {
			if(a % j == 0) {
				f = 0;
				break;
			}
		}
		if(f) ret++;
	}
	cout << ret << endl;
	return 0;
}

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

int main(){
  int a,b;
  cin>>a>>b;
  vector<string> origin(a);
  for(int i=0;i<a;i++){
    cin>>origin[i];
  }
  vector<string> cover(b);
  for(int i=0;i<b;i++){
    cin>>cover[i];
  }
  int count1=0,count2=0;
  while(count2<=a-b){
    bool flag=false;
    for(int i=0;i<b;i++){
      for(int j=0;j<b;j++){
        if(cover[i].at(j)!=origin[i+count1].at(j+count2)){
          count1++;
          if(count1==a-b){
            count1=0;
            count2++;
          }
          flag=true;
          break;
        }
        if(i==b-1&&j==b-1){
          cout<<"Yes"<<endl;
          return 0;
        }
      }
      if(flag) break;
    }
  }
  cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cfloat>
using namespace std;

int main() {
  double h, m = DBL_MAX, M = 0.0;
  while (scanf("%lf", &h)==1) {
    m = min(m, h);
    M = max(M, h);
  }
  printf("%lf\n", M-m);
  return 0;
}

Measured memory_bytes: 1076
#include "bits/stdc++.h"
using namespace std;


// =========================== DEBUGGER =================================

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ((it == d.b) ? "" : ", ") << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define tag(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

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







#define ll long long
const ll int INF = 1e15;

ll int dp[105][200005];
int val[105];
int wgt[105];


ll int kil(int idx, int value)
{
  if(value < 0)
    return INF;
  if(idx == 0)
  {
    if(value == 0)
      return 0;
    return INF;
  }
  if(dp[idx][value] != -1)
    return dp[idx][value];

  dp[idx][value] = INF;
  dp[idx][value] = min(dp[idx][value], kil(idx-1, value));
  dp[idx][value] = min(dp[idx][value], (kil(idx-1, value - val[idx]) + wgt[idx]));

  return dp[idx][value] = (dp[idx][value] > INF) ? INF : dp[idx][value];
}




int main()
{
  ll int n, w, ans;
  cin>>n>>w;

  for(int i=1;i<=n;i++)
    cin>>wgt[i]>>val[i];

  // for(int i=1;i<=n;i++)
  // {
  //     dp[i][wgt[i]] = val[i];
  //     for(int j=1;j<=w;j++)
  //     {
  //       dp[i][j] = max(dp[i][j], dp[i-1][j]);
  //       if(j - wgt[i] > 0 && dp[i-1][j-wgt[i]] > 0)
  //         dp[i][j] = max(dp[i][j], dp[i-1][j-wgt[i]] + val[i]);
  //
  //       dp[i][j] = max(dp[i][j], dp[i][j-1]);
  //     }
  // }
  //
  // cout<<dp[n][w]<<endl;



  memset(dp, -1, sizeof dp);

  for(int value = 100003; value >= 0; value--)
  {
    ans = kil(n, value);
    if(ans <= w && ans != -1)
    {
      ans = value;
      break;
    }
  }

  //because base case is zero
  // memset(dp, 0, sizeof dp);
  //
  // for(int idx = 1; idx <= n; idx++)
  //   for(int value = 0; value < 100005; value++)
  //   {
  //     dp[idx][value] = 1e15;
  //     dp[idx][value] = min(dp[idx][value], dp[idx-1][value]);
  //     dp[idx][value] = min(dp[idx][value], dp[idx-1][value + val[idx]] + wgt[idx]);
  //   }


  // for(int value = 100003; value >= 0; value--)
  //   for(int idx = 1; idx <= n; idx++)
  //   {
  //     if(dp[idx][value] <= w && dp[idx][value] != -1)
  //     {
  //       ans = value;
  //       break;
  //     }
  //   }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 164352
N = int(input())
X = input()

n1 = X.count("1")
Xn = int(X, 2)

Xms = (Xn % (n1 - 1)) if n1 > 1 else 0
Xml = Xn % (n1 + 1)

p2s = [1]
p2l = [1]
s2 = 1
l2 = 1
for i in range(N - 1):
    s2 = (s2 * 2) % (n1 - 1) if n1 > 1 else 0
    l2 = (l2 * 2) % (n1 + 1)
    p2s.append(s2)
    p2l.append(l2)


def f(n):
    if n == 0:
        return 0
    return f(n % bin(n).count("1")) + 1


for i in range(N):
    cnt = 0
    p2 = 2 ** (N - i - 1)
    Xim = 0

    if X[i] == "1" and n1 == 1:
        print(cnt)
        continue
    elif X[i] == "1":
        Xim = (
            Xms - p2s[-i - 1]
            if Xms - p2s[-i - 1] >= 0
            else ((n1 - 1) + (Xms - p2s[-i - 1]))
        )
    else:
        Xim = (
            Xml + p2l[-i - 1]
            if Xml + p2l[-i - 1] < (n1 + 1)
            else (Xml + p2l[-i - 1] - (n1 + 1))
        )
    print(f(Xim) + 1)



Measured memory_bytes: 100808
#![allow(dead_code)]
#![allow(unused_imports)]
#![allow(unused_variables)]

use proconio::{fastout, input};
use std::cmp::{max, min};

const INF: i32 = 1001001001;
const LNF: i64 = 1001001001001001001;
const MOD: i32 = 1000000007;

#[fastout]
fn main() {
  input!(n: usize);
  let mut v = vec![1 as i64; n + 1];
  for i in 2..=n {
    for j in (i..=n).step_by(i) {
      v[j] += 1;
    }
  }
  let mut ans = 0;
  for i in 1..=n {
    ans += v[i] * i as i64;
  }
  println!("{}", ans);
}


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

int a, b, c, ans = 0;

int main()
{
    scanf( "%d%d%d", &a, &b, &c );

    if( a > b ) swap( a, b );
    if( b > c ) swap( b, c );
    if( a > b ) swap( a, b ); 

    while( a < c-1 ) a += 2, ans ++;
    while( b < c-1 ) b += 2, ans ++;

    if( a != c && b != c ) ans ++;
    if( a != c && b == c ) ans += 2;
    if( a == c && b != c ) ans += 2; 

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

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=3e6+10, MOD=1e9+7;
int a[N],n,b[N],prime[N],cnt,vis[N],mx[N];
ll ans,tmp=1;
ll Power(ll a,ll b=MOD-2)
{
	ll c=1;
	for (;b;b>>=1, a=a*a%MOD)
		if (b&1) c=c*a%MOD;
	return c%MOD;
}
int main()
{
	scanf("%d",&n);
	for(int i=2;i<=2e6;i++)
	{
    	if(!vis[i]) prime[cnt++]=i;
        for(int j=0;j<cnt&&i*prime[j]<=n;j++){
            vis[i*prime[j]]=1;
            if(i%prime[j]==0) break;
        }
    }
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		b[i]=a[i];
		for (int j=0;prime[j]<=sqrt(a[i]);j++)
		{
			int sum=0;
			while (a[i]%prime[j]==0) sum++, a[i]/=prime[j];
			if (sum>mx[prime[j]]) mx[prime[j]]=sum;
		}
		mx[a[i]]=max(1,mx[a[i]]);
	}
	for (int i=2;i<=2e6;i++) if (mx[i]) tmp=(tmp*Power(i,mx[i]))%MOD;
	for (int i=1;i<=n;i++) ans=(ans+tmp*Power(b[i])%MOD)%MOD;
	printf("%lld",ans);
}

Measured memory_bytes: 20480
/*input

*/


// assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;

// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ll          long long int
#define pb          push_back
#define pii         pair<ll ,ll >
#define vpii        vector< pii >
#define vi          vector<ll >
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define debug(x)     cout << #x << " " << x << endl;
#define debug_p(x)   cout << #x << " " << x.F << " " << x.S << endl;
#define debug_v(x)   {cout << #x << " "; for (auto ioi : x) cout << ioi << " "; cout << endl;}
#define debug_vp(x)  {cout << #x << " "; for (auto ioi : x) cout << '[' << ioi.F << " " << ioi.S << ']'; cout << endl;}
#define debug_v_v(x) {cout << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cout << ioi2 << " "; cout << '\n';} cout << "*/" << #x << endl;}

int solve()
{
	ll n;cin>>n;
	cout<<n+n*n+n*n*n;
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	//cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

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

int main()
{
	std::string s;
	std::cin >> s;
	int ans = 0;
	int pans = 0;
	for (int i = 0; i < s.length(); i++)
	{
		while (s[i] == 'A'||s[i] == 'C'||s[i] == 'G'||s[i] == 'T')
		{
			++pans;
			++i;
		}
		if (pans >= ans)
			ans = pans;
		pans = 0;
	}
	std::cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
A, B, M = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
ans = min(a) + min(b)
for i in range(M):
    x, y, c = map(int, input().split(' '))
    ans = min(ans, a[x - 1] + b[y - 1] - c)
print(ans)

Measured memory_bytes: 70340
#include <iostream>
#include <algorithm>

using namespace	std;
int main(){
  int n;
  int month[2] = {19,20};
  int days[3] = {200,195,195};
  cin >> n;
  for(int i=0;i<n;i++){
    int y,m,d;
    cin >> y >> m >> d;
    int	day = 0;
    for(int j=y+1;j<1000;j++){
      day += days[j%3];
    }
    for(int j=m+1;j<11;j++){
      if(y%3 == 0){
        day += month[1];
      }else{
	day += month[j%2];
      } 
    }
    if(y%3 == 0){
      for(int j=d;j<month[1]+1;j++){
	day++;
      } 
    }else{
      for(int j=d;j<month[m%2]+1;j++){
	day++;
      } 
    }
    cout << day << endl;
  }
}

Measured memory_bytes: 1160
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

S = list(map(int, input()))
N = len(S)
D = INT()

# dp[i][j] := i桁目まで見て、桁和がmod Dでjの時の通り数
dp0 = list2d(N+1, D, 0)
dp1 = list2d(N+1, D, 0)
dp0[0][0] = 1
for i, a in enumerate(S):
    for j in range(D):
        if not dp0[i][j] and not dp1[i][j]:
            continue
        for k in range(10):
            if k < a:
                dp1[i+1][(j+k)%D] += dp0[i][j]
                dp1[i+1][(j+k)%D] += dp1[i][j]
            elif k == a:
                dp0[i+1][(j+k)%D] += dp0[i][j]
                dp1[i+1][(j+k)%D] += dp1[i][j]
            else:
                dp1[i+1][(j+k)%D] += dp1[i][j]
        dp0[i+1][j] %= MOD
        dp1[i+1][j] %= MOD
ans = (dp0[N][0] + dp1[N][0] - 1) % MOD
print(ans)


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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x)*(x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int W, H;
char field[70][70];

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

string maxstr(const string& s1, const string& s2) {
    if (s1.length() == s2.length()) {
        if (s1 > s2) {
            return s1;
        } else {
            return s2;
        }
    } else {
        if (s1.length() > s2.length()) {
            return s1;
        } else {
            return s2;
        }
    }
}

void replace(string& s) {
    while (s.find("0") == 0) s.replace(0, 1, "");
}

string maxstr0(string s1, string s2) {
    replace(s1);
    replace(s2);

    if (s1.length() == s2.length()) {
        if (s1 > s2) {
            return s1;
        } else {
            return s2;
        }
    } else {
        if (s1.length() > s2.length()) {
            return s1;
        } else {
            return s2;
        }
    }
}

int main() {
    while (cin >> W >> H, W|H) {
        REP(y, H) REP(x, W) {
            cin >> field[y][x];
        }

        vector<vector<string>> s(H, vector<string>(W));

        string ma = "";
        for (int y = H-1; y >= 0; y--)
        for (int x = W-1; x >= 0; x--) {
            if (isdigit(field[y][x])) {
                REP(i, 2) {
                    int sx = x + dx[i], sy = y + dy[i];
                    if (0 <= sx && sx < W && 0 <= sy && sy < H && isdigit(field[sy][sx])) {
                        s[y][x] = maxstr(s[y][x], field[y][x] + s[sy][sx]);
                    }
                }
                if (s[y][x].length() == 0) {
                    s[y][x] = field[y][x];
                }
                ma = maxstr0(ma, s[y][x]);
            }
        }

        cout << ma << endl;
    }
}

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

const int MAX_N = 51;
int alphabet[MAX_N][26];
int N;

void init() {
    cin >> N;
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < 26; ++j) alphabet[i][j] = 0;
        string S;
        cin >> S;
        for(int j = 0; j < S.size(); ++j) ++alphabet[i][S[j] - 'a'];
    }
}

int main()
{
    init();
    int res[26];
    fill(res, res + 26, 100);
    for(int i = 0; i < N; ++i) 
        for(int j = 0; j < 26; ++j)
            res[j] = min(res[j], alphabet[i][j]);
    
    string T;
    for(int i = 0; i < 26; ++i)
        for(int j = 0; j < res[i]; ++j)
            T.push_back('a' + i);
    
    cout << T << endl;
    return 0;
}

Measured memory_bytes: 256
#coding:utf-8

n = gets.chomp.to_i

n.times{|i|
	num1 = gets.chomp.split('').map(&:to_i).reverse!
	num2 = gets.chomp.split('').map(&:to_i).reverse!
	a,b = num1.size, num2.size

	short,long = (a>b) ? num2 : num1, (a>b) ? num1 : num2	 

	tmp = Array.new(long.size-short.size,0)
	short =   short + tmp

	c = 0
	ans = Array.new(long.size)
	long.size.times{|j|
		x = long[j] + short[j] + c
		if x > 9 then 
			c = 1 
			ans[j] = x-10
		else
			c = 0
			ans[j] = x
	 	end
		
		#桁を越えた際
		if j==long.size-1 && c==1  then
			ans << c
		end
	}


	#表示
	str = String.new
	ans.size.times{|k|
		str << ans[ans.size-k-1].to_s
	}
	if str.size<=80 then
		puts str
	else 
		puts "overflow"
	end
}

Measured memory_bytes: 6116
N = int(input())
start = 0
ans = 0
for i in range(1,N+1,2):
  flag = 0
  for j in range(1,N+1):
      if i % j == 0:
          flag += 1
      elif i < j:
          break
  if flag == 8:
    ans += 1
print(ans)
  
      

Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main()
{
    double x[3], y[3];
    double a[3];
    for(int i = 0; i < 3; i++) cin >> x[i] >> y[i];
    for(int i = 0; i < 3; i++)
        a[i] = sqrt((x[(i + 1) % 3] - x[(i + 2) % 3]) * (x[(i + 1) % 3] - x[(i + 2) % 3]) +
                    (y[(i + 1) % 3] - y[(i + 2) % 3]) * (y[(i + 1) % 3] - y[(i + 2) % 3]));
    double c[3];
    for(int i = 0; i < 3; i++)
        c[i] = (a[(i + 1) % 3] * a[(i + 1) % 3] + a[(i + 2) % 3] * a[(i + 2) % 3] - a[i] * a[i]) /
               (2 * a[(i + 1) % 3] * a[(i + 2) % 3]);
    sort(a, a + 3, greater<double>());
    sort(c, c + 3, greater<double>());
    double l = a[0];
    double t0 = sqrt(2 / (c[0] + 1) - 1);
    double t1 = sqrt(2 / (c[1] + 1) - 1);
    cout << fixed << setprecision(15) << (t0 * t1 * l) / (t0 + t1 + 2 * t0 * t1) << endl;
}

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

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;
long long stint(string str) {
	long long ret;
	stringstream ss; ss << str;
	ss >> ret;
	return ret;
}

void solve() {
	int n;
	cin >> n;
	int sum = 0;
	int mini = 1000000;
	rep(i, n) {
		int a;
		cin >> a;
		int count = 0;
		while (a % 2 == 0) {
			count++;
			a /= 2;
		}
		mini = min(mini, count);
	}
	P(mini);
}

int main() {
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <list>
#include <utility>
#include <set>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <random>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x,T a,T b){return a<=x&&x<=b;}
template<class T> void amin(T &a,T v){if(a>v) a=v;}
template<class T> void amax(T &a,T v){if(a<v) a=v;}
int ROUND(double x) { return (int)(x+0.5); }
bool ISINT(double x) { return fabs(ROUND(x)-x)<=EPS; }
bool ISEQUAL(double x,double y) { return fabs(x-y)<=EPS*max(1.0,max(fabs(x),fabs(y))); }
double SQSUM(double x,double y) { return x*x+y*y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;

// 値本位で表引き
// sFirstIndexTable[x]=y 配列pにx以下の値がでてくる最初のindex
// 計算量はpの範囲
// あらかじめpを座標圧縮という手もあるかも…。

#if 1


int main()
{
	int N;
	scanf("%d",&N);

	vector <int> a;
	a.push_back(-1);
	for (int i = 0; i < N; ++i)
	{
		int tmp;
		scanf("%d", &tmp);
		a.push_back(tmp);
	}
	a.push_back(-1);

	N = SZ(a);

	vector <ll> numRightBigger(N);
	vector <ll> numLeftSmaller(N);


	{
		stack <pair <int, int> > st;
		for (int i = 0; i < N; ++i)
		{
			if (!st.empty())
			{
				while (1)
				{
					auto tp = st.top();

					if (a[i] > tp.first)
					{
						break;
					}
					else
					{
						st.pop();
						numRightBigger[tp.second] = i - tp.second;
						if (st.empty())
						{
							break;
						}
					}
				}
			}
			st.push(make_pair(a[i], i));
		}
	}


	{
		stack <pair <int, int> > st;
		for (int i = N-1; i >= 0; --i)
		{
			if (!st.empty())
			{
				while (1)
				{
					auto tp = st.top();

					if (a[i] > tp.first)
					{
						break;
					}
					else
					{
						st.pop();
						numLeftSmaller[tp.second] = tp.second - i;
						if (st.empty())
						{
							break;
						}
					}
				}
			}
			st.push(make_pair(a[i], i));
		}
	}

	ll ret = 0;
	for (int i = 1; i < N-1; ++i)
	{
		ret += numRightBigger[i] * numLeftSmaller[i] * a[i];
	}

	cout << ret << endl;

	return 0;



}


#else


int main()
{
	stack <char> ls;
	string s;

	cin >> s;
	for (int i = 0; i < SZ(s); ++i)
	{
		ls.push(s[i]);
		while (SZ(ls) >= 2)
		{
			char lst = ls.top();
			ls.pop();
			char lst2 = ls.top();
			ls.pop();

			if (lst == 'T' && lst2 == 'S')
			{
			}
			else
			{
				ls.push(lst2);
				ls.push(lst);
				break;
			}
		}
	}

	printf("%d\n",SZ(ls));


	return 0;
}

#endif

Measured memory_bytes: 5748
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cstdlib>
#include <iostream>

using namespace std;

#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

const int P = 4000;

int N, K;
pair<i64, i64> dp[110][P]; // cnt, profit

void add(pair<i64, i64> &a, i64 ct, i64 pf)
{
	a = make_pair((a.first + ct) % MOD, (a.second + pf) % MOD);
}

int main()
{
	scanf("%d%d", &N, &K);

	for (int i = 0; i <= N; ++i) {
		for (int j = 0; j < P; ++j) {
			dp[i][j] = make_pair(0LL, 0LL);
		}
	}
	dp[N][0] = make_pair(1LL, 0LL);
	for (int i = N; i >= 1; --i) {
		for (int j = 0; j < P; ++j) {
			if (dp[i][j] == make_pair(0LL, 0LL)) continue;

			for (int k = 0; k <= K; ++k) {
				if (k > i) { // too large
					add(dp[i - 1][j], dp[i][j].first, dp[i][j].second);
				} else {
					int chg = k + j;
					int j2 = j + chg / i;
					add(dp[i - 1][j2], dp[i][j].first, dp[i][j].second + dp[i][j].first * chg);
				}
			}
		}
	}
	i64 ret = 0;
	for (int i = 0; i < P; ++i) {
		ADD(ret, dp[0][i].first * i);
	//	printf("%d %lld %lld\n", i, dp[0][i].first, dp[0][i].second);
	}

	i64 base = K * (K + 1) / 2;
	for (int i = 0; i < N - 1; ++i) base = base * (K + 1) % MOD;
	base = base * N % MOD;

	printf("%lld\n", (base + MOD - ret) % MOD);

	return 0;
}


Measured memory_bytes: 6528
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

#define guo cerr<<"guo"<<endl
typedef long long ll;

ll n,top;
vector<int> ans;

inline void dfs(ll x)
{
	if(x==1)return;
	int v=++top;
	if(x&1)
		ans.push_back(v),dfs(x-1);
	else
		dfs(x>>1),ans.push_back(v);
}

int main()
{
	if(fopen("vj.in","r"))
	{
		freopen("vj.in","r",stdin);
		freopen("vj.out","w",stdout);
	}

	scanf("%lld",&n);
	dfs(n+1);
	printf("%d\n",ans.size()*2);
	for(int i=0;i<ans.size();i++)
		printf("%d ",ans.size()-ans[i]+1);
	for(int i=0;i<ans.size();i++)
		printf("%d ",i+1);

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void f(long long int n);
int main()
{
    long long int n;
    scanf("%lld",&n);
    f(n);
    return 0;
}
void f(long long int n)
{
    if(n==0)
        return;
    n--;
    f(n/26);
    putchar('a'+(n%26));
}


Measured memory_bytes: 3760
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;

int main(void){
    ll k,a,b;cin>>k>>a>>b;
    if(a+2>=b)cout<<1+k<<endl;
    else{
        if((k-a+1)%2==0){
            cout<<a+((k-a+1)/2)*(b-a)<<endl;
        }else{
            cout<<a+((k-a+1)/2)*(b-a)+1<<endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<bitset>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    int m;
    int d;
    int ans=0;
    scanf("%d%d",&m,&d);
    for(int i=10;i<=d;i++){
        int ten=i/10;
        int one=i%10;
        int wa=ten*one;
        if(0<wa && wa<=m && ten>1 && one>1){
            ans++;
            //printf("%d %d\n",i,wa);
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 1000000009
typedef long long ll;
typedef pair<int,int> P;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define int ll

signed main(void){
    int N;
    cin >> N;
    int Ans = N+50;
    REP(i,N){
        if(i==0)continue;
        int M=N-i;
        int sum=0;
        int kam=1;
        REP(j,6){
            sum+=(((i/kam)%10));
            kam*=10;
        }
        kam=1;
        REP(j,6){
            sum+=(((M/kam)%10));
            kam*=10;
        }
        Ans=min(Ans,sum);
        //cout << i << " "<<M << " "<<sum << endl;
    }
    cout << Ans << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
L = []
c = 0
for i in range(N - 2):
	if a[i] == a[i + 1]:
		c += 1
	else:
		L.append(c + 1)
		c = 0
if a[N - 2] == a[N - 1]:
		c += 1
L.append(c + 1)

s = 0
for i in L:
	s += i // 2
print(s)

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());
  cout << (s < t ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>
#include<functional>

using namespace std;
using  ull = unsigned long long int;

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



int main() {

	int sum=0;

	vector<int>num(3);

	rep(i, 0, 3)cin >> num[i];

	sort(num.begin(), num.end());

	sum += num[0] + num[1];

	cout << sum << endl;




	return 0;
}

Measured memory_bytes: 256
using LinearAlgebra

function solve()
    H, W, K = parse.(Int, split(readline()))

    c = zeros(Int, H, W)

    for i = 1:H
        s = readline()
        for j = 1:W
            c[i,j] = Int(s[j] == '.' ? 0 : 1)
        end
    end

    sumrow = [sum(view(c, i, 1:W)) for i = 1:H]
    sumcol = [sum(view(c, 1:H, j)) for j = 1:W]

    stack = [[0],[1]]

    cnt = 0

    while !isempty(stack)
        now = pop!(stack)
        if length(now) < H+W
            push!(stack, vcat(now, [0]))
            push!(stack, vcat(now, [1]))
            continue
        end

        P = Diagonal(now[1:H])
        Q = Diagonal(now[(H+1):(H+W)])

        if sum(P*c*Q) == K cnt += 1 end
    end

    println(cnt)
end

solve()


Measured memory_bytes: 222800
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include<ext/rope>
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pair<ll,ll> >   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pair<int,int> >   vpi;
typedef    vector<pair<double,double> >   vpd;
typedef    pair<double,double>   pd;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   1000000007
#define    inf  9223372036854775807
#define    ninf   -inf
#define    ima   2147483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define all(x) x.be(),x.en()
#define    eps   1e-9
#define    coutd   cout<<setprecision(10)<<fixed
const    ld   PI=3.14159265359;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}


int main()
{
io
int testcases=1;//cin>>testcases;
while(testcases--)
{

int a,b;
cin>>a>>b;
if(a>=13)
cout<<b;
else if(a>5)
cout<<b/2;
else
cout<<0;









}return 0;}

Measured memory_bytes: 256
num = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
d = []

for i in range(num):
    c.append(a[i] ^ a[(i+1)%num])
    d.append(b[i] ^ b[(i+1)%num])
    
c += c

# print(c)
# print(d)

# テーブル作成
table = [0]
k = 0
for i in range(1, num+1):
    table.append(k)
    if i == num:
        continue
    
    if d[i] == d[k]:
        k += 1
    else:
        k = 0

# print(table)

i = 0 # 探索される文字列の位置
j = 0 # 探索する文字列の位置
k = 0 # kの初期値
while k < num:
    
    while True:
        # print(i, j, k)
        if c[i] == d[j]:
            if j == num - 1:
                print(k, a[k] ^ b[0])
                i += 1
                j = table[num]
                k = i - j
                break
            
            i += 1
            j += 1
        elif j != 0:
            j -= 1
        else:    
            i += 1
            j = table[j]
            break
    
    k = i - j

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

int main() {

  int N;
  cin >> N;

  bool flg = true;
  int current = 0;
  int v = 0;

  while (flg) {
    v = pow(2, current);
    if (N < v) {
      flg = false;
    } else {
      current++;
    }
  }

  cout << pow(2, current - 1) << endl;

}

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

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve();
			Console.Out.Flush();
		}

		const int mod = 1000000007;  // 10^9+7
		static int Mod(long x, int m) { return (int)((x % m + m) % m); }
		static long Mod(long x, long m) { return (x % m + m) % m; }

		static public void Solve()
		{
			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			int n = int.Parse(Console.ReadLine());
			if (n < 1000) {
				Console.WriteLine("ABC");
			} else {
				Console.WriteLine("ABD");
			}

		}
	}
}


Measured memory_bytes: 27332
import collections
n = int(input())
a = list(map(int, input().split()))
count = collections.Counter(a)
q = int(input())
s = sum(a)

for i in range(q):
  b, c = map(int, input().split())
  s = s - (b - c) * count[b]
  
  count[c] += count[b]
  count[b] = 0
  print(s)

Measured memory_bytes: 24060
function Main(input) {
	input = input.trim();
  var len = parseInt(input.split("\n")[0]);
  var list = input.split("\n")[1].split(" ").map((a)=>Number(a));
  list.sort(function(a,b){
    return a - b;
  });
  console.log(list[len - 1] - list[0]);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
N = int(input())
b_list = list(map(int, input().split()))

ans = []
while len(b_list) > 0:
    f = -1
    for i in range(len(b_list)):
        if b_list[i] == i + 1:
            f = i
    if f == -1:
        print(-1)
        exit()
    ans.append(b_list[f])
    b_list.pop(f)

ans = reversed(ans)
for a in ans:
    print(a)


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String word = input.readLine();

        boolean state = true;

        state &= word.charAt(0) == 'A';
        boolean foundC = false;

        for (int i = 1; i < word.length(); i++) {
            if (!foundC && i >=2 && i <= word.length() -2 && word.charAt(i) == 'C'){
                foundC = true;
            }else if (!Character.isLowerCase(word.charAt(i))){
                state = false;
                break;
            }
        }

        if (foundC && state)
            System.out.println("AC");
        else
            System.out.println("WA");
    }
}


Measured memory_bytes: 22996
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

signed main() {
	int N;
	cin >> N;
	vector<int>v(N + 1, 0);
	rep(i, N) {
		int A;
		cin >> A;
		v[i + 1] = v[i] + A;
	}
	int mn = INF;
	for (int i = 0; i <= N; i++) {
		int left = v[i] - v[0];
		int right = v[N] - v[i];
		mn = min(mn, abs(left - right));
	}
	cout << mn;
}

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

int N, M;
int a[1010], b[1010], c[5000];

int dp[1010][5050];

int main() {
    cin >> N >> M;
    rep(i, M) {
        cin >> a[i] >> b[i];
        rep(j, b[i]) {
            int t;
            cin >> t;
            t--;
            c[i] += (1<<t);
        }
    }

    fill(dp[0], dp[M+1], 1e8);
    dp[0][0] = 0;
    for (int i=0; i<M; ++i) {
        for (int j=0; j<(1<<N); ++j) {
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
            dp[i+1][j | c[i]] = min(dp[i+1][j | c[i]], dp[i][j] + a[i]);
        }
    }

    if (dp[M][(1<<N)-1] == 1e8) cout << -1 << endl;
    else cout << dp[M][(1<<N)-1] << endl;
}


Measured memory_bytes: 19968
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
using namespace std;
vector <int> edges[50];
int a[50];
int b[50];
int edge_ind[50][50];
int u[20];
int v[20];
bool is_white[50];
bool dfs_used[50];
bool dfs(int s, int t){
  if(s == t){
    return true;
  }
  dfs_used[s] = true;
  for(int i = 0; i < edges[s].size(); i++){
    int next = edges[s][i];
    if(!dfs_used[next]){
      if(dfs(next, t)){
        is_white[edge_ind[s][next]] = true;
        return true;
      }
    }
  }
  return false;
}

int main(){
  int N;
  cin >> N;
  for(int i = 0; i < N - 1; i++){
    cin >> a[i] >> b[i];
    a[i] --;
    b[i] --;

    edges[a[i]].push_back(b[i]);
    edges[b[i]].push_back(a[i]);

    edge_ind[a[i]][b[i]] = i;
    edge_ind[b[i]][a[i]] = i;
  }

  

  int M;
  cin >> M;
  for(int i = 0; i < M; i++){
    cin >> u[i] >> v[i];
    u[i] --;
    v[i] --;
  }

  long long not_ans = 0;
  for(int bit_set = 1; bit_set < (1 << M); bit_set++){
    for(int i = 0; i < N - 1; i++){
      is_white[i] = false;
    }

    int set_size = 0;
    for(int i = 0; i < M; i++){
      if(((bit_set >> i) & 1) == 1){
        set_size ++;
        for(int j = 0; j < N; j++){
          dfs_used[j] = false;
        }
        dfs(u[i], v[i]);
      }
    }

    int white_num = 0;
    for(int i = 0; i < N - 1; i++){
      if(is_white[i]){
        white_num ++;
      }
    }

    if(set_size % 2 == 0){
      not_ans -= ((long long) 1 << (N - 1 - white_num));
    } else {
      not_ans += ((long long) 1 << (N - 1 - white_num));
    }

  }
  cout << ((long long) 1 << (N - 1)) - not_ans << endl;
  return 0;
}


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

int main() {
    int X,N; cin >> X >> N;
    vector<int> p(N);
    int now;
    for(int i=0; i<N; i++){
        cin >> p.at(i);
    }
    int len=max(X,100-X);
    int checks=0;
    int checkl=0;
    for(int i=0; i<len+1; i++){
        checks=0; checkl=0;
        for(int j=0; j<N; j++){
            if(X-i == p.at(j)){
                checks=1;
            }
            if(X+i == p.at(j)){
                checkl=1;
            }
        }
        if(checks==0){
            X=X-i;
            break;
        }
        if(checks!=0 && checkl==0){
            X=X+i;
            break;
        }

    }
    cout << X << endl;
    }

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

int main() {
    int w, h;
    string s;
    cin >> w >> h >> s;
    REP(i,h){
        cout << (i==0||i==h-1?"+":"|");
        REP(j,w-2) {
            if(i==0||i==h-1) cout << "-";
            else cout << (i==h/2&&j==w/2-1?s:".");
        }
        cout << (i==0||i==h-1?"+":"|") << endl;
    }
    return 0;
}



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

int main(){
	int N, M;
	cin >> N >> M;
	int Lmax = 1, Rmin = N;
	for(int i = 0; i < M; i++){
		int L, R;
		cin >> L >> R;
		Lmax = max(Lmax,L);
		Rmin = min(Rmin,R);
	}
	int ans;
	if(Lmax > Rmin)
		ans = 0;
	else
		ans = Rmin - Lmax + 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <cstdio>
#include <cmath>
#include <time.h>
#define all(c) ((c).begin(),(c).end())
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n)
#define vsort(v) sort(v.begin(),v.end())
#define vvsort(v) sort(v.begin(),v.end(),greater<int>())
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
double x, y, s;
int main() {
	while (cin >> x >> y >> s) {
		if (x == 0)return 0;
		int ans = 0;
		for (int i = 1; i < s; i++) {
			for (int j = 1; j < s; j++) {
				if ((int)(i*(100 + x) / 100) + (int)(j*(100 + x) / 100) == s) {
					ans = max(ans, (int)(i*(100 + y) / 100) + (int)(j*(100 + y) / 100));
				}
			}
		}
			
		cout << ans << endl;
	}
}

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

const int MAX_N = 105;
int64_t as[MAX_N];

int main() {
  int N;
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    scanf("%lld", as + i);
  }
  std::sort(as, as + N);
  int ans = 0;
  for (int a = 0; a < N; ++a) {
    for (int b = a + 1; b < N; ++b) {
      for (int c = b + 1; c < N; ++c) {
        if (as[a] == as[b] || as[b] == as[c] || as[a] == as[b]) continue;
        if (as[a] + as[b] > as[c]) ans++;
      }
    }
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 3816
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
 
void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}
 
int main(){
  ll N;
  cin>>N;
  ll ans;
  if(1<=N&&10>N) ans=N;
  else if(10<=N&&100>N) ans=9;
  else if(100<=N&&1000>N) ans=N-100+1+9;
  else if(1000<=N&&10000>N) ans=909;
  else if(10000<=N&&100000>N) ans=N-10000+1+909;
  else if(N==100000) ans=90909;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import math

A, B, H, M = map(int, input().split())

a = (60 * H + M) * 0.5
b = M * 6
c = max(a, b) - min(a, b)
if c > 180:
    c = 360 - c

if c == 180:
    print(A + B)
elif c == 0:
    print(max(A, B) - min(A, B))
else:
    C2 = A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(c))
    C = math.sqrt(C2)
    print(C)

Measured memory_bytes: 9592
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define to_ll(b) stoll(b)
#define MOD 1000000007
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp

signed main(){
	ll s; cin>>s;
	ll ans=0;
	rep(i,1,s+1){
		string a=to_string(i);
		ll b=a.size();
		if(b%2==1) ans++;
	}
	cout<<ans;
	
	
	return 0;
}

Measured memory_bytes: 256