akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>pii;
typedef vector<int>vi;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define fi first
#define se second
#define de(x) cout<<#x<<"="<<x<<"\n"
#define dd(x) cout<<#x<<"="<<x<<" "
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define lowbit(a) ((a)&-(a))
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
const int N=2e5+5;
int n;
pii p[N]; 
struct TwoSat{
	static const int N = ::N<<3;
	int dfn[N] , low[N],id[N],st[N],_st,_,cc,ba,to[N];
	vi g[N];
	int mark[N],n;
	void init(int _n){rep(i , 0 , (n = _n<<1))g[i].clear();}
	int newnode(){
		rep(i , 0 , 2)g[n++].clear();
		return n - 2;
	}
	void addedge(int a,  int b) {   
		g[a].pb(b); g[b ^ 1].pb(a ^ 1);
	} 
	void build(int l,int r,int rt){
		to[rt] = newnode();
		if(l == r){
			addedge(to[rt],p[l].se^1 );
			return;
		}
		int m = l + r>>1;
		build(l , m , rt<<1);
		build(m + 1,r,rt<<1|1);
		addedge(to[rt],to[rt<<1]);
		addedge(to[rt],to[rt<<1|1]);
	}
	void add(int u,int L,int R,int l,int r,int rt){
		if(L <= l && r <= R){
			addedge(u , to[rt]);
			return;
		}
		int m = l + r>>1;
		if(L <= m)add(u , L , R ,l , m , rt<<1);
		if(R > m)add(u , L , R ,m + 1, r , rt<<1|1); 
	}
	void dfs(int c,vi g[]){
		dfn[c] = low[c] = ++cc;
		st[_st++] = c;
		for(auto t : g[c])
			if(!dfn[t])dfs(t,g),low[c] = min(low[c],low[t]);
			else if(!id[t])low[c] = min(low[c],dfn[t]);
		if(low[c] == dfn[c]){
			++_;
			do{id[st[--_st]] = _;}while(st[_st] != c);
		}
	}
	void find(){
		fill_n(dfn,n,cc= 0);
		fill_n(low,n,_st = 0);
		fill_n(id , n,_ = 0);
		rep(i , 0 , n)if(!dfn[i])dfs(i , g);
		rep(i , 0 , n)--id[i];
		return;
	}
	bool solve(){
		find();
		for(int i = 0;i < n;i += 2){
			if(id[i] == id[i + 1])return 0;
			mark[i >>1] = (id[i] > id[i + 1]);
		}
		return 1;	
	}
}ts;
bool ck(int d){
	d--;
	ts.init(n);
	ts.build(0 , 2*n - 1,1);
	for(int i = 0 ;i < 2*n;i++){
		int l , r;
		l = lower_bound(p , p + 2*n , pii(p[i].fi - d,0)) - p;
		r = lower_bound(p , p + 2*n , pii(p[i].fi + d,0)) - p - 1;
	//	dd(i),dd(p[i].fi),dd(p[i].se),dd(l),de(r); 
		if(l < i)ts.add(p[i].se , l , i - 1, 0 , 2*n - 1, 1);
		if(r > i)ts.add(p[i].se , i + 1, r , 0 , 2*n - 1, 1);
	}
	if(ts.solve())return true;
	return false;
}
int main()
{
	scanf("%d",&n);
	rep( i ,0  , 2*n){
		 scanf("%d",&p[i].fi);
		 p[i].se = i;
	} 
	sort(p,p + 2*n);
	int ans = 0 ,L = 1,R = 1e9;
	while(L <= R){
		int mid = (L + R)>>1;
		if(ck(mid)){
			ans = mid;
			L = mid + 1; 
		}
		else R = mid - 1;
	}
	
	printf("%d\n",ans);
	return 0;
}




Measured memory_bytes: 62796
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=2147483647;
const ll LLMAX=9223372036854775807;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N,M;
    cin>>N>>M;
    vll x(M),y(M);
    for(ll i=0;i<M;i++){
        cin>>x[i]>>y[i];
        x[i]--;y[i]--;
    }
    
    vector<bool> ans(N,false);
    ans[0]=true;
    vll count(N,1);
    for(ll i=0;i<M;i++){
        if(ans[x[i]])ans[y[i]]=true;
        count[x[i]]--;count[y[i]]++;
        if(count[x[i]]==0)ans[x[i]]=false;
    }
    
    ll ansN=0;
    for(ll i=0;i<N;i++){
        if(ans[i] && count[i]>0)ansN++;
    }
    cout<<ansN<<endl;
    
    return 0;
}


Measured memory_bytes: 2688
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

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();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

struct node {int to,cost; };

typedef vector< vector<node> > G;

inline void add_edge(G& g,int from,int to,int cost=1){
	node in; in.to=to; in.cost=cost;
	g[from].pb(in);
}

inline void add_both_edge(G& g,int from,int to,int cost=1){	
	add_edge(g,from,to,cost);
	add_edge(g,to,from,cost);
}

void dfs(const G& g,int cur,int prev,int &k,vi& order, vi& low,vi& parent) {
	order[cur]=k++;
	low[cur]=order[cur];

	rep(i,g[cur].size()){
		int to=g[cur][i].to;
		if(order[to]==-1){
			parent[to]=cur;
			dfs(g,to,cur,k,order,low,parent);
			low[cur]=min(low[cur],low[to]);
		}else if(to!=prev)
			low[cur]=min(low[cur],order[to]);
	}
	return;
}

