akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
struct edge {
    ll to,cost;
};
/*
const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
*/

int main(){
    int N,K; cin >> N >> K;
    string s; cin >> s;
    int cnt = 1;
    for (int i = 1; i < N; i++){
        if (s[i-1] != s[i]){
            cnt++;
        }
    }
    cout << N-max(1,cnt-2*K) << endl;
}


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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

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

const lli MOD = 1000000007LL;

lli modpow(lli a, lli n){
    lli res = 1;

    for(lli ai = a; n; n>>=1){
        if(1&n) res = (res*ai)%MOD;
        ai=(ai*ai)%MOD;
    }
    return res;
}

lli inv(lli n){
    return modpow(n, MOD-2);
}

lli modperm(lli n, lli k){
    lli res = 1;
    rep(i, k){
        res = (res*(n-i))%MOD;
    }
    return res;
}

lli modcomb(lli n, lli k){
    return (modperm(n, k)*inv(modperm(k, k)))%MOD;
}

lli posmod(lli n){
    lli res = n;
    res %= MOD;
    if(res < 0) res += MOD;
    return res;
}
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

#define MAX_K 100000

lli n, k;
lli fx[MAX_K+10];
lli res;

int main(void){
    cin >> n >> k;
    rep(i, k+1){
        fx[i] = 0;
    }
    res = 0;
    for(lli x = k; x >= 1; x--){
        fx[x] += modpow(k/x, n);
        auto d = divisor(x);
        for(auto i : d){
            if(i<x) fx[i]-=fx[x];
        }
        (res += posmod(x%MOD*fx[x]))%=MOD;
    }
    cout << res << endl;
    return 0;
}


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

