akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)

void printVec(std::vector<int> &vec)
{
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout << *it << " ";
	}
	cout << '\n';
}
void printVec1(std::vector<string> &vec)
{
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout << *it << " ";
	}
	cout << '\n';
}
void printVec2(std::vector<Int> &vec)
{
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout << *it << " ";
	}
	cout << '\n';
}

Int gcd(Int a, Int b)
{
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b)
{
	return a / gcd(a, b) * b;
	//a*bは64bit integer overflow
}

bool integer(double num)
{
	return floor(num) == num;
}

Int fact(int num)
{
	if (num == 0)
		return 1;
	else
		return num * fact(num - 1);
}

int main(){
	IOS;
	int n,x;cin>>n;
	// int a,b,c;cin>>a>>b>>c;
	string str;cin>>str;

	// vector<int> l(n);
	// vector<string> s(n);
	if(n>=3200)cout<<str;
	else cout<<"red";
	// for(int i=0;i<n;i++){
		
	// }
	





	cout << endl;
	return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


Measured memory_bytes: 256
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import qualified Data.Array.IO as A
import Debug.Trace
import Data.List
import Control.Monad


r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

main :: IO ()
main = do
    a <- readLn
    s <- getLine
    putStrLn $ if a >= 3200
        then s
        else "red"


Measured memory_bytes: 508
#include <iostream>
#include <cstdio>
#define N 20005
using namespace std;

int n, k, mx, a[N][N];
char t;
int main()
{
	int i, j, t1, t2, t3;
	cin >> n >> k;
	for (i = 0; i < n; i++) {
		scanf("%d %d %s", &t1, &t2, &t);
		t3 = (t == 'B');
		if ((t1 / k + t2 / k + t3) % 2) a[t1 % k + k][t2 % k]++, a[t1 % k][t2 % k + k]++;
		else a[t1 % k][t2 % k]++, a[t1 % k + k][t2 % k + k]++;
	}
	for (i = 1; i < k * 2; i++) a[0][i] += a[0][i - 1], a[i][0] += a[i - 1][0];
	for (i = 1; i < k * 2; i++) for (j = 1; j < k * 2; j++) a[i][j] += a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1];
	for (i = k; i < k * 2; i++) {
		for (j = k; j < k * 2; j++) {
			t1 = a[i][j] - a[i][j - k] - a[i - k][j] + a[i - k][j - k];
			mx = max(mx, max(t1, n - t1));
		}
	}
    cout << mx << endl;
    return 0;
}

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