void Lowlink(const G& g, vi& order,vi& low,vi& parent) {
	int v=g.size();
	order.assign(v,-1);
	low.resize(v);
	parent.resize(v);
	int k=0;
	parent[0]=-1;
	dfs(g,0,-1,k,order,low,parent);
	return ;
}

int main(void){
	int n,m;
	cin >> n >> m;
	G graph(n);
	rep(i,m){
		int a,b;
		cin >> a >> b;
		add_both_edge(graph,a,b);
	}
	vi order,low,parent;
	Lowlink(graph,order,low,parent);

	/*rep(i,n){
		if(i){
			bool ok=false;
			rep(j,graph[i].size()){
				int to=graph[i][j].to;
				if(i==parent[to]&&order[i]<=low[to])
					ok=true;
			}
			if(ok) cout << i << endl;
		}else{
			int d=0;
			rep(j,n) if(parent[j]==0) d++;
			if(d>=2) cout << i << endl;
		}
	}*/
	
	vector<pii> res;

	rep(i,n){
		int t=i,f=parent[i];
		if(f==-1) 
			continue;
		if(t<=f)
			swap(f,t);
		if(order[f] < low[t] || order[t] < low[f] ){
			pii ok; ok.first=f; ok.second=t;
			res.pb(ok);
		}
	}
	sort(res.begin(),res.end());
	each(it,res) cout << (*it).first << " " << (*it).second << endl;
	return 0;
}

Measured memory_bytes: 3840
N = int(input())
[t, x, y] = [[0],[0],[0]]
for i in range(N):
  input_line = list(map(int, input().split()))
  t.append(input_line[0])
  x.append(input_line[1])
  y.append(input_line[2])

can = True
for i in range(0, N):
  dt = t[i+1] - t[i]
  dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
  if dt < dist:
    can = False
  if dt%2 != dist%2:
    can = False
  
if can == True:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 12060
#include <stdio.h>

int main(void){
  int i;
  int n, S;

  while(1){
    scanf("%d", &n);
    if(n == 0) break;

    if(n == 1){
      printf("deficient number\n");
      continue;
    }

    S = 1;

    for(i = 2; i * i <= n; i++){
      if(n % i != 0) continue;
      S += i;

      if(i != n / i){
        S += n / i;
      }
    }

    if(S == n){
      printf("perfect number\n");
    }
    else if(S < n){
      printf("deficient number\n");
    }
    else{
      printf("abundant number\n");
    }
  }

  return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 1e5
#define INF 1<<30
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;
int main() {
	cin >> H >> W;
	vector<vector<ll>>c(10, vector<ll>(10));
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> c[i][j];
		}
	}
	for (int bit = 1; bit < (1 << 9); bit++) {
		vector<int>v;
		for (int i = 0; i < 9; i++) {
			if (bit&(1 << i)) {
				if (i == 0)v.push_back(i);
				else v.push_back(i + 1);
			}
		}
		if (v.size() < 2)continue;
		do {
			ll tmp = 0;
			for (int i = 1; i < v.size(); i++) {
				tmp += c[v[i - 1]][v[i]];
			}
			tmp += c[v[v.size() - 1]][1];
			c[v[0]][1] = min(c[v[0]][1], tmp);
		} while (next_permutation(v.begin(), v.end()));
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> A;
			if (A != -1 && A != 1)ans += c[A][1];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
S = [int(input()) for i in range(N)]
S.sort()
sum = sum(S)
if sum%10==0:
    for i in range(N):
        if (sum-S[i])%10!=0:
            sum -= S[i]
            print(sum)
            exit()
    print(0)
else:
    print(sum)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;
int mod2=998244353;

signed main(){
  while(true){
    int n,m;
    cin>>n>>m;
    if(!n&&!m)break;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    int ans=0;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        if(i!=j&&a[i]+a[j]<=m)ans=max(ans,a[i]+a[j]);
      }
    }
    if(ans)cout<<ans<<endl;
    else cout<<"NONE"<<endl;
  }
}



Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int N;
int n4 = 0;
int n2 = 0;





int main()
{

	cin >> N;

	bool flg = false;

	REP(i,N){
		int a;
		cin >> a;
		if(a%4==0)
			n4++;
		else if(a%2==0)
			n2++;
	}
	if(n4*2+1 >= N)
		flg = true;
	else if(n4 != 0 && (n4*2 + n2) >= N)
		flg = true;
	else if(n4 == 0 && n2 == N)
		flg = true;
	else
		flg = false;



	if(flg)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;



}


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

#ifdef DEBUG
#define watch(x) cout << "DEBUG: " << (#x) << " = " << (x) << endl
#else
#define watch(x) ;
#endif

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define endl "\n"
const int INF = 0x3f3f3f3f;

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - (((begin) > (end)) << 1))

#define fi first
#define se second
#define pb push_back
#define all(X) begin(X),end(X)

#define rd1(x) scanf("%d", &x)
#define rd2(x, y) scanf("%d%d", &x, &y)
#define rd3(x, y, z) scanf("%d%d%d", &x, &y, &z)

#define rdl1(x) scanf("%lld", &x)
#define rdl2(x, y) scanf("%lld%lld", &x, &y)
#define rdl3(x, y, z) scanf("%lld%lld%lld", &x, &y, &z)

#pragma GCC optimize ("Ofast")
#pragma GCC target("avx,avx2")

int a[100003];

