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

typedef long long ll;
typedef pair<int, int> ii;

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

    char inp[h][w + 2];
    for (int i = 0; i < h; i++) {
        scanf("%s", inp[i]);
    }

    int ans = 0;
    for (int i = 0; i < (1 << h); i++) {
        for (int j = 0; j < (1 << w); j++) {
            char tmp[h][w + 2];
            for (int x = 0; x < h; x++)
                strcpy(tmp[x], inp[x]);

            for (int x = 0; x < h; x++) {
                if ((i >> x) & 1) {
                    for (int y = 0; y < w; y++) {
                        tmp[x][y] = '-';
                    }
                }
            }

            for (int y = 0; y < w; y++) {
                if ((j >> y) & 1) {
                    for (int x = 0; x < h; x++) {
                        tmp[x][y] = '-';
                    }
                }
            }

            int cnt = 0;
            for (int x = 0; x < h; x++)
                for (int y = 0; y < w; y++)
                    if (tmp[x][y] == '#')
                        cnt++;

            ans += (cnt == k);
        }
    }

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

    return 0;
}


Measured memory_bytes: 3828
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;
#define LL long long

int N,ans;
int cnt[10][10]={};

int main(){
	cin>>N;
	for(int i=1;i<=N;i++){
		if(i%10==0)continue;
		int tmp;
		for(tmp=1;tmp<=i;tmp*=10);
		tmp/=10;
		cnt[i/tmp][i%10]++;
		if(i/tmp==i%10)
			ans+=cnt[i/tmp][i%10]*2-1;
		else ans+=cnt[i%10][i/tmp]*2;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int a,b,c;cin>>a>>b>>c;
	if(a==b&b==c){cout<<"Yes"<<endl;}
	else{cout<<"No"<<endl;}
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long int64;
map<int, int> P;
map<int, int> M;

int main() {
	int N;
	cin >> N;
	int tmp;
	int64 ans = 0;
	for (int i = 0; i < N; ++i) {
		cin >> tmp;
		if (tmp < 200000) {
			++P[i+tmp];
			if (i-tmp > 0) ++M[i-tmp];
		}
	}
	for (int i = 1; i < N; ++i) {
		ans += (int64)P[i] * M[i];
	}
	cout << ans << "\n";
	return 0;
}


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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

struct RollingHash {
  static const ll base1 = 1007, base2 = 2009;
  static const ll mod1 = 1000000007, mod2 = 1000000009;
  vector<ll> hash1, hash2, power1, power2;

  // construct
  RollingHash(const string& S) {
    ll n = (ll)S.size();
    hash1.assign(n + 1, 0);
    hash2.assign(n + 1, 0);
    power1.assign(n + 1, 1);
    power2.assign(n + 1, 1);
    for (ll i = 0; i < n; ++i) {
      hash1[i + 1] = (hash1[i] * base1 + S[i]) % mod1;
      hash2[i + 1] = (hash2[i] * base2 + S[i]) % mod2;
      power1[i + 1] = (power1[i] * base1) % mod1;
      power2[i + 1] = (power2[i] * base2) % mod2;
    }
  }

  // get hash of s[l..r-1]
  inline P get(ll l, ll r) const {
    long long res1 = hash1[r] - hash1[l] * power1[r - l] % mod1;
    if (res1 < 0) res1 += mod1;
    long long res2 = hash2[r] - hash2[l] * power2[r - l] % mod2;
    if (res2 < 0) res2 += mod2;
    return {res1, res2};
  }

  // get lcp of s[a..] and s[b..]
  inline ll getLCP(ll a, ll b) const {
    ll len = min((ll)hash1.size() - a, (ll)hash1.size() - b);
    ll low = 0, high = len;
    while (high - low > 1) {
      ll mid = (low + high) >> 1;
      if (get(a, a + mid) != get(b, b + mid))
        high = mid;
      else
        low = mid;
    }
    return low;
  }
};

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  string s;
  cin >> n >> s;

  RollingHash rh(s);
  ll ans = 0;
  rep(i, n-1) repLRE(j, i+1, n) chmax(ans, min(rh.getLCP(i, j), j - i));

  cout << ans << endl;;

  return 0;
}


Measured memory_bytes: 3740
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;

void Main()
{
	int N;
	std::cin >> N;
	std::vector<std::pair<int, int>> vec(N);
	for (int i : boost::irange(0, N))
	{
		int a;
		std::cin >> a;
		vec[i] = std::make_pair(a, i);
	}
	boost::sort(vec, std::greater<>());
	for (int i : boost::irange(0, N))
	{
		if (vec[0].second == i)
		{
			std::cout << vec[1].first << std::endl;
		}
		else
		{
			std::cout << vec[0].first << std::endl;
		}
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll n; cin >> n;

    ll cnt[1010] = {};

    //2〜Nまでの素因数分解を行う
    for (ll i = 2; i <= n; ++i) {
        ll now = i;
        for (int j = 2; j <= now; ++j) {
            //ある数字で割り切れる場合はずっと割る
            while (now % j == 0) {
                ++cnt[j];
                now /= j;
            }
        }
    }

    ll ans = 1;

    for (int i = 0; i <= n; ++i) {
        if (cnt[i] != 0) {
            ans *= cnt[i] + 1;
            ans %= MOD;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const double PI = 2 * acos(0);
int N, K;
LL dp[100001];

LL pangkat(LL a, LL b) {
	if (b == 0) return 1;
	LL tmp = pangkat(a, b / 2) % MOD;
	tmp *= tmp; tmp %= MOD;
	if (b % 2) tmp *= a, tmp %= MOD;
	return tmp; 
}

LL rek(int x) {
	if (dp[x] == -1) {
		int cnt = K / x;
		LL p = pangkat(cnt, N) % MOD;
		for (int i = 2 * x; i <= K; i += x) {
			p -= rek(i);
			while (p < 0) p += MOD;
		}
		dp[x] = p;
	}
	return dp[x];
}

int main() {
	memset(dp, -1, sizeof dp);
	scanf("%d%d", &N, &K);
	LL ans = 0;
	for (int i = 1; i <= K; i++) {
		ans += (i * rek(i)) % MOD;
		ans %= MOD;
	}	
	printf("%lld\n", ans);
} 

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

int main(){
  int N,T;
  cin >> N >> T;
  
  vector<int> cost(N);
  vector<int> time(N);
  
  for(int i=0; i<N; i++){
    cin >> cost.at(i) >> time.at(i);
  }
  int ans = 0;
  
  for(int i=0; i<N; i++){
    if(time.at(i) <= T){
      if(ans == 0){
        ans = cost.at(i);
      }else{
        ans = min(ans, cost.at(i));
      }
    }
  }
  
  if(ans == 0){
    cout << "TLE" << endl;
  }else{
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;

int main() {

string a,b,c;
cin>>a>>b>>c;
cout<<'A'<<b[0]<<'C'<<endl;


    return 0;
}


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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}
template<typename T1,typename T2> inline T1 gmax(T1 &a,T2 b){return a=a<b?b:a;}
template<typename T1,typename T2> inline T1 gmin(T1 &a,T2 b){return a=a<b?a:b;}


namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 200007 , __ = _<<1;

int to[__],ne[__],he[_]={0},ecnt=1;
inline void adde(int a,int b){to[++ecnt]=b,ne[ecnt]=he[a],he[a]=ecnt;}
inline void addde(int a,int b){adde(a,b),adde(b,a);}

int n,dep[_]={0},mxdep;

void dfs(int x,int ff)
{
	dep[x]=1;
	for(int i=he[x];i;i=ne[i])
		if(to[i]!=ff)dfs(to[i],x),gmax(mxdep,dep[x]+dep[to[i]]),gmax(dep[x],dep[to[i]]+1);
	gmax(mxdep,dep[x]);
}

int main()
{
	n=ty();
	for(int i=1,a,b;i<n;i++)a=ty(),b=ty(),addde(a,b);
	mxdep=0,dfs(1,0);
	puts(mxdep%3==2?"Second":"First");

	return 0;
}


Measured memory_bytes: 13952
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int a,b,c;
    int count=0;
    cin >> a >> b >> c;
    if(a == b){
        count ++;
    }
    if(c == b){
        count ++;
    }
    if(a == c){
        count ++;
    }
    if(count == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
class Node
  attr_accessor :parent, :rank
  def initialize(n)
    @parent = n
    @rank = 0
  end
end

class UnionFindTree
  def initialize(n)
    @nodes = (0..n).map { |i| Node.new(i) }
  end

  def unite(a, b)
    pa = find(a)
    pb = find(b)
    return if pa == pb

    if @nodes[pa].rank < @nodes[pb].rank
      @nodes[pb].parent = pa
    else
      @nodes[pa].parent = pb
      @nodes[pa].rank += 1 if @nodes[pa].rank == @nodes[pb].rank
    end
  end

  def find(x)
    return x if @nodes[x].parent == x
    @nodes[x].parent = find(@nodes[x].parent)
  end
end

n,k,l = gets.split(" ").map(&:to_i)

road = UnionFindTree.new(n)
1.upto(k) do
  x,y = gets.split(" ").map(&:to_i)
  road.unite(x,y)
end

rail = UnionFindTree.new(n)
1.upto(l) do
  x,y = gets.split(" ").map(&:to_i)
  rail.unite(x,y)
end

pair = Array.new
hash = Hash.new(0)
1.upto(n) do |p|
 x = road.find(p)
 y = rail.find(p)
 key = [x,y]
 pair.push(key)
 
 hash[key] = hash[key] + 1
  
end

pair.each do |key|
 print hash[key], " "
end
print "\n"

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

int main(){
  int N,T;
  cin>>N>>T;
  int time=0;
  vector<int> vec(N);
  cin>>vec.at(0);
  for(int i=1;i<N;i++){
    cin>>vec.at(i);
    if(vec.at(i)-vec.at(i-1)>T) time+=T;
    else time+=vec.at(i)-vec.at(i-1);
  }
  cout<<time+T<<endl;
}

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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

vector<ll> v;

int main() {
    double N;
    cin >> N;
    cout << ceil (N / 2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n, a, b;
    cin >> n >> a >> b;
    
    int ans = 0;
    for (int i=1; i<=n; i++) {
        int sum = 0;
        int j = i;
        while(j > 0) {
           sum += j % 10;
           j/=10;
        }
        if (a <= sum && sum <= b) ans += i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int n;
string s;
map<char,int>mp,mp1;
int main(){
	//freopen("readin.txt","r",stdin);
	cin >> n >> s;
	for(auto i : s)mp[i]++;
	int ans = 1e9;
	for(auto i : s){
		mp[i]--;
		ans = min(ans,mp1['W'] + mp['E']);
		mp1[i]++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 900
#include<iostream>
using namespace std ;
int main()
{
	int m=0 , f=0 , b=0 ;
	cin >> m >> f >> b ;
	if(m<=b&&m+f>=b) cout << b-m << endl ;

	else if(m+f<b) cout << "NA" << endl ;

	else cout << 0 << endl ;

	return 0 ;
}



Measured memory_bytes: 3112
/** "Ever tried.
         Ever failed.
               No matter.
                   Try Again.
                        Fail again.
                             Fail better.**/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define bp  __builtin_popcount
#define pb push_back
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define sz(s) (int)(s.size())
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define Unique(n)        (n).erase(unique(s(n)), (n).end())
#define NumofDigits(n)   ((long long)log10(n)+1)
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e5+5;
const  double EPS = 1e-9;
const int MOD = 1e9+7;
/*
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll fastpow(ll b, ll p)
{if(!p)return 1;ll ret = fastpow(b, p >> 1);ret *= ret;if(p&1)ret*= b;return ret;}
int dx[] = {- 1, 0, 0, 1, 0 };
int dy[] = { 0,- 1, 1, 0, 0 };*/
void File()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    string w;
    cin>>w;
    vector<int> fr(26,0);
    for(int i=0; i<sz(w); i++)
        fr[w[i]-'a']++;
    for(int i=0; i<26; i++)
        if(fr[i]&1)
         return cout<<"No",0;
    cout<<"Yes";
}


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

using namespace std;

int main()
{
  int n;

  cin>>n;

  vector<int>v(n);

  vector<int>a(n);

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

  }
  v=a;
  sort(v.begin(),v.end());
  for(int i=0;i<n;i++)
  {
      if(a[i]!=v[n-1]){
        cout<<v[n-1]<<endl;
      }
     else
     {
         cout<<v[n-2]<<endl;
     }
  }
}


Measured memory_bytes: 3200
#include<stdio.h>
#include<stdlib.h>

int cmp(const void*p,const void*q){
    return (*(int*)p - *(int*)q);
}

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

    long v[N];
    int i;

    for(i=0;i<N;i++){
        scanf("%ld",&v[i]);
    }

    qsort(v,sizeof(v)/sizeof(long),sizeof(long),cmp);

    long base=1;

    for(i=1;i<N;i++){
        v[i]*=base;
        base*=2;
    }

    long value_sum=0;

    for(i=0;i<N;i++){
        value_sum+=v[i];
    }

    double value=((double)value_sum)/base;

    printf("%lf",value);



    return 0;
}

Measured memory_bytes: 128
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
#define        u64             uint64_t
#define        ll              long long
#define        endl            "\n"
#define        PI              acos(-1)
#define        fi              first
#define        si              second
#define        mkp             make_pair
#define        pb              push_back
#define        set0(arr)       memset(arr, 0, sizeof(arr))
#define        setinf(arr)     memset(arr, 126, sizeof(arr))
#define        all(x)          (x).begin(),(x).end()
#define        sz(v)           ((int)(v).size())
#define        IOS             ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
using          pll        =      pair<ll, ll> ;
using          vl         =      vector<ll> ;
using          vpll       =      vector<pll> ;
using          mll        =      map<ll, ll> ;
using          mcl        =      map<char, ll> ;
using          msl        =      map<string,ll> ;
using          sl         =      set<ll> ;
using          sc         =      set<char> ;
using          dl         =      deque<ll> ;
const int N = 1e6+5 ;

ll      mod = 1e9+7 ;
vl      adj[N] ;
vpll    adjc[N] ;
ll      vis[N] ;
ll      arr[N] ;



int main()
{
    IOS;
    ll a, b, c, d, n, m, p, x, y, z, i, j, k, f = 0, tc, cnt = 0, sum = 0, mul = 1, mi = 1e18, ma = -1e18;
    string   str ;
    char     ch ;
    double   db ;
    ll       l, r ;
    //code

    cin>>x>>k>>d;
    x=abs(x);
    p=x/d;
    r=x%d;
    if(p<=k)
    {
           if(p==k)
           cout<<r<<endl;
           else
           {
                  c=k-p;
                  if(c%2!=0)
                  {
                         cout<<abs(r-d)<<endl;
                  }
                  else cout<<r<<endl;
           }
    }
    else{
           cout<<x-(k*d)<<endl;
    }

    //code
    return 0;
}




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

ans = 0
A.sort(reverse=True)
#print(A)
from collections import deque
d = deque(A)
for i in range(1,N):
    if i == 1:
        ans += d.popleft()
        continue
    if i % 2 == 0:
        ans += d[0]
    else:
        ans += d.popleft()
#print(A)
print(ans)



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

ans = [0] * (n+1)


def f(x, y, z):
    return x**2+y**2+z**2+x*y+y*z+x*z


for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            c = f(x, y, z)
            if c <= n:
                ans[c] += 1

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


Measured memory_bytes: 74592
N = int(input())
As = [int(x) for x in input().split()]
S = sum(As)

ans = None
subsum = 0
for i in range(1,N):
    subsum += As[i-1]
    temp = abs(2 * subsum - S)
    if ans is None or temp < ans:
        ans = temp
print(ans)


Measured memory_bytes: 24832
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int dfs(const int cur, const int par, int time, const vector<vi> &g, vi &d, vi &f) {
  if (d[cur] != 0)
    return time;
  d[cur] = time;
  time++;
  for (const auto u : g[cur]) {
    if (u == par)
      continue;
    time = dfs(u, cur, time, g, d, f);
  }
  f[cur] = time;
  time++;
  return time;
}

int main() {
  int n;
  cin >> n;
  vector<vi> g(n);
  REP(i, n) {
    int id, k;
    cin >> id >> k;
    id--;
    REP(j, k) {
      int u;
      cin >> u;
      u--;
      g[id].push_back(u);
    }
  }

  vi d(n, 0), f(n, 0);
  int time = 1;
  REP(i, n) { time = dfs(i, -1, time, g, d, f); }
  REP(i, n) { cout << i + 1 << " " << d[i] << " " << f[i] << endl; }
  return 0;
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

string S;
ll dp[112345][13];

ll dfs(int n, int x) {
	if (dp[n][x] != -1) return dp[n][x];
	if (n == S.size()) return x == 5;
	ll res = 0;
	if (S[n] != '?') res = dfs(n + 1, (x * 10 + S[n]-'0') % 13);
	else REP(i, 10) res += dfs(n + 1, (x * 10 + i) % 13);
	
	return dp[n][x] = res % MOD;
}

int main() {
	cin >> S;
	
	memset(dp, -1, sizeof(dp));
	cout << dfs(0, 0) << endl;
	return 0;
}


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

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int result = 0; // 答えを格納する変数
    for (int n = 1; n <= N; ++n) {
        int sum = 0;
        int n2 = n;
        while (n2) {
            sum += n2 % 10;
            n2 /= 10;
        }
        if (sum >= A && sum <= B) result += n;
    }
    cout << result << endl;
}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    int n;cin>>n;
    ll ans=pow(3,n);
    int ecnt=0;
    rep(i,n){
        int tmp;cin>>tmp;
        if(tmp%2==0)ecnt++;
    }
    ans -= pow(2,ecnt);
    co(ans);
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
 
using namespace std;
 
#define RY 3
#define N 9
 
typedef struct board {
  int hira[N];
  int maru;
  vector<int> path;
 
  bool operator < (const board &t) const {
    for (int i = 0; i < N; i++) {
      if (hira[i] == t.hira[i]) continue;
      else if (hira[i] < t.hira[i]) return true;
      else return false;
    }
    return false;
  }
} cubic;

int xx[4] = { 0, 1, 0, -1 };
int yy[4] = { 1, 0, -1, 0 };
 
bool fingoal(cubic b) {
  for (int i = 0; i < N-1; i ++)
    if (b.hira[i] != i+1) return false;
 
  return true;
}
 
void meltd(cubic b) {
  map<cubic, bool> visited;
  queue<cubic> q;
  q.push(b);
 
  while (!q.empty()) {
    cubic bcur = q.front(); q.pop();
    visited[bcur] = true;
 
    if (fingoal(bcur)) {
      cout << bcur.path.size() << endl;
      return;
    }
 
    for (int i = 0; i < 4; i ++) {
      cubic b = bcur;
      int nx = (bcur.maru / RY) + xx[i];
      int ny = (bcur.maru % RY) + yy[i];
 
      if (nx < 0 || nx > 2 || ny < 0 || ny > 2) continue;
 
      b.maru = nx * RY + ny;
      swap(b.hira[b.maru], b.hira[bcur.maru]);
 
      if (visited[b]) continue;
 
      b.path.push_back(b.maru);
      q.push(b);
    }
  }
}
 
int main() {
  cubic b;
 
  for (int i = 0; i < N; i++) {
    cin >> b.hira[i];
    if (b.hira[i] == 0) b.maru = i;
  }
 
  meltd(b);
}

Measured memory_bytes: 52196
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		while (n != 0) {
			int i = 0;
			int[] a = new int[n];
			for (i = 0; i <= n - 1; i++) {
				int j = s.nextInt();
				a[i] = j;

			}
			int max = 0;
			int min = 1000;
			int sum = 0;
			for (i = n - 1; i >= 0; i--) {
				if (a[i] > max) {
					max = a[i];
				}
				if (a[i] < min) {
					min = a[i];
				}
				sum += a[i];
			}
			sum -= max;
			sum -= min;
			int point = sum / (n - 2);
			System.out.println(point);
			n = s.nextInt();
		}
	}
}

Measured memory_bytes: 28864
n = int(input())
a = list(map(int,input().split()))

mod = 10**9 + 7
ans = 0

b = [a[0]]
for i in range(n-1):
    b.append((b[-1] + a[i+1]) % mod)

for i in range(n-1):
    ans += a[i] * (b[-1] - b[i])
    ans %= mod

print(ans)


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

map<long, int> sq;

int f(int n)
{
    int res=0;
    for(long x=1; x*x<n; ++x) {
        for(long y=1; y*y<n; ++y) {
            long d=(x+y)*(x+y)-4*(x*x+y*y+x*y-n);
            if (d<0) continue;
            if (!sq.count(d)) continue;
            d=sq[d];
            long a=d-x-y;
            if (a%2==0 and a/2>0) ++res;
        }
    }
    return res;
}

int main()
{
    int n; cin>>n;
    for(long i=1; i<10000; ++i) sq[i*i]=i;

    for(int i=1; i<=n; ++i)
        cout<<f(i)<<'\n';
}


Measured memory_bytes: 4264
from collections import defaultdict, deque
import sys

sys.setrecursionlimit(100000)

MIN = -10 ** 9
MAX = 10 ** 9 + 7


def main():
    N = int(input())
    # A, B = [int(a) for a in input().split()]

    print(3*N*N)


if __name__ == '__main__':
    main()


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

//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

using namespace std;

#define F first
#define S second
#define pb push_back
#define m_t make_tuple
#define m_p make_pair
#define mp make_pair

typedef long long ll;
typedef long double ld;


#define FILE "teleports"
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);
#else
//  freopen(FILE".in", "r", stdin);
//  freopen(FILE".out", "w", stdout);
#endif // LOCAL
  int n, a;
  cin >> n >> a;
  if (n % 500 <= a){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
#ifdef LOCAL
  cerr << fixed << setprecision(10) << "TIME = " << 1.0 * clock() / CLOCKS_PER_SEC << '\n';
#endif // LOCAL
  return 0;
}


Measured memory_bytes: 256
import math
a,b,theta = map(int,input().split())
theta = math.pi*theta/180
print("{0:.8f}".format(math.sin(theta)*b*a/2))
print("{0:.8f}".format(a+b+math.sqrt(a**2+b**2-2*a*b*math.cos(theta))))
print("{0:.8f}".format(math.sin(theta)*b))


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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if ((a + b) > (c + d)) {
        cout << "Left" << endl;
    } else if ((a + b) == (c + d)) {
        cout << "Balanced" << endl;
    } else {
        cout << "Right" << endl;
    }
    return 0;
}

Measured memory_bytes: 3548
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *
from fractions import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

def main():
    N = int(input())
    states = [s + t + u for s in 'ACGT' for t in 'ACGT' for u in 'ACGT']
    states.remove('AGC')
    states.remove('ACG')
    states.remove('GAC')
    transitions = defaultdict(list)
    ngs = []
    for s in 'ACGT':
        for t in 'ACGT':
            for u in 'ACGT':
                for v in 'ACGT':
                    if 'AGC' in s + t + u + v or 'AGC' in t + s + u + v or 'AGC' in s + u + t + v or 'AGC' in s + t + v + u:
                        ngs.append(s + t + u + v)
    for s in states:
        for t in states:
            if s[1:] == t[:2] and s[0] + t not in ngs:
                transitions[s].append(t)
    count = {s: 1 for s in states}
    for _ in range(N - 3):
        updated = {s: 0 for s in states}
        for fr, tos in transitions.items():
            for to in tos:
                updated[to] += count[fr]
                updated[to] %= 10 ** 9 + 7
        count = updated
    print(sum(count.values()) % (10 ** 9 + 7))

main()


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

int main(){
  int N,A,B,total=0,souwa=0;
  cin >> N >> A >> B;

  
  for(int i = 1; i <= N; i++){
    souwa = i / 10000 + i % 10000 / 1000 + i % 1000 / 100 + i % 100 / 10 + i % 10;
    if(A <= souwa && souwa <= B) total += i;
  }
  cout << total << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define fo(i, n) for (ll i = 0; i < n; i++)
#define fo1(i, n) for (ll i = 1; i <= n; i++)
#define pi (double)3.14159265359
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define vect vector<ll>
#define pb push_back
#define mod (ll) pow(10, 9) + 7
#define prq priority_queue <int, vector<int>, greater<in1t>>
#define scan(x) scanf("%lld",&x);
#define print(x) printf("%lld\n",x);
using namespace std;

void solve(){
	ll n;
	ll ac=0,wa=0,tle=0,re=0;
	cin>>n;
	fo(i,n){
		string str;
		cin>>str;
		if(str == "AC") ac++;
		else if(str == "WA") wa++;
		else if(str == "TLE") tle++;
		else re++;
	}
	cout<<"AC x "<<ac<<endl;
	cout<<"WA x "<<wa<<endl;
	cout<<"TLE x "<<tle<<endl;
	cout<<"RE x "<<re<<endl;
} 
int main(){
	int t=1;
	//scanf("%d",&t);
	while (t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 3628
Vertex, Line = map(int, input().split())
LineList = [[int(_) for _ in input().split()] for i in range(Line)]
graph = [[] for _ in range(Vertex)]

for a, b in LineList:
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

total_one_stroke_path = 0
def search_path(now_node = 0, check_passed = 0):
    check_passed += 1 << now_node
    global total_one_stroke_path

    for next_node in graph[now_node]:
        if check_passed & (1 << next_node) == 0:
            search_path(next_node, check_passed)

    if check_passed == (1 << Vertex) - 1:
        total_one_stroke_path += 1

    return

search_path()
print(total_one_stroke_path)
exit()

Measured memory_bytes: 41564
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

int mp[1000010], is_ok[1000010];
int main() {
    int N; scanf("%d", &N);

    for(int i=0; i<N; i++) {
        int v; scanf("%d", &v);
        mp[v]++;
        is_ok[v] = true;
    }

    int ans = 0;
    for(int v=1; v<=1000000; v++) {
        int c = mp[v];
        if(c == 0) continue;
        if(c >= 2) is_ok[v] = false;

        for(int k=2*v; k<=1000000; k+=v) {
            if(mp[k]) {
                is_ok[k] = false;
            }
        }
    }

    for(int i=0; i<=1000000; i++) {
        ans += is_ok[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11492
fun main(args: Array<String>) {
    val array = Array(3) { readLine()!!.split(" ").map(String::toInt) }

    for (a1 in 0..100) {
        val b1 = array[0][0] - a1
        val b2 = array[0][1] - a1
        val b3 = array[0][2] - a1
        for (a2 in 0..100) {
            if (!(b1 == array[1][0] - a2 && b2 == array[1][1] - a2 && b3 == array[1][2] - a2)) {
                continue
            }
            for (a3 in 0..100) {
                if (b1 == array[2][0] - a3 && b2 == array[2][1] - a3 && b3 == array[2][2] - a3) {
                    println("Yes")
                    return
                }
            }
        }
    }
    println("No")
}



Measured memory_bytes: 37732
n, k = map(int,input().split())
s = input()
nums = []

now = 1
cnt = 0
for i in range(len(s)):
    if s[i] == str(now): cnt += 1
    else:
        nums.append(cnt)
        now = 1 - now
        cnt = 1
if not cnt == 0: nums.append(cnt)
if len(nums) % 2 == 0: nums.append(0)

summ = [0]
for i in range(len(nums)):
    summ.append(summ[i]+nums[i])

ans = 0
for i in range(len(nums))[::2]:
    left = i
    right = min(i+k*2+1, len(nums))
    tmp = summ[right] - summ[left]

    ans = max(tmp, ans)


print(ans)

Measured memory_bytes: 7924
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807;
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
#define bool    _Bool
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }



int main() {
	int N, P;
	int evencnt = 0, oddcnt = 0;
	scanf("%d%d", &N, &P);
	int *A = (int *)malloc(sizeof(int)*N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
		if (A[i] % 2 == 0) {
			evencnt++;
		}
		if (A[i] % 2 == 1) {
			oddcnt++;
		}
	}

	ll cnt = 0;
	ll ans = 0;
	//Aiがすべて偶数の場合は，どのように袋を選んでも食べるビスケットの枚数は偶数である．よって，P= 0の場合は答えは2N，P= 1の場合は答えは0である．
	if (evencnt == N && P == 0) {
		cnt = (ll)pow(2, (double)N);
	}
	if (evencnt == N && P == 1) {
		cnt = 0;
	}
	//Aiの中に奇数が含まれているものとすると，Akが奇数であるようなkをとることができる．k番目の袋以外のN1個の袋の選び方は2N1通りである．
	//れらの2N1通りの選び方のそれぞれについて，k番目の袋を選ぶか選ばないかでちょうど1通り，合計を偶数にする方法および奇数にする方法が存在する．よって，この場合の答えはPによらず2N1である．
	else if (oddcnt >= 1) {
		cnt = (ll)pow(2, (double)N - 1);
	}

	ans = cnt;
	printf("%lld\n", ans);

#ifdef DEBUGF
	getch();
#endif
	return 0;
}


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

int main(){
  string s;
  bool YYMM = false;
  bool MMYY = false;
  cin >> s;
  int front;
  int back;
  front = (s[0]-'0') * 10 + (s[1] -'0');
  back = (s[2]-'0') * 10 + (s[3] -'0');

  if(front>0 && front <=12) MMYY = true;
  if(back>0 && back <=12) YYMM = true;

  if(YYMM==true && MMYY == true){
        cout << "AMBIGUOUS";
  }else if(YYMM==true){
        cout << "YYMM";
  }else if(MMYY==true){
        cout << "MMYY";
  }else{
        cout << "NA";
  }

  return 0;
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 123;

char a[N][N];
bool sc[N], sr[N];

void solve() {
  int h, w; scanf("%d%d", &h, &w);
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      scanf(" %c", a[i]+j);
      if (a[i][j] == '#') {
	sr[i] = true;
	sc[j] = true;
      }
    }
  }
  for (int i = 0; i < h; ++i) {
    if (!sr[i]) continue;
    for (int j = 0; j < w; ++j) {
      if (!sc[j]) continue;
      putchar(a[i][j]);
    }
    puts("");
  }
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A=0,B=0,C=0,X=0,Y=0,i=0,j=0;
  cin>>A>>B>>C>>X>>Y;
  int low_cost=A*X+B*Y;
  for (int k=0;k<=X || k<=Y;k++){
    i = X-k;
    j = Y-k;
    if (i<=0){
      i=0;
    }
    if (j<=0){
      j=0;
    }
    if (low_cost>i*A+j*B+k*C*2){
      low_cost=i*A+j*B+k*C*2;
    }
  }
  cout<<low_cost;
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    double prob[n+1];
    double dp[n+1][n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>prob[i];
    }
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            dp[i][j]=0;
        }
        //cout<<endl;
    }
    dp[0][1]=1-prob[1];
    dp[1][1]=prob[1];
    for(int i=0;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(i==1 && j==1)
            continue;
            if(i > j)
            continue;
            if(i==0 && j==1)
            continue;
            if(i==0 && j > 1)
            {
                dp[i][j]=dp[i][j-1]*(1-prob[j]);
            }
            else if(i==j)
            {
                dp[i][j]=dp[i-1][j-1]*prob[j];
            }
            else
            {
                dp[i][j]=dp[i][j-1]*(1-prob[j])+dp[i-1][j-1]*prob[j];
            }
        }
    }

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

    double ans=0;
    for(int i=n/2+1;i<=n;i++)
    {
        ans+=dp[i][n];
    }
    printf("%.10f",ans);
}


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int N; cin >> N;
    int A[N+5];
    string inp; cin >> inp;
    for(int i = 0;i<N;i++){
        if(inp[i]=='1'){
            A[i]=1;
        }
        else if(inp[i]=='2'){
            A[i] = 2;
        }
        else{
            A[i] = 3;
        }
    }
    int B[N+5];
    bool one = false;
    for(int i=1;i<N;i++){
        B[i-1]=abs(A[i]-A[i-1]);
        if (B[i-1]==1){
            one = true;
        }
    }
    int mult = 1;
    if(one == false){
        for(int i=0;i<N-1;i++){
            B[i] = B[i]/2;
        }
        mult = 2;
    }
    int ans = 0;
    for(int i=0;i<N-1;i++){
        if(i==0){
            ans += B[i];
        }
        else{
            int even = false;
            int temp = 2*(N-2);
            for(int j = i;j>0;j=j/2){
                temp /= 2;
                if (j%2>temp%2){
                    even = true;
                    break;
                }
            }
            if(even == false){
                ans += B[i];
            }
        }
    }
    cout << (ans%2)*mult;
    return 0;
}


Measured memory_bytes: 9116
#include <iostream>
#include <cstdio>
using namespace std;
typedef unsigned long long ll;

ll n, x, s, mn=1e18, a[200005];
int main() {
	int i, j, k;
	scanf("%lld%lld", &n, &x);
	for(i=1; i<=n; i++) scanf("%lld", &a[i]), a[i] += a[i-1];
	for(i=1; i<=n; i++) {
		s = (n+i) * x;
		for(j=n, k=5; j>0; j-=i) {
			s += k * (a[j] - a[max(j-i, 0)]);
			if(j<n) k += 2;
		}
		mn = min(mn, s);
	}
	printf("%lld", mn);
	return 0;
}

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

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


int main() {

string s;
cin >> s;
bool c[1000000];
char alpha[25];

for(char moji = 'a';moji<='z';moji++)alpha[moji-'a']=moji;

for(char moji = 'a';moji<='z';moji++){
    for(int i=0;i<s.length();i++){
        if(s.at(i)==moji)c[s.at(i)-'a']=true;
    }
}
   

int tem=0;  
for(int j=0;j<26;j++){
    if(c[j]==0){
        cout << alpha[j] << endl;
        return 0;
        }
}
cout << "None" << endl;



return 0;

}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

#define INF 100000001

using namespace std;

int DP[101][101];
int *p;

int rec(int r, int c){
    int Min = INF;
    int num = c-r;

    for(int i=0; i<num; i++){
        Min = min(Min, DP[r][r+i] + DP[r+i+1][c] + p[r-1]*p[r+i]*p[c]);
    }

    return Min;
}

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

    for(int i=1; i<=N; i++) DP[i][i] = 0;

    p = (int *)malloc(sizeof(int)* (N+1));

    cin >> p[0];
    cin >> p[1];

    int bb;
    for(int i=2; i<=N; i++){
        cin >> bb;
        cin >> p[i];
    }

    for(int i=1; i<N; i++) DP[i][i+1] = p[i-1]*p[i]*p[i+1];

    for(int j=0; j<=N-3; j++){
        for(int i=3+j; i<=N; i++){
            DP[i-2-j][i] = rec(i-2-j, i);
        }
    }

    cout << DP[1][N] << endl;

    return 0;
} 



Measured memory_bytes: 3148
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll

int32_t main()
{
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	#endif
	
	int n,x,y;
	cin>>n>>x>>y;
	int dist[n+1][n+1];
	dist[x][y]=1;
	for(int i=1;i<=n;i++)
	{
		//if(i==x or i==y)continue;
		dist[i][x]=dist[x][i]=abs(x-i);
		dist[i][y]=dist[y][i]=abs(y-i);
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			dist[i][j]=dist[j][i]=min(abs(i-j),dist[i][x]+dist[y][j]+1);
		}
	}
	vector<int> f(n);
	for(int i=1;i<=n;i++)
	for(int j=i+1;j<=n;j++)
	{f[dist[i][j]]++;}
	for(int i=1;i<n;i++)cout<<f[i]<<'\n';
	
}

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            string tmp;
            string[] inp;
            List<int> res = new List<int>();

            while (true)
            {
                tmp = Console.ReadLine();
                if (tmp == null)
                {
                    break;
                }
                inp = tmp.Split(' ');
                a = int.Parse(inp[0]);
                b = int.Parse(inp[1]);

                int c = a + b;

                int keta = 1;
                while (c > 9)
                {
                    c = c / 10;
                    keta++;
                }
                res.Add(keta);
            }
            for (int i = 0; i < res.Count; i++)
            {
                Console.WriteLine(res[i]);
            }
        }
    }
}