int main(){
  int A, B;
  cin >> A >> B;
  //どちらかが偶数なら偶数
  if ( A % 2 == 0 or B % 2 == 0) {
    cout << "Even" << endl;
  } else {
    cout << "Odd" << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);

		String w = sc.next();
		
		char ch[] = w.toCharArray();
		
		boolean result = true;
		char al = 'a';
		for(int i=0; i<26; i++){
			int cnt = 0;
			for(int j=0; j<ch.length; j++){
				if(al == ch[j]){
					cnt++;
				}
			}
			if(cnt%2 != 0){
				result = false;
				break;
			}
			al++;
		}
		
		
		
		
		
		
		if (result){
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}


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

using namespace std;

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

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

struct UnionFind {
  vector<int> par;
  vector<int> sz;
  UnionFind(int n) { init(n); }

  void init(int n) {
    par.resize(n);
    sz.resize(n);
    for (int i = 0; i < n; ++i) {
      par[i] = i;
      sz[i] = 1;
    }
  }

  int find(int x) {
    if (par[x] == x) {
      return x;
    } else {
      return par[x] = find(par[x]);
    }
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (sz[x] < sz[y]) {
      par[x] = y;
      sz[y] += sz[x];
    } else {
      par[y] = x;
      sz[x] += sz[y];
    }
  }

  bool same(int x, int y) { return find(x) == find(y); }

  int size(int x) { return sz[find(x)]; }
};

int main() {
  int n, m;
  cin >> n >> m;
  int a[m], b[m];
  for (int i = 0; i < m; ++i) {
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
  }
  UnionFind uf(n);
  vector<ll> ans;
  ll res = 1ll * n * (n - 1) / 2;
  for (int i = m - 1; i >= 0; --i) {
    ans.push_back(res);
    if (!uf.same(a[i], b[i])) {
      res -= 1ll * uf.size(a[i]) * uf.size(b[i]);
      uf.unite(a[i], b[i]);
    }
  }
  reverse(ans.begin(), ans.end());
  for (int i = 0; i < m; ++i) {
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int a[N];
bool prime(int x){
	if(x<2)return false;
	for(int i=2;i*i<=x;i++)
		if(x%i==0)return false;
	return true;
}
void div(int x){
	int cnt=0;
	for(int i=1;cnt<=x;i++)
		if(prime(i))a[++cnt]=i;
}
int find(int x){
    int l=1,r=x;
    while(l<=r){
        int mid=(l+r)/2;
        if(a[mid]>=x)r=mid-1;
        else l=mid+1;
    }
    return l;
}
int main(){
	std::ios::sync_with_stdio(0);
	int n;
	cin>>n;
	div(n);
	cout<<a[find(n)]<<'\n';
    return 0;
}

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

int main() {
    
    int n, k;
    cin >> n >> k;
    int sm = 0;
    for (int i=0; i<n; i++) {
		int x;
		cin >> x;
		sm += min(x, k-x);
	}
	cout << sm * 2 << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int64_t i = 0; i < (n); i++)
ll n,m,l=1,a[100010],i;
ll r(){ll x;cin>>x;return x;}
ll f(){
    REP(i,n){
        l=l/__gcd(a[i],l)*a[i];
        if(l>m)return 0;
    }
    REP(i,n)if(!(l/a[i]%2))return 0;
    return m/l+1>>1;
}
int main(){
    cin>>n>>m;
    REP(i,n)a[i]=r()/2;
    cout<<f()<<endl;
 	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  while(cin>>a>>b>>c,a){
    int p[a];
    for(int i=0;i<a;++i) cin>>p[i];
    sort(p,p+a);
    int x=0, y;
    for(int i=a-b;i>=a-c;--i)
      if(p[i]-p[i-1]>=x) x=p[i]-p[i-1], y=i;
    cout<<a-y<<endl;
  }
  return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)	
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define REVSORT(c) SORT(c);REVERSE(c)
#define ALL(x) (x).begin(),(x).end()
#define LOOP while(true)
#define INF 1e9
const long long MOD = 1000000007;
typedef long long ll;

int mid(int a, int b, int c){
	return a + b + c - max(max(a, b), c) - min(min(a, b), c);
}

int max3(int a, int b, int c){
	return max(max(a, b), c);
}

int min3(int a, int b, int c){
	return min(min(a, b), c);
}

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	cout << ((max3(a, b, c) == mid(a, b, c) + min3(a, b, c)) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int main(){
  int M, K;
  cin >> M >> K;
  int max_num = 1;
  rep(i, M){
    max_num *= 2;
  }
  max_num--;

  if(K == 0){
    rep(i, max_num + 1){
      if(i != max_num){
        printf("%d %d ", i, i);
      }else{
        printf("%d %d\n", i, i);
      }
    }
  }else if(max_num >= K){
    if(M == 1 && K == 1){
      puts("-1");
      return 0;
    }
    printf("%d", K);
    rep(i, max_num + 1){
      if(i != K) printf(" %d", i);
    }
    printf(" %d", K);
    rrep(i, max_num + 1){
      if(i != K) printf(" %d", i);
    }
  }else{
    puts("-1");
  }
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;



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

    vector<P> p;
    rep(i, m){
        int a, b;
        cin >> a >> b;
        p.emplace_back(a, b);
    }

    int i;
    if(n == 1)i = 0;
    else i = pow(10, n - 1);
    for(; i < pow(10, n); i++){
        string now = to_string(i);
        bool f = true;
        rep(j, m){
            int fst = p[j].first, snd = p[j].second;
            if(now[fst - 1] - '0' != snd)f = false;
        }
        if(f){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1;
}



Measured memory_bytes: 384
while True: #無限ループ
    i = int(input()) #人数を標準入力する
    if i == 0:break #0人ならループを終わる
    else: #0人以外なら処理をする
        num_list = [] #空リスト
        for _ in range(i): #人数回繰り返す
            num_list.append(int(input())) #待ち時間をリストに加える
        num_list.sort() #リスト中身を小さい順にする
        kei = 0 #変数を初期化する
        kei_list = [] #空リスト作成
        for j in range(0,i - 1): #繰り返し
            kei += num_list[j] #待ち時間を計算する
            kei_list.append(kei) #リストに加える
        print(sum(kei_list)) #待ち時間の合計を計算する


Measured memory_bytes: 6108
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0 ,-1};
signed main(){
    int A,B;
    cin >> A >> B;
    if(A <= 8 && B <= 8) {
        cout << "Yay!" << endl;
    }
    else {
        cout << ":(" << endl;
    }
}


Measured memory_bytes: 3588
def colorful_subsequence(N: int, S: str)->int:
    MOD = (10 ** 9) + 7
    cum = {}
    for c in S:
        cum.setdefault(c, 0)
        cum[c] += 1

    values = list(cum.values())
    count = 1
    for v in values:
        count *= (1 + v)
        count %= MOD

    return (count-1) % MOD


if __name__ == "__main__":
    N = int(input())
    S = input()
    ans = colorful_subsequence(N, S)
    print(ans)


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

using namespace std;

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if (AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


const int NM = 201001;//ここを問題の制約を見ながらいじる．配列の確保に使う．
//ll P[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
//ll dp[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．
ll H[NM];//あまり褒められたことではないが関数の外側に配列を確保すると怒られにくい．


ll MOD = 1000000007;
int digit_length(int num)
{
    int count = 0;
    while (num) {
        num = num / 10;
        ++count;
    }
    return count;
}


ll gcd(ll a, ll b) {
    ll v0 = a, v1 = b, v2 = a % b;
    while (v2 != 0) {
        v0 = v1;
        v1 = v2;
        v2 = v0 % v1;
    };
    return v1;
}


// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

//ll lcm(ll a, ll b) {
//    return a / (gcd(a, b) % MOD) * (b % MOD);
//}

ll lcm(ll a, ll b) {
    return( (a % MOD) *modinv(gcd(a, b), MOD) * (b % MOD)) % MOD;
}
       // Main program
void solve() {
    ll  H;
    cin >> H;
    ll sum = 0;
    //ll MOD = 1000000007;

    ll res = log2(H);
    H = pow(2,res);

    while (H != 1) {
        sum += H;
        H = H >> 1;
    }

    cout << sum+1;

    return;
    //ll  N;
    //cin >> N;
    //ll sum = 0;

    //ll Top = 0;
    //ll Bottom = 0;
    //ll Len = 0;

    //for (ll i = 1; i < N; i++) {
    //    Len = digit_length(i);
    //    Top = i / Len;
    //    Bottom = i %10;

    //    if (i < 10) {
    //        sum++;
    //        for (ll j = 1; j < 6; j++) {
    //            if (i >= Bottom * pow(10,j) + Top) {
    //                sum++;
    //            }
    //        }
    //    }
    //    else if (i < 100) {
    //        //sum++;
    //        for (ll j = 1; j < 6; j++) {
    //            if (i >= Bottom * pow(10, j) + Top) {
    //                sum++;
    //            }
    //        }
    //    }
    //    else if (i < 1000) {
    //        //sum+=10;
    //        for (ll j = 1; j < 6; j++) {
    //            if (i >= Bottom * pow(10, j) + Top) {
    //                sum++;
    //            }
    //        }
    //    }
    //    else if (i < 10000) {
    //        sum += 100;
    //    }
    //    else if (i < 100000) {
    //        sum += 1000;
    //    }
    //    else if (i < 1000000) {
    //        sum += 10000;
    //    }
    //}
    //cout << sum;
    //   
    //return;

}



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







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

using Graph = vector<vector<int>>;

void dfs(Graph &G, int v, int p, vector<ll> &val) //pはvの親
{
    if (p != -1)
        val[v] += val[p]; //pが-1でないなら→vが根でないなら(親を持つなら)
    for (auto e : G[v])
    {
        if (e == p)
            continue;
        dfs(G, e, v, val);
    }
}

int main()
{
    int n, q;
    cin >> n >> q;

    Graph G(n);
    rep(i, n - 1)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--; //0インデックスに変更
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<ll> val(n);
    rep(i, q)
    {
        int p, x;
        cin >> p >> x;
        p--;
        val[p] += x;
    }
    //以上入力まで

    dfs(G, 0, -1, val);
    for (auto v : val)
        cout << v << " ";
    cout << endl;
}

Measured memory_bytes: 27392
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  ll x, k, d;
  cin >> x >> k >> d;

  x = abs(x);
  if (x / d >= k) {
    x -= d * k;
  } else {
    k -= x / d;
    x = x % d;
    if (k % 2 == 1) {
      x = abs(x - d); 
    }
  }
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int n,m;
  cin>>n>>m;
  
  UnionFind uni(n);
  int x,y,z;
  REP(i,m){
    cin>>x>>y>>z;
    x--;y--;
    uni.connect(x,y);
  }
  
  vector<int> used(n,false);
  int ans=0;
  int u;
  REP(i,n){
    u=uni.root(i);
    if(!used[u]){
      ans++;
      used[u]=true;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1024
PRICE_CAKE = 4
PRICE_DOUGHNUT = 7

n = int(input())
max_cakes = n // PRICE_CAKE

valid = False
for i in range(max_cakes + 1):
  n_left = n - i * PRICE_CAKE
  if n_left % PRICE_DOUGHNUT == 0:
    valid = True
    break
    
print("Yes" if valid else "No")

Measured memory_bytes: 3060
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

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

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

template<class T>
bool umax(T &a, const T &b){
    if (a<b) {
        a=b; return 1;
    }
    return 0;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b<a) {
        a=b; return 1;
    }
    return 0;
}

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


int dx[5]={1,0,-1,0};
int dy[5]={0,1,0,-1};
// v.front() = -BOUND;
// v.back() = BOUND;

// 始点、終点、辺の長さのタプル
typedef tuple<ll,ll,ll> T;
int main(){
    vector<T>S;
    ll N=0,M=0;
    ll L;
    cin >> L;

    // 必要最小の頂点数を求める
    ll temp=L;
    while(temp>0){
        N++;
        temp>>=1;
    }

    // まず頂点iとi+1(1<=i<=N)に0と2^(i-1)の長さの辺を張る
    for(ll i=1; i<N; i++){
        ll start,goal;
        start=i, goal=i+1;
        ll p_length=1ll<<(i-1);
        S.emplace_back(T(start,goal,0LL));
        S.emplace_back(T(start,goal,p_length));
        // パスの数を増やす
        M+=2;
    }
    
    for(ll t=N-1; t>0; t--){
        if(L>=(1LL<<(N-1)) + (1LL<<(t-1))){
            M++;
            S.emplace_back(T(t,N,L-(1LL<<(t-1))));
            L-=(1LL<<(t-1));
        }
    }

    cout << N << " " << M << endl;

    for(auto x:S){
        cout << get<0>(x) << " " << get<1>(x) << " " << get<2>(x)<< endl;
    }
    return 0;
}



Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	double[][] memo;
	int[] board;
	int n;
	
	double calc(int p, int turn) {
		if (turn < 0) return 0;
		if (memo[p][turn] < 0) {
			if (p == n) memo[p][turn] = 1;
			else if (turn == 0) memo[p][turn] = 0;
			else {
				memo[p][turn] = 0;
				for (int i = 1; i <= 6; i++) {
					int t;
					if (p+i <= n) t = p+i;
					else t = n-(p+i-n);
					if (board[t] == 1)
						memo[p][turn] += calc(t, turn-2)/6.0;
					else if (board[t] == -1)
						memo[p][turn] += calc(0, turn-1)/6.0;
					else
						memo[p][turn] += calc(t, turn-1)/6.0;
				}
			}
		}
		return memo[p][turn];
	}
	
	void run() {
		while (true) {
			int t, l, b;
			n = sc.nextInt(); t = sc.nextInt(); l = sc.nextInt(); b = sc.nextInt();
			if (n == 0) break;
			board = new int[n+1];
			for (int i = 0; i < l; i++)
				board[sc.nextInt()] = 1;
			for (int i = 0; i < b; i++)
				board[sc.nextInt()] = -1;
			
			memo = new double[n+1][t+1];
			for (int i = 0; i <= n; i++)
				Arrays.fill(memo[i], -1);
			
			out.printf("%.7f\n", calc(0, t));
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 24288
#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) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline ll getint() {
	ll A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	ll N = getint(), K = getint();
	ll S[100001] = {};
	rep(i, N) {
		int a = getint(), b = getint();
		S[a] += b;
	}
	int k;
	for (k = 1; k <= 100000; k++) {
		K -= S[k];
		if (K <= 0) break;
	}
	co(k);

	Would you please return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){

  int n;
  cin>>n;
  
  int a[n+1] = {0};
  for(ll i = 0; i < n - 1 ; i++){
  	ll tmp;
    cin>>tmp;
    a[tmp]++;
  }
  
  for(ll i = 1; i < n + 1 ; i++){
  	cout<<a[i]<<endl;
  }

}

Measured memory_bytes: 4356
if __name__ == "__main__":
    A, B = list(map(int, input().split()))
    num_of_tap = 0
    num_of_hole = 1
    while(num_of_hole < B):
        num_of_tap += 1
        num_of_hole = (A-1)*(num_of_tap-1) + A

    print(num_of_tap)

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

int main()
{
    int N, tmp;
    int count = 0;
    cin >> N;

    vector<vector<int>> list(2, vector<int>(N));

    for (int i = 0; i < 2; i++)
    {
        for (int j = 0; j < N; j++)      
        {
            cin >> list.at(i).at(j);
        }
    }

    for (int i = 0; i < N; i++)
    {
        tmp = 0;
        for (int j = 0; j <= i; j++)
            tmp += list.at(0).at(j);
        for (int j = i; j < N; j++)
            tmp += list.at(1).at(j);

        if (count < tmp)
            count = tmp;
    }

    cout << count;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int N =sc.nextInt();
        
        if(N%10 == 9){
            System.out.println("Yes");
        }else if(N/10 == 9){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21972
from collections import deque
n = int(raw_input())
R = deque()
for i in xrange(n):
    L = raw_input().split()
    order = L[0]
    value = 0
    if len(L) > 1:
        value = int(L[1])
    if order == 'insert':
        R.appendleft(value)
    if order == 'delete' and value in R:
        R.remove(value)
    if order == 'deleteFirst':
        R.popleft()
    if order == 'deleteLast':
        R.pop()
print ' '.join(map(str, R))

Measured memory_bytes: 49124
#include <bits/stdc++.h>
using namespace std;
#define int long long int
mt19937 rng(chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N=1000005;
#define M 1000000000
#define double long double
#define BINF 10000000000001
#define init(arr,val) memset(arr,val,sizeof(arr))
#define MAXN 5000004
#define deb(x) cout << #x << " " << x << "\n";
const int LG = 22;

int dp[2005][2005];
int n, a[2005];
vector<pair<int, int>> v;

int foo(int l, int r){
    if(l > r)
        return 0;
    if(dp[l][r] != -1)
        return dp[l][r];
    int i = l + (n - 1 - r);
    int res = 0;
    res = max(abs(v[i].S - l) * v[i].F + foo(l + 1, r), abs(v[i].S - r) * v[i].F + foo(l, r - 1));
    return dp[l][r] = res;
}

#undef int 
int main() {
#define int long long int
ios_base::sync_with_stdio(false); 
cin.tie(0); 
cout.tie(0);


    //int t;
    //cin >> t;
    //for(int tc = 1; tc <= t; tc++){
        //cout << "Case #" << tc << ": ";
        init(dp, -1);
        v.clear();
        cin >> n;
        for(int i = 0; i < n; i++){
            cin >> a[i];
            v.push_back(make_pair(a[i], i));
        }
        sort(v.rbegin(), v.rend());
        int ans = foo(0, n - 1);

        cout << ans << endl;

    //}

return 0;
}










Measured memory_bytes: 35204
n,a=map(int, input().split())
x=list(map(int, input().split()))
x=[i-a for i in x]
d={0:1}
for i in x:
    for j,k in list(d.items()):
        d[i+j]=d.get(i+j,0)+k
print(d[0]-1)
#sample code.

Measured memory_bytes: 3188
n = int(input())
s = list(map(int, input().split()))
count = 0
sidx = 0

ls = [s]
count = 0
while len(ls) != 0:
    l = ls.pop()
    mins = min(l)
    for i in range(len(l)):
        l[i] -= mins
    count += mins
    tmpl = []
    for i in l:
        if i == 0:
            if len(tmpl) != 0:
                ls.append(tmpl)
            tmpl = []
        else:
            tmpl.append(i)
    else:
        if len(tmpl) != 0:
            ls.append(tmpl)

print(count)

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

int main(){
    int n;
    int a[200];
    int i;
    int max,min;

    cin>>n;

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

    max=a[0];
    min=a[0];

    for(i=0;i<n;i++){
        if(max<a[i]){
            max=a[i];
        }
        if(min>a[i]){
            min=a[i];
        }
    }

    cout<<max-min;
}



Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for (int i = 1; i <= n; i++) {
			int count = 0;
			for (int x = 1; ; x++) {
				if (i < (x*x + 3 + 2*x)) {
					break;
				}
				for (int y = 1; ; y++) {
					if (i < (x*x + y*y + 1 +x*y + y + x)) {
						break;
					}
					for (int z = 1; ; z++) {
						int m = x*x + y*y + z*z +x*y + y*z + z*x;
						if (m < i) {
							continue;
						} else if (m == i) {
							count++;
						} else {
							// オーバー
							break;
						}
					}
				}
			}
			System.out.println(count);
		}
	}
}


Measured memory_bytes: 39180
import java.util.Scanner;
 
public class Main{
	public static void main(String[] args){
 
		Scanner scan = new Scanner(System.in);
		
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
 
		if((a <= c) &&(c <= b)){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23764
#include <stdio.h>



int main(){
	int a,b,c;
	scanf("%d %d %d\n",&a,&b,&c);
	if(a<=c)
	{
		if(c<=b)
		{
			puts("Yes");
		}
		else
		{
			puts("No");
		}
	}
	else
	{
		puts("No");
	}
}


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


int main() 
{
    int R,D,X2000;
    cin >> R >> D >> X2000;
    int ans = X2000;

    for( int i=0 ; i<10 ; i++ )
    {
        ans = R * ans - D;
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
using System;

    class Program
    {
        static void Main(string[] args)
        {
            // get a int N
            string[] n = Console.ReadLine().Split(' ');
            if (Convert.ToInt16(n[0]) == Convert.ToInt16(n[1]) && Convert.ToInt16(n[1]) == Convert.ToInt16(n[2]))
                Console.Write("Yes");
            else
                Console.Write("No");
        }
    }

Measured memory_bytes: 11220
#include<iostream>
using namespace std;
const int mod=1e9+7;
int main()
{
	int n;cin>>n;
	if(n<2)cout<<"1";
	else if(n<4)cout<<"2";
	else if(n<8)cout<<"4";
	else if(n<16)cout<<"8";
	else if(n<32)cout<<"16";
	else if(n<64)cout<<"32";
	else cout<<"64";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

int main() {
    int n;
    cin >> n;
    auto a = vector<int>(n);
    for (auto& a_i : a)
        cin >> a_i;
    sort(a.rbegin(), a.rend());

    auto tier = vector<vector<int>>();
    auto comf = 0LL;

    auto t = 0;
    tier.emplace_back(vector<int>{a[0]});
    for (auto i = 1; i < n; ++t) {
        tier.emplace_back();
        auto size = (1 << t);

        for (auto j = 0; j < size && i < n; ++i, ++j) {
            tier.back().push_back(a[i]);
            comf += tier[t][j / 2];
        }
    }

    cout << comf << endl;
    return 0;
}


Measured memory_bytes: 5280
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc095/tasks/arc096_b
N, C = read_ints()
X, V = read_col(N)
# 遠くの寿司も見ないとダメそう(vがバカでかい可能性がある)
# とりあえず右スタートを前提に考える。歩く距離の最小は2パターン。
# 1. 右に進んで食べるだけ
# 2. 途中まで右に進んで途中で左に戻る


def ret_ans1(X, V):  # 右スタート想定
    sum_v = 0
    ans = -1
    for x, v in zip(X, V):
        sum_v += v
        ans = max(ans, sum_v - x)
    return ans


def ret_ans2(X, V):  # ただし右スタートを想定
    Z = []
    sum_v = 0
    for x, v in zip(X, V):
        sum_v += v
        Z.append(sum_v - 2 * x)

    Y = []
    sum_v = 0
    for x, v in reversed(list(zip(X, V))):
        sum_v += v
        Y.append(sum_v - (C - x))
    Y = list(reversed(Y))

    # optimize
    ans = max_sum(Z, Y)
    return ans


def max_sum(X, Y):
    # X_i + Y_j (i<j)を最大化する O(n)
    X_accum = [-10**15]
    for x in X:
        X_accum.append(max(x, X_accum[-1]))

    del X_accum[0]

    Y_accum = [-10**15]
    for y in reversed(Y):
        Y_accum.append(max(y, Y_accum[-1]))
    Y_accum = list(reversed(Y_accum))
    del Y_accum[-1]
    ret = 0
    for i in range(len(X) - 1):
        ret = max(ret, X_accum[i] + Y_accum[i + 1])
    return ret


ans = 0
ans = max(ans, ret_ans1(X, V))
ans = max(ans, ret_ans2(X, V))

# 左周りにスタートする
V = list(reversed(V))
X_r = []
for x in reversed(X):
    X_r.append(C - x)

ans = max(ans, ret_ans1(X_r, V))
ans = max(ans, ret_ans2(X_r, V))
print(ans)


Measured memory_bytes: 92380
#include<stdio.h>
#include<math.h>

typedef struct {
  double x;
  double y;
}p;

int kock(int n, p p1, p p2){
  if(n==0) return 0;
  
  p s,t,u;
  
  s.x = ( 2*p1.x + 1*p2.x )/3;
  s.y = ( 2*p1.y + 1*p2.y )/3;
  t.x = ( 1*p1.x + 2*p2.x )/3;
  t.y = ( 1*p1.y + 2*p2.y )/3;
  u.x = ( t.x - s.x ) * 0.5 - ( t.y - s.y ) * (sqrt(3.0)/2.0) + s.x;
  u.y = ( t.x - s.x ) * (sqrt(3.0)/2.0) + ( t.y - s.y ) * 0.5 + s.y;
  
  
  kock(n-1,p1,s);
  printf("%lf %lf\n",s.x,s.y);
  kock(n-1,s,u);
  printf("%lf %lf\n",u.x,u.y);
  kock(n-1,u,t);
  printf("%lf %lf\n",t.x,t.y);
  kock(n-1,t,p2);
 
}

int main(char args[]){
  
  int n;
  p p1 = {0,0},p2 = {100,0};
  
  
  scanf("%d",&n);
  
  printf("%lf %lf\n",p1.x,p1.y);
  kock(n,p1,p2);
  printf("%lf %lf\n",p2.x,p2.y);
  
  return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
     
#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair
     
using namespace std;
     
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vll a;
  vll b;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    a.pb(x + y);
    b.pb(x - y);
  }
  sort(all(a));
  sort(all(b));
  ll mx = 0;
  for (int i = 0; i < n; i++) {
    mx = max(mx, abs(a[i] - a[0]));
    mx = max(mx, abs(a[i] - a[n - 1]));
    mx = max(mx, abs(b[i] - b[0]));
    mx = max(mx, abs(b[i] - b[n - 1]));
  }
  cout << mx << '\n';
  return (0);
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int q; cin >> q;
    REP(i,q){
        string S,T; cin >> S >> T;
        int dp[S.size()+1][T.size()+1]; CLR(dp);
        REP(i,S.size())REP(j,T.size()){
            if(S[i] == T[j]) chmax(dp[i+1][j+1], dp[i][j]+1);
            chmax(dp[i+1][j+1], dp[i][j+1]);
            chmax(dp[i+1][j+1], dp[i+1][j]);
        }
        cout << dp[S.size()][T.size()] << en;
    }
    return 0;
}


Measured memory_bytes: 7056
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int N;
  cin >> N;
  vector<int> A;
  for (int i = 0; i < 2 * N; i++) {
    int a;
    cin >> a;
    A.push_back(a);
  }
  sort(all(A));
  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += min(A[2 * i], A[2 * i + 1]);
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  int c[100]={};
  int ans=0;
  for(int i=2;i<=N;i++){
    for(int j=i,p=2;j>1;){
      if(j%p==0){c[p]++;j/=p;}
      else p++;
    }
  }
    int y[1100]={};
    for(int j=2;j<100;j++){
      y[c[j]+1]++;
    }
    for(int j=1000;j>1;j--){
      y[j]+=y[j+1];
    }
    int k=y[5]*(y[5]-1)/2*(y[3]-2)+y[15]*(y[5]-1)+y[25]*(y[3]-1)+y[75];
    ans+=k;
    //printf("%d,%d,%d:%d,%d,%d,%d,%d\n",c[2],c[3],c[5],y[3],y[5],y[15],y[25],y[75]);
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a,b,c,k;

int main()
{
	scanf("%d%d%d%d",&a,&b,&c,&k);
	if(k<=a)	
	{
		printf("%d",k);
	}
	else 
	{
		int sum=a;
		k-=a;
		if(k<=b)
		{
			printf("%d",sum);
		}
		else
		{
			k-=b;
			printf("%d",sum-k);
		}
	}
	return 0;
} 

Measured memory_bytes: 3720
import array
import itertools
from collections import defaultdict, deque


def log(s):
    # print("| " + str(s), file=sys.stderr)
    pass


def output(x):
    print(x, flush=True)


def input_ints():
    return map(int, input().split())


def solve():
    num_nodes, num_edges = tuple(input_ints())

    edges = [tuple(input_ints()) for _ in range(num_edges)]

    navigability = defaultdict(lambda: [])

    for e in edges:
        navigability[e[0]].append(e[1])
        navigability[e[1]].append(e[0])

    def solve1(path, result):
        if len(path) == num_nodes:
            result.append(path)
            return

        for m in navigability[path[-1]]:
            if m not in path:
                solve1(path + [m], result)

        return result

    return solve1([1], [])


def main():
    print(len(solve()))


main()


Measured memory_bytes: 4076
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
void print() { cout << "\n"; }
template <class T> void print(const T &x) { cout << x << "\n"; }
template <class T, class... Args> void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
template <class T> void printVector(const vector<T> &v) {
    for(const T &x : v) {
        cout << x << " ";
    }
    cout << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(ll i=0;i<(ll)n;++i)
const ll INF = 999999999999999;
int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n){
    scanf("%ld",&(a.at(i)));
    --a.at(i);
  }
  vector<bool> b(n,false);
  
  //cnt : テレポート回数
  ll cnt = 0;
  //now : 現在の街のid , lp_id : ループの始まりであり、終わりでもある街
  ll now = 0,lp_id;
  while(1){
    // k回テレポートした場合
    if( cnt == k ){
      cout << now+1 << endl;
      return 0;
    }
    //すでに訪れたかどうか <- 訪れているのならループしている
    if( b.at(now) ){
      lp_id = now;
      break;
    }else{
      b.at(now) = true;
    }
    //テレポートする
    now = a.at(now);
    ++cnt;
  }
  
  k -= cnt;
  ll lp_len = 0;
  //ループの長さを数える
  while(1){
    if( lp_len != 0 && now == lp_id ) break;
    now = a.at(now);
    ++lp_len;
  }
  
  //kの残り
  k %= lp_len;
  
  cnt = 0;
  now = lp_id;
  
  while(1){
    if( cnt == k ){
      cout << now+1 << endl;
      return 0;
    }
    now = a.at(now);
    ++cnt;
  }
 
  
  return 0;
}

Measured memory_bytes: 4848
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")

// #pragma GCC optimize("O3")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

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

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int n;
  cin >> n;
  vector<ll> a(n + 1);
  cin >> a;
  vector<ll> mx(n + 1);
  ll x = accumulate(all(a), 0ll) - 1ll;
  if (a[0] > 1) {
    cout << -1 << endl;
    return;
  }
  mx[0] = 1ll - a[0];
  for (int i = 1; i <= n; i++) {
    mx[i] = min(mx[i - 1] * 2 - a[i], LLINF);
    if (mx[i] < 0) {
      cout << -1 << endl;
      return;
    }
  }
  // dmp(mx);
  vector<ll> mb(n + 1);
  ll rem = x;
  for (int i = 0; i <= n; i++) {
    mb[i] = min(rem, mx[i]);
    rem -= min(rem, mx[i]);
  }
  assert(rem == 0);
  // dmp(mb);
  vector<ll> num(n + 1);
  num[0] = 1ll;
  for (int i = 1; i <= n; i++) { num[i] = num[i - 1] + mb[i - 1] - a[i - 1]; }
  // dmp(num);
  cout << accumulate(all(num), 0ll) << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


Measured memory_bytes: 6368
let () =
  let s = Scanf.scanf "%s " (fun a -> a) in

  let s_len = String.length s in
  let p_len = Batteries.String.to_list s |> List.filter (fun x -> x = 'p') |> List.length in

  Printf.printf "%d\n" @@ (s_len/2) - p_len


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

int main()
{
  string s;
  cin >> s;
  int i;
  int num;
  int nmin = 1000;
  for(i = 0; i < s.length()-2; i++)
  {
    num = (s.at(i)-'0')*100+(s.at(i+1)-'0')*10+(s.at(i+2)-'0');
    if(abs(num-753) < nmin)
    {
      nmin = abs(num-753);
    }
  }
  cout << nmin << endl;
}

Measured memory_bytes: 256
//無断転用の一切を禁ずるよ//////////////////////////
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<utility>//swapで数値交換するよ
#define rt "\n"//改行を最速化するよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define cncn int cnt=0
#define please return
#define AC 0
/////////////////////////////////////////////////
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool; 
//////////////////////////////////////////////////
//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　（A＋B）÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}


int main(void) {
	int n, k;
	string s;
	cin >> n >> s >> k;
	rep(i, n) {
		if (s[i] != s[k-1])s[i] = '*';
	}
	cout << s << rt;
	please AC;
}

// abc : 141 , aoj : ITP1_6_D
//sort, abs, swap, reverse, max, min
//__gcd, sbstring, erase, push_back,stoll、stoi

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int n;
	ll ans = 0;
	string str,march = "MARCH";
	set<char>s;
	for (auto ma : march)s.insert(ma);
	cin >> n;
	vector<string>name;
	rep(i, n) {
		cin >> str;
		if (!s.count(str[0]))continue;
		name.push_back(str);
	}
	map<char, ll>m;
	for (auto mp : name)m[mp[0]]++;
	rep(i, 3) for (int j = i + 1; j < 4; j++)for (int k = j + 1; k < 5; k++) {
		ans += m[march[i]] * m[march[j]] * m[march[k]];
	}

	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 7292
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n, h, w;
    std::cin >> n >> h >> w;
    std::cout << (n >= h && n >= w ? (n - h + 1) * (n - w + 1) : 0) << std::endl;

    return 0;
}

Measured memory_bytes: 764