int main() {

#ifdef DEBUG
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
	int n, m;
	rd2(n,m);

	rep(i,0,m){
		int l,r;
		rd2(l,r);
		a[l]++;
		a[r+1]--;
	}

	int res = 0;
	rep(i,1,n+1) {
		a[i] += a[i-1];
		if(a[i] >= m)
			res++;
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = GetString();
            var s1 = S[0].ToString();
            var s2 = S[1].ToString();
            var s3 = S[2].ToString();
            var count = 0;

            if (s1 == "R")
            {
                count++;

                if (s2 == "R")
                {
                    count++;

                    if (s3 == "R")
                    {
                        count++;
                    }
                }
            }
            else if (s2 == "R")
            {
                count++;

                if (s3 == "R")
                    {
                        count++;
                    }
            }
            else if (s3 == "R")
            {
                count++;
            }

            Console.WriteLine(count);
        }

        private static long[] GetLongNumArray()
        {
            var input = Console.ReadLine().Split(' ');
            return input.Select(x => long.Parse(x)).ToArray();
        }

        private static long GetLongNum()
        {
            return long.Parse(Console.ReadLine());
        }

        private static string[] GetStringArray()
        {
            return Console.ReadLine().Split(' ');
        }

        private static string GetString()
        {
            return Console.ReadLine();
        }
    }
}


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

struct Node {
    Node() : val(0), end(false) {}

    uint64_t val;
    std::vector<Node*> dests;
    bool end;
};

int main() {
    uint64_t N, Q;
    std::cin >> N >> Q;
    
    Node nodes[N];

    for (std::size_t i = 0; i < N-1; ++i) {
        uint64_t a, b;
        std::cin >> a >> b;
        
        nodes[a-1].dests.push_back(&(nodes[b-1]));
        nodes[b-1].dests.push_back(&(nodes[a-1]));
    }
   
    for (std::size_t i = 0; i < Q; ++i) {
        uint64_t p, x;
        std::cin >> p >> x;

        nodes[p-1].val += x;
    }

    std::queue<Node*> q;
    q.push(&(nodes[0]));
    while (q.empty() == false) {
        Node* node = q.front();
        q.pop();
        node->end = true;

        for (Node* dst : node->dests) {
            if (dst->end == true) {
                continue;
            }
            dst->val += node->val;
            q.push(dst);
        }
    }
    
    for (std::size_t i = 0; i < N; ++i) {
        if (i != 0) {
            std::cout << " ";
        }
        std::cout << nodes[i].val;
    }

    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 19440
#include<time.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
using namespace std;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

template<typename ...Ts>
void show(Ts... ts){
  cout<<"#:";
  auto print=[](auto v){cout<<v<<" ";};
  initializer_list<int>{(void(print(ts)),0)...};
  cout<<endl;
}

int main(void){
    int a,b,ans=0;
    
    cin>>a>>b;
    if (a>b)a-=1;
    cout<<a;
}







Measured memory_bytes: 256
a, b, c = map(int,input().split())
sum = a+b+c
flag = False
if sum/2 == a + b:
  flag = True
if sum/2 == b + c:
  flag = True
if sum/2 == c + a:
  flag = True

if flag == True:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define MOD 1000000007
using namespace std;

int main(){
	ll x; cin>>x;	
	if(x <= 6)cout<<1<<endl;
	else{
		ll ans = (x/11)*2;	
		if(x%11 == 0){}
		else if(x%11 <= 6)ans++;
		else ans+=2;
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N, A, B, C, D = MAP()
S = list(input())

def cango(a, b):
	for i in range(a, b):
		if S[i] == "#" and S[i+1] == "#":
			return False
			break
	else:
		return True

if C < D:
	if cango(A-1, C-1) and cango(B-1, D-1):
		print("Yes")
	else:
		print("No")

else:
	for i in range(B-2, D-1):
		if S[i] == S[i+1] == S[i+2] == ".":
			S[i+1] = "#"
			break
	else:
		print("No")
		exit()

	if cango(A-1, C-1):
		print("Yes")
	else:
		print("No")

Measured memory_bytes: 12260
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug "<< i << std::endl

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n;
  std::cin>>n;

  std::vector<ll> a(n);
  rep(i,0,n)std::cin>>a[i];

  std::sort(all(a));

  if(a[n-1]-a[0]>1){
    std::cout<<"No";
    return 0;
  }

  if(a[n-1]==a[0]){
    if(a[0]==n-1 || 2*a[0]<=n)std::cout<<"Yes";
    else std::cout<<"No";
  }else{
    ll cnt=0,itr=0;
    while(a[itr]==a[0]){
      cnt++;itr++;
    }
    if(cnt<a[n-1]&&2*(a[n-1]-cnt)<=n-cnt)std::cout<<"Yes";
    else std::cout<<"No";
  }

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
# define M_PI 3.14159265358979323846
using namespace std;

#define int long long
#define loop(x) for(int i = 0;i<(x);i++)
string alpha = "abcdefghijklmnopqrstuvwxyz";
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout.tie(0);
	int x; cin >> x;
	cout << (2.0 * (double)x * M_PI);
}

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

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

	for (int i = 0; i < n; i++) {
		while (a[i] % 2 == 0) {
			a[i] /= 2;
			cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=22;
int ch[2][1<<N],id[N][1<<(N-1)],cnt,a[N][1<<N],siz[N],c[N][1<<N],num[N][1<<N],ans[N],n,K;
char s[1<<(N-1)];
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(isdigit(ch))
	{
		x=(x<<1)+(x<<3)+ch-'0';
		ch=getchar();
	}
	return x*f;
}
inline void dfs(int d,int s)
{
	if(ans[d]==-1)ans[d]=s;
	for(int p=0;p<=1;p++)
	{
		int tot=0;
		for(int i=0;i<siz[d];i++)
		{
			int v=ch[p][a[d][i]];
			if(v==-1) continue;
			if(num[d+1][v]==-1)
			{
				a[d+1][siz[d+1]]=v;
				num[d+1][v]=siz[d+1];
				siz[d+1]++;
			}
			tot+=c[d][i];
			c[d+1][num[d+1][v]]+=c[d][i];
		}
		if(tot>=K)dfs(d+1,(s<<1)|p);
		for(int i=0;i<siz[d+1];i++)
		{
			num[d+1][a[d+1][i]]=-1;
			c[d+1][i]=0;
		}
		siz[d+1]=0;
	}
}
inline void pre()
{
	id[0][0]=(cnt++);
	ch[0][id[0][0]]=ch[1][id[0][0]]=-1;
	for(int i=1;i<=20;i++)
	{
		int t=(1<<i),k=(t>>1);
		for(int s=0;s<t;s++)
		{
			id[i][s]=(cnt++);
			int p=(s&k),q=(p?1:0);
			ch[q][id[i][s]]=id[i-1][s^p];
			ch[!q][id[i][s]]=ch[!q][id[i-1][s^p]];
		}
	}
}
int main(void)
{
	n=read();
	K=read();
	pre();
	for(int i=0;i<=n;i++)for(int j=0;j<cnt;j++)num[i][j]=-1;
	for(int i=0;i<=n;i++)
	{
		scanf("%s",s);
		int t=(1<<i);
		for(int j=0;j<t;j++)if(s[j]=='1')
		{
			num[0][a[0][siz[0]]=id[i][j]]=siz[0];
			c[0][num[0][id[i][j]]]++;
			siz[0]++;
		}
		ans[i]=-1;
	}
	dfs(0,0);
	for(int i=n;i>=0;i--)if(ans[i]!=-1)
	{
		for(int j=i-1;j>=0;j--)putchar(((ans[i]>>j)&1)+'0');
		puts("");
		return 0;
	}
}

Measured memory_bytes: 388352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)

int main(int argc, char** argv) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if (argc == 2 && atoi(argv[1]) == 123456789)
        freopen("d:\\code\\cpp\\stdin", "r", stdin);

    int n, a, b;
    cin >> n >> a >> b;

    cout << min(a,b) << " " << max(0, a+b-n);

    return 0;
}


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

using namespace std;

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);
  
  string s;
  cin >> s;
  bool ans = s[0] == s[1] || s[1] == s[2] || s[2] == s[3];
  cout << (ans ? "Bad" : "Good") << endl;
}