Measured memory_bytes: 9112
/*
  AtCoder Beginner Contest 102
  A - Multiple of 2 and N
*/

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

int N;

int main() {   
  scanf("%d", &N);
  if (N % 2 == 0) printf("%d\n", N);
  else printf("%d\n", N * 2);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n;
	while (cin >> n){
		if (n == 0)return 0;
		long long y[4000] = { 0 };
		vector<int>l;
		for (int i = 0; i < n; i++){
			int a;
			long long b, c;
			cin >> a >> b >> c;
			y[a] += b * c;
			if (find(l.begin(),l.end(), a) == l.end())l.push_back(a);
		}
		vector<int>ll;
		for (long long i: l) {
			if (y[i] >= 1000000)ll.push_back(i);
		}
		sort (l.begin(), l.end());
		if (ll.size() == 0)cout << "NA" << endl;
		else for (int i:ll){
			cout << i << endl;
		}
	}
}

Measured memory_bytes: 3108
program sample
    implicit none
    
    integer(8) :: a,b,c,i,j,m,n,k,a1,b1,c1
    integer(8), allocatable  ::x(:) 

    read(*,*) n
    k=6
    do while(n<2**k)
        k=k-1
    end do
    write(*,*)2**k
    
    stop
end program sample
  



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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
 