int main(){
    int W, H, N;
    cin >> W >> H >> N;

    vector< vector<int> > redict(H, vector<int>(W));

    vector<int> x(N);
    vector<int> y(N);
    vector<int> a(N);

    for(int i = 0; i < N; i++){
        cin >> x.at(i);
        cin >> y.at(i);
        cin >> a.at(i);
    }

    for(int i = 0; i < N; i++){
        if(a.at(i) == 1){
            for(int j = 0; j < H; j++){
                for(int k = 0; k < x.at(i); k++){
                    redict.at(j).at(k) = 1;
                }
            }
        }
        if(a.at(i) == 2){
            for(int j = 0; j < H; j++){
                for(int k = x.at(i); k < W; k++){
                    redict.at(j).at(k) = 1;
                }
            }
        }
        if(a.at(i) == 3){
            for(int j = 0; j < y.at(i); j++){
                for(int k = 0; k < W; k++){
                    redict.at(j).at(k) = 1;
                }
            }
        }
        if(a.at(i) == 4){
            for(int j = y.at(i); j < H; j++){
                for(int k = 0; k < W; k++){
                    redict.at(j).at(k) = 1;
                }
            }
        }
    }

    int ans;

    for(int j = 0; j < H; j++){
        for(int k = 0; k < W; k++){
            if(redict.at(j).at(k) == 0) ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

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

 int main() {
   int N;
   cin >> N;

   string ans;

   while (N != 0) {
     int r = N % (-2);
     if (r < 0) r += 2;

     N = (N - r) / (-2);
     ans += (char)(r + '0');
   }

   reverse(ans.begin(), ans.end());
   if (ans== "") ans = "0";
   cout << ans << endl;
 }


Measured memory_bytes: 256
import math
N,D=map(int,input().split())
X=[list(map(int,input().split())) for i in range(N)]
ans=0
for i in range(1,N+1):
    x=0
    for j in range(i,N):

        x=sum(list(map(lambda x,y:(x-y)**2,X[i-1],X[j])))
        if math.sqrt(x)==int(math.sqrt(x)):
            ans+=1


        
print(ans)


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

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

  int odd = 0;
  int even = 0;
  rep(i,S.length()){
    if(i&1){
      if(S[i]&1){
        odd++;
      } else {
        even++;
      }
    } else {
       if(S[i]&1){
        even++;
      } else {
        odd++;
      }
    }
  }
  cout << min(even,odd) << endl;
}

Measured memory_bytes: 512
// template.cpp

	// Defines.
	//#define DEBUG
	#define NUMBER_OF_DIGITS 6

	// Includes.
	#include <bits/stdc++.h>

	#ifdef DEBUG
	#include <chrono>
	#endif

	// Usings.
	using namespace std;

	// Main function.
	int main()
	{
	#ifdef DEBUG
		chrono::system_clock::time_point start, end;
		
		start = chrono::system_clock::now();
	#endif
		
		// settings.
		ios::sync_with_stdio(false);
		
		//cout << fixed;
		//cout << setprecision(NUMBER_OF_DIGITS);
		
		// logic.
		int n;
		cin >> n;
		
		int honests[n];
		int unhonests[n];
		for (int i = 0; i < n; i++)
		{
			int a;
			cin >> a;
			int honest = 0;
			int unhonest = 0;
			for (int j = 0; j < a; j++)
			{
				int x, y;
				cin >> x >> y;
				
				if (y == 1)
				{
					honest |= (1 << (x - 1));
				}
				else
				{
					unhonest |= (1 << (x - 1));
				}
			}
			
			honests[i] = honest;
			unhonests[i] = unhonest;
		}
		
		int max = 0;
		for (int i = 0; i < (1 << n); i++)
		{
			bool all_ok = true;
			for (int j = 0; j < n; j++)
			{
				if (i & (1 << j))
				{
					int honest = honests[j];
					int unhonest = unhonests[j];
					
					if ((honest | i) != i)
					{
						all_ok = false;
						break;
					}
					
					if ((unhonest & i) != 0)
					{
						all_ok = false;
						break;
					}
				}
			}
			
			if (all_ok == true)
			{
				if (max < __builtin_popcount(i))
				{
					max = __builtin_popcount(i);
				}
			}
		}
		
		cout << max << endl;
		
		
		
	#ifdef DEBUG
		end = chrono::system_clock::now();
		
		double elapsed = chrono::duration_cast<std::chrono::milliseconds>(end-start).count();
		cout << elapsed << "[ms]" << endl;
	#endif
		
		return 0;
	}


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


signed main(){

  int n,t,a;

  cin >> n >> t >> a;

  vector<int> h(n);

  int min_idx = 0;

  for(int i=0;i<n;i++){
    cin >> h[i];
    h[i] = abs((t*1000 - h[i] * 6) - a*1000);

    if(h[min_idx] > h[i]){
      min_idx = i;
    }
  }

  cout << min_idx + 1 << endl;


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


}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main(){
  ll n,l,a[111111];
  cin>>n>>l;
  ll suml=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    suml+=a[i];
  }

  if(suml<l){
    cout<<"Impossible"<<endl;
    return 0;
  }

  
  for(int i=1;i<n;i++){
    if(a[i-1]+a[i]<l)continue;
    cout<<"Possible"<<endl;
    for(int j=1;j<i;j++){
	 cout<<j<<endl;
    }
    for(int j=n-1;j>i;j--){
	 cout<<j<<endl;
    }
    cout<<i<<endl;
    return 0;
  }

  cout<<"Impossible"<<endl;  
	   
  return 0;
}


Measured memory_bytes: 1664
s=int(input())
a=[]
a.append(s)
k=0
while True:
    if a[k]%2==0:a.append(a[k]//2)
    else:a.append(3*a[k]+1)
    k+=1
    for i in range(k):
        if a[i]==a[k]:
            print(k+1)
            exit()


Measured memory_bytes: 2940
# N,Kの把握
l1 = list(map(int, input().split()))
N = l1[0]
K = l1[1]

#リストをすぐに作成するのが悪手。数値と回数をセット作成
dic = {}
for i in range(N):
	l2 = list(map(int, input().split()))
	a = l2[0]
	b = l2[1]
	if a in dic:
		dic[a] += b #既に存在する数値であればそのまま回数を＋
	else:
		dic.update({a: b}) #新規の数値であれば追加

dic = sorted(dic.items(), key=lambda x:x[0])

x = 0
for key, value in dic: #回数値を足していき、総回数＞＝Kとなったときの数値を出力する。
	x += value
	if x >= K:
		print(str(key))
		break

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

int main(){
  string S;
  cin >> S;
  int f=0, b=S.size()-1;
  int ans =0;
  while(f<b){
    if(S[f]==S[b]){
      f++; b--;
    }
    else if(S[f]=='x'){
      f++;
      ans++;
    }else if(S[b]=='x'){
      b--;
      ans++;
    }else{
      cout << "-1" << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
K, N = map(int, input().split())
A = list(map(int, input().split()))

A.insert(0, A[N-1] - K)
diffs = []
for i in range(1, len(A)):
    diff = A[i] - A[i-1]
    diffs.append(diff)

print(K - max(diffs))

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

int main(int argc, char * argv[])
{
int n, a, b;
int p[100];
std::cin >> n;
std::cin >> a;
std::cin >> b;
for (int i=0; i<n; i++) std::cin >> p[i];

int n1=0, n2=0, n3=0;
for(int i=0; i<n; i++)
{
if (p[i] <= a) n1++;
else if (p[i] <= b) n2++;
else n3++;
}
std::cout << std::min(n1, std::min(n2, n3));

return 0;
}

Measured memory_bytes: 256
w = str(input())
L = []
for i in w:
  L.append(i)
if len(L) % 2 == 1:
  print('No')
  exit()
L.sort()
for j in range(0,len(L),2):
  if L[j] != L[j + 1]:
    print('No')
    exit()
print('Yes')
  


Measured memory_bytes: 9028
n, m = gets.split.map(&:to_i)
a = n.times.map { gets.chomp }
b = m.times.map { gets.chomp }
flag = false
for i in 0..(n-m) do
  for j in 0..(n-m) do
    count = 0
    for ii in 0...m do
      if a[i+ii].slice(j, m) == b[ii]
        count += 1
      else
        break
      end
    end
    if count == m
      flag = true
      break
    end
  end
  break if flag
end
puts flag ? "Yes" : "No"


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}



int main(){
  const ll a=2019;
  ll l,r;
  cin >> l >> r;
  if(r-l+1>2019){
    cout << 0 << endl;
    return 0;
  }
  ll ans=1000000000000;
  ll f=2000000000000,s=2000000000000,tmp;
  for(ll i=l;i<=r;i++){
    for(ll j=l;j<=r;j++){
      if(i==j)continue;
      chmin(ans,i*j%a);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))

#def DP(i):
#    if i <= 0:
#        return 0
#    DP1 = DP(i-1) + abs(h[i-2] - h[i-1])
#    DP2 = DP(i-2) + abs(h[i-3] - h[i-1])
#    return min(DP1, DP2)

DP = [10000]*N
DP[0] = 0
DP[1] = abs(h[1]- h[0])

for i in range(0, N-2):
    DP[i+2] = min(DP[i+1] + abs(h[i+2] - h[i+1]), DP[i] + abs(h[i+2]- h[i]))

#print(DP)
print(DP[N-1])


Measured memory_bytes: 13976
n = int(input())
p = list(map(int, input().split()))
c = 0
for i in range(2,n):
  p1 = p[i-2]
  p2 = p[i-1]
  p3 = p[i]
  if p1 < p2 < p3 or p3 < p2 < p1:
    c += 1
print(c)

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

using namespace std;

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define SORT(v) sort(v.begin(), v.end())
typedef long long ll;

int f(int n)
{
    int ans = 1;
    for (int i = 0; i <= n; i++)
    {
        ans *= 2;
        if (ans >= 1000000007)
        {
            ans = ans % 1000000007;
        }
    }
    return ans;
}

int main()
{
    int n, k;
    ll ans = 0;

    cin >> n >> k;

    // for (int i = k; i <= n + 1; i++)
    // {
    //     ans += ((n + 2 - i) % 1000000007);
    //
    //     ans = ans % 1000000007;
    //
    //     ans += (((i - 1) * (n + 1 - i)) % 1000000007);
    //
    //     ans = ans % 1000000007;
    // }

    for (int i = k; i <= n + 1; i++)
    {
        ans += ((n + 2 - i) % 1000000007);
        if (ans >= 1000000007)
        {
            ans = ans % 1000000007;
        }
        // REP(j, i - 1)
        // {
        ans += ((ll)(i - 1) * (ll)(n + 1 - i));
        if (ans >= 1000000007)
        {
            ans = ans % 1000000007;
        }
        // }
        // ans = ans % 1000000007;
    }

    cout << ans;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll a,b,c;
  cin>>a>>b>>c;
  if(b-a==c-b) {
cout<<"YES"<<endl;
  }
  else {
cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 3612
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>

using namespace std;

int main() {
  struct {
    int to, next;
  } E[1000];
  vector<int> LE(100, -1);
  int n, m;
  cin >> n >> m;
  for (int i = 0, s, t; i < m; ++i) {
    cin >> s >> t;
    E[i] = {t, LE[s]};
    LE[s] = i;
  }
  int post[100]{0}, pre[100]{0};
  struct data {
    int id, p;
  };
  stack<data> dfs;
  int clk = 0;
  for (int i = 0; i < n; ++i) {
    if (pre[i])
      continue;
    dfs.push({i, 0});
    while (!dfs.empty()) {
      data u = dfs.top();
      dfs.pop();
      if (pre[u.id] && u.p) {
        post[u.id] = ++clk;
      }
      if (!pre[u.id]) {
        pre[u.id] = ++clk;
        dfs.push({u.id, 1});
        for (int e = LE[u.id]; e != -1; e = E[e].next)
          dfs.push({E[e].to, 0});
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int e = LE[i]; e != -1; e = E[e].next) {
      if (pre[E[e].to] < pre[i] && post[E[e].to] > post[i]) {
        cout << 1 << endl;
        exit(0);
      }
    }
  }
  cout << 0 << endl;
}


Measured memory_bytes: 3188
#include <iostream>
#include <cstring>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <assert.h>
#include <stdlib.h>
using namespace std;

void smain();
int main() {
    ios_base::sync_with_stdio(0);
#ifdef TASK
    freopen(TASK".in","rt",stdin);
    const clock_t start = clock();
#endif
    smain();
#ifdef TASK
    cerr << "\nTotal Execution Time: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

#ifndef M_PI
#define M_PI 3.14159265358979311599796346854418516
#endif
#define forn(i,n) for (int i=0;i<n;i++)
#define rforn(i,n) for (int i=n-1;i>=0;i--)
#define LL long long
#define int long long
#define mp(a,b) make_pair(a,b)
#define INF 2305843009213693951LL
#define MOD 1000000007
#define EPS 1E-9
#define N 400002
/* --------- END TEMPLATE CODE --------- */
int a[N], b[N], n;
int d[N][2];

void smain() {
    for (; cin >> n; ) {
        forn(i, n) cin >> b[i];
        int res = 0, m = 0;
        forn(i, n) if (b[i]) {
            if (b[i] > 2) {
                int k = (b[i] - 2) / 2;
                b[i] -= 2 * k;
                res += k;
            }
            forn(j, b[i]) a[m++] = i;
        }
        for (int i = 1; i < m; ++i) {
            d[i][0] = max(d[i-1][0], d[i-1][1]);
            d[i][1] = d[i][0];
            if (a[i] - a[i - 1] <= 1) d[i][1] = d[i-1][0] + 1;
        }
        cout << max(d[m-1][0], d[m-1][1]) + res << endl;
    }
}


Measured memory_bytes: 8064
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,pp,money = 100000; // 10万円
  cin >> n;
  for(int i=0;i<n;i++){
    money = money + (int)(money * 0.05); 
    if(money % 1000 > 0){
      money = (money + 1000) - (money % 1000);
    }
  }
  cout << money << endl;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 2000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
#define int long long

int gcd(int a, int b) {
  if(a < b) return gcd(b, a);
  int r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int lcm(int a, int b){
    return a * b / gcd(a, b);
}

signed main(){
  int n,m;
  cin >> n >> m;
  int a[100000];
  int lc = 1;
  LOOP(i,n){
    cin >> a[i];
    lc = lcm(a[i],lc);
    if(lc>m*2){
      cout << 0 << endl;
      return 0;
    }
  }
  // cout << lc << endl;
  LOOP(i,n){
    if((lc/a[i])%2==0){
      cout << 0 << endl;
      return 0;
    }
  }
  if(lc/2 <= m){
    cout << (m-lc/2)/lc+1 << endl;
  }

}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(int,char**){
  int n,d,*x,*y,i,c=0;
  cin>>n>>d;
  x=new int[n];
  y=new int[n];
  for(i=0;i<n;i++){
    cin>>x[i]>>y[i];
  }
  long d2=static_cast<long>(d)*d,x2y2;
  for(i=0;i<n;i++){
    x2y2=static_cast<long>(x[i])*x[i]+static_cast<long>(y[i])*y[i];
    if(x2y2<=d2)c++;
  }
  cout<<c<<endl;
}

Measured memory_bytes: 5188
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a,b,c;
  cin>>a>>b>>c;
  if(a[a.length()-1]==b[0] && b[b.length()-1]==c[0])cout<<"YES\n";
  else cout<<"NO\n";
  cerr<<a[a.length()-1]<<" "<<b[b.length()-1]<<" "<<c[c.length()-1]<<endl;
  return 0;
}


Measured memory_bytes: 256
#gcdは3.4.3だとfractionsにある
from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "Yes"
no = "No"

def main():
    n,r = mi()
    if n >= 10:
        print(r)
    else:
        print(100*(10-n)+r)


main()



Measured memory_bytes: 5716
//https://atcoder.jp/contests/abc158/tasks/abc158_b
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	ll b;
	cin>>b;
	ll r;
	cin>>r;
	ll sum=0;
	sum=b+r;
	ll a;
	a=n/sum;
	ll c;
	c=n%sum;
	ll ans=0;
	if(c>=b)
	{
		ans=(b*a)+b;
	}
	else
	{
		ans=(b*a)+c;
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3648
# ABC-081_B-ShiftOnly

N = int(input())
in_list = input().split()

div_list = []
count = 1
times = 0

while count == 1:
    for i in range(N):
        if int(in_list[i])%2 == 0:
            in_list[i] = int(in_list[i])/2
        else:
            count = 0
            break;
    if count == 1:
        times += 1

print(times)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
	ll s,mod=pow(10,9)+7;
	cin>>s;
	vector<int> dp(s+1,0);
	dp[0]=1;
	for(int i=3;i<=s;i++){
		for(int j=3;(i-j)>=0;j++){
			dp[i]=(dp[i]%mod+dp[i-j]%mod)%mod;
		}
// 		cout<<dp[i]<<" ";
	}
// 	cout<<endl;
	cout<<dp[s]<<endl;
}

Measured memory_bytes: 3576
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;
const int Inf = 1 << 30;

int main()
{
	int ans,p,a[3];
	char s[3][105];
	while(~scanf("%s",s[0] + 1)){
		scanf("%s",s[1] + 1);
		scanf("%s",s[2] + 1);
		for(int i = 0;i < 3;i++) a[i] = strlen(s[i] + 1);
		p = 0;ans = -1;
		while(ans == -1){
			a[p]--;
			if(a[p] == -1) ans = p;
			else p = s[p][strlen(s[p] + 1) - a[p]] - 'a';
		}
		printf("%c\n",'A' + ans);
	}
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pb push_back 
/*ll lessthan(vector<ll> v,ll x)
{
    ll low=0,high=v.size()-1,mid,ans;
    while(low<=high)
    {
        mid=low+(high-low)/2;
        if(v[mid]>x)
        {
            ans=high;
            high=mid-1;
        }
        else
        {
            
            low=mid+1;
        }
    }
    return ans;
}*/
int main()
{
    ll m, n,t,i,j,p,ans=0;
    cin>>m>>n>>t;
    vector<ll> a(m+1,0),b(n+1,0);
    for(i=1;i<=m;i++)
    {
        cin>>a[i];
    }
    for(i=1;i<=n;i++)
    {
        cin>>b[i];
    }
    for(i=1;i<=m;i++)
    {
        a[i]=a[i]+a[i-1];
    }
    for(i=1;i<=n;i++)
    {
        b[i]=b[i]+b[i-1];
    }
    for(i=0;i<=m;i++)
    {
        if(a[i]<=t)
        {
            p=i;
            p+=upper_bound(b.begin(),b.end(),t-a[i])-b.begin()-1;
            //cout<<a[i]<<" "<<b[upper_bound(b.begin(),b.end(),t-a[i])-b.begin()-1]<<" "<<a[i]+b[upper_bound(b.begin(),b.end(),t-a[i])-b.begin()-1]<<endl;
            ans=max(p,ans);
        }
    }
    cout<<ans<<endl;
    //cout<< upper_bound(a.begin(),a.end(),0)-a.begin()-1;
    
    
   
    return 0;
}


Measured memory_bytes: 6372
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

#ifdef WIN32
	#define LL "%I64d"
#else
	#define LL "%lld"
#endif

#ifdef CT
	#define debug(...) printf(__VA_ARGS__)
	#define setfile() 
#else
	#define debug(...)
	#define filename ""
	#define setfile() freopen(filename".in", "r", stdin); freopen(filename".out", "w", stdout)
#endif

#define R register
#define getc() (S == T && (T = (S = B) + fread(B, 1, 1 << 15, stdin), S == T) ? EOF : *S++)
#define dmax(_a, _b) ((_a) > (_b) ? (_a) : (_b))
#define dmin(_a, _b) ((_a) < (_b) ? (_a) : (_b))
#define cmax(_a, _b) (_a < (_b) ? _a = (_b) : 0)
#define cmin(_a, _b) (_a > (_b) ? _a = (_b) : 0)
#define cabs(_x) ((_x) < 0 ? (- (_x)) : (_x))
char B[1 << 15], *S = B, *T = B;
inline int F()
{
	R char ch; R int cnt = 0; R bool minus = 0;
	while (ch = getc(), (ch < '0' || ch > '9') && ch != '-') ;
	ch == '-' ? minus = 1 : cnt = ch - '0';
	while (ch = getc(), ch >= '0' && ch <= '9') cnt = cnt * 10 + ch - '0';
	return minus ? -cnt : cnt;
}

int main()
{
//	setfile();
	int a = F(), b = F();
	if (a == b) puts("Draw");
	else if (a == 1 || (a > b && b != 1)) puts("Alice");
	else puts("Bob");
	return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  
  map<int, int> M;
  
  for (int i = 0; i < N; ++i) {
    int num;
    cin >> num;
    M[num]++;
  }
//cout << M.size() << "]" << K << endl;
  int ans;
  if (K >= M.size()) {
    ans = 0;
    cout << ans << endl;
    return 0;
  }
  // M.size > K
  int msize = M.size();
  
  typedef pair<int, int> int_pair;
  struct pair_order {
    bool operator()(int_pair& l, int_pair& r) {
    	return tie(l.second, l.first) > tie(r.second, r.first);
    }
  };
  
  priority_queue<int_pair, vector<int_pair> ,pair_order> pq;
  
  for (int_pair m : M) {
    pq.push(m); 
  }
  
  ans = 0;
  while(M.size() > K) {
//cout << K << "[" << msize << "[" << ans << endl;
    int_pair m = pq.top();
    ans += m.second;
    M.erase(m.first);  
    
    pq.pop(); 
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 14632
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm> 
using namespace std;

int main() {
	string a;
	char aa[100100];
	int j=0;
	cin >> a;
	for (int i = 0; i < a.size(); i++) {
		if (i % 2 == 0) {
			aa[j] = a[i];
			j++;
		}
	}
	for (int i = 0; i <j; i++) {
		cout << aa[i];
	}
	cout << endl;
	

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    string s; cin >> s;
    string t; cin >> t;
    ll ans = 0;
    REP(i, s.size()){
        ans += (s[i] != t[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3884
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li      int32_t
#define lli     long long
#define ulli unsigned long long

#define pn          printf("\n")
#define nl          cout<<'\n'
#define sf(N)       scanf("%lld",&N)
#define pf(N)       printf("%lld",N)
#define sl          cout<<' '
#define ps          printf(" ")

#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))

#define pb      push_back
#define pob     pop_back
#define itr     iterator
#define sz()    size()
#define szof    sizeof
#define lb      lower_bound
#define ub      upper_bound
#define mp      make_pair
#define vlli    vector<lli>
#define plli    pair<lli,lli>
#define vplli   vector<plli >
#define F       first
#define S        second
#define ALL(V)  V.begin(),V.end()
#define Dup erase(unique(V.begin(),V.end()),V.end())

#define Inf     1000000000000000
#define mod     1000000007
using namespace std;

lli Power(lli a,lli b)
{
    lli result=1;

    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }

        b=b>>1;
        a=(a*a)%mod;
    }

 return result;
}

int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/
    
    ulli N,i;
    cin>>N;
    
    vector<pair<ulli,ulli> > V(N),Store(N);
    
    rep(i,0,N)
    {
        cin>>V[i].F>>V[i].S;
    }
    
    Store[0].F=V[0].F;
    Store[0].S=V[0].S;
    
    rep(i,1,N)
    {
        ulli x,y;
        x=Store[i-1].F/V[i].F;
        y=Store[i-1].S/V[i].S;
    
        if(Store[i-1].F%V[i].F)
        {
            x++;
        }
        
        if(Store[i-1].S%V[i].S)
        {
            y++;
        }
        
        Store[i].F=max(x,y)*V[i].F;
        Store[i].S=max(x,y)*V[i].S;
    }
    
    cout<<Store[N-1].F+Store[N-1].S;
    









 return 0;
}


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

int Calc(int x, int y, int z) {
    return (x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x);
}

int main() {
    int N;
    cin >> N;

    
    for (int i = 1; i <= N; i++)
    {
        int ans = 0;
        int x = 1;
        while (x * x <= i) {
            int y = 1;
            while (y * y <= i) {
                int z = 1;
                while (z * z <= i) {
                    int w = Calc(x, y , z);
                    if (w == i) {
                        ans++;
                    }
                    else if (w > i){
                        break;
                    }
                    z++;
                }
                y++;
            }
            x++;
        }
    cout << ans << endl;
    }
    
    return 0;
}


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

using namespace std;

int a[200005], h[200005], lx, ly;
long long tree[800005], lval;

void update(int l, int r, int ind) {
	if (l == r) {
		tree[ind] = lval;
		return;
	}
	int mid = (l + r) / 2;
	if (lx <= mid) update(l, mid, ind * 2);
	else update(mid + 1, r, ind * 2 + 1);
	tree[ind] = max(tree[ind * 2], tree[ind * 2 + 1]);
}

void query(int l, int r, int ind) {
	if (lx <= l && r <= ly) {
		lval = max(lval, tree[ind]);
		return;
	}
	int mid = (l + r) / 2;
	if (lx <= mid) query(l, mid, ind * 2);
	if (ly > mid) query(mid + 1, r, ind * 2 + 1);
}

int main() {
	int n;
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++) scanf("%d", &h[i]);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	
	long long res = 0;
	
	for (int i = 0; i < n; i++) {
		lx = 1;
		ly = h[i];
		lval = 0;
		query(1, n, 1);
		lval += a[i];
		res = max(res, lval);
		lx = h[i];
		update(1, n, 1);
	}
	
	printf("%lld\n", res);
}


Measured memory_bytes: 8064
n = int(input())
A = [int(l) for l in input().split(' ')]
kn = int(input())
k_list = [int(l) for l in input().split(' ')]

def linear_search(k,A,n):
  i = 0
  while A[i] != k:
    i += 1
    if i == n:
      return False
  return True

sum = 0
for k in k_list:
   sum += 1 if linear_search(k,A,n) else 0
print(sum)


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

string S,T;

int main(){
	cin>>S>>T;
	for(int i=0;i<S.size();i++){
		if(S[i]!=T[i]){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}


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

const string C = "[]()";

int main() {
  for(string s; getline(cin, s) && s != ".";) {
    try {
      stack<int> stk;
      for(int i = 0; i < s.size(); ++i) {
        int p = C.find(s[i]);
        if(p == string::npos) continue;
        if(p % 2 == 0) {
          stk.push(p);
        } else {
          if(stk.empty() || stk.top() != p-1) {
            throw "no";
          }
          stk.pop();
        }
      }
      if(stk.size()) throw "no";
      throw "yes";
    } catch(const char *res) {
      cout << res << endl;
    }
  }
  return 0;
}

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

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

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

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

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

// xxoo xxyy xxyy
// yyxx yyxx yyoo
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    string s[2];
    cin >> s[0] >> s[1];

    LL ans = 1;
    bool flag = false;
    REP(i, s[0].size()){
        if(s[0][i] == s[1][i]){
            if(i == 0){
                ans = 3;
            }else{
                if(!flag) ans = ans * 2 % MOD;
            }
            flag = false;
        }else{
            if(i == 0){
                ans = 6;
            }else{
                if(flag) ans = ans * 3 % MOD;
                else ans = ans * 2 % MOD;
            }
            flag = true;
            i++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


public class Main {
    FastIO io = new FastIO("in.txt");
    long K;

    long check(long a){
        int n7 = 0;
        while(a > 0){
            if(a % 10 != 7) return -1;
            n7++;
            a /= 10;
        }
        return n7;
    }

    long solve(){
        if(K % 2 == 0 || K % 5 == 0) return -1;
        long k0 = K % 10;
        long a = 0;
        long ans = 0;
        while(true){
            for(int b=0; b<10; b++){
                long c = b * K + a;
                if(c % 10 == 7){
                    a = c / 10;
                    ans++;
                    break;
                }
            }
            if(a == 0) break;
        }
        return ans;
    }

    public void main() throws Exception {
        K = io.nextLong();
        io.out(solve() + "\n");
    }

    public static void main(String[] args) throws Exception {
        Main task = new Main();
        task.main();
    }

    class FastIO {
        BufferedReader br;
        StringTokenizer sk;

        public FastIO(String fname){
            try{
                File f = new File(fname);
                if(f.exists()) {
                    System.setIn(new FileInputStream(fname));
                }

            }catch (Exception e){
                throw new IllegalArgumentException(e);
            }

            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastIO(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next(){
            while(sk==null || !sk.hasMoreElements()){
                try {
                    sk = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new IllegalArgumentException(e);
                }
            }
            return sk.nextToken();
        }

        public int nextInt(){
            return Integer.parseInt(next());
        }

        public char nextChar(){
            return next().charAt(0);
        }

        public long nextLong(){
            return Long.parseLong(next());
        }

        public double nextDouble(){
            return Double.parseDouble(next());
        }

        public String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            }catch (Exception e){
                e.printStackTrace();
            }
            return str;
        }

        public void out(String v){
            System.out.print(v);
        }

        public void out(int v) {
            System.out.print(v);
        }

        public void out(long v){
            System.out.print(v);
        }

        public void out(double v) {
            System.out.print(v);
        }
    }
}



Measured memory_bytes: 36604
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=1000000007;
	static readonly int[][] di=new int[][]{new int[]{-1,0},new int[]{1,0},new int[]{0,-1},new int[]{0,1}};
	static void Main(){
		Sc sc=new Sc();
		int[] s=sc.Ia;int h=s[0],w=s[1];
		string[] bm=new string[h+2];
		bool[][] b=new bool[h+2][];
		Queue<Tuple<int,int,int>> qu=new Queue<Tuple<int,int,int>>();
		bool bo=true;
		for(int i = 1;i<=h;i++) {
			bm[i]="X"+sc.S+"X";
			b[i]=new bool[w+2];
			for(int j = 1;j<=w&&bo;j++) {
				if(bm[i][j]=='S'){
					qu.Enqueue(Tuple.Create(0,i,j));
					bo=false;
					break;
				}
			}
		}
		bm[0]=new string('X',w+2);
		bm[h+1]=new string('X',w+2);
		int ans=int.MaxValue;
		while(qu.Count>0){
			var q=qu.Dequeue();
			if(q.Item1>s[2]){break;}
			ans=Math.Min(ans,q.Item2-1);
			ans=Math.Min(ans,q.Item3-1);
			ans=Math.Min(ans,h-q.Item2);
			ans=Math.Min(ans,w-q.Item3);
			for(int i = 0;i<4;i++) {
				if(bm[q.Item2+di[i][0]][q.Item3+di[i][1]]=='.'&&!b[q.Item2+di[i][0]][q.Item3+di[i][1]]){
					b[q.Item2+di[i][0]][q.Item3+di[i][1]]=true;
					qu.Enqueue(Tuple.Create(q.Item1+1,q.Item2+di[i][0],q.Item3+di[i][1]));
				}
			}
		}
		Console.WriteLine("{0}",(ans/s[2]+(ans%s[2]!=0?1:0)+1));
	}
}
public class Sc{
	private string[] a;
	private int n=-1,m=0;
	public int I{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return int.Parse(a[n]);}}
	public long L{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return long.Parse(a[n]);}}
	public double D{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return double.Parse(a[n]);}}
	public string S{get{if(n==-1||n==a.Length-1){n=-1;a=Console.ReadLine().Split();}n++;return a[n];}}
	public int[] Ia{get{if(n!=-1&&n!=a.Length-1){m=n;n=-1;return Array.ConvertAll(a.Skip(m+1).ToArray(),int.Parse);}return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

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

using namespace std;

typedef long long ll;

ll mod = 1e9+7;

typedef vector< vector<ll> > Matrix;

int N, K, C, T;

vector<int> shuffle(vector<int>& v, int a, int b) {
	vector<int> res;
	for (int i = 0; i < b; ++i) {
		res.push_back(v[a+i]);
	}
	for (int i = 0; i < a; ++i) {
		res.push_back(i);
	}
	for (int i = a+b; i < N; ++i) {
		res.push_back(i);
	}
	return res;
}
vector<int> make_shuffle(int a, int b) {
	vector<int> v(N);
	for (int i = 0; i < N; ++i) {
		v[i] = i;
	}
	v = shuffle(v, a, b);
	vector<int> res(N);
	for (int i = 0; i < N; ++i) {
		res[v[i]] = i;
	}
	return res;
}

vector< vector<ll> > make_E() {
	vector< vector<ll> > res(N*5, vector<ll>(N*5, 0));
	for (int i = 0; i < N*5; ++i) {
		res[i][i] = 1;
	}
	return res;
}
vector< vector<ll> > mul(Matrix A, Matrix B) {
	vector< vector<ll> > res(N*5, vector<ll>(N*5, 0));
	for (int k = 0; k < N*5; ++k) {
		for (int j = 0; j < N*5; ++j) {
			for (int i = 0; i < N*5; ++i) {
				res[i][j] = (res[i][j] + A[i][k] * B[k][j] % mod);
				if (res[i][j] >= mod) res[i][j] -= mod;
			}
		}
	}
	return res;
}

vector< vector<ll> > power(Matrix A, int n) {
	Matrix res = make_E();
	for (int i = 1; i <= n; i <<= 1) {
		if (n & i) {
			res = mul(res, A);
		}
		A = mul(A, A);
	}
	return res;
}

int main() {
	cin >> N >> K >> C >> T;
	vector< vector< vector<ll> > > pat(5, vector< vector<ll> >(N, vector<ll>(N, 0)));
	for (int i = 0; i < K; ++i) {
		int a, b, t; cin >> a >> b >> t; --a, --t;
		vector<int> to = make_shuffle(a, b);
		for (int j = 0; j < to.size(); ++j) {
			++pat[t][j][to[j]];
		}
	}
	vector< vector<ll> > G(N*5, vector<ll>(N*5, 0));
	for (int t = 0; t < 5; ++t) {
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				int from = i*5;
				int to = j*5+t;
				G[from][to] += pat[t][i][j];
			}
		}
	}
	for (int i = 0; i < N; ++i) {
		for (int t = 1; t < 5; ++t) {
			G[i*5+t][i*5+t-1] = 1;
		}
	}
	vector< vector<ll> > g = power(G, T);
/*	for (int i = 0; i < N*5; ++i) {
		for (int j = 0; j < N*5; ++j) {
			cout << g[i][j] << " ";
		}
		cout << endl;
	}
*/	cout << g[(C-1)*5][0*5] << endl;
}

Measured memory_bytes: 4976
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
#pragma warning(disable : 4996)
using namespace std;
int n, m;
int main() {
	scanf("%d%d", &n, &m);
	vector<int> x(n);
	for (int i = 0; i < n; i++) scanf("%d", &x[i]), x[i]--;
	vector<vector<int> > sum(m, vector<int>(n + 1, 0));
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < n; j++) {
			sum[i][j + 1] = sum[i][j] + (x[j] == i ? 1 : 0);
		}
	}
	vector<int> bsum(1 << m, 0);
	for (int i = 0; i < m; i++) {
		for (int j = 1 << i; j < 2 << i; j++) {
			bsum[j] = bsum[j - (1 << i)] + sum[i][n];
		}
	}
	vector<int> dp(1 << m, 999999999); dp[0] = 0;
	for (int i = 1; i < 1 << m; i++) {
		for (int j = 0; j < m; j++) {
			if (!(i & (1 << j))) continue;
			dp[i] = min(dp[i], dp[i - (1 << j)] + (bsum[i] - bsum[i - (1 << j)]) - (sum[j][bsum[i]] - sum[j][bsum[i - (1 << j)]]));
		}
	}
	printf("%d\n", dp[(1 << m) - 1]);
	return 0;
}

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

using namespace std;

#define ll long long
const ll MOD = 1e9 + 7;
#define all(x)      (x).begin(), (x).end()
#define UN(a)       sort(all(a)), a.erase(unique(all(a)), a.end())

int n, m, N;
int mp[110][110];
bool vis[110][110];
int a[10010];
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
bool go(int x, int y){
    return x >= 0 && x < n && y >= 0 && y < m;
}
int ind, num, cur, step;
void dfs(int i, int j){
    vis[i][j] = 1;
    mp[i][j] = cur;
    num--;
    step++;
    if(!num && ind == N - 1){
//            cout<<i<<"aaaaaaaaaaaa"<<j<<endl;
            return;
    }
    if(num == 0){
        ind ++;
        cur ++;
        num = a[ind];
    }
    for(int k = 0; k < 4; ++k){
        int nx = i + dx[k];
        int ny = j + dy[k];
        if(!vis[nx][ny] && go(nx, ny)){
            dfs(nx, ny);
        }
    }
    return;
}
int main(){
    cin >> n>>m;
    cin >> N;
    for(int i = 0; i < N; ++i){
        cin >> a[i];
    }
    ind = 0; cur = 1; num = a[ind], step = 0;
    dfs(0, 0);
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < m; ++j){
            cout << mp[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

template<typename T>
vector<pair<int, T>> continuousLen(const vector<T>& v){
    
    vector<pair<int, T>> vRet; vRet.push_back(make_pair(1, v[0]));
    T prev = v[0];
    for(uint i=1; i<v.size(); ++i){
        if(prev!=v[i]){ vRet.push_back(make_pair(1, v[i])); prev=v[i]; continue; }
        ++(vRet[vRet.size()-1].first);
    }
    sort(vRet.begin(), vRet.end(), greater<pair<int,T>>());
    return vRet;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n; cin >> n;
    int nd2 = n/2; // n div 2
    
    vector<int> vO(nd2); // odd
    vector<int> vE(nd2); // even
    for(int i=0; i<nd2; ++i){
        cin >> vO[i];
        cin >> vE[i];
    }
    sort(vO.begin(), vO.end());
    sort(vE.begin(), vE.end());
    
    vector<pair<int, int>> vCL_o = continuousLen(vO);
    vector<pair<int, int>> vCL_e = continuousLen(vE);
    
    int len_o = vCL_o[0].first;
    int len_e = vCL_e[0].first;
    int len_o1 = vCL_o[1].first;
    int len_e1 = vCL_e[1].first;
    int val_o = vCL_o[0].second;
    int val_e = vCL_e[0].second;
    int ans;
    if(val_o != val_e){
        ans = n - len_o - len_e;
    }else{
        int ans1 = n - len_o1 - len_e;
        int ans2 = n - len_o  - len_e1;
        ans = min(ans1, ans2);
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define pii 3.14
#define mod (ll)(1e9 + 7)
#define inf (ll)(1e18)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ordered_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
#define pi pair<int,int>
#define N (ll)(5e5+5)

void solve()
{
    ll a,b;
    cin>>a>>b;
    cout<<a*b;
}

int main()
{
    fio;
    ll tc = 1;
    //cin>>tc;
    while(tc--)
    {
        solve();
    }
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

struct UnionFind{
  int N, Group[int(2e5+5)];
  void Make(){
    for (int i = 1; i <= N; i++) Group[i] = i;
  }
  void Union(int u, int v){
    int Gu = Group[u], Gv = Group[v];
    while (Gu != Group[Gu]) Gu = Group[Gu];
    while (Gv != Group[Gv]) Gv = Group[Gv];
    Group[max(Gu, Gv)] = min(Gu, Gv);
  }
  bool Check(int u, int v){
    int Gu = Group[u], Gv = Group[v];
    while (Gu != Group[Gu]) Gu = Group[Gu];
    while (Gv != Group[Gv]) Gv = Group[Gv];
    if (Gu == Gv) return true;
    else return false;
  }
};

int main(){
  int N, Q; cin >> N >> Q;
  UnionFind UF; UF.N = N; UF.Make();

  for (int i = 0; i < Q; i++){
    int T, U, V; cin >> T >> U >> V;
    if (T == 0) UF.Union(U, V);
    else cout << UF.Check(U, V) << endl;
  }

  return 0;
}


Measured memory_bytes: 4248
#pragma warning disable
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
using System.Collections;
using static System.Math;
using static System.Console;
class E { static void Main() => new J(); }
class J
{
	const int Mod = 1000000007;
	int F() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	public J()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F();
		var a = G();
		var min = long.MaxValue;
		var s = 0L;
		foreach (var x in a) s += x;
		var t = 0L;
		for (var i = 1; i < N; i++)
		{
			t += a[i - 1];
			var y = s - t;
			min = Min(min, Abs(t - y));
		}
		WriteLine(min);
	}
	long GCD(long a, long b)
	{
		var n = (ulong)Abs(a); var m = (ulong)Abs(b);
		if (n == 0) return (long)m; if (m == 0) return (long)n;
		int zm = 0, zn = 0;
		while ((n & 1) == 0) { n >>= 1; zn++; }
		while ((m & 1) == 0) { m >>= 1; zm++; }
		while (m != n)
		{
			if (m > n) { m -= n; while ((m & 1) == 0) m >>= 1; }
			else { n -= m; while ((n & 1) == 0) n >>= 1; }
		}
		return (long)n << Min(zm, zn);
	}
}

Measured memory_bytes: 33628
/* ANTHOR KUMAR DAS
KUET ECE 2K18*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sc(a) scanf("%d",&a)
#define sc1(n) scanf("%lld",&n)
#define sc2(b,c) scanf("%lld%lld",&b,&c)
#define f(a,b) for(a=0;a<b;a++)
#define pb(a) push_back(a)
#define br break
int main()
{
    int n,i,j,s=0;
    cin>>n;
    int a[n];
    f(i,n)
    {
        cin>>a[i];
    }
    f(i,n-1)
    {
        for(j=i+1;j<n;j++)
        {
            s=s+(a[i]*a[j]);
        }
    }
    cout<<s<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

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

    while(h!=0 && w!=0) {
      for(int i=0; i<h; ++i){
        for(int j=0; j<w; ++j) {
          if(i==0 || i==(h-1)) {
            printf("#");
            continue;
          }
          else
            if(j==0 || j==(w-1))
              printf("#");

            else
              printf(".");
        }

        printf("\n");
      }

      printf("\n");
      scanf("%d %d", &h, &w);
    }

    return 0;
}



Measured memory_bytes: 2044
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <stack>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

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

int main() {
	int n, d;
	while(cin >> n >> d) {
		if(n == 0 && d == 0) break;

		stack<int> st[n];
		vector<int> sum(n);
		rep(i, n) {
			int m;
			cin >> m;

			rep(j, m) {
				int x;
				cin >> x;

				st[i].push(x);
				sum[i] += x;
			}
		}

		int id = 0, cnt = 0;
		while(cnt != n) {
			if(st[id].size() == 0) {
				id = (id + 1) % n;
				cnt++;
				continue;
			}

			int p = st[id].top();
			sum[id] -= p;

			int vmin = INF, vmax = 0;
			rep(i, n) {
				vmin = min(vmin, sum[i]);
				vmax = max(vmax, sum[i]);
			}

			if(vmax - vmin <= d) {
				st[id].pop();
				cnt = 0;
			} else {
				sum[id] += p;
				cnt++;
			}

			id = (id + 1) % n;
		}

		bool flag = true;
		rep(i, n) {
			if(sum[i] == 0) continue;
			flag  = false;
		}

		if(flag) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 1276