Measured memory_bytes: 256
#[test]
fn test_solve() {
   assert_eq!(solve("1\n3 7\n"), "2\n");
   assert_eq!(solve("4\n13 13\n7 11\n7 11\n2017 2017\n"), "1\n0\n0\n1\n");
   assert_eq!(solve("6\n1 53\n13 91\n37 55\n19 51\n73 91\n13 49\n"), "4\n4\n1\n1\n1\n2\n");
}
fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    const MAX:usize = 50_000;

    let ipm = is_prime_table(2*MAX);
    let mut sum = vec![0; MAX+1];
    for i in 0..MAX {
        sum[i+1] = sum[i];
        sum[i+1] += (ipm[2*i+1] && ipm[i+1]) as usize;
    }
    
    let mut ret = String::new();
    use std::fmt::Write;
    
    let q: usize = sc.read();
    for _ in 0..q {
        let l: usize = sc.read();
        let r: usize = sc.read();
        let (l, r) = (l >> 1, r >> 1);
        writeln!(&mut ret, "{}", sum[r+1] - sum[l]).unwrap();
    }
    
    ret
}
fn is_prime_table(n: usize) -> Vec<bool> {
    let mut ipm = vec![true; n + 1];
    ipm[0] = false;
    ipm[1] = false;
    let nsr = (n as f64).sqrt() as usize;
    for p in 2..nsr + 1 {
        if ipm[p] {
            let mut mpp = 2 * p;
            while mpp <= n {
                ipm[mpp] = false;
                mpp += p;
            }
        }
    }
    ipm
}
fn main() {
    let mut buf = String::new();
    use std::io::{Read, Write};
    std::io::stdin().read_to_string(&mut buf).unwrap();
    std::io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}
struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
}


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

typedef long long int ll;

int main()
{
    ll n, p;
    bool co = true;
    cin >> n >> p;
    vector<ll> a(n);
    for(ll i = 0;i < n;i++){
        cin >> a[i];
        if(a[i] % 2 == 1){
            co = false;
        }
    }

    if(co){
        if(p == 0){
            cout << setprecision(20) << pow(2, n);
        }
        else{
            cout << 0;
        }
    }
    else{
        ll o = 0;
        for(ll i = 0;i < n;i++){
            if(a[i] % 2 != 0){
                o++;
            }
        }

        cout << setprecision(20) << pow(2, n - 1);
    }

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int ac = 0, wa = 0, tle = 0, re = 0;
	rep(i,n){
		string s;
		cin >> s;
		if(s == "AC") ++ac;
		if(s == "WA") ++wa;
		if(s == "TLE") ++tle;
		if(s == "RE") ++re;
	}
	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;
	return 0;
}

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

int main() {
 int A,B,X;
  cin >> A >> B >> X;
  
  if(A > X){
	cout << "NO" << endl;
  }
  
  else if(A + B <= X){
    cout << "NO" << endl;
  }
  
  else{
    cout << "YES" << endl;
  }
  
}
  