#define VV(T) vector<vector< T > >
 
template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  reep(i,0,n)
#define clr(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
#define PB push_back

const int INF = (1e9);
const ll MOD = 1e9+7;
const double EPS = 1e-5;
const double PI=atan2(0,-1);

int solve(){

}

int main(void){
    int a,b,c;
    cin >> a >> b >> c;
    if (b-a == c-b)
        cout << "YES";
    else
        cout << "NO";
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_poizcy.hpp>
typedef long long  ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (int i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef long double lldb;
typedef pair<ll, ll>  ii;
typedef pair<lldb, lldb>  iidb;
typedef pair<ll, ii>  iii;
typedef vector<ll>     vi;
typedef vector<ll>      vll;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9+7;
const lldb PI = acos(-1);
#define initseg ll new_nodo=(nodo*2),mid=(iz+der)/2;
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define tam 2020000
#define offset 200
#define ptr nodo*
const ll MOD=1e9+7;
#define lazy first
#define sum second
ll N=50;
vector<ll> v(50,0);
void doit()
{
	ii minn={1e18,0};
	forr(i,0,N)
	{
		minn=min(minn,{v[i],i});
	}
	forr(i,0,N)
	{
		if (minn.se==i)
			v[i]+=N;
		else
			v[i]--;
	}
}
int main()
{
	forr(i,0,N)
		v[i]=i;
	ll K;
	cin>>K;
	forr(i,0,N)
	v[i]+=(K/N);
	K%=N;
	while(K!=0)
	{
		doit();
		K--;
	}
	cout<<N<<endl;
	forr(i,0,N)
		cout<<v[i]<<' ';
}

Measured memory_bytes: 3632
l=int(input())
flag=1
count=1
list=[l]
while flag:
 if  l%2==0:
  l=l/2
 else: 
  l=3*l+1
 if l in list:
  flag=0
  count=count+1
 else:
  list.append(l)
  count=count+1
print(count)

Measured memory_bytes: 3060