akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(50)
#define _popcnt __builtin_popcount

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long
#define double long double

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

	int N, M; cin >> N >> M;
	int s[5]; char c[5];
	bool zero = (N==1);
	REP(i, M){
		cin >> s[i] >> c[i];
		zero &= (c[i] =='0');
	}
	if(zero){
		cout << 0 << endl;
		return 0;
	}
	for(int i = pow(10, N-1); i < pow(10, N); i++){
		string S = to_string(i);
		bool ok = 1;
		REP(j, M){
			ok &= (S[s[j]-1] == c[j]);
		}
		if(ok){
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}

Measured memory_bytes: 256
//
//  main.cpp
//  At
//
//  Created by 熊本和正 on 2020/03/07.
//  Copyright © 2020 kumamotone. All rights reserved.
//

#define ALL(obj) (obj).begin(), (obj).end()
 
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
 
using namespace std;
typedef long long ll;
const ll INF = 1e18;
 
ll A, B;
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> A >> B;

    ll a = ceil(A * 12.5);
    ll adash = ceil((A+1)*12.5);
    ll b = B * 10;
    ll bdash = (B+1) * 10;

    if (a==b) {
        cout << b << endl;
    } else if(a>b) {
        if (bdash > a) {
            cout << a << endl;
        } else {
            cout << "-1" << endl;
        }
    } else if(a<b) {
        if (b < adash) {
            cout << b << endl;
        } else {
            cout << "-1" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
using namespace std;
#define ll long long
int main(){
    int test, n, m, x, sum=0;
    cin >> n >> m;
    for (int i=0; i<m; i++){
    	cin >> x;
    	sum+=x;
    }
    if (sum>n) cout << -1;
    else cout << n-sum;
    return 0;
}







Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
int n,m,a[100010];
int gcd(int x,int y)
{
	return((y==0)?x:gcd(y,x%y));
}
int twos(int&x)
{
	int ret=0;
	while(!(x&1))
	{
		x>>=1;
		ret++;
	}
	return ret;
}
int main()
{
	scanf("%d%d%d",&n,&m,&a[1]);
	a[0]=twos(a[1]);
	for(int i=2;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(twos(a[i])!=a[0])
		{
			printf("0\n");
			return 0;
		}
	}
	for(int i=2;i<=n;i++)
	{
		if((long long)(a[1]/gcd(a[1],a[i])*a[i])>m)
		{
			printf("0\n");
			return 0;
		}
		else
			a[1]=a[1]/gcd(a[1],a[i])*a[i];
	}
	printf("%d\n",((m/a[1])>>a[0]-1)+1>>1);
	return 0;
}

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

using namespace std;

#define ll long long

const int mxN = 2e5 + 5;

int n;
ll st[mxN*4];
ll h[mxN], a[mxN];
ll dp[mxN];

ll stmax(int ti, int l, int r, int ql, int qr) {
    if (l >= ql && r <= qr) {
        return st[ti];
    } else if (l > qr || r < ql) {
        return 0;
    } else {
        return max(stmax(ti * 2, l, (l + r) / 2, ql, qr),
                   stmax(ti * 2 + 1, (l + r) / 2 + 1, r, ql, qr));
    }
}

void stup(int ti, int l, int r, int pos, ll val) {
    if (pos < l || pos > r)
        return;
    st[ti] = max(st[ti], val);
    if (l != r) {
        stup(ti * 2, l, (l + r) / 2, pos, val);
        stup(ti * 2 + 1, (l + r) / 2 + 1, r, pos, val);
    }
}

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

    cin >> n;

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

    for (int i = 0; i < n; i++) {
        dp[h[i]] = stmax(1, 1, n, 1, h[i] - 1) + a[i];
        stup(1, 1, n, h[i], dp[h[i]]);
    }

    //for (int i = 1; i <= n; i++) { cout << dp[i] << endl; }
    cout << st[1] << endl;
}


Measured memory_bytes: 10496
package main

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

func main() {
	var s string
	fmt.Scan(&s)

	ans := make([]int, len(s))

	for i := 0; i < 2; i++ {
		count := 0
		for j := 0; j < len(s); j++ {
			if s[j] == 'R' {
				count++
			} else {
				ans[j] += count / 2
				ans[j-1] += (count + 1) / 2
				count = 0
			}
		}

		s = ReverseUsingRunes(s)
		ans = ReverseIntSlice(ans)
	}

	w := bufio.NewWriter(os.Stdout)
	for i := 0; i < len(s); i++ {
		w.Write([]byte(fmt.Sprintf("%d", ans[i])))
		if i != len(s)-1 {
			w.Write([]byte(" "))
		}
	}
	w.Write([]byte("\n"))
	w.Flush()

}

func ReverseUsingRunes(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	for i := 0; i < len(runes); i++ {
		if runes[i] == 'R' {
			runes[i] = 'L'
		} else {
			runes[i] = 'R'
		}
	}
	return string(runes)
}

func ReverseIntSlice(is []int) []int {
	reverse := make([]int, len(is))
	for i, j := 0, len(is)-1; i < len(is); i, j = i+1, j-1 {
		reverse[i] = is[j]
	}
	return reverse
}


Measured memory_bytes: 7552
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> heya(200000,vector<int>(0));//[N]部屋Nから繋がる先
vector<int> shirube(200000,-1);//-1未探索
queue<int> nexts;
string ans="Yes";

void tansaku(){
  int h=nexts.front();nexts.pop();
  int s=heya[h].size();
  for(int i=0;i<s;i++){
    int n=heya[h][i];
    if(shirube[n]==-1){
      shirube[n]=h;
      nexts.push(n);
    }
  }
}

int main() {
  int N,M;cin>>N>>M;
  for(int i=0;i<M;i++){
    int a,b;cin>>a>>b;
    heya[a].push_back(b);
    heya[b].push_back(a);
  }
  nexts.push(1);
  
  while(nexts.size()>0){
    tansaku();
  }
  
  cout<<ans<<endl;
  for(int i=2;i<=N;i++){
    cout<<shirube[i]<<endl;
  }
}

Measured memory_bytes: 12940
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

const int N_MAX = 10000001;

int main() {
  vl div(N_MAX,0);
  int n;
  cin >> n;
  for(int i = 1; i<=N_MAX;i++){
    for(int j = i;j<=N_MAX;j+=i){
      div[j]++;
    }
  }
  ll sum = 0;
  srep(i,1,n+1){
    sum+=div[i]*i; 
  }
  cout<<sum<<endl;
  return 0;
}

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

typedef long long ll;

#define        optimize           ios::sync_with_stdio(0); cin.tie(0);
#define PI    acos(-1.0)
#define pb push_back
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define RESET(a, b) memset(a, b, sizeof(a))
#define pii pair <int, int>
#define pll pair <ll, ll>
#define gcd(a, b) __gcd(a, b)

#define        MX        200005

vector <pii> edges;
vector <int> adj[MX];
vector <int> order;
vector <bool> visited;
int prio[MX];
int dp[MX];

void dfs(int n)
{
    visited[n] = 1;
    for(auto x: adj[n]){
        if(!visited[x]){
            dfs(x);
        }
    }
    order.push_back(n);
}
bool func(pii a, pii b)
{
    return prio[a.first] < prio[b.first];
}
int main()
{
    optimize
    int n, m;
    cin>>n>>m;
    for(int i = 0; i < m; i++){
        int u, v;
        cin>>u>>v;
        adj[u].push_back(v);
        edges.push_back({u, v});
    }

    visited = vector <bool> (n+1);
    for(int i = 1; i <= n; i++){
        if(!visited[i]) dfs(i);
    }

    reverse(order.begin(), order.end());
    for(int i = 0; i < n; i++){
        prio[order[i]] = i;
    }
    sort(edges.begin(), edges.end(), func);

    int ans = 0;
    for(int i = 0; i < edges.size(); i++){
        int u = edges[i].first, v = edges[i].second;
        dp[v] = max(dp[v], dp[u]+1);
        ans = max(ans, dp[v]);
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 15540
_, m = gets.split(' ').map(&:to_i)
a = gets.split(' ').map(&:to_i)
sorted_a = a.sort.reverse
sum = a.inject(0) { |s, a_i| s + a_i }
print(sorted_a[m - 1] < (sum / (4 * m).to_f) ? 'No' : 'Yes')


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

namespace ABC
{
    class ProgramB
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(" ");
            var n = long.Parse(inputs[0]);
            var k = long.Parse(inputs[1]);

            var result = k * Math.Pow(k - 1, n - 1);
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 27820
#define DEBUG 0

/**
 * File    : D2.cpp
 * Author  : Kazune Takahashi
 * Created : 3/5/2019, 6:58:47 PM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(10101010));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

class UnionFind
{
public:
  vector<long long> par;

  UnionFind(int n) : par(n, -1) {}
  void init(int n)
  {
    par.assign(n, -1);
  }

  int root(int x)
  {
    if (par[x] < 0)
    {
      return x;
    }
    return par[x] = root(par[x]);
  }

  bool is_same(int x, int y)
  {
    return root(x) == root(y);
  }

  bool merge(int x, int y)
  {
    x = root(x);
    y = root(y);
    if (x == y)
    {
      return false;
    }
    if (par[x] > par[y])
    {
      swap(x, y);
    }
    par[x] += par[y];
    par[y] = x;
    return true;
  }

  long long size(int x)
  {
    return -par[root(x)];
  }
};

ll N;
int M;
int A[100010], B[100010];
vector<ll> ans;

int main()
{
  cin >> N >> M;
  for (auto i = 0; i < M; i++)
  {
    cin >> A[i] >> B[i];
    A[i]--;
    B[i]--;
  }
  reverse(A, A + M);
  reverse(B, B + M);
  UnionFind UF(N);
  ll cnt = N * (N - 1) / 2;
  ans.push_back(cnt);
  for (auto i = 0; i < M - 1; i++)
  {
    if (!UF.is_same(A[i], B[i]))
    {
      cnt -= UF.size(A[i]) * UF.size(B[i]);
      UF.merge(A[i], B[i]);
    }
    ans.push_back(cnt);
  }
  reverse(ans.begin(), ans.end());
  for (auto x : ans)
  {
    cout << x << endl;
  }
}

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

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#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 all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using namespace std;

using ll = long long;

const long long MOD = 998244353;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

ll N;
ll K;
std::vector<ll> L;
std::vector<ll> R;

vector<ll> dp;

vector<pair<ll, ll>> f(ll i) {
  vector<pair<ll, ll>> ret;
  rep(k, K) {
    ll l = L.at(k);
    ll r = R.at(k);
    if (i - l > 0) {
      pair<ll, ll> p = {i - l, max(1LL, i - r)};
      ret.push_back(p);
    }
  }
  return ret;
}

void solve() {
  dp.resize(N, 0);
  dp.at(0) = 1;

  vector<ll> acc(N + 1, 0);
  acc.at(0) = 0;
  acc.at(1) = 1;

  rep(i, N - 1) {
    for (auto p : f(i + 2)) {
      ll l = p.second - 1;
      ll r = p.first;
      dp.at(i + 1) += (acc.at(r) - acc.at(l) + MOD) % MOD;
      dp.at(i + 1) %= MOD;
    }
    acc.at(i + 2) = (acc.at(i + 1) + dp.at(i + 1)) % MOD;
  }

  cout << dp.at(N - 1) % MOD << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  scanf("%lld", &N);
  scanf("%lld", &K);
  L.resize(K);
  R.resize(K);
  for (int i = 0; i < K; i++) {
    scanf("%lld", &L[i]);
    scanf("%lld", &R[i]);
  }
  solve();
  return 0;
}


Measured memory_bytes: 6412
#include <bits/stdc++.h>
using namespace std;
struct flower
{
    long long int hi,bty;
};
long long int solve(vector<flower> &v,long long int n)
{
    vector<long long int> dp(n+1);
    dp[1]=v[1].bty;
    map<long long int,long long int> meaningfull;
    meaningfull[v[1].hi]=v[1].bty;
    long long int ans=dp[1];
    for(int i=2;i<=n;i++)
    {
        dp[i]=v[i].bty;
        auto it=meaningfull.lower_bound(v[i].hi);
        if(it!=meaningfull.begin())
        {
            it--;
            dp[i]+=it->second;
        }
        meaningfull[v[i].hi]=dp[i];
       
        it=meaningfull.upper_bound(v[i].hi);
        
        
        while(it!=meaningfull.end()&&it->second<=dp[i])
        {
            auto temp=it;
            temp++;
            meaningfull.erase(it);
            it=temp;
        }
        ans=max(ans,dp[i]);
    }
    return ans;
}
int main() {
	long long  int n;
	cin>>n;
	vector<flower> v(n+1);
	
	for(int i=1;i<=n;i++)
	{
	    cin>>v[i].hi;
	}
	for(int i=1;i<=n;i++)
	{
	    cin>>v[i].bty;
	}
	long long int ans=solve(v,n);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 20168
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int n, l;
    cin >>n >> l;
    int eat = INF, su = 0;

    REP(i, n){
        su += l + i;
        if(abs(eat) > abs(l + i)) eat = l + i;
    }
    cout << su - eat << endl;
}

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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define INF 1<<30

long calc(long n, long x){
    if(n==x || x==0) return 0;
    if(n%2==0 && n/2 == x) return x*3;

    if(n/2 < x) x = n-x;

    return calc(x+(n-x)%x, x) + ((n-x)/x)*x*3;
}

int main(){
    long n,x;
    cin>>n>>x;

    cout<< calc(n,x) << endl;

    return 0;
}


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

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

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;

int c[N];

int32_t main()
{
    IOS;
    int n,x;
    cin>>n;
    FOR(i,1,n+1)
    {
        cin>>x;
        c[x]++;
    }
    if((n%2 == 0 && c[0]) || (c[0] > 1))
    {
        cout<<"0\n";
        return 0;
    }
    int ans = 1;
    if(c[2])
    {
        for(int i=2;i<=n-1;i+=2)
        {
            if(c[i] != 2)
            {
                cout<<"0\n";
                return 0;
            }
            else
            {
                ans = (ans * 2) % MOD;
            }
        }
    }
    else
    {
        for(int i=1;i<=n-1;i+=2)
        {
            if(c[i] != 2)
            {
                cout<<"0\n";
                return 0;
            }
            else
            {
                ans = (ans * 2) % MOD;
            }
        }
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 1024
// A.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <cmath>
#include <map>
#include <set>

using namespace std;

typedef long double LD;

int main(int argc, char* argv[]) {
	int a, r = 0;
	cin >> a;
	LD p = 0, q = 0;

	for (int t = 1; t < 1000000; ++t) {
		r = (r + a) % 360;
		LD x = cos(2 * M_PI * r / 360) * 65536;
		LD y = sin(2 * M_PI * r / 360) * 65536;
		p += x, q += y;
		if (abs(p) < 0.1 && abs(q) < 0.1) {
			cout << t << endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 4004
// author: Saman Mahdanian
#include <bits/stdc++.h>

using namespace std;
const int N = 1e5 + 10;

struct cmp { bool operator() (const int &, const int &) const; };

int n;
set <int> g[N];
bool mark[N];

set <int, cmp> heap;

int main() {
	cin >> n;
	for (int i = 1; i < n; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].insert(b);
		g[b].insert(a);
	}

	for (int i = 0; i < n; i++) 
		heap.insert(i);

	while (!heap.empty()) {
		int v = *heap.begin();
		heap.erase(v);

		if (mark[v])
			continue;
		mark[v] = true;

		// assert(g[v].size() == 1);
		int pv = *g[v].begin();

		heap.erase(pv);
		mark[pv] = true;

		g[pv].erase(v);
		g[v].erase(pv);

		for (int u: g[pv]) {
			assert(heap.find(u) != heap.end());
			heap.erase(u);
			g[u].erase(pv);
			if (g[u].empty()) {
				cout << "First" << endl;
				return 0;
			}
			heap.insert(u);
		}
		g[pv].clear();
		// cerr << v + 1 << ' ' << pv + 1 << endl;
	}

	cout << "Second" << endl;
}


bool cmp::operator() (const int &v, const int &u) const {
	return g[v].size() != g[u].size()? g[v].size() < g[u].size() : v < u;
}


// SamMHD :: Feb17-2019 :: Another Simulation


Measured memory_bytes: 19072
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define MIN(a,b) ((a) <= (b) ? (a) : (b))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort( ALL(v) )

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



int main()
{


    string s; cin>>s;

    if(s[3-1]==s[4-1] && s[5-1]==s[6-1])
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}


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

int main(){
  int n,m,x,y; cin>>n>>m>>x>>y;
  vector<int> X(n);
  vector<int> Y(m);
  for(int i=0; i<n; i++){
    cin>>X.at(i);
  }
  for(int i=0; i<m; i++){
    cin>>Y.at(i);
  }
  sort(X.begin(),X.end());
  sort(Y.begin(),Y.end());
  
  
  bool war = true;
  for(int i=x+1; i<=y; i++){
    if(X.at(n-1) < i and Y.at(0) >= i){
      war = false;
      break;
    }
  }
  
  if(war)
    cout<<"War"<<endl;
  else
    cout<<"No War"<<endl;
}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  
  if (A == B && B == C) {
    cout << 1 << endl;
  } else if (A == B && B != C || A == C && A != B || B == C && A != B) {
    cout << 2 << endl;
  } else {
    cout << 3 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int f[N],n,ans[N],x=0,a,b,temp;
void Check(){
	f[1]=1;
	for(int i=2;i<=N;i++)
	for(int j=i*2;j<N;j+=i)
	f[j]=1;
}
int main(){
	Check();
	ans[1]=0;
		for(int i=3;i<=N;i+=2){
		if(!f[i]&&!f[(i+1)>>1]){
		ans[i]=temp+1;
		temp=ans[i];
	}
	else
	ans[i]=temp;
	}
		cin>>n;
		while(n--){
			cin>>a>>b;
			if(!f[a]&&!f[(a+1)>>1])
			cout<<(ans[b]-ans[a]+1)<<endl;
			else
			cout<<ans[b]-ans[a]<<endl;
		}
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    String s=gs();
	    //int x=gi();
	    //int y=gi();
	    //int z=gi();
	    
	    System.out.print(String.valueOf(s.charAt(0))+ (s.length()-2)+s.charAt(s.length()-1));

//	    if (s.charAt(2)==s.charAt(3) && s.charAt(4)== s.charAt(5)) {
//        	System.out.print("Yes");
//        }else {
//        	System.out.print("No");
//        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

class BIT{
private:
  int n;
  vector<LL> bit;
public:
  BIT(int n_){
	n = n_;
	bit.assign(n+1, 0);
  }

  LL max(int i){
	LL s = 0;
	while(i > 0){
	  maxi(s, bit[i]);
	  i -= i & -i;
	}
	return s;
  }

  void add(int i, LL x){
	while(i <= n){
	  maxi(bit[i], x);
	  i += i & -i;
	}
  }
};

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

  LL N;
  cin >> N;
  VL xs(N);
  REP(i,N) cin >> xs[i];

  BIT bit(N+1);
  LL ans = 0;
  REP(i,N){
	LL t = xs[i] + bit.max(xs[i]);
	maxi(ans, t);
	bit.add(xs[i], t);
  }
  cout << N * (N+1) / 2 - ans << endl;

  return 0;
}

Measured memory_bytes: 4408
n = int(input())
TXY = []
tc, xc, yc = 0, 0, 0
for i in range(n):
    t, x, y = map(int, input().split())
    d = abs(x-xc)+abs(y-yc)
    if d > t-tc or (t-tc-d)%2 == 1:
        print('No')
        exit()
    else:
        tc, xc, yc = t, x, y
else:
    print('Yes')


Measured memory_bytes: 74448
s=input()

def check(ss):
  for i in range(len(ss)):
    if ss[i]!=ss[len(ss)-i-1]:
      return False
  return True

N=len(s)
if check(s) and check(s[:(N-1)//2]) and check(s[(N+2)//2:]):print('Yes')
else:print('No')


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

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

	string S;
	cin >> S;

	vector<int> Nums;

	int now = 1;
	int cnt = 0;
	for (auto& c : S) {
		if (c == (char)('0' + now)) ++cnt;
		else
		{
			Nums.push_back(cnt);
			cnt = 1;
			now = 1 - now;
		}
	}
	if (cnt != 0) Nums.push_back(cnt);

	if (Nums.size() % 2 == 0) Nums.push_back(0);

	int add = 2 * K + 1;
	int ans = 0;

	int left = 0;
	int right = 0;

	int tmp = 0;

	for (int i = 0; i < Nums.size(); i += 2) {
		int left_next = i;
		int right_next = min(i + add, (int)Nums.size());
		while (left_next > left) {
			tmp -= Nums[left];
			++left;
		}
		while (right_next > right) {
			tmp += Nums[right];
			++right;
		}
		ans = max(ans, tmp);
	}

	cout << ans << endl;
}

Measured memory_bytes: 1020
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iostream>
#include <set>
#include <string>
#include <unordered_map>

using namespace std;

int main() {
  int a_health, a_power, b_health, b_power;

  cin >> a_health >> a_power >> b_health >> b_power;

  int a_dead_turn = ceil((double)a_health / b_power);
  int b_dead_turn = ceil((double)b_health / a_power);

  if (a_dead_turn >= b_dead_turn) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 3596
N = int(input())
A = list(map(int, input().split()))
idx = {v: i for i, v in enumerate(A)}

ans = 0
idx_l, idx_r = list(range(N + 2)), list(range(N + 2))
for a in range(N, 0, -1):
    i = idx[a]
    l, r = idx_l[i], idx_r[i]
    ans += a * (i - l + 1) * (r - i + 1)
    idx_l[r + 1], idx_r[l - 1] = l, r

print(ans)

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

typedef long long ll;

int main() {
    int D;
    cin >> D;
    vector<ll> c(26), t(D);
    rep(i, 26) cin >> c[i];
    vector<vector<ll>> s(D, vector<ll>(26)), last(D + 1, vector<ll>(26, 0));
    rep(i, D) rep(j, 26) cin >> s[i][j];
    ll p = 0;
    rep(d, D) {
        ll q, r = 0, maxq = -1e18;
        rep(j, 26) {
            q = s[d][j];
            rep(i, 26) last[d + 1][i] = last[d][i];
            last[d + 1][j] = d + 1;
            rep(i, 26) {
                q -= c[i] * (d + 1 - last[d + 1][i]);
            }
            if (q > maxq) {
                maxq = q;
                r = j;
            }
        }
        cout << r + 1 << "\n";
        p += maxq;
        rep(i, 26) last[d + 1][i] = last[d][i];
        last[d + 1][r] = d + 1;
    }
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << " " << b << " " << c << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<string> b(n);
    for(int i=0;i<n;i++){
        cin >> b.at(i);
    }
    int m;
    cin >> m;
    vector<string> r(m);
    for(int i=0;i<m;i++){
        cin >> r.at(i);
    }
    int ans=0;

    for(int i=0;i<n;i++){
        int sum=0;

        for(int j=0;j<n;j++){
            if(b.at(i)==b.at(j)){
                ++sum;
            }
        }
        for(int j=0;j<m;j++){
            if(b.at(i)==r.at(j)) {
                --sum;
            }
        }
        if(ans<sum) 
            ans=sum;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
Cerberus97
Hanit Banga
*/

#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e2 + 10, H = 64, K = (H - 2) / 2;

char s[N][N];

int main() {
	int a, b;
	cin >> a >> b;
	--a; --b;
	for (int i = 1; i <= H; ++i) {
		for (int j = 1; j <= K + 1; ++j) {
			s[i][j] = '#';
			s[i][j + K + 1] = '.';
		}
	}
	for (int i = 1; i <= H; i += 2) {
		for (int j = 1; j <= K; j += 2) {
			if (a) {
				s[i][j] = '.';
				--a;
			}
			if (b) {
				s[i][j + K + 2] = '#';
				--b;
			}
		}
	}
	cout << H << ' ' << H << endl;
	for (int i = 1; i <= H; ++i) {
		cout << (s[i] + 1) << '\n';
	}
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x, y) debug(x), debug(y)
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	vector<pi> a(n);
	set<int> pos;
	rep(i, n) cin >> a[i].fi, a[i].se = i;
	sort(all(a));
	ll ans = 0LL;
	rep(i, n){
		ll le = -1;
		ll ri = n;
		if(pos.size() && *pos.begin() < a[i].se){
			auto it = --pos.ub(a[i].se);	
			le = *it;
		}
		auto it = pos.ub(a[i].se);	
		if(it != pos.end()) ri = *it;
		ll cur = (ll)((ll)(a[i].se - le) * (ll)(ri - a[i].se) * (ll)(a[i].fi));
		ans += cur;
		pos.insert(a[i].se);
	}
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 14292
#include<bits/stdc++.h>
using namespace std ;
vector<string>lol;
vector<vector<int>>wow(10);
int n,m,ans=0;
int p[100];

bool check(string s)
{
    bool ret=1;
    for(int i=0;i<m;i++)
    {
        int x=0;
        for(int j=1;j<=wow[i][0];j++)
        {
            if(s[wow[i][j]-1]=='1')x++;
        }
       // cout<<x<<endl;
        if(x%2!=p[i])
        {
            ret=0;
            break;
        }
    }
    return ret;
}
void a(string s)
{
    if(s.size()==n)
    {
        //cout<<s<<endl;
        if(check(s))ans++;
        return;
    }
    s+='1';
    a(s);
    s.pop_back();
    s+='0';
    a(s);

}

int main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int x;
        cin>>x;
        wow[i].push_back(x);
        for(int j=0;j<x;j++)
        {
            int y;
            cin>>y;
            wow[i].push_back(y);
        }
    }
    for(int i=0;i<m;i++)cin>>p[i];
    a("");
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
 int N, L, R;
  int Goukei = 0;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> L >> R;
    Goukei += R - L + 1;
  }
  cout << Goukei << endl;
}

Measured memory_bytes: 3580
local inp = io.read()
local n,x
for i=1,string.len(inp),1 do
  if inp:sub(i,i)==' ' then
    n = tonumber(inp:sub(1,i-1))
    x = tonumber(inp:sub(i+1,string.len(inp)))
  end
end
local le = {}
local p = {}

function f(x,n)
  if x == 0 then
    return 0
  elseif n == 0 then
    return 1
  elseif 2*x<le[n+1] then
    return f(x-1,n-1)
  else
    return p[n]+1+f(x-le[n]-2,n-1)
   end
end

le[1]=1
for i=1,n,1 do
  le[i+1]=le[i]*2+3
end
p[1]=1
for i=1,n,1 do
  p[i+1]=p[i]*2+1
end
print(f(x,n))

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


ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
    ll x = a / gcd(a, b);
    return x * b;
}

int main() {
    int N;
    cin >> N;
    vl T(N);
    rep(i, N) {
        cin >> T[i];
    }

    if (N == 1) {
        cout << T[0] << endl;
        return 0;
    }

    ll ans = lcm(T[0], T[1]);
    for (int i = 2; i < N; i++) {
        ans = lcm(ans, T[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n,m;
cin >> n >> m;
vector<ll> x(m),y(m);
set<ll> st;
vector<ll> balls(n,1);
st.insert(0);
for(ll i = 0; i < m; i++){
    cin >> x[i] >> y[i];
    x[i]--;
    y[i]--;
} 
for(ll i = 0; i < m; i++){
    if(st.count(x[i]))
        st.insert(y[i]);
        balls[x[i]]--;
        balls[y[i]]++;
        if(balls[x[i]] == 0)
        st.erase(x[i]);
}

cout << st.size() << endl;
}


Measured memory_bytes: 7296
#include<stdio.h>
#include<string.h>
int main()
{
    int i,n,ac=0,wa=0,tle=0,re=0;
    char s[5];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
    scanf("%s",s);
    if(strcmp(s,"AC")==0) ac++;
    if(strcmp(s,"WA")==0) wa++;
    if(strcmp(s,"TLE")==0) tle++;
    if(strcmp(s,"RE")==0) re++;    
      }
      printf("AC x %d\n",ac);
      printf("WA x %d\n",wa);
      printf("TLE x %d\n",tle);
      printf("RE x %d\n",re);
     return 0;

}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n ;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (s == "Y") {
      cout << "Four" << endl;
      return 0;
    } 
    
  }
  cout << "Three" << endl;  
}


Measured memory_bytes: 3588
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
visited = [[0 for _ in range(w)] for _ in range(h)]
disList = [[[[0 for _ in range(w)] for _ in range(h)] for _ in range(w)] for _ in range(h)]
# print(s)
for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            visited[i][j] = 1
import copy

ans = 0
for i in range(h):
    for j in range(w):
        nowdis = 0
        now = 0
        next_point = [[i, j, nowdis]]
        thisVisited = copy.deepcopy(visited)
        thisVisited[i][j] = 1
        if s[i][j] == "#":
            continue

        while now < len(next_point):
            nowi = next_point[now][0]
            nowj = next_point[now][1]
            nowdis = next_point[now][2]
            disList[i][j][nowi][nowj] = nowdis

            if nowi != 0:
                if thisVisited[nowi - 1][nowj] == 0:
                    next_point.append([nowi - 1, nowj, nowdis + 1])
                    thisVisited[nowi - 1][nowj] = 1

            if nowi != h - 1:
                if thisVisited[nowi + 1][nowj] == 0:
                    next_point.append([nowi + 1, nowj, nowdis + 1])
                    thisVisited[nowi + 1][nowj] = 1

            if nowj != w - 1:
                if thisVisited[nowi][nowj + 1] == 0:
                    next_point.append([nowi, nowj + 1, nowdis + 1])
                    thisVisited[nowi][nowj + 1] = 1

            if nowj != 0:
                if thisVisited[nowi][nowj - 1] == 0:
                    next_point.append([nowi, nowj - 1, nowdis + 1])
                    thisVisited[nowi][nowj - 1] = 1
            now += 1

# print(disList)
ans = 0
for i in disList:
    for j in i:
        for k in j:
            # print(k)
            ans = max(ans, max(k))

print(ans)

Measured memory_bytes: 59608
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>

using namespace std;
typedef long long ll;
const int LEN = 100000;

struct fastio {
  int it, len;
  char s[LEN + 5];
  fastio() {
    it = len = 0;
  }
  char get() {
    if(it < len) return s[it++];
    it = 0, len = fread(s, 1, LEN, stdin);
    return len ? s[it++] : EOF;
  }
  bool notend() {
    char c;
    for (c = get();c == ' ' || c == '\n';c = get());
    if (it) it--;
    return c != EOF;
  }
  void put(char c) {
    if(it == LEN) fwrite(s,1,LEN,stdout), it = 0;
    s[it++] = c;
  }
  void flush() {
    fwrite(s, 1, it, stdout);
  }
}buff, bufo;
inline int getint() {
  char c; int res = 0, sig = 1;
  for (c = buff.get(); c < '0' || c > '9'; c = buff.get()) if(c == '-') sig = -1;
  for (;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline ll getll() {
  char c; ll res = 0, sig = 1;
  for (c = buff.get(); c < '0' || c > '9'; c = buff.get()) if (c == '-') sig = -1;
  for (; c >= '0' && c <= '9'; c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline void putint(int x, char suf) {
  if (!x) bufo.put('0');
  else {
    if (x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[15];
    while (x) {
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for (; k; k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline void putll(ll x, char suf) {
  if (!x) bufo.put('0');
  else {
    if (x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[25];
    while (x) {
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for (; k; k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline char get_char() {
  char c;
  for (c = buff.get(); c == ' ' || c == '\n'; c = buff.get());
  return c;
}
bool a[1035][1035];
void build(int n) {
  if (!n) a[0][0] = 0;
  else {
    build(n - 1);
    int hf = (1 << (n - 1)), w = (1 << n);
    for (int i = 0; i < hf; i++)
      for (int j = hf; j < w; j++)
        a[i][j] = a[i][w - 1 - j];
    for (int i = hf; i < w; i++)
      for (int j = 0; j < hf; j++)
        a[i][j] = a[w - 1 - i][j];
    for (int i = hf; i < w; i++)
      for (int j = hf; j < w; j++)
        a[i][j] = !a[i][w - 1 - j];
  }
}
int n, m, res[1035][1035];
int main() {
  build(10);
  n = getint(), m = getint();
  for (int i = 1; i < (1 << n); i++) {
    for (int j = 1; j < (1 << m); j++) {
      bufo.put('0' + (a[i][j] ^ a[i - 1][j] ^ a[i][j - 1] ^ a[i - 1][j - 1]));
    }
    bufo.put('\n');
  }
  bufo.flush();
  return 0;
}


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

int main() {
  int N;
  int A = 0;
  cin >> N ;
  for(int i = 0; i<N; i++) {
     int l,r;
    cin>>l>>r;
    A+=r-l+1;
    
  }
    cout << A;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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()
{
  int n;
  cin >> n;
  ll ans = 0;
  for (int i = 1 ; i <= n; i++)
  {
    if (i % 3 > 0 && i % 5 > 0)
      ans += i;
  }
  cout << ans << endl;

  return 0;
}

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

int sosu(int);

int main(){
  int n,i,c=0;
  int A[10000];
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&A[i]);
    }
  for(i=0;i<n;i++){
    c+=sosu(A[i]);
  }
  printf("%d\n",c);
  return 0;
}

int sosu(int x){
  if(x<=1)return 0;
  else if(x==2)return 1;
  else if(x%2==0)return 0;
  double sq=pow(x,0.5);
  int i;
  for(i=3;i<=sq;i+=2){
    if(x%i==0){
      return 0;
    }
  }
  return 1;
}



Measured memory_bytes: 2128
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
using namespace std;

template<class T>
void in(vector<T>& V) {
	for (auto itr = V.begin(); itr != V.end(); itr++)cin >> *itr;
	return;
}

template<class T>
void out(vector<T>& V) {
	for (T& itr : V)cout << itr << endl;
	return;
}


template< typename T >
struct edge {
	int src, to;
	T cost;

	edge(int to, T cost) : src(-1), to(to), cost(cost) {}

	edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

	edge& operator=(const int& x) {
		to = x;
		return *this;
	}

	operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
vector< T > dijkstra(WeightedGraph< T >& g, int s) {
	const auto INF = numeric_limits< T >::max();
	vector< T > dist(g.size(), INF);

	using Pi = pair< T, int >;
	priority_queue< Pi, vector< Pi >, greater< Pi > > que;
	dist[s] = 0;
	que.emplace(dist[s], s);
	while (!que.empty()) {
		T cost;
		int idx;
		tie(cost, idx) = que.top();
		que.pop();
		if (dist[idx] < cost) continue;
		for (auto& e : g[idx]) {
			auto next_cost = cost + e.cost;
			if (dist[e.to] <= next_cost) continue;
			dist[e.to] = next_cost;
			que.emplace(dist[e.to], e.to);
		}
	}
	return dist;
}


int N, M;
vector<vector<int>> open;
vector<long long> cost;

int main() {
	cin >> N >> M;
	open.resize(M + 1,vector<int>());
	cost.resize(M + 1);
	for (int m = 1; m <= M; m++) {
		int b;
		cin >> cost[m] >> b;
		for (int bb = 0; bb < b; bb++) {
			int c;
			cin >> c;
			open[m].push_back(--c);
		}
	}
	WeightedGraph<long long> G(1 << N);
	for (int m = 1; m <= M; m++) {
		int code = 0;
		for (int n : open[m]) {
			code |= (1 << n);
		}
		for (int n = 0; n < (1 << N); n++) {
			G[n].push_back(edge<long long>(n, (n | code), cost[m]));
		}
	}
	int end = (1 << N) - 1;
	long long ans = dijkstra(G, 0)[end];
	if (ans == LLONG_MAX)cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MOD 1000000007
#define INF 100100100

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


int main(){
  int n, x;
  cin >> n >> x;
  if(2 * n - 1 == x || x == 1){
    cout << "No" << endl;
    return 0;
  }

  map<int, int> mp;
  map<int, bool> use;

  mp[n] = x;
  use[x] = true;
  use[x-1] = true;
  use[x+1] = true;
  if(x > 2){
    mp[n-1] = x+1;
    mp[n+1] = x-1;
    mp[n-2] = x-2;
    use[x-2] = true;
  }else{
    mp[n-1] = x+1;
    mp[n+1] = x-1;
    mp[n+2] = x+2;
    use[x+2] = true;
  }
  // print(use);

  vector<int> tmp;
  int skip1 = 1;
  // int skip2 = 0;
  cout << "Yes" << endl;
  for (int i = 1; i <= 2*n-1; i++) {
    if(mp[i] != 0) {
      cout << mp[i] << endl;
      use[mp[i]] = true;
      // tmp.push_back(i);
    } else {
      if(!use[i]){
        use[i] = true;
        cout << i << endl;
      }else{
        for (int j = skip1; j <= 2*n-1; j++) {
          if(!use[j]){
            cout << j << endl;
            use[j] = true;
            skip1 = j;
            break;
          }
        }
        // print(tmp);
        // cout << skip1 << endl;
        // if(int(tmp.size()) > skip1 && !use[tmp[skip1]]){
        //   cout << tmp[skip1] << endl;
        //   use[tmp[skip1]] = true;
        //   skip1++;
        // }else{
        //   cout << 2*n-1 - skip2 << endl;
        //   use[2*n-1 - skip2] = true;
        //   skip2++;
        // }
      }
    }

  }
}


Measured memory_bytes: 20224
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main() {
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++)cin >> a[i];
	int count = 0;
	int flag = 0;
	while (flag == 0) {
		for (int i = 0; i < n; i++) {
			if (a[i] % 2 == 0 ) {
				a[i] /= 2;
				count++;
			}
			else flag = 1;
		}
	}
	cout << count/n << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	int a[200001];
	scan(N);
	rep(i,N){
		scan(a[i]);
	}
	if(N%2==0){
		for(int i=N-1;i>=0;i-=2){
			printf("%d ",a[i]);
		}
		for(int i=0;i<=N-2;i+=2){
			printf("%d ",a[i]);
		}
		kaigyo;
	}
	else{
		for(int i=N-1;i>=0;i-=2){
			printf("%d ",a[i]);
		}
		for(int i=1;i<=N-2;i+=2){
			printf("%d ",a[i]);
		}
		kaigyo;
	}
	return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
	int n, r;
	scanf("%d%d", &n, &r);
	
	int res = 0;
	if (n < 10)
	{
		res = r + 100 * (10 - n);
	}
	else
	{
		res = r;
	}

	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    
    int i,a,b,c;
    
    scanf("%d%d%d",&a,&b,&c);
    
    for(i=1;i<=b;i++){
        if((a*i)%b==c){
            printf("YES\n");
            return 0;
        }
    }
    printf("NO\n");
    return 0;
}


Measured memory_bytes: 1644
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<iomanip>
#include<fstream>
#include<ctime>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int MAXX = 100;

int a, b, i, j;

void inc(int &a, int &b) {
	if (b == MAXX - 1) {
		a++;
		b = 0;
		printf("\n");
	} else b++;
}

void white() {
	printf(".");
}

void black() {
	printf("#");
}

int main() {
scanf("%d %d", &a, &b);
i = 0;
j = 0;
printf("%d %d\n", MAXX, MAXX);
while (a > 1) {
	if (i % 2 == 0) black(); else if (j % 2 == 0) black(); else {white(); a--;}
	inc(i, j);
}
for (j=j;j<MAXX;j++) black();
printf("\n");
i++;
for (j=0;j<MAXX;j++) black();
printf("\n");
b--;
i++;
int curr = i % 2;
j = 0;
while (i < MAXX) {
	if (i % 2 == curr) white(); else if (j % 2 == 0 && b > 0) {black(); b--; } else white();
	inc(i, j);
}
return 0;
}



Measured memory_bytes: 256
N, M = map(int, input().split())
S = input()
T = input()


# 最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


# 最小公倍数
def lcm(a, b):
    return a * b // gcd(a, b)


step = gcd(N, M)
step_N = N // step
step_M = M // step

if S[::step_N] == T[::step_M]:
    print(lcm(N, M))
else:
    print(-1)


Measured memory_bytes: 3316