Measured memory_bytes: 256
#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 n,k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	
	
	vector<ll> sum(n+1);
	sum[0] = 0;
	rep(i,n) sum[i+1] = sum[i] + a[i];
	
	vector<ll> nn(n+1);
	rep(i,n+1) nn[i] = (sum[i] - i) % k;
	
	/*
	rep(i,n+1) cout << sum[i] << " ";
	cout << endl;
	rep(i,n+1) cout << nn[i] << " ";
	
	cout << endl;
	*/
	map<int,int> cnt;
	ll res = 0;
	rep(i,n+1){
		if(i < k){
			res += cnt[nn[i]];
			cnt[nn[i]]++;
		}
		else{
			cnt[nn[i-k]]--;
			res += cnt[nn[i]];
			cnt[nn[i]]++;
		}
	}
	
	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 13568
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <stack>
#include <algorithm>
#include <vector>
using namespace std;

int main() { 
  int s = 0;
  char c;
  stack<int> S1;
  stack<pair<int, int> > S2;
  for (int i = 0; (c = getchar()) != EOF; i++) {
    switch (c) {
      case '\\':
        S1.push(i);
        break;
      case '/':
        if (S1.empty()) {
          break;
        } else {
          int j = S1.top(); S1.pop();
          s += i - j;
          int a = i - j;
          while (!S2.empty() &&S2.top().first > j) {
            a += S2.top().second; S2.pop();
          }
          S2.push(make_pair(j, a));
        } 
    }
  }
  printf("%d\n%d", s, (int)S2.size());
  vector<int> ans;
  while (!S2.empty()) {ans.push_back(S2.top().second); S2.pop();}
  while (!ans.empty()) {printf(" %d", ans.back()); ans.pop_back();}
  printf("\n");
  return 0;
}

Measured memory_bytes: 3328
#include <climits>
#include <iostream>
#include <algorithm>
#include <stack>
#include <vector>
#include <unordered_set>
using namespace std;

struct Data_path
{
    long long pos;
    long long len;
    unordered_set<long long> flag;
};

int main()
{
    long long ans = LLONG_MAX;
    long long N, M, R;

    cin >> N >> M >> R;

    vector<long long> r;
    r.resize(R);
    vector<vector<long long>> way;
    way.resize(N);
    for (long long i = 0; i < N; i++)
    {
        way[i].resize(N);
    }

    for (long long i = 0; i < R; i++)
    {
        cin >> r[i];
        r[i] -= 1;
    }

    for (long long i = 0; i < N; i++)
    {
        for (long long j = 0; j < N; j++)
        {
            way[i][j] = LLONG_MAX;
        }
        way[i][i] = 0;
    }

    for (long long i = 0; i < M; i++)
    {
        long long A;
        long long B;
        long long C;
        cin >> A >> B >> C;
        A -= 1;
        B -= 1;
        way[A][B] = way[B][A] = C;
    }

    for (long long k = 0; k < N; k++)
    {
        for (long long i = 0; i < N; i++)
        {
            for (long long j = 0; j < N; j++)
            {
                if (way[i][k] != LLONG_MAX && way[k][j] != LLONG_MAX)
                    way[i][j] = min(way[i][j], way[i][k] + way[k][j]);
            }
        }
    }

    stack<Data_path> stack;
    for (long long i = 0; i < R; i++)
    {
        unordered_set<long long> flag = {r[i]};
        Data_path dp;
        dp.pos = r[i];
        dp.len = 0;
        dp.flag = flag;
        stack.push(dp);
    }

    while (!stack.empty())
    {
        Data_path dp = stack.top();
        stack.pop();
        if (dp.flag.size() == R)
        {
            ans = min(ans, dp.len);
            continue;
        }
        else
        {
            for (long long i = 0; i < R; i++)
            {
                if (dp.flag.find(r[i]) != dp.flag.end() || dp.len == LLONG_MAX)
                {
                    continue;
                }
                else
                {
                    unordered_set<long long> new_flag = dp.flag;
                    new_flag.insert(r[i]);
                    Data_path new_dp;
                    new_dp.pos = r[i];
                    new_dp.len = dp.len + way[dp.pos][r[i]];
                    new_dp.flag = new_flag;
                    stack.push(new_dp);
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
const int MOD = (int)1e9 + 7;
const double PI = acos(-1.0);


int32_t main(){
	int a[6];
	for(int i = 1; i <= 5; i++)
		cin >> a[i];
	for(int i = 1; i <= 5; i++){
		if(!a[i])
			 cout << i << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define pi 3.1415926535
#define endl '\n'
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const ll inf=1e18;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/
//ll fac[250001];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    char ch;
    cin>>ch;
    ch++;
    cout<<ch<<endl;
}


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

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n; cin >> n;
    int tmp[n]; for(int i=0; i < n; ++i) cin >> tmp[i];
    vector<int> a;
    for(int i=0; i < n; ++i) {
        a.push_back(tmp[i]);
        if(tmp[i] == 0) {
            int cnt = i;
            while(tmp[i] == 0 && i < n) ++i;
            a.push_back(i-cnt);
            --i;
        }
    }
    n = a.size();

    long long ans = 0;
    for(int i = 0; i < n; ++i) {
        long long x = 0, s = 0, z = 1, w = 1, tans = 0;
        if(a[i] == 0) w = a[i+1];
        for(int j = i; j < n; ++j) {
            x ^= a[j];
            s += a[j];
            if(a[j] == 0) z = a[++j];
            else z = 1;

            if(x == s) tans = tans + z;
            if(x <  s) break;
        }
        if(w > 1) tans = (tans + tans - w + 1) * w / 2;
        if(a[i] == 0) ++i;
        ans += tans;
    }

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

Measured memory_bytes: 2168
// ABC061
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

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

typedef long long ll;

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

    vector<int> road(N+1, 0);
    for(int i = 1; i <= M; i++)
    {
        int a, b;
        cin >> a >> b;
        road[a]++;
        road[b]++;
    }
    for(int i = 1; i <= N; i++)
    {
        cout << road[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define clr cin.ignore(numeric_limits<streamsize>::max(), '\n')
#define _val(x) cerr << #x << " is " << x << "\n";
#define all(container) container.begin(), container.end()
#define rall(container) container.rbegin(), container.rend()
#define pb push_back
#define mp make_pair
#define rep(x, a, b, c) for(ll x = a; x <= b; x += c)
#define rrep(x, a, b, c) for(ll x = a; x >= b; x -= c)

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef pair<long long, long long> pll;
typedef vector<pair<long long, long long> > vpll;
const ll INF = 0x3f3f3f3f;
const ll maxn = 1e6+1;
const double eps = 1e-6;

void solve() {
	int n; cin >> n;
	int arr[n-1], sol[n];
	rep(i, 0, n-2, 1) cin >> arr[i];
	sol[0] = arr[0];
	rep(i, 1, n-2, 1) {
		sol[i] = min(arr[i-1], arr[i]);
	}
	sol[n-1] = arr[n-2];
	int ans = 0;
	rep(i, 0, n-1, 1) ans += sol[i];
	cout << ans << "\n";
}		

int main(void){
	// #ifndef ONLINE_JUDGE
	//  	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int t = 1; //cin >> t;
	while(t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
typedef pair<int,int> pii;
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<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;}
/*----------------------------------------------------------------*/
// const int MOD = 998244353;
const int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){

	
	string s;
	cin >> s;
	int n = s.size();

	int ans = 0;
	for(int i = 1;i < n/2;i++){
		int f = 1;
		rep(j,i){
			if(s[j] != s[j+i])f = 0;
		}
		if(f)ans = 2*i;
	}
	cout << ans << endl;


	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://abc066.contest.atcoder.jp/tasks/abc066_b

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    const int MAXW = 100;

    int A, B;
    cin >> A >> B;

    vvi d(A + 1, vi(B + 1));
    for (int i = 1; i <= A; i++) {
        for (int j = 1; j <= B; j++)
            cin >> d[i][j];
    }

    vvi c(MAXW + 1, vi(MAXW + 1));
    for (int xc = 0; xc <= MAXW; xc++) {
        for (int yc = 0; yc <= MAXW; yc++) {
            for (int x = 1; x <= A; x++) {
                for (int y = 1; y <= B; y++) {
                    c[xc][yc] = max(c[xc][yc], d[x][y] - xc * x - yc * y);
                }
            }
        }
    }

    for (int x = 1; x <= A; x++) {
        for (int y = 1; y <= B; y++) {
            int sp = INT_MAX;
            for (int xc = 0; xc <= MAXW; xc++) {
                for (int yc = 0; yc <= MAXW; yc++) {
                    sp = min(sp, xc * x + yc * y + c[xc][yc]);
                }
            }
            if (sp != d[x][y]) { cout << "Impossible\n"; return 0; }
        }
    }

    int XL = 1, YL = XL + MAXW + 1;
    int V = YL + MAXW + 1, E = MAXW + MAXW + (MAXW + 1) * (MAXW + 1);

    cout << "Possible\n";
    cout << V << " " << E << "\n";
    for (int xc = 1; xc <= MAXW; xc++)
        cout << (XL + xc - 1) << " " << (XL + xc) << " X\n";
    for (int yc = 0; yc < MAXW; yc++)
        cout << (YL + yc + 1) << " " << (YL + yc) << " Y\n";
    for (int xc = 0; xc <= MAXW; xc++)
        for (int yc = 0; yc <= MAXW; yc++)
            cout << (XL + xc) << " " << (YL + yc) << " " << c[xc][yc] << "\n";

    cout << 1 << " " << YL << "\n";

    return 0;
}



Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
  int charcount[26]={0}, num;
  char ch;

  while ( scanf("%c", &ch) != EOF) {
    if (ch<='Z' && ch>='A')
      ch += 'a'-'A';
    if (ch<='z' && ch>='a')
      charcount[ch-'a']++;
  }

  for(num=0; num<26; num++) {
    printf("%c : %d\n", 'a'+num,charcount[num]);
  }

  return 0;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  int A[M]={0};
  
  for(int i =0; i <N ; i++){
    int k;
    cin >> k;
    for(int j = 0; j < k; j++){
      int tmp;
      cin >> tmp;
      A[tmp-1]++;
    }
  }
  int count = 0;
  for(int i = 0; i < M ; i++){
    //cout << A[i] << endl;
    if(A[i]==N)count++;
  }
  
  cout << count << endl;
  
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define int long long

int gtNCg(int N){
	int is_used[8], i, j, ans = 1;
	for(i = 1; i <= 7; i++){
		is_used[i] = 0;
	}
	for(i = 1; i <= 7; i++){
		ans *= (N + i);
		for(j = 1; j <= 7; j++){
			if(is_used[j] == 0 && ans % j == 0){
				ans /= j;
				is_used[j] = 1;
			}
		}
	}
	return ans;
}

signed main(){
	int K, N, i, j, k;
	scanf("%lld", &K);
//	for(N = 0; gtNCg(N) <= K; N++);
	N = 600;
//	printf("N = %lld\n", N);
//	printf("%lld\n", gtNCg(N));
	int *a = (int *)malloc(sizeof(int) * N);
	for(i = N - 1; i >= 0; i--){
		a[i] = K / gtNCg(i);
		K %= gtNCg(i);
	}
/*	for(i = 0; i < N; i++){
		printf("a[%lld] = %lld\n", i, a[i]);
	}
*/	char *s = (char *)malloc(sizeof(char) * 5001);
	char fes[8] = "FESTIVAL";
	for(i = 0, j = 0; i < N; i++){
		for(k = 0; k < 7; k++){
			s[j + k] = fes[k];
		}
		j += 7;
		for(k = 0; k < a[i]; k++){
			s[j + k] = fes[7];
		}
		j += a[i];
	}
	s[j] = '\0';
	printf("%s\n", s);
//	printf("%lld\n", j);
	return 0;
}

Measured memory_bytes: 256
//@author :  |< U $ |-|
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<algorithm>
#include<list>
#include<cstring>
#include<unordered_map>
#define ll long long
#define vi vector<long long>
#define pb push_back
#define pop pop_back
#define pi pair<long long ,long long>
#define vp vector<pair<long long,long long> >
#define mkp make_pair
#define in(i,n) for(i=0;i<n;i++)
#define fon(i,n,m) for(i=n;i<m;i++)
#define rfon(i,n,m) for(i=n;i>=m;i--)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
// #define map map<long long,long long>
#define inm1(b)  memset(b,-1,sizeof(b))
#define in0(b) memset(b,0,sizeof(b))
#define ininf(b) memset(b,1000000001,sizeof(b))
#define MOD         1000000007
#define I 1000000000000000001
#define t(a) cout<<a<<" "<<endl
#define tt(a,b) cout<<a<<" "<<b<<endl
#define th(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define TakeInput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
using namespace std;
ll gcd(ll a, ll b) {  if (a == 0)  return b; return gcd(b % a, a); }

ll power(ll x, ll y)
{
    if (y == 0)
        return 1;
    else if (y % 2 == 0)
        return power(x, y / 2) * power(x, y / 2);
    else
        return x * power(x, y / 2) * power(x, y / 2);
}



int main(){
    jaldi
    #ifndef ONLINE_JUDGE
    TakeInput
    #endif
    ll n;
    cin>>n;

    cout<<n+n*n+n*n*n;
}











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

#define ll long long
#define ld long double
#define pb push_back
#define all(n) n.begin(),n.end()
#define eb emplace_back
#define endl "\n"
#define pll pair<ll,ll>
#define ff first
#define ss second
using namespace std;
const ll maxn=1e6+50;
const ll mod=998244353;
const ll base=1e15;
bool dd[maxn];
ll cnt[maxn];
ll a[maxn];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    if (fopen("terrorists.inp","r"))
    {
        freopen("terrorists.inp","r",stdin);
        freopen("terrorists.out","w",stdout);
    }
    ll n;
     cin>>n;
     bool x=true;
    for (int i=1;i<=n;i++)
    {
        cin>>a[i];
        cnt[a[i]]++;
    }
    dd[1]=1;
    for (int i=2;i<maxn;i++)
    {
        ll cnt1=0;
       for (int j=i;j<maxn;j+=i)
       {
           cnt1+=cnt[j];
       }
       if (cnt1>1)
       {
           x=false;
           break;
       }
    }
    if (x)
    {
        cout <<"pairwise coprime";
    }
    else
    {
       ll t=a[1];
       for (int i=1;i<=n;i++)
       {
           t=__gcd(t,a[i]);
       }
       if (t==1)
       {
           cout <<"setwise coprime";

       }
       else
       {
           cout <<"not coprime";
       }
    }


}


Measured memory_bytes: 19216
/*
*/

//#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-8
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 600031;

int n,m;
vector<int> g[N];
int L[N],R[N],D[N];

long long ans[N];
int othr,should_be,used[N];

void dfs(int v){
	used[v]=1;
	//cout<<v<<" "<<ans[v]<<endl;
	for (int i=0;i<g[v].size();i++){
		int id=g[v][i];
		int othr=L[id]+R[id]-v;
		if (used[othr])
			continue;
		long long ps;
		if (L[id]==v)
			ps=ans[v]+D[id];
		else
			ps=ans[v]-D[id];
		ans[othr]=ps;
		dfs(othr);
	}
}

int main(){
//	freopen("apache.in","r",stdin);
//	freopen("apache.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
//	cin.tie(0);

	cin>>n>>m;
	for (int i=1;i<=m;i++){
		cin>>L[i]>>R[i]>>D[i];
		g[L[i]].push_back(i);
		g[R[i]].push_back(i);
	}

	for (int i=1;i<=n;i++){
		if (used[i])
			continue;
		dfs(i);
	}

	for (int i=1;i<=n;i++){
		for (int j=0;j<g[i].size();j++){
			int id=g[i][j];
			if (L[id]==i){
				othr=R[id];
				should_be=ans[i]+D[id];
			}
			else
			{
				othr=L[id];
				should_be=ans[i]-D[id];
			}
			if (ans[othr]!=should_be){
				cout<<"No"<<endl;
				return 0;
			}
		}
	}

	cout<<"Yes"<<endl;

//	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 32384
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

string s,t;
unordered_map<char,set<ll>> mp;
int main(){
    cin>>s>>t;
    for(ll i=0;i<s.length();i++){
        mp[s[i]].insert(i);
    }
    ll ans=0;
    ll pre=-1;
    for(ll i=0;i<t.length();i++){
        set<ll>& st=mp[t[i]];
        if(st.size()==0){
            cout<<-1;return 0;
        }
        auto it=st.upper_bound(pre);
        if(it==st.end()){
            ans+=(s.length()-pre)+(*st.begin());
            pre=(*st.begin());
        }else{
            ans+=*it-pre;
            pre=*it;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 5120
n, t = map(int, input().split())
root = [list(map(int, input().split())) for i in range(n)]

INF = 1000000007
ans = INF
for r in root:
  if r[1] > t:
    continue
  ans = min(ans, r[0])

if ans == INF:
  print('TLE')
else:
  print(ans)



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

main() {
  bool flg = false;
  string S; cin >> S;
  while (!flg) {
    S.erase(S.end() - 2, S.end());
    int len = S.length();
    rep(i, len / 2 + 1) {
      if (i == len / 2) {
        flg = true;
        break;
      }
      if (S[i] != S[len / 2 + i]) break;
    }
  }
  cout << S.length() << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int i,j;
	int m,f,r;
	char result[10000]={'\0'};

	for(i=0;;i++){
		scanf("%d %d %d",&m,&f,&r);
		if(m==-1&&r==-1&&f==-1) break;
		
		

		if(m+f>=80) result[i] = 'A';
		else if(m+f>=65) result[i] = 'B';
		else if(m+f>=50) result[i] = 'C';
		else if(m+f>=30){
			if(r>=50) result[i] = 'C' ;
			else result[i] = 'D';
		}
		else result[i] = 'F';

		if(m==-1||f==-1) result[i]='F';
	}
	for(j=0;j<i;j++) printf("%c\n",result[j]);
	return 0;
}

Measured memory_bytes: 616
n=int(input())
l=[int(input()) for i in range(n)]
s=sum(l)
ans=0
if s%10!=0:
    print(s)
else:
    for i in l:
        res=s-i
        if res%10==0:
            continue
        else:
            ans=max(ans,res)
    print(ans)

Measured memory_bytes: 3060
import bisect as bs
def prime(m):
  N = range(1,m+1, 2)
  N[0] = 2
  for i in range(1, int(m**.5)+1):
    x = N[i]
    if x: N[i+x::x] = [0] * len(N[i+x::x])
  return filter(None, N)

P = prime(10000)
x = [P[i] for i in range(1,len(P)) if P[i] - P[i-1]==2]
while 1:
  n = input()
  if n==0: break
  a = x[bs.bisect_right(x, n)-1]
  print a-2, a

Measured memory_bytes: 4592
#include<bits/stdc++.h>
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define INF 2000000000
#define PI 3.1415926535897932384626
const ll MOD=1e9+7;
char in[105];
int main(){
        int n;
        while(~scanf("%s",in)){
                bool flag=0;
                F(i,0,3) if(in[i]==in[i+1]){
                        puts("Bad");
                        flag=1;
                        break;
                }
                if(!flag) puts("Good");
        }
}

Measured memory_bytes: 256
fun main(args:Array<String>): Unit {
    while(true){
        val str = readLine()!!.trim()
        if (str == "#") return
        val (y, m, d) = str.split(' ').drop(1).map(String::toInt)
        println(if (y > 31 || (y == 31 && m >= 5)){
            "? ${y - 30} $m $d"
        }else str)
    }
}


Measured memory_bytes: 32908
def gcd(m, n)
	if m < n 
		gcd(n, m)
	elsif n == 0
		m
	else
		gcd(n, m % n)
	end 
end

def compute_lcm(m, n)
	m * n / gcd(m, n)
end

class Array
	def accum
		ac = Array.new(size + 1)
		ac[0] = 0
		(1..size).each do |i|
			ac[i] = ac[i-1] + self[i-1]
		end
		ac
	end
end

class LCMTree
	def initialize(a, l, r)
		@l, @r = l, r
		if l == r
			@lcm = a[l]
			@left = @right= nil
		else
			@left= LCMTree.new(a, l, (l+r)/2)
			@right= LCMTree.new(a, (l+r)/2+1, r)
			@lcm = compute_lcm(@left.lcm, @right.lcm)
		end
	end

	def lcm(l = @l, r = @r)
		if l == @l && r == @r
			@lcm
		elsif r <= @left.r
			@left.lcm(l, r)
		elsif @right.l <= l
			@right.lcm(l, r)
		else
			compute_lcm(@left.lcm(l, @left.r), @right.lcm(@right.l, r))
		end
	end

	attr_reader :l, :r
end

n, q = gets.split.map(&:to_i)
perm = [nil] + gets.split.map(&:to_i)

cycle = Array.new(n+1)
add_per_perm = Array.new(n+1)
(1..n).each do |x0|
	k = 1
	x = perm[x0]
	add_per_perm[x0] = x
	until x == x0
		k += 1
		x = perm[x]
		add_per_perm[x0] += x
	end
	cycle[x0] = k
	add_per_perm[x0] = Rational(add_per_perm[x0], k)
end
add_per_perm.shift
accum = add_per_perm.accum

t = LCMTree.new(cycle, 1, n)

q.times do
	l, r = gets.split.map(&:to_i)
	k = t.lcm(l, r)
	add = accum[r] - accum[l-1]
	p (add * k).to_i % (10 ** 9 + 7)
end

Measured memory_bytes: 62280